Shop OBEX P1 Docs P2 Docs Learn Events
Need More Memory or smaller program — Parallax Forums

Need More Memory or smaller program

ClineCline Posts: 36
edited 2006-07-01 16:52 in BASIC Stamp
Hello everyone,

I have working on a tracking system using camera,Ir and thermal, using a bs2 and matrix lcd with keypad.

I written the code for the basic program and Chris Savage helped me get the lcd working, All is well except that all the serout's to the lcd take up all the memory, I use the camera on app mod and wired the ir and thermal,
so its all together just not enough room for programing all of them. I have another board of education and was wondering if i should move some systems to it or could i just wire two pins together and use the memory from the other, I just need some direction, What is the best way,,,

can i buy a memory mod?

thanks guys,girls

Cline
C.E.O.
Integrated Security Services

Comments

  • ClineCline Posts: 36
    edited 2006-06-28 20:29
    Ive read that the bs2 has lots of memory, I am not familiar with storing or changing what is stored where, Im curious now if i have more memory and just not managing it correctly,hmm
    Sure would be nice if i understood how the stamp uses its memory,, im going to read up on it,

    IF you would like to see the code let me know, ill post it,,

    Thanks Again

    Cline
    C.E.O.
    Integrated Security Services
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2006-06-28 21:18
    Are you using a BS1 at present?· The BS2 has a lot more program memory (someone will be along momentarily with an exact number, I can feel it.)·

    Go ahead and post your program anyway.
  • dandreaedandreae Posts: 1,375
    edited 2006-06-28 21:37
    I suggest using the BS2pe which is cost effective·compared to·using·two stamps.· The BS2pe has 32K of memory for programming and data collection.· Here is a link for more information:

    http://www.parallax.com/detail.asp?product_id=BS2PE

    Dave

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Dave Andreae

    Tech Support
    dandreae@parallax.com
    Http://www.parallax.com



    Post Edited (Dave Andreae (Parallax)) : 6/28/2006 10:16:45 PM GMT
  • Mike GreenMike Green Posts: 23,101
    edited 2006-06-28 22:46
    Keep in mind that the BS2 series has only 2K for program storage of a single program. Most of the BS2 models beyond the "plain" BS2 (like the BS2pe) have several banks of program storage where you can essentially have overlays. Even though the overlay setup isn't "seamless", it's pretty easy and you can use some of the banks for data as well (data that's not changed often like tables). Basic data storage in all of the BS2 series is 26 bytes. Data can be stored in individual bits, in nibbles (4 bits), bytes (8 bits) and words (16 bits). Most BS2 models also have RAM storage, either 64 or 128 bytes that can be accessed with specific statements. You can also easily connect external memory (serial EEPROM or serial FRAM) using the I2C protocol. These are fairly cheap and come in sizes up to 128K bytes. The FRAM (from Ramtron) is a little more expensive, but can be written an unlimited number of times and is quite fast.
  • Mike GreenMike Green Posts: 23,101
    edited 2006-06-28 22:49
    Often, you can simplify a Stamp program so that it takes less memory for the program and variables can be reused. Commonly, several parts of a program are nearly identical and can be made into a subroutine that takes less space.
  • FranklinFranklin Posts: 4,747
    edited 2006-06-28 23:07
    As Mike says sometimes it's as simple as changing the way the program is written. If you could attach the program someone might be able to help you streamline it.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • RinksCustomsRinksCustoms Posts: 531
    edited 2006-06-29 01:00
    Yeah there are ways to "condense" your code, here's a glimpse of 1 way you could condense your code by way of the DATA directive. By using this technique you can store letters, symbols, numbers, and recall them with little code as many times as you need to.

    This code holds enough DATA to generate my whole touchscreen menu system I'm working on,... if i could only get the %$^& subroutines to work right with the program!!

    ' {$STAMP BS2}
    ' {$PBASIC 2.5}
    'This program is LASI TS (TouchScreen)
    '==================== INITIALIZE ===================
    x       VAR   Byte    'cursor x position
    xloc    VAR   Byte    'stored cursor "button" text position
    y       VAR   Byte    'cursor y position
    yloc    VAR   Byte    'stored cursor "button" text position
    
    menu    VAR   Byte    'menu location
    submenu VAR   Byte    'sub menu location
    char    VAR   Byte    'character variable
    temp    VAR   Byte    '"temp" byte
    cnt     VAR   Byte    'count variable
    xm      VAR   Byte    'unknown memory location for reading characters (DATA)
    xa      VAR   Byte    'variable for upper LT button text start memory address
    xb      VAR   Byte    'variable for upper RT button text start memory address
    xc      VAR   Byte    'variable for lower LT button text start memory address
    xd      VAR   Byte    'variable for lower RT button text start memory address
    
    x     = 0
    xloc  = 0
    y     = 0
    yloc  = 0
    char  = 0
    temp  = 0
    cnt   = 0
    xm    = 0
    menu  = 0
    
    '-------------------- MENU BACKGROUND -------------
    DATA CLS,CRSRXY,7,1,"[noparse][[/noparse]]",CRSRXY,7,2,"[noparse][[/noparse]]",CR,
    "----------------",CRSRXY,7,4,"[noparse][[/noparse]]",CRSRXY,7,5,"[noparse][[/noparse]]"
    'menu background runs from mem loc $0 - $26
    '-------------------- MENU "ITEMS" ------------------
    'data  @ $26       $2d      $34       $3b
    DATA    " LASI  "," X-OVER","PWR OPT","  N/A  ",
           ' $42       $49       $50       $57
            " INPUT "," OUTPUT"," FREQ  ","  TRIG ",
           ' $5e       $65       $6c       $73
            "  LOW  ","  MID  "," HIGH  ","  FULL ",
           ' $7a       $81       $88       $8f
            " BANK1 "," BANK2 "," BANK3 "," BANK4 ",
           ' $96       $9d       $a4       $ab
            "   1   ","   2   ","   3   ","   4   ",
           ' $b2       $b9       $c0       $c7
            "  60Hz "," 220Hz "," 1.3KHz"," 8.5KHz",
           ' $ce       $d5       $dc       $e3
            "X-TYPE ","CUT OFF","CTR FRQ","QUALITY"
    
    'Fine adjust background
    DATA CLS,CRSRXY,0,4,
                                     '$ea
    "   _____0_____  ",CR,
    " - _____|_____ +",0
    DATA CLS,CRSRXY,0,2,
                                     '$110
    "_____",CRSRXY,5,3,
         "?__________",0
    DATA CLS,CRSRXY,8,4,             '$128
          "____",CR,
    "_____/    ?_____",0
    DATA CLS,CRSRXY,8,4,             '$142
          "____",CR,
    "_____?    \_____",0
    DATA CLS,CRSRXY,12,4,            '$15c
               "_____",CR,
    "__________?",0
    '================================================================================================
    '================================================================================================
    '                                       MAIN
    '================================================================================================
    '================================================================================================
    
                    'print background
    xm = 0
    FOR cnt = $0 TO $26
      READ xm, char
      DEBUG char
      xm=xm+1
    NEXT
    
    DEBUG HOME,"MAIN############"  'simulated title bar, for the SX video board use the INVON/INVOFF
                                  'comand instead of the "#" for a cleaner looking interface
    
    xa=$26 : xb=$2d : xc=$34 : xd=$3b
    FOR cnt = 0 TO 3
        LOOKUP xloc,[noparse][[/noparse]0,9,0,9],x                 'get x,y locations of text for "virtual" buttons
        LOOKUP yloc,[noparse][[/noparse]2,2,5,5],y                 'and place cordinates in x & y variables
        DEBUG CRSRXY, x,y                       'set cursor at syncronized x,y position for "button"
      IF (x=0 AND y=2) THEN xm=xa              'test for upper left button
      IF (x=9 AND y=2) THEN xm=xb              'test for upper right button
      IF (x=0 AND y=5) THEN xm=xc              'test for lower left button
      IF (x=9 AND y=5) THEN xm=xd              'test for lower right button
        FOR temp = 0 TO 6                       'onscreen buttons are always 7 characters
            READ xm, char
            DEBUG char
            xm = xm + 1
          NEXT
      xloc = xloc + 1
      yloc = yloc + 1
    NEXT
    PAUSE 5000
    'show program is going to end
    shut_down:
    PAUSE 2000
    DEBUG CRSRX,18,CRSRY,23,"END!"
    PAUSE 2000
    DEBUG CLS
    END
    

    And I thought the BS2 had 32K of E2 memory ....

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Definetly a E3 (Electronics Engineer Extrodinare!)
    "I laugh in the face of imposible,... not because i know it all, ... but because I don't know well enough!"
  • ClineCline Posts: 36
    edited 2006-07-01 14:35
    Hey everyone,

    · Thanks for all the help. Here is the code i have written so far, I would like help on condensing it. I omitted the main routine,but i would like to change how i enter the password to enter the program. I have to type the pasword into the debug terminal, i would like to have it on the keypad and it show up on the lcd,· Iv tried all i know, just cant get it together,

    thanks guys, after this i will get the memory and hopefully this project will start taking shape,,
    ' {$STAMP BS2}
    ' {$PBASIC 2.5}
    DEBUG"Micro Board System " , CR
    '
    [noparse][[/noparse] Declarations ]
    'LCD
    'Interface
    tx················· PIN······· 0······ 'Transmit pin to LCD
    Rx················· PIN······· 1······ 'Receive pin from LCD
    Baud··············· CON······· 84····· 'Equals baud rate of 9.6k
    Int················ CON······· 254···· 'place befor each instruction
    'Commands
    Auto_Wrap_On······· CON······· 67·····
    Auto_Wrap_Off······ CON······· 68·····
    Auto_Scroll_On····· CON······· 81·····
    Auto_Scroll_Off···· CON······· 82·····
    Cursor_pos········· CON······· 71····· 'Needs Column and row
    Cur_home··········· CON······· 72·····
    Under_Line_On······ CON······· 74·····
    Under_Line_Off····· CON······· 75·····
    Blinking_On········ CON······· 83·····
    Blinking_Off······· CON······· 84·····
    Cursor_Left········ CON······· 76·····
    Cursor_Right······· CON······· 77·····
    Clear_screen······· CON······· 88·····
    Contrast··········· CON······· 80····· 'Needs level $00 to $FF
    Backlight_On······· CON······· 66····· 'SET $00 = on, minute max $FF
    Backlight_Off······ CON······· 70····· ''See LCD manual for more detail
    GP_pin_off········· CON······· 86····· 'NEEds $01 to $06 for pin #
    GP_pin_on·········· CON······· 87····· 'NEEds $01 to $06 for pin #
    'Key pad
    Auto_repeat_on····· CON······· 126···· '$00 = resend $01 = key up/down
    Auto_repeat_off···· CON······· 96·····
    Auto_Trans_On······ CON······· 65····· 'Sends key press data immediately
    Auto_Trans_Off····· CON······· 79····· 'STORE 10 key presses until polled
    Clear_buffer······· CON······· 69····· 'See LCD manual for more detail
    Poll_keypad········ CON······· 38····· 'Polls LCD for last key press
    Debounce_time······ CON······· 85····· 'Set in 6.554ms units default 52mS
    'Bar graphs
    Wide_vert_bar······ CON······· 118···· 'Initialize wide vertical bar
    Naro_vert_bar······ CON······· 115···· 'Initialize narrow vertical bar
    Draw_vert_bar······ CON······· 61·····
    Horz_bar··········· CON······· 104···· 'Initialize horizontal bar
    Draw_horz_bar······ CON······· 124
    Cusstom_char······· CON······· 78·····
    Large_dig·········· CON······· 110
    Place_lrg_dig······ CON······· 35····· 'Column $01/$12 digit $00/$09
    'data directives
    Password··········· DATA··· "33722"
    'variable declarations
    index······· VAR·· Nib
    userentry··· VAR·· Byte(5)
    ·temp··············· VAR······· Byte··· 'Working variable
    Key················ VAR······· Byte··· 'key storage variable
    io_pin············· VAR······· Byte··· 'GP I/O variable
    'initialization routine
    GOSUB check_password
    'main routine
    DEBUG CR, "complete"
    END
    'subroutine
    check password
    check_password:
    ·DO
    · DEBUG CR,"Enter Password"
    · DEBUGIN STR userentry \5
    · FOR index=0 TO 4
    · READ password + index, temp
    · IF temp <> userentry(index) THEN EXIT
    · NEXT
    · IF index <> 5 THEN
    · DEBUG CR, "password incorrect"
    · ENDIF
    · LOOP UNTIL index=5
    · DEBUG CR, "accessed"
    'display
    ·SEROUT 0, 84, [noparse][[/noparse]Int,Clear_screen]······· 'Command Prefix
    SEROUT 0, 84, [noparse][[/noparse]"· Mainframe Online "]
    PAUSE 2000
    ·SEROUT 0, 84, [noparse][[/noparse]Int,Clear_screen]
    ·SEROUT 0, 84, [noparse][[/noparse]"····· A.W.O.T. "]
    ·SEROUT 0, 84, [noparse][[/noparse]"·········· SYSTEMS· "]
    ·PAUSE 2000
    · SEROUT 0, 84, [noparse][[/noparse]Int,Clear_screen]
    · SEROUT Tx,Baud,[noparse][[/noparse]"DESIGNED BY ",Int,Cursor_pos,1,2,
    ·············· "Charles Cline", Int,Cursor_pos,1,4,"Starting Sub-Program"]
    · '
    [noparse][[/noparse] Initialization ]
    PAUSE 4000····························· 'Waits for 250ms
    Initialize:··························· 'label
    SEROUT Tx,Baud,[noparse][[/noparse]Int,Clear_screen]····· 'Clears screen
    SEROUT Tx,Baud,[noparse][[/noparse]Int,Auto_trans_off]··· 'Turns off buffer for key pad
    'Sets up text on LCD
    SEROUT Tx,Baud,[noparse][[/noparse]"Press 0-9 or A to",Int,Cursor_pos,1,2,
    ·············· "POWER on all systems",
    ·············· Int,Cursor_pos,1,3,"B to turn them all",
    ·············· Int,Cursor_pos,1,4,"off.C to Exit,D=MP"]
    '
    [noparse][[/noparse] Main Routine ]
    In_Put:······························· 'Label
    GOSUB key_pad························· 'Jumps to key pad polling routine
    · IF key = "#" THEN I_O_On············ 'coMPares key and jumps if true
    · IF key = "*" THEN I_O_Off··········· 'coMPares key and jumps if true
    GOTO In_Put··························· 'Jumps to listed label

    '
    [noparse][[/noparse] Subroutines ]
    I_O_Off:······························ 'Label
    'Sends text to LCD
    SEROUT Tx,Baud,[noparse][[/noparse]Int,Clear_screen,"I/O pin ",DEC io_pin,Int,Cursor_pos,1,2,
    ·············· "Is now turned off. "]
    SEROUT Tx,Baud,[noparse][[/noparse]Int,GP_Pin_Off,io_pin] 'SetS I/O pin to off
    PAUSE 2000···························· 'PAUse for 2000ms
    GOTO Initialize······················· 'JUmps to listed label
    I_O_On:······························· 'Label
    'Sends text to LCD
    SEROUT Tx,Baud,[noparse][[/noparse]Int,Clear_screen,"I/O pin ",DEC io_pin,Int,Cursor_pos,1,2,
    ·············· "Is now turned on. "]
    SEROUT Tx,Baud,[noparse][[/noparse]Int,GP_Pin_On,io_pin]· 'listed I/O pin to on
    PAUSE 2000···························· 'Pause for 2000ms
    GOTO Initialize······················· 'Jumps to listed label
    key_pad:······························ 'Label
    SEROUT Tx,Baud,[noparse][[/noparse]Int,Poll_keypad]······ 'Request last key press from LCD
    SERIN Rx,Baud,[noparse][[/noparse]temp]·················· 'Store key press in temp
    · IF temp = 0 THEN key_pad············ 'coMPares key and jumps if true
    ·· GOSUB Convert······················ 'JumP to listed label
    · IF temp = "A" THEN All_On··········· 'coMPares key and jumps if true
    · IF temp = "B" THEN All_Off·········· 'coMPares key and jumps if true
    ·IF temp = "C" THEN Exit_p
    ·IF temp = "D" THEN Main_P
    ·IF temp= "1" THEN One_p
    ·IF temp= "2" THEN Two_p
    · IF temp= "3" THEN Three_p
    IF temp= "4" THEN Four_p
    · IF temp= "5" THEN Five_p
    · IF temp= "6" THEN Six_p
    · IF temp= "7" THEN Seven_p
    · IF temp= "8" THEN Eight_p
    · IF temp= "9" THEN Nine_p
    · IF temp= "0" THEN zero_p
    · IF temp > 54 OR temp < 49 THEN Error 'coMPares key and jumps if true
    'Displays in ASCll
    io_pin = temp - 48···················· 'Converts ASCll to decimal
    SEROUT Tx,Baud,[noparse][[/noparse]Int,Clear_screen,"Please press an * to",Int,Cursor_pos,1,2,
    ·············· "turn off Pin ",DEC io_pin," or #",Int,Cursor_pos,1,3,
    ·············· "to turn it on."]
    Wait_For_key:························· 'Label
    'Displays character typed in ASCll
    SEROUT Tx,Baud,[noparse][[/noparse]Int,Poll_keypad]······ 'Request last key press from LCD
    SERIN Rx,Baud,[noparse][[/noparse]temp]·················· 'Store key press in temp
    IF temp = 0 THEN Wait_For_key········· 'If no key Press jump to label
    · GOSUB Convert······················· 'Jump to listed label
    · key = temp·························· 'StorES temp in to key variable
    RETURN································ 'Jump to next line UNDER last gosub
    Convert:······························ 'Label
    'Table to convert variable
    LOOKDOWN· temp,[noparse][[/noparse]66,67,68,69,71,72,73,74,76,77,78,79,81,82,83,84],temp
    'Table to convert variable
    LOOKUP··· temp,[noparse][[/noparse]"D","#","0","*","C","9","8","7","B","6","5","4","A","3",
    ·············· "2","1"],temp
    RETURN································ 'Jump to next line UNDER last gosub
    All_On:
    ·SEROUT Tx,Baud,[noparse][[/noparse]Int,Clear_screen]······························ 'Label
    SEROUT Tx,Baud,[noparse][[/noparse]"All on"]············· 'Displays text
    FOR io_pin = 1 TO 6··················· 'CyCLEs io_pin variable fro 1 to 6
    ·SEROUT Tx,Baud,[noparse][[/noparse]Int,GP_Pin_On,io_pin] 'SETs listed I/O pin to on
    NEXT·································· 'cycles until io_pin = 6
    PAUSE 1000···························· 'Pauses for 1000 ms or 1 second
    GOTO Initialize······················· 'Jumps to listed label
    All_Off:
    ·SEROUT Tx,Baud,[noparse][[/noparse]Int,Clear_screen]····························· 'Label·· INCOmPlETE
    SEROUT Tx,Baud,[noparse][[/noparse]"All Off"]············ 'Displays text
    FOR io_pin = 1 TO 6··················· 'CYCles io_pin variable fro 1 to 6
    ·SEROUT Tx,Baud,[noparse][[/noparse]Int,GP_Pin_Off,io_pin]'Sets listed I/O pin to off
    NEXT·································· 'cycles until io_pin = 6
    PAUSE 1000···························· 'Pauses for 1000 ms or 1 second
    GOTO Initialize······················· 'Jumps to listed label
    Error:································ 'Label
    ·SEROUT Tx,Baud,[noparse][[/noparse]Int,Clear_screen]···· 'Clears screen
    'Displays text
    ·SEROUT Tx,Baud,[noparse][[/noparse]"······· ERROR··············· "]
    ·PAUSE 1000··························· 'Pauses for 1000 ms or 1 second
    GOTO Initialize······················· 'Jumps to listed label
    ·· ' dont know where these go
    Exit_p:
    SEROUT Tx,Baud,[noparse][[/noparse]Int,Clear_screen]
    ··· SEROUT Tx,Baud,[noparse][[/noparse]"··· ..WARNING..",Int,Cursor_pos,1,2,
    ·············· "*All SYSTEMS LOCKED*" ]
    ·············· PAUSE 500
    ·· GOTO check_password

    ·· Main_p:
    ··· SEROUT Tx,Baud,[noparse][[/noparse]Int,Clear_screen]
    ·· SEROUT Tx,Baud,[noparse][[/noparse]"··· Main· Program "]
    ·· PAUSE 500
    ···· GOTO Initialize
    ··· One_p:
    · SEROUT Tx,Baud,[noparse][[/noparse]Int,Clear_screen]
    ·· SEROUT Tx,Baud,[noparse][[/noparse]"Camera· Program "]
    ·· PAUSE 1000
    ·· GOTO Initialize
    ·Two_p:
    SEROUT Tx,Baud,[noparse][[/noparse]Int,Clear_screen]
    ·· SEROUT Tx,Baud,[noparse][[/noparse]"I.R.Tracking Program "]
    ·· PAUSE 1000
    · GOTO Initialize
    ·Three_p:
    ·SEROUT Tx,Baud,[noparse][[/noparse]Int,Clear_screen]
    ·· SEROUT Tx,Baud,[noparse][[/noparse]"Thermal· Program "]
    ·· PAUSE 1000
    ·· GOTO Initialize
    Four_p:
    SEROUT Tx,Baud,[noparse][[/noparse]Int,Clear_screen]
    ·· SEROUT Tx,Baud,[noparse][[/noparse]"Bluetooth Program "]
    ·· PAUSE 1000
    ·· GOTO Initialize
    Five_p:
    SEROUT Tx,Baud,[noparse][[/noparse]Int,Clear_screen]
    ·· SEROUT Tx,Baud,[noparse][[/noparse]"··· Five· Program "]
    ·· PAUSE 500
    ·· GOTO Initialize
    Six_p :
    SEROUT Tx,Baud,[noparse][[/noparse]Int,Clear_screen]
    ·· SEROUT Tx,Baud,[noparse][[/noparse]"··· Six· Program "]
    ·· PAUSE 500
    ·· GOTO Initialize
    Seven_p:
    SEROUT Tx,Baud,[noparse][[/noparse]Int,Clear_screen]
    ·· SEROUT Tx,Baud,[noparse][[/noparse]"··· Seven· Program "]
    ·· PAUSE 500
    ·· GOTO Initialize
    Eight_p:
    SEROUT Tx,Baud,[noparse][[/noparse]Int,Clear_screen]
    ·· SEROUT Tx,Baud,[noparse][[/noparse]"··· Eight Program "]
    ·· PAUSE 500
    ·· GOTO Initialize
    Nine_p :
    SEROUT Tx,Baud,[noparse][[/noparse]Int,Clear_screen]
    ·· SEROUT Tx,Baud,[noparse][[/noparse]"··· Nine Program "]
    ·· PAUSE 500
    ·· GOTO Initialize
    · zero_p :
    SEROUT Tx,Baud,[noparse][[/noparse]Int,Clear_screen]
    ·· SEROUT Tx,Baud,[noparse][[/noparse]"··· Zero Program "]
    ·· PAUSE 500
    ·· GOTO Initialize
  • Bruce BatesBruce Bates Posts: 3,045
    edited 2006-07-01 15:23
    Cline -

    You should be able to take the following part of your program and change it as shown:

    IF temp= "0" THEN zero_p
    IF temp= "1" THEN One_p
    IF temp= "2" THEN Two_p
    IF temp= "3" THEN Three_p
    IF temp= "4" THEN Four_p
    IF temp= "5" THEN Five_p
    IF temp= "6" THEN Six_p
    IF temp= "7" THEN Seven_p
    IF temp= "8" THEN Eight_p
    IF temp= "9" THEN Nine_p

    Change to:

    On temp GoTo (zero_p, One_p, Two_p, Three_p, Four_p, Five_p, Six_p, Seven_p, Eight_p, Nne_p)
    I suspect the variable "io_pin" can also be changed to a NIB sized variable.

    Regards,

    Bruce Bates


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    <!--StartFragment -->

    Post Edited (Bruce Bates) : 7/1/2006 9:19:27 PM GMT
  • ClineCline Posts: 36
    edited 2006-07-01 15:56
    I will try that, do i type

    ' On temp goto........... just like you wrote it?
  • ClineCline Posts: 36
    edited 2006-07-01 16:03
    so am i correct that the bs2 with the app mod only has 2k of mem?, its the same board as the boe-bot,

    ·
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2006-07-01 16:28
    You use this a lot --
    SEROUT Tx,Baud,[noparse][[/noparse]Int,Clear_screen]·····

    Make a sub-routine:
    clr_scrn:
    ·SEROUT Tx,Baud,[noparse][[/noparse]Int,Clear_screen]
    ·RETURN

    Then, Wherever you currently have SEROUT Tx,Baud,[noparse][[/noparse]Int,Clear_screen] -- replace it with GOSUB clr_scrn

    I think that alone will recover about Hex200 in program space.

    Also, you might consider some abbreviations, eliminating 'dots', etc.
  • ClineCline Posts: 36
    edited 2006-07-01 16:39
    thats great info, ill use that, any ideas on the pasword part?
  • Mike GreenMike Green Posts: 23,101
    edited 2006-07-01 16:47
    The board that comes with the BOE-BOT normally has a BS2 chip included. This one has only 2K of program memory. You can buy other Stamps (like the BS2p, BS2px, BS2pe, BS2sx) that have other features. Some are faster, some have more program memory, some have additional statements, and some have more data storage in a separate area. All of the Stamp processors will work with the BOE. As mentioned, the other Stamps with additional program memory require that you split your program into banks (like overlays). You can't just compile a bigger program. As you are finding out, you can usually make a program a lot smaller by combining similar portions and using subroutines. Sometimes you can use tables to control complex logic and that can save a lot of space. In your case, with a lot of menu choices, you can probably put that logic into a table like:

    table Data "a",10,"choice 000",
    Data 0

    Each entry starts with a byte containing the menu choice character
    The next byte contains the total size of the string that follows
    Next is the text to be sent to the display
    The next table entry follows this one and the last entry is followed by a zero byte (for the menu choice character)

    ptr = table
    gosub doit
    ...
    doit: read ptr,menu
    ptr = ptr + 1
    if menu = 0 then notthere
    if menu = theChar then gotit
    read ptr,menu
    ptr = ptr + menu
    goto doit
    gotit: serout tx,baud,[noparse][[/noparse]int,clearscreen]
    read ptr,count
    domore:
    ptr = ptr + 1
    read ptr,temp
    serout tx,baud,[noparse][[/noparse]temp]
    count = count - 1
    if count > 0 then domore
    return
    notthere:
    ?????
    return
  • Tracy AllenTracy Allen Posts: 6,658
    edited 2006-07-01 16:52
    This kind of statement,
    SEROUT Tx,Baud,[noparse][[/noparse]"Bluetooth Program "]
    where the display text is part of a serout or debug command consumes gobs of program space. It is much more efficient to store the text in DATA statements and use a display routine to read them out:

    Three_p_dat  DATA Int, Clear_screen, "Thermal  Program ", 0   ' <--- null terminated strings
    Four_p_dat DATA Int, Clear_screen, "Bluetooth Program", 0
    ' etc....
    
    main:
       daPointer = Four_p_dat  ' <--- reference by pointer
       GOSUB display
       PAUSE 1000
       END
    
    display:
      DO 
        READ daPointer,char
        IF char=0 THEN EXIT   ' <--- read & show up to null
        SEROUT Tx,Baud,[noparse][[/noparse]char]
        daPointer = daPointer + 1
      LOOP
    



    oops -- I editied the program to increment daPointer

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com

    Post Edited (Tracy Allen) : 7/1/2006 5:52:24 PM GMT
Sign In or Register to comment.