Skip to content

Commit 8a73a90

Browse files
committed
Fixed 'display firmware' command. It was overlapping on custom chars.
1 parent 02d2584 commit 8a73a90

File tree

2 files changed

+39
-31
lines changed

2 files changed

+39
-31
lines changed

firmware/OpenLCD/OpenLCD.ino

Lines changed: 32 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ enum displayMode
5353
MODE_COMMAND, //Used to indicate if a command byte has been received
5454
MODE_SETTING, //Used to indicate if a setting byte has been received
5555
MODE_CONTRAST, //First setting mode, then contrast change mode, then the value to change to
56-
MODE_TWI, //First setting mode, then custom char mode, then record 8 bytes
56+
MODE_TWI, //First setting mode, then I2C mode, then change I2C address
5757
MODE_RECORD_CUSTOM_CHAR, //First setting mode, then custom char mode, then record 8 bytes
5858
MODE_SET_RGB //First setting mode, then RGB mode, then get 3 bytes
5959
} currentMode = MODE_NORMAL;
@@ -202,22 +202,50 @@ void updateDisplay()
202202
{
203203
changeIgnore();
204204
}
205+
//Record custom characters
206+
else if (incoming >= 27 && incoming <= 34)
207+
{
208+
//User can record up to 8 custom chars
209+
customCharNumber = incoming - 27; //Get the custom char spot to record to
210+
211+
currentMode = MODE_RECORD_CUSTOM_CHAR; //Change to this special mode
212+
}
213+
214+
//Display custom characters, 8 characters allowed, 35 to 42 inclusive
215+
else if (incoming >= 35 && incoming <= 42)
216+
{
217+
SerLCD.write(byte(incoming - 35)); //You write location zero to display customer char 0
218+
}
205219
//Set Backlight RGB in one command to eliminate flicker
206-
else if (incoming == '+') {
220+
else if (incoming == 43) //+ character
221+
{
207222
currentMode = MODE_SET_RGB; //Go to new mode
208223
}
209224
//Display current firmware version
210-
else if (incoming == '\'') {
225+
else if (incoming == 44) //, character
226+
{
211227
displayFirmwareVersion();
212228
}
213229
//Clear screen and buffer
214-
else if (incoming == '-')
230+
else if (incoming == 45) //- character
215231
{
216232
SerLCD.clear();
217233
SerLCD.setCursor(0, 0);
218234

219235
clearFrameBuffer(); //Get rid of all characters in our buffer
220236
}
237+
//If we get a second special setting character, then write it to the display
238+
//This allows us to print a pipe by escaping it as a double
239+
else if (incoming == 124) //| character
240+
{
241+
SerLCD.write(incoming);
242+
243+
currentFrame[characterCount++] = incoming; //Record this character to the display buffer
244+
if (characterCount == settingLCDwidth * settingLCDlines) characterCount = 0; //Wrap condition
245+
}
246+
247+
//The following commands start at integer value 128
248+
221249
//Backlight Red or standard white
222250
else if (incoming >= SPECIAL_RED_MIN && incoming <= (SPECIAL_RED_MIN + 29))
223251
{
@@ -236,28 +264,6 @@ void updateDisplay()
236264
byte brightness = map(incoming, SPECIAL_BLUE_MIN, SPECIAL_BLUE_MIN + 29, 0, 255); //Covert 30 digit value to 255 digits
237265
changeBLBrightness(BLUE, brightness);
238266
}
239-
//Record custom characters
240-
else if (incoming >= 27 && incoming <= 34)
241-
{
242-
//User can record up to 8 custom chars
243-
customCharNumber = incoming - 27; //Get the custom char spot to record to
244-
245-
currentMode = MODE_RECORD_CUSTOM_CHAR; //Change to this special mode
246-
}
247-
248-
//Display custom characters, 8 characters allowed, 35 to 42 inclusive
249-
else if (incoming >= 35 && incoming <= 42)
250-
{
251-
SerLCD.write(byte(incoming - 35)); //You write location zero to display customer char 0
252-
}
253-
//If we get a second special setting character, then write it to the display
254-
//This allows us to print a pipe by escaping it as a double
255-
else if (incoming == SPECIAL_SETTING) {
256-
SerLCD.write(incoming);
257-
258-
currentFrame[characterCount++] = incoming; //Record this character to the display buffer
259-
if (characterCount == settingLCDwidth * settingLCDlines) characterCount = 0; //Wrap condition
260-
}
261267
}
262268
else if (currentMode == MODE_TWI)
263269
{

firmware/OpenLCD/System_Functions.ino

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -238,11 +238,7 @@ void setupSplash()
238238
SerLCD.setCursor(0, 0); //First position, 1st row
239239
SerLCD.print(F("SparkFun OpenLCD"));
240240
SerLCD.setCursor(0, 1); //First position, 2nd row
241-
SerLCD.print(F("Baud: "));
242-
SerLCD.print(F(" v"));
243-
SerLCD.print(firmwareVersionMajor);
244-
SerLCD.print(F("."));
245-
SerLCD.print(firmwareVersionMinor);
241+
SerLCD.print(F("Baud:"));
246242

247243
//Read what the current UART speed is from EEPROM memory
248244
//Default is 9600
@@ -254,6 +250,12 @@ void setupSplash()
254250
}
255251

256252
SerLCD.print(lookUpBaudRate(settingUARTSpeed));
253+
254+
//Display firmware version
255+
SerLCD.print(F(" v"));
256+
SerLCD.print(firmwareVersionMajor);
257+
SerLCD.print(F("."));
258+
SerLCD.print(firmwareVersionMinor);
257259
}
258260
else
259261
{

0 commit comments

Comments
 (0)