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: README.md
+16-16Lines changed: 16 additions & 16 deletions
Original file line number
Diff line number
Diff line change
@@ -14,19 +14,19 @@ To see your clock’s software version, hold **Select** briefly while powering u
14
14
15
15
**A universal digital clock codebase for Arduino,** maintained by [Luke](https://theclockspot.com).
16
16
17
-
* Time of day with automatic DST change and chimes.
18
-
* Perpetual calendar with day counter and local sunrise/sunset times.
19
-
* Daily alarm with snooze and automatic weekday/weekend skipping.
20
-
* Chronograph and timer with reset/interval options.
21
-
* Simple control via three/four buttons, a rotary encoder, and/or an [IMU](https://en.wikipedia.org/wiki/Inertial_measurement_unit) (tilt control).
22
-
* Signals via piezo beeper, switch (e.g. appliance timer), and/or pulse (e.g. bell ringer).
23
-
* Supports Nixie displays of two SN74141 chips driving four/six tubes, with anti-cathode poisoning.
24
-
* Supports LED displays of three/four MAX7219 chips (via SPI) driving 8x8 LED matrices ([example](https://www.amazon.com/HiLetgo-MAX7219-Arduino-Microcontroller-Display/dp/B07FFV537V/)).
25
-
* Supports scheduled display dim/shutoff and switchable backlighting with optional PWM fade.
17
+
***Time of day** with automatic DST change and chimes.
18
+
***Perpetual calendar** with day counter and local sunrise/sunset times.
19
+
***Alarm** with snooze and automatic weekday/weekend skipping.
20
+
***Chronograph and timer** with reset/interval options.
21
+
* Runs on both classic Arduino Nano (AVR) and Nano 33 IoT (SAMD21).
22
+
* Supports **web-based config and NTP sync** over Wi-Fi on Nano 33 IoT.
23
+
***Simple control** via three/four buttons, a rotary encoder, and/or Nano 33 IoT’s [IMU](https://en.wikipedia.org/wiki/Inertial_measurement_unit) (tilt control).
24
+
***Signals** via piezo beeper, switch (e.g. appliance timer), and/or pulse (e.g. bell ringer).
25
+
* Supports **Nixie displays** of two SN74141 chips driving four/six tubes, with anti-cathode poisoning.
26
+
* Supports **LED displays** of three/four MAX7219 chips (via SPI) driving 8x8 LED matrices ([example](https://www.amazon.com/HiLetgo-MAX7219-Arduino-Microcontroller-Display/dp/B07FFV537V/)).
27
+
* Scheduled nightly/weekly **display dim/shutoff** and switchable backlighting with optional PWM fade.
26
28
* Timekeeping can be internal, or based on a DS3231 RTC (via I2C) for reliability/accuracy.
27
-
* Supports both AVR and SAMD Arduinos (tested on Arduino Nano and Nano 33 IoT).
28
-
* On Nano 33 IoT, supports web-based config and NTP sync over Wi-Fi.
29
-
* User settings kept in persistent storage, but also mirrored in RAM in case of EEPROM/flash failure.
29
+
* Settings stored persistently in case of power loss, and mirrored in RAM in case of EEPROM/flash failure.
30
30
31
31
Written to support [RLB Designs’](http://rlb-designs.com/) Universal Nixie Driver Board (UNDB):
32
32
@@ -38,13 +38,13 @@ Written to support [RLB Designs’](http://rlb-designs.com/) Universal Nixie Dri
38
38
39
39
# Configuration, compilation, and upload
40
40
41
-
Various options, such as enabled functionality, RTC, display, I/O pins, timeouts, and control behaviors, are specified in a config file. This allows you to maintain configs for multiple clock hardware profiles, and simply include the relevant config at the top of the `.ino` before compiling. Several [example configs](https://github.com/clockspot/arduino-clock/tree/master/arduino-clock/configs) are provided, and [`~sample.h`](https://github.com/clockspot/arduino-clock/blob/master/arduino-clock/configs/%7Esample.h) includes all possible options with detailed comments.
41
+
Various options, such as enabled functionality, RTC, display, I/O pins, timeouts, and control behaviors, are specified in a config file. This allows you to maintain configs for multiple clock hardware profiles, and simply include the relevant config at the top of `arduino-nixie.h` before compiling. Several [example configs](https://github.com/clockspot/arduino-clock/tree/master/arduino-clock/configs) are provided, and [`~sample.h`](https://github.com/clockspot/arduino-clock/blob/master/arduino-clock/configs/%7Esample.h) includes all possible options with detailed comments.
42
42
43
-
You may also wish to adjust the defaults for the clock’s user-configurable values to best suit its intended use. Some of these are specified in the config; others are in the main code (`optsDef[]` for [settings](https://github.com/clockspot/arduino-clock/blob/master/INSTRUCTIONS.md#settings-menu) and `initEEPROM()` for other values).
43
+
You may also wish to adjust the defaults for the clock’s user-configurable values to best suit its intended use, in case the user performs a hard reset. Some of these are specified in the config; others, for now, are hardcoded in `arduino-nixie.ino` (`optsDef[]` for [settings](https://github.com/clockspot/arduino-clock/blob/master/INSTRUCTIONS.md#settings-menu) and `initEEPROM()` for other values).
44
44
45
45
I use the Arduino IDE to compile and upload, due to the use of various Arduino and Arduino-oriented libraries. Make sure the relevant libraries are installed in the Library Manager, per the config in use.
46
46
47
-
* EEPROM (Arduino) for AVR Arduinos (e.g. original Nano)
47
+
* EEPROM (Arduino) for AVR Arduinos (e.g. classic Nano)
48
48
* SPI (Arduino) and [LedControl](http://wayoda.github.io/LedControl) for MAX7219-based displays
49
49
*[Encoder](https://github.com/PaulStoffregen/Encoder) if rotary encoder is used for Up/Down inputs
50
50
* Arduino_LSM6DS3 (Arduino) if using Nano 33 IoT’s IMU for inputs
@@ -57,4 +57,4 @@ I use the Arduino IDE to compile and upload, due to the use of various Arduino a
57
57
Before compiling and uploading, you will need to select the correct board, port, and (for AVR) processor in the IDE’s Tools menu.
58
58
59
59
* If your Arduino does not appear as a port option, you may have a clone that requires [drivers for the CH340 chipset](https://sparks.gogo.co.nz/ch340.html).
60
-
* If upload fails for an ATMega328P Arduino (e.g. original Nano), try selecting/unselecting “Old Bootloader” in the processor menu.
60
+
* If upload fails for an ATMega328P Arduino (e.g. classic Nano), try selecting/unselecting “Old Bootloader” in the processor menu.
Copy file name to clipboardExpand all lines: arduino-nixie/arduino-nixie.ino
+4-4Lines changed: 4 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -749,7 +749,6 @@ bool initEEPROM(bool hard){
749
749
if(hard || readEEPROM(6,false)<1 || readEEPROM(6,false)>31) changed += writeEEPROM(6,31,false,false); //6: ...31st. (This gives the day of the year)
750
750
if(hard) changed += writeEEPROM(7,0,false,false); //7: Alt function preset
751
751
//8: TODO functions/pages enabled (bitmask)
752
-
if(hard || readEEPROM(9,false)>1) changed += writeEEPROM(9,1,false,false); //9: NTP sync on
753
752
if(hard) changed += writeEEPROM(15,0,false,false); //15: last known DST on flag - clear on hard reset (to match the reset RTC/auto DST/anti-poisoning settings to trigger midnight tubes as a tube test)
754
753
if(networkSupported()){
755
754
if(hard){ //everything in here needs no range testing
Copy file name to clipboardExpand all lines: arduino-nixie/network.cpp
+38-23Lines changed: 38 additions & 23 deletions
Original file line number
Diff line number
Diff line change
@@ -16,8 +16,14 @@
16
16
//Needs to be able to save to persistent storage
17
17
#include"storage.h"
18
18
19
-
String wssid = "Riley";
20
-
String wpass = "5802301644"; //wpa pass or wep key
19
+
//Volatile vars that back up the wifi creds in EEPROM
20
+
// 55-86 Wi-Fi SSID (32 bytes)
21
+
// 87-150 Wi-Fi WPA passphrase/key or WEP key (64 bytes)
22
+
// 151 Wi-Fi WEP key index (1 byte)
23
+
//If the EEPROM ssid/pass are a full 32/64 chars, there won't be room for the termination character '\0', we'll add that when reading
24
+
//TODO consider making these char arrays - but the memory usage on SAMD isn't bad as-is
25
+
String wssid = "";
26
+
String wpass = ""; //wpa pass or wep key
21
27
byte wki = 0; //wep key index - 0 if using wpa
22
28
23
29
unsignedint localPort = 2390; // local port to listen for UDP packets
@@ -39,7 +45,15 @@ void initNetwork(){
39
45
//Check status of wifi module up front
40
46
//if(WiFi.status()==WL_NO_MODULE){ Serial.println(F("Communication with WiFi module failed!")); while(true); }
41
47
//else if(WiFi.firmwareVersion()<WIFI_FIRMWARE_LATEST_VERSION) Serial.println(F("Please upgrade the firmware"));
42
-
networkStartWiFi();
48
+
//Get wifi credentials out of EEPROM - see wssid/wpass definitions above
49
+
//Read until a termination character is reached
50
+
for(byte i=0; i<32; i++){ if(readEEPROM(55+i,false)=='\0') break; wssid.concat((char)(readEEPROM(55+i,false))); } //Read in the SSID
51
+
for(byte i=0; i<64; i++){ if(readEEPROM(87+i,false)=='\0') break; wpass.concat((char)(readEEPROM(87+i,false))); } //Read in the pass
52
+
wki = readEEPROM(151,false); //Read in the wki
53
+
Serial.print(F("wssid=")); Serial.println(wssid);
54
+
Serial.print(F("wpass=")); Serial.println(wpass);
55
+
Serial.print(F("wki=")); Serial.println(wki);
56
+
networkStartWiFi();
43
57
}
44
58
voidcycleNetwork(){
45
59
checkClients();
@@ -130,7 +144,7 @@ unsigned long ntpSyncAgo(){
130
144
131
145
voidcueNTP(){
132
146
// We don't want to let other code startNTP() directly since it's normally asynchronous, and that other code may delay the time until we can check the result. Exception is forced call from admin page, which calls startNTP() synchronously.
133
-
ntpCued = true;
147
+
if(readEEPROM(9,false)) ntpCued = true;
134
148
}
135
149
136
150
intstartNTP(bool synchronous){ //Called at intervals to check for ntp time
//TODO this doesn't seem to return properly if the wifi was changed after the clock was booted - it syncs, but just hangs
800
814
int ntpCode = startNTP(true);
801
815
switch(ntpCode){
802
-
case -1: clientReturn = "Error: no Wi-Fi credentials."; break;
803
-
case -2: clientReturn = "Error: not connected to Wi-Fi."; break;
804
-
case -3: clientReturn = "Error: NTP response pending. Please try again shortly."; break; //should never see this one on the web since it's synchronous and the client blocks
805
-
case -4: clientReturn = "Error: too many sync requests in the last "; clientReturn += (NTP_MINFREQ/1000); clientReturn += " seconds. Please try again shortly."; break;
806
-
case -5: clientReturn = "Error: no NTP response received. Please confirm server."; break;
case -1: client.print(F("Error: no Wi-Fi credentials.")); break;
817
+
case -2: client.print(F("Error: not connected to Wi-Fi.")); break;
818
+
case -3: client.print(F("Error: NTP response pending. Please try again shortly.")); break; //should never see this one on the web since it's synchronous and the client blocks
819
+
case -4: client.print(F("Error: too many sync requests in the last ")); client.print(NTP_MINFREQ/1000,DEC); client.print(F(" seconds. Please try again shortly.")); break;
820
+
case -5: client.print(F("Error: no NTP response received. Please confirm server.")); break;
0 commit comments