Skip to content

Commit c579aa9

Browse files
committed
Add support for turning day counter off
1 parent 5708fc8 commit c579aa9

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

arduino-nixie/arduino-nixie.ino

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ void ctrlEvt(byte ctrl, byte evt); //used by input
158158
void updateDisplay(); //used by network
159159
void goToFn(byte thefn); //used by network
160160
int dateComp(int y, byte m, byte d, byte mt, byte dt, bool countUp); //used by network
161+
void findFnAndPageNumbers(); //used by network
161162

162163
//These cpp files contain code that is conditionally included
163164
//based on the available hardware and settings in the config file.
@@ -480,7 +481,7 @@ void ctrlEvt(byte ctrl, byte evt){
480481
case 2: //save date, set direction
481482
displayBlink(); //to indicate save.
482483
writeEEPROM(6,fnSetVal,false);
483-
startSet(readEEPROM(4,false),0,1,3); break;
484+
startSet(readEEPROM(4,false),1,2,3); break;
484485
case 3: //save date
485486
displayBlink(); //to indicate save.
486487
writeEEPROM(4,fnSetVal,false);
@@ -717,7 +718,7 @@ void initEEPROM(bool hard){
717718
if(hard || readEEPROM(0,true)>1439) writeEEPROM(0,420,true); //0-1: alarm at 7am
718719
//2: alarm on, handled by init
719720
//3: free
720-
if(hard || readEEPROM(4,false)<0 || readEEPROM(4,false)>1) writeEEPROM(4,1,false); //4: day counter direction: count up...
721+
if(hard || readEEPROM(4,false)<0 || readEEPROM(4,false)>2) writeEEPROM(4,2,false); //4: day counter direction: count up...
721722
if(hard || readEEPROM(5,false)<1 || readEEPROM(5,false)>12) writeEEPROM(5,12,false); //5: ...December...
722723
if(hard || readEEPROM(6,false)<1 || readEEPROM(6,false)>31) writeEEPROM(6,31,false); //6: ...31st. (This gives the day of the year)
723724
if(hard) writeEEPROM(7,0,false); //7: Alt function preset
@@ -736,7 +737,7 @@ void initEEPROM(bool hard){
736737
void findFnAndPageNumbers(){
737738
//Each function, and each page in a paged function, has a number. //TODO should pull from EEPROM 8
738739
fnDatePages = 1; //date function always has a page for the date itself
739-
if(ENABLE_DATE_COUNTER){ fnDatePages++; fnDateCounter=fnDatePages-1; }
740+
if(ENABLE_DATE_COUNTER && readEEPROM(4,false)){ fnDatePages++; fnDateCounter=fnDatePages-1; }
740741
if(ENABLE_DATE_RISESET){ fnDatePages++; fnDateSunlast=fnDatePages-1; }
741742
if(false){ fnDatePages++; fnDateWeathernow=fnDatePages-1; }
742743
if(ENABLE_DATE_RISESET){ fnDatePages++; fnDateSunnext=fnDatePages-1; }
@@ -1361,7 +1362,7 @@ void updateDisplay(){
13611362
}
13621363
}
13631364
else if(fnPg==fnDateCounter){
1364-
editDisplay(dateComp(rtcGetYear(),rtcGetMonth(),rtcGetDate(),readEEPROM(5,false),readEEPROM(6,false),readEEPROM(4,false)),0,3,false,true);
1365+
editDisplay(dateComp(rtcGetYear(),rtcGetMonth(),rtcGetDate(),readEEPROM(5,false),readEEPROM(6,false),readEEPROM(4,false)-1),0,3,false,true);
13651366
blankDisplay(4,5,true);
13661367
}
13671368
//The sun and weather displays are based on a snapshot of the time of day when the function display was triggered, just in case it's triggered a few seconds before a sun event (sunrise/sunset) and the "prev/now" and "next" displays fall on either side of that event, they'll both display data from before it. If triggered just before midnight, the date could change as well – not such an issue for sun, but might be for weather - TODO create date snapshot also

arduino-nixie/network.cpp

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ void networkStartWiFi(){
5555
WiFi.end(); //if AP is going, stop it
5656
if(wssid==F("")) return; //don't try to connect if there's no creds
5757
checkForWiFiStatusChange(); //just for serial logging
58-
//rtcDisplayTime(false); //display time without seconds //TODO replace this with what
5958
blankDisplay(0,5,false); //I'm guessing if it hangs, nixies won't be able to display anyway
6059
//Serial.println(); Serial.print(millis()); Serial.print(F(" Attempting to connect to SSID: ")); Serial.println(wssid);
6160
if(wki) WiFi.begin(wssid.c_str(), wki, wpass.c_str()); //WEP - hangs while connecting
@@ -253,7 +252,6 @@ unsigned long adminInputLast = 0; //for noticing when the admin page hasn't been
253252

254253
void networkStartAdmin(){
255254
adminInputLast = millis();
256-
//TODO display should handle its own code for displaying a type of stuff
257255
if(WiFi.status()!=WL_CONNECTED){
258256
networkStartAP();
259257
tempValDispQueue[0] = 7777; //display to user
@@ -394,13 +392,12 @@ void checkClients(){
394392
//Function preset ???????
395393
//TODO leap second support? Add NTP sync at top of hour also
396394

397-
client.print(F("<li><label>Day counter</label><select id='b4' onchange='if(this.value==2) document.getElementById(\"daycounterdeets\").style.display=\"none\"; else document.getElementById(\"daycounterdeets\").style.display=\"inline\"; save(this)'>")); for(char i=0; i<=2; i++){ client.print(F("<option value='")); client.print(i,DEC); client.print(F("'")); if(readEEPROM(4,false)==i) client.print(F(" selected")); client.print(F(">")); switch(i){
398-
case 0: client.print(F("Count days until...")); break;
399-
case 1: client.print(F("Count days since...")); break; //TODO change to have 0 be disabled - may require a reset
400-
case 2: client.print(F("DEMO hide controls")); break; //TODO change to have 0 be disabled - may require a reset
401-
default: break; } client.print(F("</option>")); } client.print(F("</select>")); //TODO replace inline with natural state
402-
403-
client.print(F("<br/><span id='daycounterdeets' style='display: inline;'><span></span><label for='b5'>Month&nbsp;</label><input type='number' id='b5' onchange='promptsave(\"b5\")' onkeyup='promptsave(\"b5\")' onblur='unpromptsave(\"b5\"); save(this)' min='1' max='12' step='1' value='")); client.print(readEEPROM(5,false),DEC); client.print(F("' />")); client.print(F(" <a id='b5save' href='#' onclick='return false' style='display: none;'>save</a>")); //Extra span is there to prevent "first" styling on the month label
395+
client.print(F("<li><label>Day counter</label><select id='b4' onchange='if(this.value==0) document.getElementById(\"daycounterdeets\").style.display=\"none\"; else document.getElementById(\"daycounterdeets\").style.display=\"inline\"; save(this)'>")); for(char i=0; i<=2; i++){ client.print(F("<option value='")); client.print(i,DEC); client.print(F("'")); if(readEEPROM(4,false)==i) client.print(F(" selected")); client.print(F(">")); switch(i){
396+
case 0: client.print(F("Off")); break;
397+
case 1: client.print(F("Count days until...")); break;
398+
case 2: client.print(F("Count days since...")); break;
399+
default: break; } client.print(F("</option>")); } client.print(F("</select>"));
400+
client.print(F("<br/><span id='daycounterdeets' style='display: ")); if(readEEPROM(4,false)==0) client.print(F("none")); else client.print(F("inline")); client.print(F(";'><span></span><label for='b5'>Month&nbsp;</label><input type='number' id='b5' onchange='promptsave(\"b5\")' onkeyup='promptsave(\"b5\")' onblur='unpromptsave(\"b5\"); save(this)' min='1' max='12' step='1' value='")); client.print(readEEPROM(5,false),DEC); client.print(F("' />")); client.print(F(" <a id='b5save' href='#' onclick='return false' style='display: none;'>save</a>")); //Extra span is there to prevent "first" styling on the month label
404401

405402
client.print(F("<br/><label for='b6'>Date&nbsp;</label><input type='number' id='b6' onchange='promptsave(\"b6\")' onkeyup='promptsave(\"b6\")' onblur='unpromptsave(\"b6\"); save(this)' min='1' max='31' step='1' value='")); client.print(readEEPROM(6,false),DEC); client.print(F("' />")); client.print(F(" <a id='b6save' href='#' onclick='return false' style='display: none;'>save</a><br/></span><span class='explain'>Appears after date. Repeats annually.</span></li>")); //TODO tip count day of year and program override to display 0 as 366 //TODO when month changes, set date max, or can you? what about 2/29? it should just do 3/1 in those cases
406403

@@ -707,8 +704,10 @@ void checkClients(){
707704
//do special stuff for some of them
708705
switch(key){
709706
case 4: case 5: case 6: //day counter
710-
//in lieu of actually switching to fnIsDate, so that only this value is seen
711-
tempValDispQueue[0] = dateComp(rtcGetYear(),rtcGetMonth(),rtcGetDate(), readEEPROM(5,false),readEEPROM(6,false),readEEPROM(4,false));
707+
//in lieu of actually switching to fnIsDate, so that only this value is seen - compare to ino
708+
if(readEEPROM(4,false)) tempValDispQueue[0] = dateComp(rtcGetYear(),rtcGetMonth(),rtcGetDate(), readEEPROM(5,false),readEEPROM(6,false),readEEPROM(4,false)-1);
709+
findFnAndPageNumbers(); //to include or exclude the day counter from the calendar function
710+
break;
712711
case 14: //utc offset
713712
cueNTP(); break;
714713
case 17: //date format

0 commit comments

Comments
 (0)