Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
916fdb5
Move to arduino-nixie; add Song class; more todos
clockspot Oct 27, 2019
95f6fe5
Alarm skip (untested)
clockspot Feb 13, 2020
fa68f39
Reintroduce Alt preset to temporary display timeout
clockspot Feb 13, 2020
7d39a0e
(WIP) begin paged date display
clockspot Feb 14, 2020
f0e4e47
Paginated calendar
clockspot Feb 16, 2020
0bc3ccf
WIP: set coords and UTC±, alarmOn, isDST, displaySun
clockspot Feb 18, 2020
be8defa
WIP: DST rewrite completed (untested)
clockspot Feb 18, 2020
bb767a1
add 100 to UTC quarter hour offset
clockspot Feb 18, 2020
df4db0c
WIP: finish displaySun (untested)
clockspot Feb 19, 2020
163ca33
Complete paginated date and sunrise/sunset
clockspot Feb 20, 2020
5f824e9
Calc sun in advance; isDSTByHour
clockspot Feb 22, 2020
a37dc72
Repeating day counter; sun/dst recalc leaving settings; Alt preset al…
clockspot Feb 22, 2020
855287d
readme; version at startup; bugfixes
clockspot Feb 23, 2020
f4afef0
ibid
clockspot Feb 23, 2020
fecca2f
Ignore unset DST EEPROM flag after upgrade to 1.6.0
clockspot Feb 23, 2020
f6ee57d
Did some TODOs
clockspot Feb 23, 2020
5482880
formatting
clockspot Feb 23, 2020
bb49dce
Merge pull request #3 from clockspot/feature/alarm-skip
clockspot Feb 23, 2020
6cff7aa
Don't need separate version file
clockspot Feb 23, 2020
52a55c4
rogue serial print
clockspot Feb 23, 2020
d08c4a7
Merge pull request #4 from clockspot/feature/alarm-skip
clockspot Feb 23, 2020
50cdc1d
README changes in advance of some other stuff
clockspot Jul 3, 2020
225da83
README remove most fn/mode references for simplicity
clockspot Jul 3, 2020
97654bb
todo update
clockspot Jul 3, 2020
e650f45
readme tweaks for github
clockspot Jul 3, 2020
bc02559
readme updates for github
clockspot Jul 3, 2020
725d6a3
readme tweaks
clockspot Jul 3, 2020
bb2065c
Many fixes, wip
clockspot Jul 4, 2020
ee5db6d
terminology cleanup
clockspot Jul 4, 2020
78e81e5
lat/long setting bugfixes; readme update
clockspot Jul 4, 2020
38145d8
extras
clockspot Jul 4, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
145 changes: 85 additions & 60 deletions README.md

Large diffs are not rendered by default.

10 changes: 8 additions & 2 deletions TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,20 @@

* Timer count up, ending options - maybe separate chrono and timer à la Timex?
* Different setting option for pushbutton (à la Timex) vs. rotary (à la microwave ovens) - external file?
* Set current DST state in EEPROM so when the clock is connected to power, it can determine whether correction is needed
* Option to display weekdays as Sun=0 or Sun=1 (per Portuguese!)
* When setting times of day, make 1439 (minutes) roll over to 0 and vice versa
* Implement options for full date every 5 minutes
* Is it possible to trip the chime *after* determining if we're in night mode or not
* Is it possible to trip the chime *after* determining if we're in night shutoff or not
* Reenable rotary encoder with libraries with workable licenses
* In display code, consider using `delayMicroseconds()` which, with its tighter resolution, may give better control over fades and dim levels
* 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`
* in `ctrlEvt()`, could we do release/shorthold on mainSel so we can exit without making changes?
* Should functions be modular in the code, and have a reserved memory location / 100 per each?
* Should functions have their own options menu?
* I2C display to help with setting?
* I2C multicolor LED to indicate which function we're in?
* Metronome function
* Alarm option should be beeping patterns, including a slow wake which defeats the 2 minute delay
* 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

See other TODOs throughout code.
58 changes: 58 additions & 0 deletions arduino-nixie/Song.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
//Try to make the beeper play Woody's chorus part from "1612"
class Song {
int bpm = 80;
int pin = 10; //that piezo is connected to
int dur = 10000; //max note length in millis
//This'll be like a proto-MIDI with events that represent sounds (notes, chords) or to stop sound.
//Need to represent chords as a single event since the beeper is mono and has to cycle through the notes.
//Event timing is in centibeats (e.g. in */4, quarters are 100, eights 50, sixteenths 25)
//First index is a placeholder. eventtimes[] has an extra time, at which it loops back to index 1.
int eventtimes[30] = {0, 0, 15, 75, 90,100,115,175,190,225,240,275,290,300,315,400,415,475,490,500,515,575,590,625,640,675,690,700,715,800};
int eventtypes[29] = {0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0};
int curevent = 0; //Current event (index in arrays above)
int cureventnote = 0; //Current note in the event (to support cycling through a chord). 1 for single note. 0 when not playing a note presently.
float transpose = 1;
unsigned long eventstart = 0; //0 when not playing a song presently.
//we will only keep track of time since last event, thus bpm may vary due to rounding errors, but millis() rollover will only cause one event skip (I think?).
public:
Song(int zero) {}
void play(){
check(true); //the true means this starts the song
} //end void play
void check(bool start){ if(start || curevent){ //if song starting or playing
unsigned long mils = millis();
//Are we moving to a new event?
int neweventdiff = (eventtimes[curevent+1]-eventtimes[curevent])*(600/bpm); //*(600/bpm) converts diff in centibeats to milliseconds
if(start || mils-eventstart >= neweventdiff){
if(start) eventstart = mils; //true start of event
else eventstart = eventstart + neweventdiff; //set start of event relative to start of last, for better timekeeping
curevent++; //Next event
if(curevent+1 == 30){ curevent=1; } //Have we looped? Go back to first event //eventtimes.size
}
//Should we do anything about the current event?
int neweventnote = (((mils-eventstart)%120)/40)+1; //a cycle of 3 every 120 ms (40ms/ea), based on current time
switch(eventtypes[curevent]){ //The type of note/chord/stop
case 1: //C Major chord, cycle of 523.25, 659.25, 784 Hz
if(cureventnote!=neweventnote) {
cureventnote = neweventnote;
tone(pin, (cureventnote==1? 523.25*transpose: (cureventnote==2? 659.25*transpose: 784*transpose)), dur);
}
break;
case 2: //F Major chord, cycle of 523.25, 698.45, 880 Hz
if(cureventnote!=neweventnote) {
cureventnote = neweventnote;
tone(pin, (cureventnote==1? 523.25*transpose: (cureventnote==2? 698.45*transpose: 880*transpose)), dur);
}
break;
case 0: //Stop - turn off sound, if playing
if(cureventnote!=0){ cureventnote=0; noTone(pin); } break;
default: break;
}
}} //end void check if song playing
void stop(){
noTone(pin);
curevent = 0;
cureventnote = 0;
eventstart = 0;
} //end void stop
}; //end class Song
Loading