Shop OBEX P1 Docs P2 Docs Learn Events
Setting numbers in memory — Parallax Forums

Setting numbers in memory

ArchiverArchiver Posts: 46,084
edited 2001-07-26 07:01 in General Discussion
Fellow Stampers,

Quick question before I reinvent the wheel.

I have a need in an application to store 5 single digit numbers in eeprom at
programming time (say 0,0,0,0,0) Then I need to be able to change these numbers
in the feild within the application.
Has anyone got code that will allow me to do this with a couple of buttons
and an LCD display? Preferably on a BS2E if that isn't asking to much.
Then i need the software to be able to read these back out at the time they
are used.

Should I use the stamps eeprom or an external unit?

I have not interfaced an external eeprom to a stamp before, is it as easy as
it sounds (!)

Regards

Tim Stockman


[noparse][[/noparse]Non-text portions of this message have been removed]

Comments

  • ArchiverArchiver Posts: 46,084
    edited 2001-07-25 16:45
    >Fellow Stampers,
    >
    > Quick question before I reinvent the wheel.
    >
    > I have a need in an application to store 5 single digit numbers
    >in eeprom at programming time (say 0,0,0,0,0) Then I need to be able
    >to change these numbers in the feild within the application.
    > Has anyone got code that will allow me to do this with a couple
    >of buttons and an LCD display? Preferably on a BS2E if that isn't
    >asking to much.
    > Then i need the software to be able to read these back out at
    >the time they are used.
    >
    > Should I use the stamps eeprom or an external unit?
    >
    > I have not interfaced an external eeprom to a stamp before, is
    >it as easy as it sounds (!)
    >
    >Regards
    >
    >Tim Stockman

    Hi Tim,

    With only 5 digits to change, and those only occasionally, the BS2e
    eeprom should work just fine. The external eeproms are easy to use,
    but nowhere near as easy as the built-in!

    By "five single digit numbers", do you mean 5 numbers that take on values 0--9?

    The user could hold down the first button and watch the LCD display
    cycle trough digit number 1-2-3-4-5-1-... They release the button
    when the one they want to modify is shown on screen. Then they hold
    down the second button and watch the value for that digit cycle
    through 0-1-2-...9-0-... They release the button when the digit
    they want appears. Is that the kind of interface you are after?

    -- Tracy
  • ArchiverArchiver Posts: 46,084
    edited 2001-07-25 23:48
    Yes Tracy,

    Thats pretty close to what I'm after.
    Yes they are 5 single digit vales from 0-9 stored individually from
    locatiosn 0-4
    It would be nice to be able to display the current 5 digits (a selcall
    ID) and then move the cursor under each digit then be able to change to
    selected digit. I am currently using a serial LCD
    The idea it to retreive the numbers from eeprom and generate the
    relevant tones from a lookup table (that part I have sussed!)

    Also another quick question, if I store some data in the 0 program it
    seems that I can retreive it from other programs in the BS2e. Is that
    susposed to happen or have I just fluked it?

    Regards
    Original Message

    From: "Tracy Allen" <tracy@e...>
    To: <basicstamps@yahoogroups.com>
    Sent: Thursday, July 26, 2001 1:15 AM
    Subject: Re: [noparse][[/noparse]basicstamps] Setting numbers in memory



    > Hi Tim,
    >
    > With only 5 digits to change, and those only occasionally, the BS2e
    > eeprom should work just fine. The external eeproms are easy to use,
    > but nowhere near as easy as the built-in!
    >
    > By "five single digit numbers", do you mean 5 numbers that take on values
    0--9?
    >
    > The user could hold down the first button and watch the LCD display
    > cycle trough digit number 1-2-3-4-5-1-... They release the button
    > when the one they want to modify is shown on screen. Then they hold
    > down the second button and watch the value for that digit cycle
    > through 0-1-2-...9-0-... They release the button when the digit
    > they want appears. Is that the kind of interface you are after?
    >
    > -- Tracy
    >
    >
    > To UNSUBSCRIBE, just send mail to:
    > basicstamps-unsubscribe@yahoogroups.com
    > from the same email address that you subscribed. Text in the Subject and
    Body of the message will be ignored.
    >
    >
    > Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
    >
    >
  • ArchiverArchiver Posts: 46,084
    edited 2001-07-26 07:01
    > Yes they are 5 single digit vales from 0-9 stored individually from
    >locatiosn 0-4
    > It would be nice to be able to display the current 5 digits (a selcall
    >ID) and then move the cursor under each digit then be able to change to
    >selected digit. I am currently using a serial LCD
    > The idea it to retreive the numbers from eeprom and generate the
    >relevant tones from a lookup table (that part I have sussed!)

    Here is possible pseudocode. There would be lots of ways to do this
    with ramifications for user interface comfort.
    1) position cursor on lcd, read out the 5 current digits and put
    them on screen along with a prompt.
    2) position the cursor on top of the first digit, and be sure the
    cursor is set to blinking block. The digit will appear to blink
    white and black.
    3) The user presses the pushbutton #1 repeatedly to position the
    cursor over one of the digits to select it.
    4) The user presses pushbutton #2 repeatedly to increment the
    selected digit in a cyclic manner.
    5) The user presses pushbutton #1 for a full 2 seconds to exit the
    routine, or else briefly to select another digit.
    6) The new selections are recorded in eeprom.

    Here is some half-baked code for steps 3 to 5:

    testbuttons:
    timer=0
    buttonstate=inA & %11 ' pushbuttons on P0 and P1, %11=>nothing pressed
    branch buttonstate,[noparse][[/noparse]both,just1,just0,neither]

    just0:
    lcdOffset=lcdOffset+1 // 5 ' position 0,1,2,3,4
    lcdPosition=lcdDigitStart+lcdOffset ' where to put the cursor
    serout ...[noparse][[/noparse]..lcdposition] ' command to set lcd position, cursor on
    waitup0:
    timer=timer+1 ' keep track of how long P0 is held down
    pause 10
    if timer=200 then exitThisRoutineAndWriteData ' this is the exit
    branch in0,[noparse][[/noparse]waitup0,testbuttons] ' waitup0 until P0 release or timeout

    just1:
    digit(i)=digit(i)+1 // 10 ' cycle through digits, one per keypress
    serout .... [noparse][[/noparse]48+digit(i), .. lcdPosition] ' send new digit and reposition
    waitup1:
    branch in0,[noparse][[/noparse]waitup1,testbuttons] ' waitup1 until P1 release

    both:
    goto testbuttons ' or whatever
    neither
    goto testbuttons ' or whatever, this might have a time-out

    I hope that helps.

    -- regards,
    Tracy Allen
    electronically monitored ecosystems
    mailto:tracy@e...
    http://www.emesystems.com





    > Also another quick question, if I store some data in the 0 program it
    >seems that I can retreive it from other programs in the BS2e. Is that
    >susposed to happen or have I just fluked it?
Sign In or Register to comment.