Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated all references of EEPROM.write to EEPROM.update #18

Merged
merged 1 commit into from
Jan 30, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions firmware/OpenLCD/OpenLCD.ino
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ void updateDisplay()

//Record this custom char to EEPROM
for (byte charSpot = 0 ; charSpot < 8 ; charSpot++)
EEPROM.write(LOCATION_CUSTOM_CHARACTERS + (customCharNumber * 8) + charSpot, customCharData[charSpot]); //addr, val
EEPROM.update(LOCATION_CUSTOM_CHARACTERS + (customCharNumber * 8) + charSpot, customCharData[charSpot]); //addr, val

//For some reason you need to re-init the LCD after a custom char is created
SerLCD.begin(settingLCDwidth, settingLCDlines);
Expand Down Expand Up @@ -444,4 +444,4 @@ void displayFrameBuffer(void)

//Return the cursor to its original position
SerLCD.setCursor(characterCount % settingLCDwidth, characterCount / settingLCDwidth);
}
}
28 changes: 14 additions & 14 deletions firmware/OpenLCD/Setting_Control.ino
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ void changeIgnore()
SerLCD.print(F("N"));
}
//Record this new setting
EEPROM.write(LOCATION_IGNORE_RX, settingIgnoreRX);
EEPROM.update(LOCATION_IGNORE_RX, settingIgnoreRX);

petSafeDelay(SYSTEM_MESSAGE_DELAY);

Expand All @@ -53,7 +53,7 @@ void displayFirmwareVersion()
//Press a or z to adjust, x to exit
void changeContrast(byte contrast)
{
EEPROM.write(LOCATION_CONTRAST, contrast); //Store this new contrast
EEPROM.update(LOCATION_CONTRAST, contrast); //Store this new contrast

//Go to this new contrast
analogWrite(LCD_CONTRAST, contrast);
Expand All @@ -74,7 +74,7 @@ void changeContrast(byte contrast)
void changeTWIAddress(byte newAddress)
{
//Record the new address
EEPROM.write(LOCATION_TWI_ADDRESS, newAddress);
EEPROM.update(LOCATION_TWI_ADDRESS, newAddress);

setupTWI(); //Leverage the regular startup function

Expand All @@ -95,7 +95,7 @@ void changeSplashContent()
{
//Record the current frame to EEPROM
for (byte x = 0 ; x < settingLCDlines * settingLCDwidth ; x++)
EEPROM.write(LOCATION_SPLASH_CONTENT + x, currentFrame[x]);
EEPROM.update(LOCATION_SPLASH_CONTENT + x, currentFrame[x]);

//Display the backlight setting
SerLCD.clear();
Expand All @@ -114,17 +114,17 @@ void changeBLBrightness(byte color, byte brightness)
{
if (color == RED)
{
EEPROM.write(LOCATION_RED_BRIGHTNESS, brightness); //Record new setting
EEPROM.update(LOCATION_RED_BRIGHTNESS, brightness); //Record new setting
analogWrite(BL_RW, 255 - brightness); //Controlled by PNP so reverse the brightness value
}
else if (color == GREEN)
{
EEPROM.write(LOCATION_GREEN_BRIGHTNESS, brightness); //Record new setting
EEPROM.update(LOCATION_GREEN_BRIGHTNESS, brightness); //Record new setting
analogWrite(BL_G, 255 - brightness); //Controlled by PNP so reverse the brightness value
}
else if (color == BLUE)
{
EEPROM.write(LOCATION_BLUE_BRIGHTNESS, brightness); //Record new setting
EEPROM.update(LOCATION_BLUE_BRIGHTNESS, brightness); //Record new setting
//analogWrite(BL_B, 255 - brightness); //Controlled by PNP so reverse the brightness value
SoftPWMSet(BL_B, 255 - brightness); //Controlled by software PWM
}
Expand Down Expand Up @@ -154,15 +154,15 @@ void changeBLBrightness(byte color, byte brightness)
//with their rgb values to eliminate flicker. Incoming brightness values should be 0 to 255
void changeBacklightRGB(byte red, byte green, byte blue) {
//update red
EEPROM.write(LOCATION_RED_BRIGHTNESS, red); //Record new setting
EEPROM.update(LOCATION_RED_BRIGHTNESS, red); //Record new setting
analogWrite(BL_RW, 255 - red); //Controlled by PNP so reverse the brightness value

//update green
EEPROM.write(LOCATION_GREEN_BRIGHTNESS, green); //Record new setting
EEPROM.update(LOCATION_GREEN_BRIGHTNESS, green); //Record new setting
analogWrite(BL_G, 255 - green); //Controlled by PNP so reverse the brightness value

//update blue (SoftPWM)
EEPROM.write(LOCATION_BLUE_BRIGHTNESS, blue); //Record new setting
EEPROM.update(LOCATION_BLUE_BRIGHTNESS, blue); //Record new setting
//analogWrite(BL_B, 255 - brightness); //Controlled by PNP so reverse the brightness value
SoftPWMSet(BL_B, 255 - blue); //Controlled by software PWM
}
Expand Down Expand Up @@ -216,7 +216,7 @@ void changeUARTSpeed(byte setting)
}

//Record this new buad rate
EEPROM.write(LOCATION_BAUD, settingUARTSpeed);
EEPROM.update(LOCATION_BAUD, settingUARTSpeed);

//Display that we are at this new speed
SerLCD.clear();
Expand Down Expand Up @@ -254,7 +254,7 @@ void changeSplashEnable()
petSafeDelay(SYSTEM_MESSAGE_DELAY);

//Record this new setting
EEPROM.write(LOCATION_SPLASH_ONOFF, settingSplashEnable);
EEPROM.update(LOCATION_SPLASH_ONOFF, settingSplashEnable);

displayFrameBuffer(); //Return the contents of the display
}
Expand Down Expand Up @@ -287,8 +287,8 @@ void changeLinesWidths(byte setting)
clearFrameBuffer();

//Record this new setting
EEPROM.write(LOCATION_WIDTH, settingLCDwidth);
EEPROM.write(LOCATION_LINES, settingLCDlines);
EEPROM.update(LOCATION_WIDTH, settingLCDwidth);
EEPROM.update(LOCATION_LINES, settingLCDlines);

//Display new settings to the user
SerLCD.clear();
Expand Down
22 changes: 10 additions & 12 deletions firmware/OpenLCD/System_Functions.ino
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ void setupUART()
if (settingIgnoreRX > 1)
{
settingIgnoreRX = false; //Don't ignore
EEPROM.write(LOCATION_IGNORE_RX, settingIgnoreRX);
EEPROM.update(LOCATION_IGNORE_RX, settingIgnoreRX);
}

if (settingIgnoreRX == false) //If we are NOT ignoring RX, then
Expand All @@ -103,7 +103,7 @@ void setupUART()
if (settingUARTSpeed > BAUD_1000000) //Check to see if the baud rate has ever been set
{
settingUARTSpeed = DEFAULT_BAUD; //Reset UART to 9600 if there is no baud rate stored
EEPROM.write(LOCATION_BAUD, settingUARTSpeed);
EEPROM.update(LOCATION_BAUD, settingUARTSpeed);
}

//Initialize the UART
Expand Down Expand Up @@ -139,7 +139,7 @@ void setupTWI()
if ((twiAddress == 0) || (twiAddress > 0x7F))
{ // If the TWI address is invalid, use a default address
twiAddress = DEFAULT_TWI_ADDRESS;
EEPROM.write(LOCATION_TWI_ADDRESS, DEFAULT_TWI_ADDRESS);
EEPROM.update(LOCATION_TWI_ADDRESS, DEFAULT_TWI_ADDRESS);
}

Wire.begin(twiAddress); //Initialize Wire library as slave at twiAddress address
Expand All @@ -154,7 +154,7 @@ void setupContrast()
if (settingContrast == 255) //Check to see if the contrast has ever been set
{
settingContrast = DEFAULT_CONTRAST_LCD; //Default
EEPROM.write(LOCATION_CONTRAST, settingContrast);
EEPROM.update(LOCATION_CONTRAST, settingContrast);
}

//Change contrast without notification message
Expand All @@ -171,14 +171,14 @@ void setupLCD()
if (settingLCDlines > 4)
{
settingLCDlines = DEFAULT_LINES;
EEPROM.write(LOCATION_LINES, settingLCDlines);
EEPROM.update(LOCATION_LINES, settingLCDlines);
}

settingLCDwidth = EEPROM.read(LOCATION_WIDTH);
if (settingLCDwidth > 20)
{
settingLCDwidth = DEFAULT_WIDTH;
EEPROM.write(LOCATION_WIDTH, settingLCDwidth);
EEPROM.update(LOCATION_WIDTH, settingLCDwidth);
}

//Check the display jumper
Expand Down Expand Up @@ -222,7 +222,7 @@ void setupSplash()
if (settingSplashEnable > 1)
{
settingSplashEnable = DEFAULT_SPLASH;
EEPROM.write(LOCATION_SPLASH_ONOFF, settingSplashEnable);
EEPROM.update(LOCATION_SPLASH_ONOFF, settingSplashEnable);
}

if (settingSplashEnable)
Expand All @@ -246,7 +246,7 @@ void setupSplash()
if (settingUARTSpeed > BAUD_1000000) //Check to see if the baud rate has ever been set
{
settingUARTSpeed = DEFAULT_BAUD; //Reset UART to 9600 if there is no baud rate stored
EEPROM.write(LOCATION_BAUD, settingUARTSpeed);
EEPROM.update(LOCATION_BAUD, settingUARTSpeed);
}

SerLCD.print(lookUpBaudRate(settingUARTSpeed));
Expand Down Expand Up @@ -284,7 +284,7 @@ void setupSplash()

SerLCD.print("Baud Reset");

EEPROM.write(LOCATION_BAUD, BAUD_9600);
EEPROM.update(LOCATION_BAUD, BAUD_9600);

petSafeDelay(SYSTEM_MESSAGE_DELAY);

Expand Down Expand Up @@ -352,9 +352,7 @@ void checkEmergencyReset(void)

//If we make it here, then RX pin stayed low the whole time
//Reset all EEPROM locations to factory defaults.
for (int x = 0 ; x < 200 ; x++)
EEPROM.write(x, 0xFF);

for (int x = 0 ; x < 200 ; x++) EEPROM.update(x, 0xFF);

//Change contrast without notification message
analogWrite(LCD_CONTRAST, 40); //Set contrast to default
Expand Down