PDA

View Full Version : Optimizing LCD commands?



jblackann
- 3rd December 2007, 19:53
I have been working on code for a small handheld programmer with a 16x2 LCD (that uses a 16F690) that will be used to program another circuit (that also has a 16F690). The programmer is used to adjust different variables and then pass them to the application circuit. The problem I have is that in my efforts to gain more control, I have added a lot of settings creating a large piece of code. The total memory space for the 16F690 is 4096 bytes of space. I have two different but similar versions of software for the handheld programmer and would like to put both on the same 16F690 but do not have enough room. I do have a lot of similar functions that I use over and over again but I am not sure if I can somehow condense the code.

I use the serial command to send out data:
SEROUT2 INFRARED_LED, 1646, ["A", EXTEND_FILL_SETTING]
SEROUT2 INFRARED_LED, 1646, ["B", EXTEND_DUMP_SETTING]
SEROUT2 INFRARED_LED, 1646, ["C", EXTEND_PULSES]
SEROUT2 INFRARED_LED, 1646, ["D", RETRACT_PULSES]
SEROUT2 INFRARED_LED, 1646, ["E", CHECKSUM_WORD.HIGHBYTE]
SEROUT2 INFRARED_LED, 1646, ["F", CHECKSUM_WORD.LOWBYTE]
SEROUT2 INFRARED_LED, 1646, ["G", RETRACT_FILL_SETTING]
and so on. I cannot think if there is a way to call this over and over again as the following
SEROUT2 INFRARED_LED, 1646, ["X", "Y"]
where X is a letter constant, and Y is the variable that I want sent out.


If possible I would want to do this with my read and write functions that I use.
WRITE 0, EXTEND_FILL_SETTING
WRITE 2, EXTEND_DUMP_SETTING
WRITE 5, EXTEND_PULSES
WRITE 6, RETRACT_PULSES
WRITE 14, RETRACT_FILL_SETTING
as WRITE "ADDRESS", Y, changing the address of each variable and changing each variable.

I also use a lot of LCDOUT commands, which I imagine are eating up alot of code. I was wondering if it would be possible to some how use a subroutine to print things that output several times.
Lcdout "Down Vent"
Lcdout "Down Fill"
Lcdout "Up Vent"
Lcdout "Up Fill"
I use Up and Down in couple other places and didn't know I could do something else other than writing them out again. I mean Call Display Up + Call Display Vent to display "Up Vent"

Any possible thoughts at making elements alittle more optimized.

Thanks for your time.

jblackann
- 4th December 2007, 16:30
With the code that I have written, I have a total of 4064 lines and need to add some more. The total available on the 16F690 is 4096. Is there anyway that I can attach a separate EEPROM chip and then utilize it for more program memory space? If so does any one have any examples. Thanks.