eeprom try1

master
Dario Ernst 13 years ago
parent 86a39db78e
commit 33519c4311

@ -1,8 +1,9 @@
#include <EEPROM.h>
#include <LiquidCrystal.h>
#include <Encoder.h>
#include <stdio.h>
LiquidCrystal lcd(9, 3, 8, 7, 6, 5, 4);
Encoder rotEnc(A0, A1);
long encVal = 0;
@ -11,6 +12,27 @@ int timerLens[3];
int grindCheck = 0;
bool updateDisplay=false;
int eeAddr1 = 0;
int eeAddr2 = 5;
int eeAddr3 = 10;
void EEPROMWriteInt(int p_address, int p_value) {
byte lowByte = ((p_value >> 0) & 0xFF);
byte highByte = ((p_value >> 8) & 0xFF);
EEPROM.write(p_address, lowByte);
EEPROM.write(p_address + 1, highByte);
}
unsigned int EEPROMReadInt(int p_address) {
byte lowByte = EEPROM.read(p_address);
byte highByte = EEPROM.read(p_address + 1);
return ((lowByte << 0) & 0xFF) + ((highByte << 8) & 0xFF00);
}
bool buttonLeftPressed=false;
void buttonLeft() {
buttonLeftPressed=true;
@ -55,7 +77,7 @@ void grind(int time) {
delay(time);
digitalWrite(2, LOW);
lcdPut("Fin...");
delay(750);
delay(550);
}
@ -142,6 +164,13 @@ void loop() {
sprintf(str, "T%1d:%5d", activeTimer, timerLens[activeTimer]);
lcdPut(str);
updateDisplay=false;
// if(EEPROMReadInt(eeAddr1) != timerLens[0])
// EEPROMWriteInt(eeAddr1, timerLens[0]);
// if(EEPROMReadInt(eeAddr2) != timerLens[1])
// EEPROMWriteInt(eeAddr2, timerLens[1]);
// if(EEPROMReadInt(eeAddr3) != timerLens[2])
// EEPROMWriteInt(eeAddr3, timerLens[2]);
}
}
@ -152,9 +181,14 @@ void setup()
{
//Serial.begin(9600);
timerLens[0] = 1000;
timerLens[1] = 250;
timerLens[2] = 9950;
// EEPROMWriteInt(eeAddr1, 4500);
// EEPROMWriteInt(eeAddr2, 500);
// EEPROMWriteInt(eeAddr3, 10000);
timerLens[0] = EEPROMReadInt(eeAddr1);
timerLens[1] = EEPROMReadInt(eeAddr2);
timerLens[2] = EEPROMReadInt(eeAddr3);
pinMode(A3, INPUT);
digitalWrite(A3,HIGH);

Loading…
Cancel
Save