Skip to content

Commit a5059c1

Browse files
committed
todos; network play beeper pitch/pattern samples (untested)
1 parent 28f46cb commit a5059c1

File tree

3 files changed

+32
-31
lines changed

3 files changed

+32
-31
lines changed

TODO.md

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,24 @@
11
# To-dos
22

3-
* Timer count up, ending options - maybe separate chrono and timer à la Timex?
4-
* Different setting option for pushbutton (à la Timex) vs. rotary (à la microwave ovens) - external file?
3+
* Persistent storage for EEPROM stuff on SAMD
4+
* Network/NTP
5+
* Why does the page sometimes drop?
6+
* Persistent storage for wi-fi credentials
7+
* wi-fi credential save fails if keys are part of the string?
8+
* DST calc may behave unpredictably between 1–2am on fallback day
9+
* Redo NTP on startup if it failed (networkStartWifi())
10+
* Handle 2038+ epochs
11+
* Notice when a leap second is coming and handle it
12+
* When setting page is used to set day counter and date, and the month changes, set date max. For 2/29 it should just do 3/1 probably.
13+
* When day counter is set to count up from 12/31, override to display 365/366 on that date
14+
* Bitmask to enable/disable features
515
* Option to display weekdays as Sun=0 or Sun=1 (per Portuguese!)
6-
* When setting times of day, make 1439 (minutes) roll over to 0 and vice versa
7-
* Implement options for full date every 5 minutes
816
* Is it possible to trip the chime *after* determining if we're in night shutoff or not
9-
* Reenable rotary encoder with libraries with workable licenses
1017
* In display code, consider using `delayMicroseconds()` which, with its tighter resolution, may give better control over fades and dim levels
11-
* in `checkInputs()`, can all this if/else business be defined at load instead of evaluated every sample? OR is it compiled that way? maybe use `#ifdef`
1218
* in `ctrlEvt()`, could we do release/shorthold on mainSel so we can exit without making changes?
13-
* Should functions be modular in the code, and have a reserved memory location / 100 per each?
14-
* Should functions have their own options menu?
15-
* I2C display to help with setting?
16-
* I2C multicolor LED to indicate which function we're in?
17-
* Metronome function
18-
* Alarm option should be beeping patterns, including a slow wake which defeats the 2 minute delay
19-
* Signalstart should create a situation where there's time on the counter, but doesn't make sound since the rtc can do that. Other beepable actions would probably cancel that counter anyway
19+
* I2C multicolor LED to indicate which function we're in? - possibly as part of display
20+
* Metronome function?
21+
* Signalstart should create a situation where there's time on the counter, but doesn't make sound since the rtc can do that. Other beepable actions would probably cancel that counter anyway (is this still applicable?)
2022
* Why does the display flicker sometimes? are we doubling up on a display cycle call?
2123

2224
See other TODOs throughout code.

arduino-nixie/arduino-nixie.ino

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@ Some are skipped when they wouldn't apply to a given clock's hardware config, se
8585
//Options menu numbers (displayed in UI and readme), locs, and default/min/max/current values.
8686
//Option numbers/order can be changed (though try to avoid for user convenience);
8787
//but option locs should be maintained so EEPROM doesn't have to be reset after an upgrade.
88-
//The current values array is wasteful, since they have to all be ints here; but there should be room. We will initialize them at startup.
8988
// General Alarm Timer Strike Night and away shutoff Geo
9089
const byte optsNum[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,11,12,13,14,15, 21,22,23, 30,31,32,33, 40, 41, 42,43,44,45, 46, 47, 50, 51, 52};
9190
const byte optsLoc[] = {16,17,18,19,20,22,26,46,45, 23,42,39,47,24,50, 43,40,48, 21,44,41,49, 27, 28, 30,32,33,34, 35, 37, 10, 12, 14};
@@ -158,6 +157,8 @@ void updateDisplay(); //used by network
158157
void goToFn(byte thefn); //used by network
159158
int dateComp(int y, byte m, byte d, byte mt, byte dt, bool countUp); //used by network
160159
void findFnAndPageNumbers(); //used by network
160+
word getHz(byte note); //used by network (play beeper pitch sample)
161+
void signalStart(byte sigFn, byte sigDur); //used by network (play beeper pattern sample)
161162

162163
#define SHOW_IRRELEVANT_OPTIONS 0 //TODO change options to settings everywhere //for debug
163164

arduino-nixie/network.cpp

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
String wssid = "Riley";
1414
String wpass = "5802301644"; //wpa pass or wep key
1515
byte wki = 0; //wep key index - 0 if using wpa
16-
//TODO how to persistent store this - one byte at a time up to the max
1716

1817
unsigned int localPort = 2390; // local port to listen for UDP packets
1918
#define NTP_PACKET_SIZE 48 // NTP time stamp is in the first 48 bytes of the message
@@ -27,9 +26,6 @@ WiFiServer server(80);
2726
#define NTP_MINFREQ 5000 //how long to enforce a wait between request starts (NIST requires at least 4sec between requests or will ban the client)
2827
#define NTPOK_THRESHOLD 3600000 //if no sync within 60 minutes, the time is considered stale
2928

30-
//TODO hide second 58 when no wifi; 59 when NTP is bad (old or 0), and retry every minute 0-5
31-
//TODO notice when a leap second is coming and handle it
32-
3329
//Declare a few functions so I can put them out of order
3430
//Placed here so I can avoid making header files for the moment
3531
void cueNTP();
@@ -398,12 +394,12 @@ void checkClients(){
398394
if(ntpSyncDiff<60){ client.print(ntpSyncDiff,DEC); client.print(F(" second(s) ago")); }
399395
else if(ntpSyncDiff<3600){ client.print(ntpSyncDiff/60,DEC); client.print(F(" minute(s) ago")); }
400396
else if(ntpSyncDiff<86400){ client.print(ntpSyncDiff/3600,DEC); client.print(F(" hour(s) ago")); }
401-
else { client.print(F(" over 24 hours ago")); } //TODO is there a display indication of this
397+
else { client.print(F(" over 24 hours ago")); }
402398
} else {
403399
if(ntpStartLast) client.print(F("No sync since time was set manually"));
404400
else client.print(F("Never synced"));
405401
}
406-
client.print(F("<br/></span><a id='syncnow' value='' href='#' onclick='document.getElementById(\"lastsync\").innerHTML=\"\"; save(this); return false;'>Sync&nbsp;now</a><br/></span><span class='explain'>Requires Wi-Fi. If using this, be sure to set your <a href='#utcoffset'>UTC offset</a> and <a href='#autodst'>auto DST</a> below.</span></li>")); //TODO sync now results in "OK!" even if it isn't necessarily ok. Get feedback to the client by making it synchronous in that case only? Also e.g. "Please wait" instead of "Saving"
402+
client.print(F("<br/></span><a id='syncnow' value='' href='#' onclick='document.getElementById(\"lastsync\").innerHTML=\"\"; save(this); return false;'>Sync&nbsp;now</a><br/></span><span class='explain'>Requires Wi-Fi. If using this, be sure to set your <a href='#utcoffset'>UTC offset</a> and <a href='#autodst'>auto DST</a> below.</span></li>"));
407403

408404
client.print(F("<li id='ntpserverli' style='display: ")); if(readEEPROM(9,false)==0) client.print(F("none")); else client.print(F("block")); client.print(F(";'><label>NTP server</label><input type='text' id='ntpip' onchange='promptsave(\"ntpip\")' onkeyup='promptsave(\"ntpip\")' onblur='unpromptsave(\"ntpip\"); save(this)' value='")); client.print(readEEPROM(51,false),DEC); client.print(F(".")); client.print(readEEPROM(52,false),DEC); client.print(F(".")); client.print(readEEPROM(53,false),DEC); client.print(F(".")); client.print(readEEPROM(54,false),DEC); client.print(F("' />")); client.print(F(" <a id='ntpipsave' href='#' onclick='return false' style='display: none;'>save</a><br/><span class='explain'><a href='https://en.wikipedia.org/wiki/IPv4#Addressing' target='_blank'>IPv4</a> address, e.g. one of <a href='https://tf.nist.gov/tf-cgi/servers.cgi' target='_blank'>NIST's time servers</a></span></li>"));
409405

@@ -433,7 +429,7 @@ void checkClients(){
433429
// const unsigned int FN_SUN = 1<<2; //4
434430
// const unsigned int FN_WEATHER = 1<<3; //8
435431
//Function preset ???????
436-
//TODO leap second support? Add NTP sync at top of hour also
432+
//TODO leap second support?
437433

438434
#if SHOW_IRRELEVANT_OPTIONS || ENABLE_DATE_COUNTER
439435
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){
@@ -443,7 +439,7 @@ void checkClients(){
443439
default: break; } client.print(F("</option>")); } client.print(F("</select>"));
444440
client.print(F("<br/><span id='daycounterdeets' style='display: ")); if(readEEPROM(4,false)==0) client.print(F("none")); else client.print(F("inline"));
445441
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
446-
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
442+
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>"));
447443
#endif
448444

449445
client.print(F("<li><label>Display date during time?</label><select id='b18' onchange='save(this)'>")); for(char i=0; i<=3; i++){ client.print(F("<option value='")); client.print(i,DEC); client.print(F("'")); if(readEEPROM(18,false)==i) client.print(F(" selected")); client.print(F(">")); switch(i){
@@ -852,20 +848,22 @@ void checkClients(){
852848
goToFn(fnIsDate); fnPg = 254; break;
853849
case 22: //auto dst
854850
isDSTByHour(rtcGetYear(),rtcGetMonth(),rtcGetDate(),rtcGetHour(),true); break;
855-
case 39: //alarm pitch //TODO beep
856-
goToFn(fnIsAlarm); break;
857-
case 40: //timer pitch //TODO beep
858-
goToFn(fnIsTimer); break;
859-
case 41: //strike pitch //TODO beep
860-
goToFn(fnIsTime); break;
861-
case 47: //alarm pattern //TODO beep
851+
case 39: case 47: //alarm pitch/pattern
862852
goToFn(fnIsAlarm); break;
863-
case 48: //timer pattern //TODO beep
853+
case 40: case 48: //timer pitch/pattern
864854
goToFn(fnIsTimer); break;
865-
case 49: //strike pattern //TODO beep
855+
case 41: case 49: //strike pitch/pattern
866856
goToFn(fnIsTime); break;
867857
default: break;
868858
}
859+
if(key==39 || key==40 || key==41){ //play beeper pitch sample - compare to updateDisplay()
860+
if(PIEZO_PIN>=0) { noTone(PIEZO_PIN); tone(PIEZO_PIN, getHz(val), 100); }
861+
}
862+
if(key==47 || key==48 || key==49){ //play beeper pattern sample - compare to updateDisplay()
863+
signalPattern = fnSetVal;
864+
signalSource = (key==49?fnIsTime:(key==48?fnIsTimer:fnIsAlarm));
865+
signalStart(-1,1); //Play a sample using the above source and pattern
866+
}
869867
}
870868
updateDisplay();
871869
client.print(clientReturn);

0 commit comments

Comments
 (0)