Counter to Save to eeprom, then go back in 24 hour's and read eeprom.
Jeff2
Posts: 46
What I am looking to do is. In the program I sent in this post.
Is there A way to count the # of times pin[noparse][[/noparse]23] is pushed, save the count each time to the eeprom, and then go back into the eeprom and see how many
times is was pushed. Like in 24 hour's?
Is there A way to count the # of times pin[noparse][[/noparse]23] is pushed, save the count each time to the eeprom, and then go back into the eeprom and see how many
times is was pushed. Like in 24 hour's?
con _clkmode = xtal1 + pll16x _xinfreq = 0_500_000 pub Kid repeat if ina [noparse][[/noparse]23] == 1 right pub right dira[noparse][[/noparse]0..19] := %11111111111111111111 outa[noparse][[/noparse]0..19] := %00000000000000000000 waitcnt(clkfreq/4 + cnt) outa[noparse][[/noparse]0..19] := %00000000000000000000 waitcnt(clkfreq/4 + cnt) outa[noparse][[/noparse]0..19] := %10000000000000000000 waitcnt(clkfreq/4 + cnt) outa[noparse][[/noparse]0..19] := %11000000000000000000 waitcnt(clkfreq/4 + cnt) outa[noparse][[/noparse]0..19] := %11100000000000000000 waitcnt(clkfreq/4 + cnt) outa[noparse][[/noparse]0..19] := %11110000000000000000 waitcnt(clkfreq/4 + cnt) outa[noparse][[/noparse]0..19] := %11111000000000000000 waitcnt(clkfreq/4 + cnt) outa[noparse][[/noparse]0..19] := %11111100000000000000 waitcnt(clkfreq/4 + cnt) outa[noparse][[/noparse]0..19] := %11111110000000000000 waitcnt(clkfreq/4 + cnt) outa[noparse][[/noparse]0..19] := %11111111000000000000 waitcnt(clkfreq/4 + cnt) outa[noparse][[/noparse]0..19] := %11111111100000000000 waitcnt(clkfreq/4 + cnt) outa[noparse][[/noparse]0..19] := %11111111110000000000 waitcnt(clkfreq/4 + cnt) outa[noparse][[/noparse]0..19] := %11111111111000000000 waitcnt(clkfreq/4 + cnt) outa[noparse][[/noparse]0..19] := %11111111111100000000 waitcnt(clkfreq/4 + cnt) outa[noparse][[/noparse]0..19] := %11111111111110000000 waitcnt(clkfreq/4 + cnt) outa[noparse][[/noparse]0..19] := %11111111111111000000 waitcnt(clkfreq/4 + cnt) outa[noparse][[/noparse]0..19] := %11111111111111100000 waitcnt(clkfreq/4 + cnt) outa[noparse][[/noparse]0..19] := %11111111111111110000 waitcnt(clkfreq/4 + cnt) outa[noparse][[/noparse]0..19] := %11111111111111111000 waitcnt(clkfreq/4 + cnt) outa[noparse][[/noparse]0..19] := %11111111111111111100 waitcnt(clkfreq/4 + cnt) outa[noparse][[/noparse]0..19] := %11111111111111111110 waitcnt(clkfreq/4 + cnt) outa[noparse][[/noparse]0..19] := %11111111111111111111 REPEAT WHILE ina[noparse][[/noparse]23] == 1 dira[noparse][[/noparse]0..19] := %11111111111111111111 outa[noparse][[/noparse]0..19] := %11111111111111111111 waitcnt(clkfreq/4 + cnt) outa[noparse][[/noparse]0..19] := %00000000000000000000
Comments
how many times it was pushed.
You read the last long using i2c.ReadLong(28, $a0, $7ffc) and you can write it using i2c.WriteLong(28, $a0, $7ffc, count).· You should follow the write by a call to WriteWait until it returns a value of zero.· You could use the loop repeat while i2c.WriteWait(28, $a0, $7ffc).
Dave
Post Edited (Dave Hein) : 5/23/2010 3:02:05 AM GMT
On another point you're going to need an accurate way to keep track of 24 hours -- not easy to do when your program is busy looking for button pushes.· That said, you can launch a software RTC into its own coq quite easily; the attached demo shows an easy way to incorporate a software RTC in your programs.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon McPhalen
Hollywood, CA
a) counted presses (these should be debounced/qualified
b) when a new press is detected, save it to EE (I2C not shown, but there's a lot of code by me and others in ObEx)
c) watched the clock -- when the time rolled over to 00:00:00 you hit 24 hours and you can display our total and do what you will
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon McPhalen
Hollywood, CA