@@ -83,21 +83,23 @@ void cycleDisplay(){
83
83
if ((unsigned long )(now-displayBlinkStart)>=500 ){ displayBlinkStart = 0 ; sendToMAX7219 (0 ,5 ); }
84
84
}
85
85
// Other display code decides whether we should dim per function or time of day
86
- bool dim = ( displayDim== 1 ? 1 : 0 ) ; // 2 should also 0
86
+ char dim = displayDim; // 2=normal, 1=dim, 0=off
87
87
// But if we're setting, decide here to dim for every other 500ms since we started setting
88
88
if (fnSetPg>0 ) {
89
89
if (setStartLast==0 ) setStartLast = now;
90
- dim = 1 -(((unsigned long )(now-setStartLast)/500 )%2 );
90
+ dim = ( 1 -(((unsigned long )(now-setStartLast)/500 )%2 ))+ 1 ;
91
91
} else {
92
92
if (setStartLast>0 ) setStartLast=0 ;
93
93
}
94
- if (curBrightness!=(dim? BRIGHTNESS_DIM: BRIGHTNESS_FULL)){
95
- curBrightness = (dim? BRIGHTNESS_DIM: BRIGHTNESS_FULL);
96
- for (int i=0 ; i<NUM_MAX; i++) { lc.setIntensity (i,curBrightness); }
94
+ if (curBrightness!=(dim==2 ? BRIGHTNESS_FULL: (dim==1 ? BRIGHTNESS_DIM: -1 ))){
95
+ curBrightness = (dim==2 ? BRIGHTNESS_FULL: (dim==1 ? BRIGHTNESS_DIM: -1 ));
96
+ if (curBrightness==-1 ) for (int i=0 ; i<NUM_MAX; i++) { lc.clearDisplay (i); }
97
+ else for (int i=0 ; i<NUM_MAX; i++) { lc.setIntensity (i,curBrightness); }
97
98
}
98
99
}
99
100
100
101
void editDisplay (word n, byte posStart, byte posEnd, bool leadingZeros, bool fade){
102
+ if (curBrightness==-1 ) return ;
101
103
// Splits n into digits, sets them into displayNext in places posSt-posEnd (inclusive), with or without leading zeros
102
104
// If there are blank places (on the left of a non-leading-zero number), uses value 15 to blank tube
103
105
// If number has more places than posEnd-posStart, the higher places are truncated off (e.g. 10015 on 4 tubes --> 0015)
@@ -114,13 +116,13 @@ void editDisplay(word n, byte posStart, byte posEnd, bool leadingZeros, bool fad
114
116
}
115
117
displayNext[posEnd-i] = (i==0 &&n==0 ? 0 : (n>=place ? (n/place)%10 : (leadingZeros?0 :15 )));
116
118
}
117
- cycleDisplay (); // fixes brightness
118
119
sendToMAX7219 (posStart,posEnd);
120
+ cycleDisplay (); // fixes brightness
119
121
}
120
122
void blankDisplay (byte posStart, byte posEnd, byte fade){
121
123
for (byte i=posStart; i<=posEnd; i++) { displayNext[i]=15 ; }
122
- cycleDisplay (); // fixes brightness
123
124
sendToMAX7219 (posStart,posEnd);
125
+ cycleDisplay (); // fixes brightness
124
126
}
125
127
126
128
// void startScroll() {}
0 commit comments