Shop OBEX P1 Docs P2 Docs Learn Events
Operating system — Parallax Forums

Operating system

David92680David92680 Posts: 10
edited 2008-04-29 18:09 in BASIC Stamp
Looking to build a project that uses the basic stamp2 with an operating system to display on an LCD 2x20 display. Will operate menus and options by 3 or 4 button inputs. Looking for some feedback on how I go about building a program to operate like an os on the basic stamp.

Comments

  • allanlane5allanlane5 Posts: 3,815
    edited 2008-04-29 18:09
    It's pretty simple.
    The BS2 has 26 bytes of 'RAM' (actually register space). Everything is 'global'.

    ' {$STAMP BS2}
    ' {$PBASIC 2.5}
    LCD1 DATA "This is the LCD1 screen", 0
    LCD2 DATA "This is the LCD2 screen", 0
    ButtonHit VAR Byte
    MenuState VAR Byte
    LCD_Msg·· VAR Word
    I·········· ·· VAR Word
    SendByte· VAR Byte
    MenuState = 0· ' zero is the 'starting' menu.
    MAIN:
    · GOSUB Read_Buttons· ' Sets ButtonHit to whatever button was hit, or zero if timeout
    · GOSUB SendLCD······· ' Sends the LCD message, based on "ButtonHit' and 'MenuState'
    · GOTO MAIN

    Read_Buttons:
    · ' Whatever it takes to read the buttons
    · ' and set "ButtonHit"
    · RETURN

    SendLCD:
    · IF MenuState = 0 THEN
    ··· LCD_Msg· = LCD1
    · ENDIF
    · GOSUB OutputLCD
    · RETURN

    OutputLCD:
    · I = LCD_Msg
    · READ I, SendByte
    · DO WHILE SendByte <> 0
    ··· ' Write SendByte to LCD Port
    ··· I = I + 1
    ··· READ I, SendByte
    · LOOP
    · RETURN
    ·
Sign In or Register to comment.