File tree Expand file tree Collapse file tree 1 file changed +25
-1
lines changed
Expand file tree Collapse file tree 1 file changed +25
-1
lines changed Original file line number Diff line number Diff line change @@ -235,13 +235,38 @@ void disableDisplay() {
235235}
236236
237237void initBacklight () {
238+ // TPS61160 init sequence
238239 setPinLow (LCD_CONTROL);
239240 delayMicroseconds (T_OFF);
240241 setPinHigh (LCD_CONTROL);
241242 delayMicroseconds (150 );
242243 setPinLow (LCD_CONTROL);
243244 delayMicroseconds (300 );
244245 setPinHigh (LCD_CONTROL);
246+
247+ // Fade from off to target brightness. Unnecessary, but looks nice.
248+ uint8_t targetRaw = i2cdata.status .brightness * 4 + 1 ;
249+ for (uint8_t rawBrightness = 1 ; rawBrightness <= targetRaw; rawBrightness++) {
250+ byte bytesToSend[] = {LCD_ADDR, rawBrightness};
251+
252+ noInterrupts ();
253+ for (int byte = 0 ; byte < 2 ; byte++) {
254+ delayMicroseconds (T_START);
255+ for (int i = 7 ; i >= 0 ; i--) {
256+ bool bit = bytesToSend[byte] & (1 << i);
257+ setPinLow (LCD_CONTROL);
258+ delayMicroseconds (bit ? T_L_HB : T_L_LB);
259+ setPinHigh (LCD_CONTROL);
260+ delayMicroseconds (bit ? T_H_HB : T_H_LB);
261+ }
262+ setPinLow (LCD_CONTROL);
263+ delayMicroseconds (T_EOS);
264+ setPinHigh (LCD_CONTROL);
265+ }
266+ interrupts ();
267+
268+ delay (20 ); // Fade step timing
269+ }
245270}
246271
247272void readSPIButtons () {
@@ -332,7 +357,6 @@ void toggleAudioCircuit() {
332357
333358void enableDisplay () {
334359 initBacklight ();
335- setBrightness ();
336360}
337361
338362void heartbeatLED () {
You can’t perform that action at this time.
0 commit comments