Skip to content

Commit 19cdfbb

Browse files
committed
Removing OLED functions
We thought about OLEDs for a bit, now committed to 16x2 and 20x4 LCDs.
1 parent ea66c56 commit 19cdfbb

File tree

4 files changed

+23
-139
lines changed

4 files changed

+23
-139
lines changed

firmware/OpenLCD/OpenLCD.ino

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@
2323
-Change baud rate: 124/12 to go to 4800bps, power cycle, send characters at 4800
2424
*/
2525

26+
//Firmware version. This is sent when requested. Helpful for tech support.
27+
const byte firmwareVersionMajor = 1;
28+
const byte firmwareVersionMinor = 1;
29+
2630
#include <Wire.h> //For I2C functions
2731
#include <SPI.h> //For SPI functions
2832
#include <LiquidCrystalFast.h> //Faster LCD commands. From PJRC https://www.pjrc.com/teensy/td_libs_LiquidCrystal.html
@@ -37,11 +41,6 @@
3741

3842
LiquidCrystalFast SerLCD(LCD_RS, LCD_RW, LCD_EN, LCD_D4, LCD_D5, LCD_D6, LCD_D7);
3943

40-
#define OLED 0
41-
#define LCD 1
42-
//#define DISPLAY_TYPE OLED
43-
#define DISPLAY_TYPE LCD
44-
4544
byte characterCount = 0;
4645
char currentFrame[DISPLAY_BUFFER_SIZE]; //Max of 4 x 20 LCD
4746

@@ -82,8 +81,7 @@ void setup()
8281
//for(int x = 0 ; x < 200 ; x++)
8382
// EEPROM.write(x, 0xFF);
8483

85-
if (DISPLAY_TYPE == LCD) setupLCD(); //Initialize the LCD
86-
else if (DISPLAY_TYPE == OLED) setupOLED(); //Initialize the OLED
84+
setupLCD(); //Initialize the LCD
8785

8886
setupContrast(); //Set contrast
8987

firmware/OpenLCD/Setting_Control.ino

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,7 @@ void changeContrast(byte contrast)
4040
EEPROM.write(LOCATION_CONTRAST, contrast); //Store this new contrast
4141

4242
//Go to this new contrast
43-
if (DISPLAY_TYPE == LCD) analogWrite(LCD_CONTRAST, contrast);
44-
else if (DISPLAY_TYPE == OLED)
45-
{
46-
SerLCD.command(0x2A); //Command: Function Set, set extension register (RE)
47-
SerLCD.command(0x79); //Command: OLED Characterization, OLED command set is enabled
48-
SerLCD.command(0x81); //Set Contrast Control
49-
SerLCD.command(contrast); //Set Contrast Control: 0 to 255
50-
SerLCD.command(0x78); //Command: OLED Characterization, OLED command set is disabled
51-
SerLCD.command(0x28); //Command: Function Set, clear extension register (RE)
52-
}
43+
analogWrite(LCD_CONTRAST, contrast);
5344

5445
//Display the new contrast
5546
SerLCD.clear();

firmware/OpenLCD/System_Functions.ino

Lines changed: 17 additions & 121 deletions
Original file line numberDiff line numberDiff line change
@@ -153,27 +153,14 @@ void setupContrast()
153153
byte settingContrast = EEPROM.read(LOCATION_CONTRAST);
154154
if (settingContrast == 255) //Check to see if the contrast has ever been set
155155
{
156-
if (DISPLAY_TYPE == LCD) settingContrast = DEFAULT_CONTRAST_LCD; //Default
157-
else if (DISPLAY_TYPE == OLED) settingContrast = DEFAULT_CONTRAST_OLED; //Default
156+
settingContrast = DEFAULT_CONTRAST_LCD; //Default
158157
EEPROM.write(LOCATION_CONTRAST, settingContrast);
159158
}
160159

161160
//Change contrast without notification message
162-
if (DISPLAY_TYPE == LCD)
163-
{
164-
setPwmFrequency(LCD_CONTRAST, 1); //Set the freq of this pin so that it doesn't cause LCD to ripple
165-
pinMode(LCD_CONTRAST, OUTPUT);
166-
analogWrite(LCD_CONTRAST, settingContrast);
167-
}
168-
else if (DISPLAY_TYPE == OLED)
169-
{
170-
SerLCD.command(0x2A); //Command: Function Set, set extension register (RE)
171-
SerLCD.command(0x79); //Command: OLED Characterization, OLED command set is enabled
172-
SerLCD.command(0x81); //Set Contrast Control
173-
SerLCD.command(settingContrast); //Set Contrast Control: 0 to 255
174-
SerLCD.command(0x78); //Command: OLED Characterization, OLED command set is disabled
175-
SerLCD.command(0x28); //Command: Function Set, clear extension register (RE)
176-
}
161+
setPwmFrequency(LCD_CONTRAST, 1); //Set the freq of this pin so that it doesn't cause LCD to ripple
162+
pinMode(LCD_CONTRAST, OUTPUT);
163+
analogWrite(LCD_CONTRAST, settingContrast);
177164
}
178165

179166
//Look up and initialize the LCD with the lines and width
@@ -211,103 +198,21 @@ void setupLCD()
211198
clearFrameBuffer();
212199
}
213200

214-
//Initialize the OLED
215-
void setupOLED()
216-
{
217-
//Look up display lines and width
218-
settingLCDlines = EEPROM.read(LOCATION_LINES);
219-
if (settingLCDlines > 4)
220-
{
221-
settingLCDlines = DEFAULT_LINES;
222-
EEPROM.write(LOCATION_LINES, settingLCDlines);
223-
}
224-
225-
settingLCDwidth = EEPROM.read(LOCATION_WIDTH);
226-
if (settingLCDwidth > 20)
227-
{
228-
settingLCDwidth = DEFAULT_WIDTH;
229-
EEPROM.write(LOCATION_WIDTH, settingLCDwidth);
230-
}
231-
232-
//Reset the OLED display
233-
pinMode(7, OUTPUT); //Pin 7 = RES#
234-
analogWrite(7, 0);
235-
delay(10);
236-
analogWrite(7, 255);
237-
delay(10);
238-
239-
SerLCD.begin(settingLCDwidth, settingLCDlines); //Setup the width and lines for this LCD
240-
241-
//Configure the OLED display - comes from mfg
242-
243-
//Turn on internal v-reg
244-
SerLCD.command(0x2A); //Command: Function Set, set extension register (RE)
245-
SerLCD.command(0x71); //Command: Function Selection A
246-
SerLCD.write(0x5C); //original: Enable internal Vdd regulator (5V I/O)
247-
SerLCD.command(0x28); //Command: Function Set, clear extension register (RE)
248-
249-
SerLCD.command(0x08); //Command: Display ON/OFF Control. Display off, cursor off, blink off
250-
251-
//Set Oscillator frequency
252-
SerLCD.command(0x2A); //Command: Function Set, set extension register (RE)
253-
SerLCD.command(0x79); //Command: OLED Characterization, OLED command set is enabled
254-
SerLCD.command(0xD5); //OLED Command: Set Display Clock Divide Ratio/Oscillator Frequency
255-
SerLCD.command(0x70); //(POR) Default oscillator freq, set divide ratio to 1
256-
SerLCD.command(0x78); //Command: OLED Characterization, OLED command set is disabled
257-
SerLCD.command(0x28); //Command: Function Set, clear extension register (RE)
258-
259-
//Set ROM and CHRAM settings
260-
SerLCD.command(0x2A); //Command: Function Set, set extension register (RE)
261-
SerLCD.command(0x08); //Extended Function Set: NW = 0 for 2-lines
262-
SerLCD.command(0x06); //COM SEG direction - this command doesn't make sense
263-
SerLCD.command(0x72); //Function Selection B - Selecting ROM and CGROM
264-
SerLCD.write(0x08); //ROM and CGROM Selection: ROM 'C' with 240 CGROM
265-
SerLCD.command(0x28); //Command: Function Set, clear extension register (RE)
266-
267-
//Setup contrast, external VSL, etc
268-
SerLCD.command(0x2A); //Command: Function Set, set extension register (RE)
269-
SerLCD.command(0x79); //Command: OLED Characterization, OLED command set is enabled
270-
SerLCD.command(0xDA); //Set SEG Pins Hardware Configuration
271-
SerLCD.command(0x10); //Set SEG Pins Hardware Configuration: Disable SEG left/right, Alternative SEG pin config
272-
SerLCD.command(0xDC); //Set VSL/GPIO: function selection C
273-
SerLCD.command(0x00); //Function Select C: Disable external VSL, disable GPIOs
274-
//Contrast is set later during setup
275-
//SerLCD.command(0x81); //Set Contrast Control
276-
//SerLCD.command(0xFF); //Set Contrast Control: 0 to 255
277-
SerLCD.command(0xD9); //Set Phase Length
278-
SerLCD.command(0xF1); //Set Phase Length: Phase 2 = 15, Phase 1 = 1
279-
SerLCD.command(0xDB); //Set VCOMH Deselect Level
280-
SerLCD.command(0x00); //Set VCOMH Deselect Level: 0.65 x VCC
281-
SerLCD.command(0x78); //Command: OLED Characterization, OLED command set is disabled
282-
SerLCD.command(0x28); //Command: Function Set, clear extension register (RE)
283-
284-
SerLCD.command(0x01); //clear display
285-
SerLCD.command(0x0C); //Command: Display ON/OFF Control. Display on, cursor off, blink off
286-
287-
SerLCD.setCursor(0, 0); //First spot
288-
289-
//Clear any characters in the frame buffer
290-
clearFrameBuffer();
291-
}
292-
293201
//Look up and start the 3 backlight pins in analog mode
294202
void setupBacklight()
295203
{
296-
if (DISPLAY_TYPE == LCD)
297-
{
298-
pinMode(BL_RW, OUTPUT);
299-
pinMode(BL_G, OUTPUT);
300-
pinMode(BL_B, OUTPUT);
301-
302-
//By default EEPROM is 255 or 100% brightness
303-
//Because there's a PNP transistor we need to invert the logic (or subtract the user value from 255)
304-
analogWrite(BL_RW, 255 - EEPROM.read(LOCATION_RED_BRIGHTNESS));
305-
analogWrite(BL_G, 255 - EEPROM.read(LOCATION_GREEN_BRIGHTNESS));
306-
307-
SoftPWMBegin(); //Start PWM
308-
SoftPWMSet(BL_B, 255 - EEPROM.read(LOCATION_BLUE_BRIGHTNESS)); //Setup this pin to be controlled with SoftPWM. Initialize to EEPROM value
309-
SoftPWMSetFadeTime(BL_B, 0, 0); //Don't fade - go immediately to this set PWM brightness
310-
}
204+
pinMode(BL_RW, OUTPUT);
205+
pinMode(BL_G, OUTPUT);
206+
pinMode(BL_B, OUTPUT);
207+
208+
//By default EEPROM is 255 or 100% brightness
209+
//Because there's a PNP transistor we need to invert the logic (or subtract the user value from 255)
210+
analogWrite(BL_RW, 255 - EEPROM.read(LOCATION_RED_BRIGHTNESS));
211+
analogWrite(BL_G, 255 - EEPROM.read(LOCATION_GREEN_BRIGHTNESS));
212+
213+
SoftPWMBegin(); //Start PWM
214+
SoftPWMSet(BL_B, 255 - EEPROM.read(LOCATION_BLUE_BRIGHTNESS)); //Setup this pin to be controlled with SoftPWM. Initialize to EEPROM value
215+
SoftPWMSetFadeTime(BL_B, 0, 0); //Don't fade - go immediately to this set PWM brightness
311216
}
312217

313218
void setupSplash()
@@ -446,16 +351,7 @@ void checkEmergencyReset(void)
446351

447352

448353
//Change contrast without notification message
449-
if (DISPLAY_TYPE == LCD) analogWrite(LCD_CONTRAST, 40); //Set contrast to default
450-
else if (DISPLAY_TYPE == OLED)
451-
{
452-
SerLCD.command(0x2A); //Command: Function Set, set extension register (RE)
453-
SerLCD.command(0x79); //Command: OLED Characterization, OLED command set is enabled
454-
SerLCD.command(0x81); //Set Contrast Control
455-
SerLCD.command(255); //Set Contrast Control: 0 to 255
456-
SerLCD.command(0x78); //Command: OLED Characterization, OLED command set is disabled
457-
SerLCD.command(0x28); //Command: Function Set, clear extension register (RE)
458-
}
354+
analogWrite(LCD_CONTRAST, 40); //Set contrast to default
459355

460356
SerLCD.clear();
461357
SerLCD.print("System reset");

firmware/OpenLCD/settings.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ const byte DEFAULT_LINES = 2;
5858
const byte DEFAULT_WIDTH = 16;
5959
const byte DEFAULT_SPLASH = true; //Default on
6060
const byte DEFAULT_CONTRAST_LCD = 5;
61-
const byte DEFAULT_CONTRAST_OLED = 254;
6261

6362
//Internal EEPROM locations for the user settings
6463
#define LOCATION_BAUD 0

0 commit comments

Comments
 (0)