Skip to content

Commit 0e2458d

Browse files
committed
wip - hide irrelevant settings
1 parent c579aa9 commit 0e2458d

File tree

2 files changed

+52
-12
lines changed

2 files changed

+52
-12
lines changed

arduino-nixie/arduino-nixie.ino

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,8 @@ 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
161161
void findFnAndPageNumbers(); //used by network
162162

163+
#define HIDE_IRRELEVANT_OPTIONS 0 //TODO change options to settings everywhere
164+
163165
//These cpp files contain code that is conditionally included
164166
//based on the available hardware and settings in the config file.
165167
//TODO revisit - This is probably not the right way to do this –
@@ -602,7 +604,7 @@ void fnOptScroll(byte dir){
602604
if(dir==0) fn = (fn==fnOpts? posLast: fn-1);
603605
//Certain options don't apply to some configurations; skip those.
604606
byte optLoc = optsLoc[fn-fnOpts];
605-
if(
607+
if(HIDE_IRRELEVANT_OPTIONS && ( //see also: network requestType=1
606608
//Hardware config
607609
(PIEZO_PIN<0 && (optLoc==39||optLoc==40||optLoc==41||optLoc==47||optLoc==48||optLoc==49)) //no piezo: no signal pitches or alarm/timer/strike beeper pattern
608610
|| ((PIEZO_PIN<0 && RELAY_MODE==0) && (optLoc==21||optLoc==50)) //no piezo, and relay is switch: no strike, or alarm fibonacci mode
@@ -611,19 +613,19 @@ void fnOptScroll(byte dir){
611613
|| ((LED_PIN<0) && (optLoc==26)) //no led pin: no led control
612614
|| ((LED_PIN<0) && (optLoc==26)) //no led pin: no led control
613615
//Functions disabled
614-
|| (!ENABLE_DATE_FN && (optLoc==17||optLoc==18||optLoc==10||optLoc==12||optLoc==14)) //date fn disabled in config: skip date and geography options
616+
|| (!ENABLE_DATE_FN && (optLoc==17||optLoc==18||optLoc==10||optLoc==12)) //date fn disabled in config: skip date and geography options - don't skip utc offset as that's now used when setting clock from network ||optLoc==14
615617
|| (!ENABLE_ALARM_FN && (optLoc==23||optLoc==42||optLoc==39||optLoc==47||optLoc==24||optLoc==50)) //alarm fn disabled in config: skip alarm options
616618
|| (!ENABLE_TIMER_FN && (optLoc==43||optLoc==40||optLoc==48)) //timer fn disabled in config: skip timer options
617619
|| (!ENABLE_TEMP_FN && (optLoc==45)) //temp fn disabled in config: skip temp format TODO good for weather also
618620
//Other functionality disabled
619-
//|| (!ENABLE_DATE_RISESET && (optLoc==10||optLoc==12)) //date rise/set disabled in config: skip geography - don't skip utc offset as that's now used when setting clock from network ||optLoc==14
621+
|| (!ENABLE_DATE_RISESET && (optLoc==10||optLoc==12)) //date rise/set disabled in config: skip geography - don't skip utc offset as that's now used when setting clock from network ||optLoc==14
620622
|| (!ENABLE_ALARM_AUTOSKIP && (optLoc==23)) //alarm autoskip disabled in config: skip autoskip switch
621623
|| (!ENABLE_ALARM_FIBONACCI && (optLoc==50)) //fibonacci mode disabled in config: skip fibonacci switch
622624
|| (!ENABLE_TIME_CHIME && (optLoc==21||optLoc==44||optLoc==41||optLoc==49)) //chime disabled in config: skip chime
623625
|| (!ENABLE_SHUTOFF_NIGHT && (optLoc==27||optLoc==28||optLoc==30)) //night shutoff disabled in config: skip night
624626
|| ((!ENABLE_SHUTOFF_NIGHT || !ENABLE_SHUTOFF_AWAY) && (optLoc==32||optLoc==35||optLoc==37)) //night or away shutoff disabled in config: skip away (except workweek)
625627
|| ((!ENABLE_SHUTOFF_NIGHT || !ENABLE_SHUTOFF_AWAY) && (!ENABLE_ALARM_AUTOSKIP || !ENABLE_ALARM_FN) && (optLoc==33||optLoc==34)) //(night or away) and alarm autoskip disabled: skip workweek
626-
) {
628+
)) {
627629
fnOptScroll(dir);
628630
}
629631
}

arduino-nixie/network.cpp

Lines changed: 46 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,9 @@ void checkClients(){
325325
client.println("Access-Control-Allow-Origin:*");
326326
client.println();
327327
if(requestType==1){ //get
328+
329+
//Re hiding irrelevant options, see also fnOptScroll in main code
330+
328331
client.print(F("<!DOCTYPE html><html><head><title>Clock Settings</title><style>body { background-color: #eee; color: #222; font-family: system-ui, -apple-system, sans-serif; font-size: 18px; line-height: 1.3em; margin: 1.5em; position: absolute; } a { color: #33a; } ul { padding-left: 9em; text-indent: -9em; list-style: none; margin-bottom: 4em; } ul li { margin-bottom: 0.8em; } ul li * { text-indent: 0; padding: 0; } ul li label:first-child { display: inline-block; width: 8em; text-align: right; padding-right: 1em; font-weight: bold; } ul li.nolabel { margin-left: 9em; } ul li h3 { display: inline-block; margin: 0; } input[type='text'],input[type='number'],input[type='submit'],select { border: 1px solid #999; margin: 0.2em 0; padding: 0.1em 0.3em; font-size: 1em; font-family: system-ui, -apple-system, sans-serif; } @media only screen and (max-width: 550px) { ul { padding-left: 0; text-indent: 0; } ul li label:first-child { display: block; width: auto; text-align: left; padding: 0; } ul li.nolabel { margin-left: 0; }} .saving { color: #66d; } .ok { color: #3a3; } .error { color: #c53; } .explain { font-size: 0.85em; line-height: 1.3em; color: #666; } @media (prefers-color-scheme: dark) { body { background-color: #222; color: #ddd; } a { color: white; } #result { background-color: #373; color: white; } input[type='text'],input[type='number'],select { background-color: black; color: #ddd; } .explain { color: #999; } }</style><meta charset='utf-8'><meta name='viewport' content='width=device-width, initial-scale=1'></head><body><h2 style='margin-top: 0;'>Clock Settings</h2><p id='loading'>Loading&hellip;<br/><br/>If page doesn't appear in a few seconds, <a href=\"#\" onclick=\"location.reload(); return false;\">refresh</a>.</p><div id='content' style='display: none;'><ul>"));
329332

330333
client.print(F("<li><h3>General</h3></li>"));
@@ -348,6 +351,7 @@ void checkClients(){
348351
}
349352
client.print(F("</li>"));
350353

354+
//We can always show this, since network is not available without wifi and ntp
351355
client.print(F("<li><label>Wi-Fi</label><form id='wform' style='display: inline;' onsubmit='save(this); return false;'><select id='wtype' onchange='wformchg()'><option value=''>None</option><option value='wpa'>WPA</option><option value='wep'>WEP</option></select><span id='wa'><br/><input type='text' id='wssid' name='wssid' placeholder='SSID (Network Name)' autocomplete='off' onchange='wformchg()' onkeyup='wformchg()' value='")); String wssid2 = wssid; wssid2.replace("'","&#39;"); client.print(wssid2); client.print(F("' /><br/><input type='text' id='wpass' name='wpass' placeholder='Password/Key' autocomplete='off' onchange='wformchg()' onkeyup='wformchg()' value='")); String wpass2 = wpass; wpass2.replace("'","&#39;"); client.print(wpass2); client.print(F("' /></span><span id='wb'><br/><label for='wki'>Key Index</label> <select id='wki' onchange='wformchg()'>")); for(char i=0; i<=4; i++){ client.print(F("<option value='")); client.print(i,DEC); client.print(F("' ")); client.print(wki==i?F("selected"):F("")); client.print(F(">")); if(i==0) client.print(F("Select")); else client.print(i,DEC); client.print(F("</option>")); } client.print(F("</select></span><br/><input id='wformsubmit' type='submit' value='Save' style='display: none;' /></form></li>"));
352356

353357
client.print(F("<li><label>NTP sync</label><select id='b9' onchange='save(this)'>")); for(char i=0; i<=1; i++){ client.print(F("<option value='")); client.print(i,DEC); client.print(F("'")); if(readEEPROM(9,false)==i) client.print(F(" selected")); client.print(F(">")); switch(i){
@@ -413,7 +417,9 @@ void checkClients(){
413417
case 1: client.print(F("Yes (01:23)")); break;
414418
default: break; } client.print(F("</option>")); } client.print(F("</select></li>"));
415419

420+
#if !defined(HIDE_IRRELEVANT_OPTIONS) || defined(DISPLAY_NIXIE)
416421
client.print(F("<li><label>Digit fade</label><input type='number' id='b20' onchange='promptsave(\"b20\")' onkeyup='promptsave(\"b20\")' onblur='unpromptsave(\"b20\"); save(this)' min='0' max='20' step='1' value='")); client.print(readEEPROM(20,false),DEC); client.print(F("' />")); client.print(F(" <a id='b20save' href='#' onclick='return false' style='display: none;'>save</a><br/><span class='explain'>Nixie tube digit fade effect, in hundredths of a second (up to 20)</span></li>"));
422+
#endif
417423

418424
client.print(F("<li><label>Auto DST</label><a name='autodst' href='#'></a><select id='b22' onchange='save(this)'>")); for(char i=0; i<=6; i++){ client.print(F("<option value='")); client.print(i,DEC); client.print(F("'")); if(readEEPROM(22,false)==i) client.print(F(" selected")); client.print(F(">")); switch(i){
419425
case 0: client.print(F("Off")); break;
@@ -426,20 +432,24 @@ void checkClients(){
426432
default: break; } client.print(F("</option>")); } client.print(F("</select><br/><span class='explain'>Automatically sets clock forward/backward at 2am on the relevant Sunday (see instructions for details). If you observe Daylight Saving Time but your locale's rules are not represented here, leave this set to Off and set the clock forward manually (and add an hour to the <a href='#utcoffset'>UTC offset</a> if using sunrise/sunset).</span></li>")); //TODO instructions
427433

428434
//TODO call everything backlight
435+
#if !defined(HIDE_IRRELEVANT_OPTIONS) || LED_PIN
429436
client.print(F("<li><label>Backlight behavior</label><a name='backlight' href='#'></a><select id='b26' onchange='save(this)'>")); for(char i=0; i<=4; i++){ client.print(F("<option value='")); client.print(i,DEC); client.print(F("'")); if(readEEPROM(26,false)==i) client.print(F(" selected")); client.print(F(">")); switch(i){
430437
case 0: client.print(F("Always off")); break;
431438
case 1: client.print(F("Always on")); break;
432439
case 2: client.print(F("On until night/away shutoff")); break;
433440
case 3: client.print(F("Off until alarm/timer sounds")); break;
434441
case 4: client.print(F("Off until switched relay")); break; //TODO skip
435442
default: break; } client.print(F("</option>")); } client.print(F("</select></li>"));
443+
#endif
436444

437445
//TODO nixie only TODO option for never
446+
#if !defined(HIDE_IRRELEVANT_OPTIONS) || defined(DISPLAY_NIXIE)
438447
client.print(F("<li><label>Anti-cathode poisoning</label><a name='antipoison' href='#'></a><select id='b46' onchange='save(this)'>")); for(char i=0; i<=2; i++){ client.print(F("<option value='")); client.print(i,DEC); client.print(F("'")); if(readEEPROM(46,false)==i) client.print(F(" selected")); client.print(F(">")); switch(i){
439448
case 0: client.print(F("Once a day")); break;
440449
case 1: client.print(F("Every hour")); break;
441450
case 2: client.print(F("Every minute")); break;
442451
default: break; } client.print(F("</option>")); } client.print(F("</select><br/><span class='explain'>Briefly cycles all digits to prevent <a href='http://www.tube-tester.com/sites/nixie/different/cathode%20poisoning/cathode-poisoning.htm' target='_blank'>cathode poisoning</a>. Will not trigger during night/away shutoff. Daily option happens at midnight or, if enabled, when night shutoff starts.</span></li>"));
452+
#endif
443453

444454
client.print(F("<li><h3>Alarm</h3></li>"));
445455

@@ -457,11 +467,18 @@ void checkClients(){
457467
case 2: client.print(F("Work week")); break;
458468
default: break; } client.print(F("</option>")); } client.print(F("</select><br/><span class='explain'>If using this, be sure to set <a href='#workweek'>work week</a> below.</span></li>"));
459469

470+
#if !defined(HIDE_IRRELEVANT_OPTIONS) || (RELAY_PIN>=0 && PIEZO_PIN>=0)
460471
client.print(F("<li><label>Signal</label><select id='b42' onchange='save(this)'>")); for(char i=0; i<=1; i++){ client.print(F("<option value='")); client.print(i,DEC); client.print(F("'")); if(readEEPROM(42,false)==i) client.print(F(" selected")); client.print(F(">")); switch(i){
461472
case 0: client.print(F("Beeper")); break;
462-
case 1: client.print(F("Relay")); break; //TODO "if in switch mode, will stay on for 2 hours"
463-
default: break; } client.print(F("</option>")); } client.print(F("</select></li>"));
464-
473+
case 1: client.print(F("Relay")); break;
474+
default: break; } client.print(F("</option>")); } client.print(F("</select>"));
475+
#if RELAY_MODE
476+
client.print(F("<br><span class='explain'>Relay will automatically switch off after ")); client.print(SWITCH_DUR/60,DEC); client.print(F(" minutes.</span>"));
477+
#endif
478+
client.print(F("</li>"));
479+
#endif
480+
481+
#if !defined(HIDE_IRRELEVANT_OPTIONS) || (PIEZO_PIN>=0)
465482
client.print(F("<li><label>Pitch</label><select id='b39' onchange='save(this)'>")); for(char i=49; i<=88; i++){ client.print(F("<option value='")); client.print(i,DEC); client.print(F("'")); if(readEEPROM(39,false)==i) client.print(F(" selected")); client.print(F(">")); switch((i-40)%12){
466483
case 0: client.print(F("C")); break;
467484
case 1: client.print(F("D&#9837;")); break;
@@ -485,13 +502,20 @@ void checkClients(){
485502
case 4: client.print(F("Quad")); break;
486503
case 5: client.print(F("Cuckoo")); break;
487504
default: break; } client.print(F("</option>")); } client.print(F("</select></li>"));
505+
#endif
488506

489507
client.print(F("<li><label>Snooze</label><input type='number' id='b24' onchange='promptsave(\"b24\")' onkeyup='promptsave(\"b24\")' onblur='unpromptsave(\"b24\"); save(this)' min='0' max='60' step='1' value='")); client.print(readEEPROM(24,false),DEC); client.print(F("' />")); client.print(F(" <a id='b24save' href='#' onclick='return false' style='display: none;'>save</a><br/><span class='explain'>In minutes. Zero disables snooze.</span></li>"));
490508

509+
#if !defined(HIDE_IRRELEVANT_OPTIONS) || (PIEZO_PIN>=0 && RELAY_MODE>0)
491510
client.print(F("<li><label>Fibonacci mode</label><select id='b50' onchange='save(this)'>")); for(char i=0; i<=1; i++){ client.print(F("<option value='")); client.print(i,DEC); client.print(F("'")); if(readEEPROM(50,false)==i) client.print(F(" selected")); client.print(F(">")); switch(i){
492511
case 0: client.print(F("Off")); break;
493512
case 1: client.print(F("On")); break;
494-
default: break; } client.print(F("</option>")); } client.print(F("</select><br><span class='explain'>To wake you more gradually, the alarm will start about 27 minutes early, by beeping at increasingly shorter intervals per the Fibonacci sequence (610 seconds, then 337, then 233...). In this mode, snooze does not take effect; any button press will silence the alarm for the day, even if the set alarm time hasn’t been reached yet. Has no effect when alarm is set to use switched relay.</span></li>")); //TODO switch etc
513+
default: break; } client.print(F("</option>")); } client.print(F("</select><br><span class='explain'>To wake you more gradually, the alarm will start about 27 minutes early, by beeping at increasingly shorter intervals per the Fibonacci sequence (610 seconds, then 337, then 233...). In this mode, snooze does not take effect; any button press will silence the alarm for the day, even if the set alarm time hasn’t been reached yet."));
514+
#if (RELAY_PIN>=0 && PIEZO_PIN>=0 && RELAY_MODE>0) //when switched relay is possible alarm signal
515+
client.print(F(" Has no effect when alarm is set to use relay."));
516+
#endif
517+
client.print(F("</span></li>"));
518+
#endif
495519

496520
client.print(F("<li><h3>Chrono/Timer</h3></li>"));
497521

@@ -502,11 +526,18 @@ void checkClients(){
502526
case 3: client.print(F("Start chrono, short signal")); break;
503527
default: break; } client.print(F("</option>")); } client.print(F("</select><br><span class='explain'>What the timer will do when it runs out. This can be set directly on the clock as well: while the timer is running, Down will cycle through these options (1-4 beeps respectively). The repeat option makes a great interval timer!</span></li>")); //TODO switch etc
504528

529+
#if !defined(HIDE_IRRELEVANT_OPTIONS) || (RELAY_PIN>=0 && PIEZO_PIN>=0)
505530
client.print(F("<li><label>Signal</label><select id='b43' onchange='save(this)'>")); for(char i=0; i<=1; i++){ client.print(F("<option value='")); client.print(i,DEC); client.print(F("'")); if(readEEPROM(43,false)==i) client.print(F(" selected")); client.print(F(">")); switch(i){
506531
case 0: client.print(F("Beeper")); break;
507-
case 1: client.print(F("Relay")); break; //TODO "if in switch mode, will stay on for 2 hours"
508-
default: break; } client.print(F("</option>")); } client.print(F("</select></li>"));
532+
case 1: client.print(F("Relay")); break;
533+
default: break; } client.print(F("</option>")); } client.print(F("</select>"));
534+
#if RELAY_MODE
535+
client.print(F("<br><span class='explain'>Relay will switch on while timer is running, like a <a href='https://en.wikipedia.org/wiki/Time_switch' target='_blank'>sleep timer</a>.</span>"));
536+
#endif
537+
client.print(F("</li>"));
538+
#endif
509539

540+
#if !defined(HIDE_IRRELEVANT_OPTIONS) || (PIEZO_PIN>=0)
510541
client.print(F("<li><label>Pitch</label><select id='b40' onchange='save(this)'>")); for(char i=49; i<=88; i++){ client.print(F("<option value='")); client.print(i,DEC); client.print(F("'")); if(readEEPROM(40,false)==i) client.print(F(" selected")); client.print(F(">")); switch((i-40)%12){
511542
case 0: client.print(F("C")); break;
512543
case 1: client.print(F("D&#9837;")); break;
@@ -530,7 +561,9 @@ void checkClients(){
530561
case 4: client.print(F("Quad")); break;
531562
case 5: client.print(F("Cuckoo")); break;
532563
default: break; } client.print(F("</option>")); } client.print(F("</select></li>"));
564+
#endif
533565

566+
#if !defined(HIDE_IRRELEVANT_OPTIONS) || (PIEZO_PIN>=0 && RELAY_MODE>0)
534567
client.print(F("<li><h3>Chime</h3></li>"));
535568

536569
client.print(F("<li><label>Chime</label><select id='b21' onchange='save(this)'>")); for(char i=0; i<=4; i++){ client.print(F("<option value='")); client.print(i,DEC); client.print(F("'")); if(readEEPROM(21,false)==i) client.print(F(" selected")); client.print(F(">")); switch(i){
@@ -540,12 +573,16 @@ void checkClients(){
540573
case 3: client.print(F("Strike the hour")); break;
541574
case 4: client.print(F("Ship's bell")); break;
542575
default: break; } client.print(F("</option>")); } client.print(F("</select><br/><span class='explain'>Will not sound during night/away shutoff (except when off starts at top of hour). <a href='https://en.wikipedia.org/wiki/Greenwich_Time_Signal' target='_blank'>Six pips refers to this.</a></span></li>"));
576+
#endif
543577

578+
#if !defined(HIDE_IRRELEVANT_OPTIONS) || (RELAY_PIN>=0 && PIEZO_PIN>=0 && RELAY_MODE>0)
544579
client.print(F("<li><label>Signal</label><select id='b44' onchange='save(this)'>")); for(char i=0; i<=1; i++){ client.print(F("<option value='")); client.print(i,DEC); client.print(F("'")); if(readEEPROM(44,false)==i) client.print(F(" selected")); client.print(F(">")); switch(i){
545580
case 0: client.print(F("Beeper")); break;
546-
case 1: client.print(F("Relay")); break; //TODO "if in switch mode, will stay on for 2 hours"
581+
case 1: client.print(F("Relay")); break;
547582
default: break; } client.print(F("</option>")); } client.print(F("</select></li>"));
548-
583+
#endif
584+
585+
#if !defined(HIDE_IRRELEVANT_OPTIONS) || (PIEZO_PIN>=0)
549586
client.print(F("<li><label>Pitch</label><select id='b41' onchange='save(this)'>")); for(char i=49; i<=88; i++){ client.print(F("<option value='")); client.print(i,DEC); client.print(F("'")); if(readEEPROM(41,false)==i) client.print(F(" selected")); client.print(F(">")); switch((i-40)%12){
550587
case 0: client.print(F("C")); break;
551588
case 1: client.print(F("D&#9837;")); break;
@@ -569,6 +606,7 @@ void checkClients(){
569606
case 4: client.print(F("Quad")); break;
570607
case 5: client.print(F("Cuckoo")); break;
571608
default: break; } client.print(F("</option>")); } client.print(F("</select></li>"));
609+
#if !defined(HIDE_IRRELEVANT_OPTIONS) || (PIEZO_PIN>=0)
572610

573611
client.print(F("<li><h3>Night/away shutoff</h3></li>"));
574612

0 commit comments

Comments
 (0)