Shop OBEX P1 Docs P2 Docs Learn Events
Large BS2P-40 project — Parallax Forums

Large BS2P-40 project

ArchiverArchiver Posts: 46,084
edited 2004-07-15 17:40 in General Discussion
Hi,

i'm making a very large problem. I'm having a large menu by LCD
display. My program is too large to download it to the stamp. To
give an example of my pin connection:

0 = Not used |
1 = Enable |
2 = R/W |
3 = RS | LCD display (going to use an 4x20 display)
4 = DB4 |
5 = DB5 |
6 = DB6 |
7 = DB7 |
8 = CS |
9 = CLK | 12bit ADC (ltc1298)
10 = D I/O |
11 =
12 =
13 =
14 =
15 =
AUX0 = Button 1 |
AUX1 = Button 2 |
AUX2 = Button 3 |
AUX3 = Button 4 | Push buttons
AUX4 = Arrow up |
AUX5 = Arrow down |
AUX6 = Arrow left |
AUX7 = Arrow right |
AUX8 = Low pressure |
AUX9 = High pressure |
AUX10 = Manometer LP |
AUX11 = Manometer HP | outputs
AUX12 = Stikstof |
AUX13 = Freon |
AUX14 = Vacuum |
AUX15 = Air |

To give an example of how i'm creating my menu:

menu:
LCDOUT 1,cleardisplay, [noparse][[/noparse]"1) Volledige test"]
LCDOUT 1,movecrsr+64,[noparse][[/noparse]"2) Vacuumtest"]
LCDOUT 1,movecrsr+148,[noparse][[/noparse]"3) Druktest"]
LCDOUT 1,movecrsr+212,[noparse][[/noparse]"4) Instellingen"]
PAUSE 1000
a=0
menu_2:
IF in21=0 THEN volledige_test
IF in22=0 THEN vacuum_test
IF in23=0 THEN druk_test
IF in24=0 THEN instellen
GOTO menu_2

Volledige_test:
LCDOUT 1,cleardisplay, [noparse][[/noparse]"1) Daikin"]
LCDOUT 1,movecrsr+64,[noparse][[/noparse]"2) Mitsubishi"]
LCDOUT 1,movecrsr+148,[noparse][[/noparse]"3) Terug naar menu"]
PAUSE 1000
a=1
volledige_test_2:
IF in21=0 THEN vol_daikin
IF in22=0 THEN vol_mitsubishi
IF in23=0 THEN menu
GOTO volledige_test_2
' vanaf hier daikin keuze
vol_daikin:
GOSUB type_keuze
vol_daikin_2:
IF in21=0 THEN type_a_dai
IF in22=0 THEN type_b_dai
IF in23=0 THEN type_c_dai
IF in24=0 THEN volledige_test
GOTO vol_daikin_2
' vanaf hier mitsubishi keuze
vol_mitsubishi:
GOSUB type_keuze
vol_mitsubishi_2:
IF in21=0 THEN type_a_mit
IF in22=0 THEN type_b_mit
IF in23=0 THEN type_c_mit
IF in24=0 THEN volledige_test
GOTO vol_mitsubishi_2

type_a_dai:
GOSUB start_stop
type_a_dai_2:
IF in21=0 THEN start_typ_a_dai
IF in22=0 THEN algemene_stop
IF in23=0 THEN vol_daikin
GOTO type_a_dai_2

type_b_dai:
GOSUB start_stop
type_b_dai_2:
IF in21=0 THEN start_typ_b_dai
IF in22=0 THEN algemene_stop
IF in23=0 THEN vol_daikin
GOTO type_b_dai_2

type_c_dai:
GOSUB start_stop
type_c_dai_2:
IF in21=0 THEN start_typ_c_dai
IF in22=0 THEN algemene_stop
IF in23=0 THEN vol_daikin
GOTO type_c_dai_2

type_a_mit:
gosub start_stop
type_a_mit_2:
if in21=0 then start_typ_a_mit
if in22=0 then algemene_stop
if in23=0 then vol_mitsubishi
goto type_a_mit_2

type_b_mit:
gosub start_stop
type_b_mit_2:
if in21=0 then start_typ_b_mit
if in22=0 then algemene_stop
if in23=0 then vol_mitsubishi
goto type_b_mit_2

type_c_mit:
gosub start_stop
type_c_mit_2:
if in21=0 then start_typ_c_mit
if in22=0 then algemene_stop
if in23=0 then vol_mitsubishi
goto type_c_mit_2


*-*-*-**-*-*-*-*-*-*-*-*-*-*-*-*-*-*-/*-*-*-*-*

I believe this is the easist way to create an LCD menu. This is only
one tiny part of my menu so U might notice that this will take a
huge amount of memory. I also must be able to write data (al kinds
of variables) to an eeprom memory and recall it when i start my
stamp. Is my method of creating a menu the shortest way or could I
do bether. I'm using so many GOSUB's as I can. Is there a way to
have a lot more memory wich I could maintain my way of creating the
program (not with a lot of writing sentences to write text to an
smartcard of an eeprom memory)? This are a few hard questions to
answer but I hope somebody could answer me on one or more of these
questions.



Kindly regards,


Tim (an desperate student @ belgium)

Comments

  • ArchiverArchiver Posts: 46,084
    edited 2004-07-15 14:24
    ok my thoughts are this:

    you really don't need to put each state of the menu into the program itself. instead, i
    would do something like this:

    put each state of the menu into eeprom, and then link them by also including the address
    in the eeprom of where each menu "button" leads to.

    then your program can just read the first menu from the eeprom, and wait for user input.
    when that comes, just jump to the next address in memory that you need.

    so in the eeprom you would store something like this:

    menu choice 1, address1
    menu choice 2, address2
    menu choice 3, address3

    granted, everything would need to be a fixed length so that you know where you can find
    the information.

    i don't think i did a very good job explaining this, but i don't know that much about
    eeprom commands myself, and am sure that somebody else can do a better job.

    --- In basicstamps@yahoogroups.com, "ikenniemandanders" <tld-nv@s...> wrote:
    > Hi,
    >
    > i'm making a very large problem. I'm having a large menu by LCD
    > display. My program is too large to download it to the stamp. To
    > give an example of my pin connection:
    >
    > 0 = Not used |
    > 1 = Enable |
    > 2 = R/W |
    > 3 = RS | LCD display (going to use an 4x20 display)
    > 4 = DB4 |
    > 5 = DB5 |
    > 6 = DB6 |
    > 7 = DB7 |
    > 8 = CS |
    > 9 = CLK | 12bit ADC (ltc1298)
    > 10 = D I/O |
    > 11 =
    > 12 =
    > 13 =
    > 14 =
    > 15 =
    > AUX0 = Button 1 |
    > AUX1 = Button 2 |
    > AUX2 = Button 3 |
    > AUX3 = Button 4 | Push buttons
    > AUX4 = Arrow up |
    > AUX5 = Arrow down |
    > AUX6 = Arrow left |
    > AUX7 = Arrow right |
    > AUX8 = Low pressure |
    > AUX9 = High pressure |
    > AUX10 = Manometer LP |
    > AUX11 = Manometer HP | outputs
    > AUX12 = Stikstof |
    > AUX13 = Freon |
    > AUX14 = Vacuum |
    > AUX15 = Air |
    >
    > To give an example of how i'm creating my menu:
    >
    > menu:
    > LCDOUT 1,cleardisplay, [noparse][[/noparse]"1) Volledige test"]
    > LCDOUT 1,movecrsr+64,[noparse][[/noparse]"2) Vacuumtest"]
    > LCDOUT 1,movecrsr+148,[noparse][[/noparse]"3) Druktest"]
    > LCDOUT 1,movecrsr+212,[noparse][[/noparse]"4) Instellingen"]
    > PAUSE 1000
    > a=0
    > menu_2:
    > IF in21=0 THEN volledige_test
    > IF in22=0 THEN vacuum_test
    > IF in23=0 THEN druk_test
    > IF in24=0 THEN instellen
    > GOTO menu_2
    >
    > Volledige_test:
    > LCDOUT 1,cleardisplay, [noparse][[/noparse]"1) Daikin"]
    > LCDOUT 1,movecrsr+64,[noparse][[/noparse]"2) Mitsubishi"]
    > LCDOUT 1,movecrsr+148,[noparse][[/noparse]"3) Terug naar menu"]
    > PAUSE 1000
    > a=1
    > volledige_test_2:
    > IF in21=0 THEN vol_daikin
    > IF in22=0 THEN vol_mitsubishi
    > IF in23=0 THEN menu
    > GOTO volledige_test_2
    > ' vanaf hier daikin keuze
    > vol_daikin:
    > GOSUB type_keuze
    > vol_daikin_2:
    > IF in21=0 THEN type_a_dai
    > IF in22=0 THEN type_b_dai
    > IF in23=0 THEN type_c_dai
    > IF in24=0 THEN volledige_test
    > GOTO vol_daikin_2
    > ' vanaf hier mitsubishi keuze
    > vol_mitsubishi:
    > GOSUB type_keuze
    > vol_mitsubishi_2:
    > IF in21=0 THEN type_a_mit
    > IF in22=0 THEN type_b_mit
    > IF in23=0 THEN type_c_mit
    > IF in24=0 THEN volledige_test
    > GOTO vol_mitsubishi_2
    >
    > type_a_dai:
    > GOSUB start_stop
    > type_a_dai_2:
    > IF in21=0 THEN start_typ_a_dai
    > IF in22=0 THEN algemene_stop
    > IF in23=0 THEN vol_daikin
    > GOTO type_a_dai_2
    >
    > type_b_dai:
    > GOSUB start_stop
    > type_b_dai_2:
    > IF in21=0 THEN start_typ_b_dai
    > IF in22=0 THEN algemene_stop
    > IF in23=0 THEN vol_daikin
    > GOTO type_b_dai_2
    >
    > type_c_dai:
    > GOSUB start_stop
    > type_c_dai_2:
    > IF in21=0 THEN start_typ_c_dai
    > IF in22=0 THEN algemene_stop
    > IF in23=0 THEN vol_daikin
    > GOTO type_c_dai_2
    >
    > type_a_mit:
    > gosub start_stop
    > type_a_mit_2:
    > if in21=0 then start_typ_a_mit
    > if in22=0 then algemene_stop
    > if in23=0 then vol_mitsubishi
    > goto type_a_mit_2
    >
    > type_b_mit:
    > gosub start_stop
    > type_b_mit_2:
    > if in21=0 then start_typ_b_mit
    > if in22=0 then algemene_stop
    > if in23=0 then vol_mitsubishi
    > goto type_b_mit_2
    >
    > type_c_mit:
    > gosub start_stop
    > type_c_mit_2:
    > if in21=0 then start_typ_c_mit
    > if in22=0 then algemene_stop
    > if in23=0 then vol_mitsubishi
    > goto type_c_mit_2
    >
    >
    > *-*-*-**-*-*-*-*-*-*-*-*-*-*-*-*-*-*-/*-*-*-*-*
    >
    > I believe this is the easist way to create an LCD menu. This is only
    > one tiny part of my menu so U might notice that this will take a
    > huge amount of memory. I also must be able to write data (al kinds
    > of variables) to an eeprom memory and recall it when i start my
    > stamp. Is my method of creating a menu the shortest way or could I
    > do bether. I'm using so many GOSUB's as I can. Is there a way to
    > have a lot more memory wich I could maintain my way of creating the
    > program (not with a lot of writing sentences to write text to an
    > smartcard of an eeprom memory)? This are a few hard questions to
    > answer but I hope somebody could answer me on one or more of these
    > questions.
    >
    >
    >
    > Kindly regards,
    >
    >
    > Tim (an desperate student @ belgium)
  • ArchiverArchiver Posts: 46,084
    edited 2004-07-15 17:40
    Just a couple of small suggestions. If you do have a lot of menu
    text it is more efficient to store it in DATA statements, and then
    have one routine that you call with a pointer to the screen of
    information that you want to display, for example:



    > LCDOUT 1,cleardisplay, [noparse][[/noparse]"1) Volledige test"]
    > LCDOUT 1,movecrsr+64,[noparse][[/noparse]"2) Vacuumtest"]
    > LCDOUT 1,movecrsr+148,[noparse][[/noparse]"3) Druktest"]
    > LCDOUT 1,movecrsr+212,[noparse][[/noparse]"4) Instellingen"]


    screen1: DATA [noparse][[/noparse]"1) Volledige test"],CR
    DATA [noparse][[/noparse]"2) Vacuumtest"],CR
    DATA,,[noparse][[/noparse]"3) Druktest"],CR
    DATA [noparse][[/noparse]"4) Instellingen"],0 ' terminating null

    ' and to call that...
    pointer=screen1
    GOSUB show_Screen

    Then you need a little show_Screen routine that reads the data one
    character at a time and sends the commands and the 4 lines to the
    screen. You call that same routine to display any screen content
    based on the pointer. It has to start by clearing the screen, and it
    has to trap the CR and move to the beginning of the next screen line,
    and finish when it detects the null. If you have many screens of
    data, this will take lots less memory than storing the data in
    individual LCDOUT commands.


    Things like this...

    > IF in21=0 THEN volledige_test
    > IF in22=0 THEN vacuum_test
    > IF in23=0 THEN druk_test
    > IF in24=0 THEN instellen

    I wonder what is in21..in24? The inX only goes from 0 to 15 and you
    need to use AUXIO and MAINIO to switch between sets of 16.

    If you can have those buttons on one nibble, it could be coded with a
    BRANCH, something like this...

    waiting:
    BRANCH NCD ~inB, [noparse][[/noparse]waiting,volledige_test, vacuum_test, druk_test, instellen]

    The NCD~inB uses one of the math operators on the 4 bits of port
    (nibble B), that maps like this:
    %1111 = 0
    %1110 = 1
    %1101 = 2
    %1011 = 3
    %0111 = 4
    selecting the branch option that loops until some button is pressed
    and then jumps to the selected routine.
Sign In or Register to comment.