Skip to content

Commit 3e76c41

Browse files
committed
clean routine display bugfix, standardize on setting millis() into now
1 parent 3924943 commit 3e76c41

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

sixtube_lm/sixtube_lm.ino

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ void checkBtn(byte btn){
197197
unsigned long now = millis();
198198
//If the button has just been pressed, and no other buttons are in use...
199199
if(btnCur==0 && bnow==LOW) {
200-
btnCur = btn; btnCurHeld = 0; inputLast2 = inputLast; inputLast = millis();
200+
btnCur = btn; btnCurHeld = 0; inputLast2 = inputLast; inputLast = now;
201201
ctrlEvt(btn,1); //hey, the button has been pressed
202202
}
203203
//If the button is being held...
@@ -816,7 +816,7 @@ void updateDisplay(){
816816

817817
if(cleanRemain) { //cleaning tubes
818818
displayDim = 2;
819-
byte digit = (11-cleanRemain)%10;
819+
byte digit = 10-((cleanRemain-1)%10); //(11-cleanRemain)%10;
820820
editDisplay(digit,0,0,true,false);
821821
editDisplay(digit,1,1,true,false);
822822
editDisplay(digit,2,2,true,false);
@@ -1036,14 +1036,14 @@ void initOutputs() {
10361036
}
10371037

10381038
void cycleDisplay(){
1039-
unsigned long mils = millis();
1039+
unsigned long now = millis();
10401040

10411041
//Other display code decides whether we should dim per function or time of day
10421042
bool dim = (displayDim==1?1:0);
10431043
//But if we're setting, decide here to dim for every other 500ms since we started setting
10441044
if(fnSetPg>0) {
1045-
if(setStartLast==0) setStartLast = mils;
1046-
dim = 1-(((unsigned long)(mils-setStartLast)/500)%2);
1045+
if(setStartLast==0) setStartLast = now;
1046+
dim = 1-(((unsigned long)(now-setStartLast)/500)%2);
10471047
} else {
10481048
if(setStartLast>0) setStartLast=0;
10491049
}
@@ -1056,7 +1056,7 @@ void cycleDisplay(){
10561056
}
10571057
else { //fading enabled
10581058
if(fadeStartLast==0) { //not fading - time to fade?
1059-
for(byte i=0; i<6; i++) if(displayNext[i] != displayLast[i]) { fadeStartLast = mils; break; }
1059+
for(byte i=0; i<6; i++) if(displayNext[i] != displayLast[i]) { fadeStartLast = now; break; }
10601060
}
10611061
if(fadeStartLast!=0) { //currently fading
10621062
//let the next digit steal some display time from the last digit
@@ -1065,8 +1065,8 @@ void cycleDisplay(){
10651065
// at 10ms, next = ((10*(6-1))/20)+1 = 3; last = (6-nextDur) = 3; ...
10661066
// at 20ms, next = ((20*(6-1))/20)+1 = 6; next = total, so fade is over!
10671067
//TODO facilitate longer fades by writing a tweening function that smooths the frames, i.e. 111121222 - or use delayMicroseconds as below
1068-
//TODO does this have more problems with the mils rollover issue?
1069-
fadeNextDur = (((unsigned long)(mils-fadeStartLast)*(fadeDur-1))/(readEEPROM(20,false)*10))+1;
1068+
//TODO does this have more problems with the millis rollover issue?
1069+
fadeNextDur = (((unsigned long)(now-fadeStartLast)*(fadeDur-1))/(readEEPROM(20,false)*10))+1;
10701070
if(fadeNextDur >= fadeLastDur) { //fade is over
10711071
fadeStartLast = 0;
10721072
fadeNextDur = 0;

0 commit comments

Comments
 (0)