You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: arduino-nixie/arduino-nixie.ino
+60-23Lines changed: 60 additions & 23 deletions
Original file line number
Diff line number
Diff line change
@@ -106,7 +106,8 @@ unsigned long inputLast2 = 0; //Second-to-last of above
106
106
int inputLastTODMins = 0; //time of day, in minutes past midnight, when button was pressed. Used in paginated functions so they all reflect the same TOD.
107
107
108
108
const byte fnOpts = 201; //fn values from here to 255 correspond to options in the options menu
byte fn = fnIsTime; //currently displayed fn per fnsEnabled in config
110
+
byte fnsOn = 0; //which fns are enabled per fnsEnabled in config - one bit per fn unique ID - this limits the available fn unique IDs to 0–7; otherwise it could be 0–200 – if you need more than 7, change from a byte to a bigger data type
110
111
byte fnPg = 0; //allows a function to have multiple pages
111
112
byte fnSetPg = 0; //whether this function is currently being set, and which option/page it's on
112
113
int fnSetVal; //the value currently being set, if any
@@ -154,7 +155,7 @@ void setup(){
154
155
initInputs();
155
156
delay(100); //prevents the below from firing in the event there's a capacitor stabilizing the input, which can read low falsely
156
157
initEEPROM(readInput(mainSel)==LOW); //Do a hard init of EEPROM if button is held; else do a soft init to make sure vals in range
157
-
//Some options need to be set to a fixed value per the hardware configuration.
158
+
//Some options need to be set to a fixed value per the configuration.
158
159
//These options will also be skipped in fnOptScroll so the user can't change them.
159
160
if(relayPin<0 || piezoPin<0) { //If no relay or no piezo, set each signal output to [if no relay, then piezo; else relay]
160
161
writeEEPROM(42,(relayPin<0?0:1),false); //alarm
@@ -166,11 +167,37 @@ void setup(){
166
167
}
167
168
if(piezoPin<0 && relayMode==0) { //If switched relay and no piezo
168
169
writeEEPROM(21,0,false); //turn off strike
169
-
//writeEEPROM(25,0,false); //turn off timer interval mode
170
170
writeEEPROM(50,0,false); //turn off fibonacci mode
171
171
}
172
-
if(!enableSoftAlarmSwitch) alarmOn = 1; //force alarm on if software switch is disabled
//TODO these pages will need different IDs to be told apart from fnDateCounter
374
+
//TODO
348
375
} break;
349
376
case fnIsAlarm: //set mins
350
377
startSet(readEEPROM(0,true),0,1439,1); break;
@@ -594,22 +621,32 @@ void fnOptScroll(byte dir){
594
621
byte posLast = fnOpts+sizeof(optsLoc)-1;
595
622
if(dir==1) fn = (fn==posLast? fnOpts: fn+1);
596
623
if(dir==0) fn = (fn==fnOpts? posLast: fn-1);
597
-
//Certain options don't apply to some hardware configurations; skip those
624
+
//Certain options don't apply to some configurations; skip those.
598
625
byte optLoc = optsLoc[fn-fnOpts];
599
626
if(
627
+
//Hardware config
600
628
(piezoPin<0 && (optLoc==39||optLoc==40||optLoc==41||optLoc==47||optLoc==48||optLoc==49)) //no piezo: no signal pitches or alarm/timer/strike beeper pattern
601
-
|| ((piezoPin<0 && relayMode==0) && (optLoc==21||optLoc==25||optLoc==50)) //no piezo, and relay is switch: no strike, timer interval mode, or alarm fibonacci mode
629
+
|| ((piezoPin<0 && relayMode==0) && (optLoc==21||optLoc==50)) //no piezo, and relay is switch: no strike, or alarm fibonacci mode
602
630
|| ((relayPin<0 || piezoPin<0) && (optLoc==42||optLoc==43||optLoc==44)) //no relay or no piezo: no alarm/timer/strike signal
603
631
|| ((relayMode==0) && (optLoc==44)) //relay is switch: no strike signal
604
632
|| ((ledPin<0) && (optLoc==26)) //no led pin: no led control
633
+
|| ((ledPin<0) && (optLoc==26)) //no led pin: no led control
634
+
//Functions disabled
635
+
|| (!((fnsOn>>fnIsDate)&1) && (optLoc==17||optLoc==18||optLoc==10||optLoc==12||optLoc==14)) //date fn disabled in config: skip date and geography options
|| (!enableChime && (optLoc==21||optLoc==44||optLoc==41||optLoc==49)) //chime disabled in config: skip chime
644
+
|| (!enableNightShutoff && (optLoc==27||optLoc==28||optLoc==30)) //night shutoff disabled in config: skip night
645
+
|| ((!enableNightShutoff || !enableAwayShutoff) && (optLoc==32||optLoc==35||optLoc==37)) //night or away shutoff disabled in config: skip away (except workweek)
646
+
|| ((!enableNightShutoff || !enableAwayShutoff) && (!enableAlarmAutoskip || !((fnsOn>>fnIsAlarm)&1)) && (optLoc==33||optLoc==34)) //(night or away) and alarm autoskip disabled: skip workweek
605
647
) {
606
648
fnOptScroll(dir);
607
649
}
608
-
if(optLoc==45) { //temp not in fnsEnabled: skip temp format option (and calib if we get to it TODO)
609
-
bool found = 0;
610
-
for(byte fnct=0; fnct<sizeof(fnsEnabled); fnct++) if(fnsEnabled[fnct]==fnIsTemp) found = 1;
611
-
if(found==0) fnOptScroll(dir);
612
-
}
613
650
}
614
651
615
652
voidswitchAlarm(byte dir){
@@ -681,9 +718,9 @@ void doSetHold(bool start){
681
718
//TODO integrate this with checkInputs?
682
719
unsignedlong now = millis();
683
720
//The interval used to be 250, but in order to make the value change by a full 9 values between btnShortHold and btnLongHold,
684
-
//the interval is now that difference divided by 9. TODO divisor may need to be a bit higher in case btnLongHold ever fires before 9th.
721
+
//the interval is now that difference divided by 9. TODO divisor may need to be a bit higher in case btnLongHold ever fires before 9th - it seems indeed it did, so 9.5.
685
722
//It may be weird not being exactly quarter-seconds, but it doesn't line up with the blinking anyway.
0 commit comments