@@ -153,27 +153,14 @@ void setupContrast()
153
153
byte settingContrast = EEPROM.read (LOCATION_CONTRAST);
154
154
if (settingContrast == 255 ) // Check to see if the contrast has ever been set
155
155
{
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
158
157
EEPROM.write (LOCATION_CONTRAST, settingContrast);
159
158
}
160
159
161
160
// 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);
177
164
}
178
165
179
166
// Look up and initialize the LCD with the lines and width
@@ -211,103 +198,21 @@ void setupLCD()
211
198
clearFrameBuffer ();
212
199
}
213
200
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
-
293
201
// Look up and start the 3 backlight pins in analog mode
294
202
void setupBacklight ()
295
203
{
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
311
216
}
312
217
313
218
void setupSplash ()
@@ -446,16 +351,7 @@ void checkEmergencyReset(void)
446
351
447
352
448
353
// 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
459
355
460
356
SerLCD.clear ();
461
357
SerLCD.print (" System reset" );
0 commit comments