How to set defaults and keep them
Torquewrench
Posts: 28
Hi,
I am working on a project for automating the firing of a paintball gun. I've made huge progress in developing the code. I have a firing sequence, firing modes, and LCD menu control (thanks big time to Nuts & Volts, Jon Williams, you rock!).
My question concerns how to incorporate presets to variables that can then be changed and kept.
To clarify, here are my variables
Shot counter 'short term shots, easily reset
Odometer 'lifetime shots, difficult to reset
firing rate limit
burst count
solenoid dwell
drop time between shots
low battery voltage
So I would like to load up defaults when I first load the program on the stamp, but afterwards I have built menus to be able to adjust these values, and when the stamp is turned off I would like these user configured settings to remain.
I have attached the menu portion of my code if it helps, but I think this is a more general question.
Thank you,
Phil
I am working on a project for automating the firing of a paintball gun. I've made huge progress in developing the code. I have a firing sequence, firing modes, and LCD menu control (thanks big time to Nuts & Volts, Jon Williams, you rock!).
My question concerns how to incorporate presets to variables that can then be changed and kept.
To clarify, here are my variables
Shot counter 'short term shots, easily reset
Odometer 'lifetime shots, difficult to reset
firing rate limit
burst count
solenoid dwell
drop time between shots
low battery voltage
So I would like to load up defaults when I first load the program on the stamp, but afterwards I have built menus to be able to adjust these values, and when the stamp is turned off I would like these user configured settings to remain.
I have attached the menu portion of my code if it helps, but I think this is a more general question.
Thank you,
Phil
bs2
22K
Comments
kelvin
What I'm thinking is I need an EEPROM location for the default values, and somehow copy these to the variables and the user set EEPROM locations only at programming time. Once programming is complete the user can modify the user set EEPROM locations only.
If this is what you described, could you maybe give me a sample of code on how this is done?
Thank you,
Phil
DATA 0, 60 'firing rate limit
DATA 1, 31 'low battery voltage *10
firerate var byte
lowbat var byte
Main:
READ 0, firerate
READ 1, lowbat
Then to change them through the menu, then WRITE and they will be stored.
WRITE 0, firerate
WRITE 1, lowbat
Check the help in the editor for more info on these commands, but it should do want you want.
Post Edited (Orion) : 8/21/2005 3:19:48 PM GMT
·· I don't know if you realize with your code where the data is going.· With your current code the EEPROM will contain 0, 60, 1 and 31.· So when the code is run the 0 and 60 will be read in for the firing rate and lowbat.· The 1 and 31 will never be accessed.
·· Also, this program writes to EEPROM what it read.· You should change the values first to see the effect.· But other than that it will store the values written at run-time in place of those DATA values (The first 2).
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
DATA 60,31
instead of
data 0,60
data 1,31
Post Edited (Orion) : 8/21/2005 3:20:27 PM GMT
DATA @0, 60
DATA @1, 31
In this case, however, it just creates more typing than required.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
GetKey:
key = %11000000 ' assume all pressed
FOR loop = 1 TO 5 ' test five times
key = key & ~tempB ' test against new input
PAUSE 5 ' wait 5 ms between tests
NEXT
RETURN
~ = invert bits, check the help file in the Stamp editor.
kelvin
x VAR Byte
DATA @0,5
READ 0,x
DEBUG DEC x,CR
PAUSE 2000
x=2
WRITE 0,x
DEBUG DEC x,CR
PAUSE 2000