Skip to content

Commit 4e58a5d

Browse files
authored
Merge pull request #9 from clockspot/dev
Dev
2 parents 5b6151d + 579e9fa commit 4e58a5d

12 files changed

+1022
-544
lines changed

README.md

+5-4
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ This feature can count up (chrono) or down (timer), up to 100 hours each way. Wh
6767
> **Hardware variations**
6868
> * If your clock has a [switched relay](#hardware-configuration) and the chrono/timer is [set to use it](#optionstimer), it will switch on while the timer is running, like the “sleep” function on a clock radio. The runout options will still work, but won’t signal.
6969
> * If your clock does not have a beeper, the runout options cannot be set.
70-
> * If your clock uses a rotary encoder for **Up/Down** rather than buttons, **Down** will stop the chrono/timer, and **Up** will display lap times (chrono) and cycle through runout options (timer).
70+
> * If your clock uses a rotary encoder for **Up/Down** rather than buttons, while running, **Up** will display lap times (chrono) and cycle through runout options (timer), and **Down** will stop. To prevent accidental resets, **Down** does nothing while stopped. To reset to `0`, simply switch to another display while stopped.
7171
7272
## The Alt button
7373

@@ -150,11 +150,12 @@ You can also set the **defaults for the options menu** (in main code, currently)
150150

151151
## Compiling the sketch
152152

153-
**To compile the sketch,** ensure these libraries are added and enabled in your Arduino IDE, via the Library Manager:
153+
**To compile the sketch,** ensure these libraries are installed in your Arduino IDE via Library Manager, as needed:
154154

155155
* Wire (Arduino built-in)
156156
* EEPROM (Arduino built-in)
157-
* DS3231 ([NorthernWidget](https://github.com/NorthernWidget/DS3231))
158-
* Dusk2Dawn ([dmkishi](https://github.com/dmkishi/Dusk2Dawn))
157+
* [DS3231](https://github.com/NorthernWidget/DS3231) by NorthernWidget
158+
* [Dusk2Dawn](https://github.com/dmkishi/Dusk2Dawn) by DM Kishi - if sunrise/sunset display is enabled
159+
* [Encoder](https://github.com/PaulStoffregen/Encoder) by Paul Stoffregen - if rotary encoder is equipped
159160

160161
**To upload the sketch to your clock,** if it doesn’t appear in the IDE’s Ports menu (as a USB port), your UNDB may be equipped with an Arduino clone that requires [drivers for the CH340 chipset](https://sparks.gogo.co.nz/ch340.html).

arduino-nixie/arduino-nixie.ino

+238-199
Large diffs are not rendered by default.

arduino-nixie/configs/v5-4tube.h

+53-53
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
//UNDB v5, 4-tube display
22

3-
const byte displaySize = 4; //number of tubes in display module. Small display adjustments are made for 4-tube clocks
3+
#define DISPLAY_SIZE 4 //number of tubes in display module. Small display adjustments are made for 4-tube clocks
44

55
// Which functionality is enabled in this clock?
66
// Related options will also be enabled in the options menu.
7-
const bool enableDate = true;
8-
const bool enableDateCounter = true; // Adds a "page" to the date with an anniversary counter
9-
const bool enableDateSunriseSunset = true; // Adds "pages" to the date with sunrise/sunset times
10-
const bool enableAlarm = true;
11-
const bool enableAlarmAutoskip = true;
12-
const bool enableAlarmFibonacci = true;
13-
const bool enableTimer = true;
14-
const bool enableChime = true;
15-
const bool enableNightShutoff = true; // If disabled, tubes will be full brightness all the time.
16-
const bool enableAwayShutoff = true; // Requires night shutoff.
17-
const bool enableTemp = false; //Temperature per DS3231 - will read high – leave false for production
18-
const bool enableTest = false; //Cycles through all tubes – leave false for production
7+
#define ENABLE_DATE_FN true // Date function, optionally including pages below
8+
#define ENABLE_DATE_COUNTER true // Adds date page with an anniversary counter
9+
#define ENABLE_DATE_RISESET true // Adds date pages with sunrise/sunset times. Requires DM Kichi's Dusk2Dawn library to be installed in IDE.
10+
#define ENABLE_ALARM_FN true
11+
#define ENABLE_ALARM_AUTOSKIP true
12+
#define ENABLE_ALARM_FIBONACCI true
13+
#define ENABLE_TIMER_FN true
14+
#define ENABLE_TIME_CHIME true
15+
#define ENABLE_SHUTOFF_NIGHT true // If disabled, tubes will be full brightness all the time.
16+
#define ENABLE_SHUTOFF_AWAY true // Requires night shutoff.
17+
#define ENABLE_TEMP_FN false //Temperature per DS3231 - will read high – leave false for production
18+
#define ENABLE_TUBETEST_FN false //Cycles through all tubes – leave false for production
1919

2020
// These are the UNDB v5 board connections to Arduino analog input pins.
2121
// S1/PL13 = Reset
@@ -28,64 +28,64 @@ const bool enableTest = false; //Cycles through all tubes – leave false for pr
2828
// A6-A7 are analog-only pins that aren't quite as responsive and require a physical pullup resistor (1K to +5V), and can't be used with rotary encoders because they don't support pin change interrupts.
2929

3030
// What input is associated with each control?
31-
const byte mainSel = A2; //main select button - must be equipped
32-
const byte mainAdjUp = A1; //main up/down buttons or rotary encoder - must be equipped
33-
const byte mainAdjDn = A0;
34-
const byte altSel = 0; //alt select button - if unequipped, set to 0
31+
#define CTRL_SEL A2 //main select button - must be equipped
32+
#define CTRL_UP A1 //main up/down buttons or rotary encoder - must be equipped
33+
#define CTRL_DN A0
34+
#define CTRL_ALT 0 //alt select button - if unequipped, set to 0
3535

36-
// What type of adj controls are equipped?
37-
// 1 = momentary buttons. 2 = quadrature rotary encoder.
38-
const byte mainAdjType = 2;
36+
// What type of up/down controls are equipped?
37+
// 1 = momentary buttons. 2 = quadrature rotary encoder: requires Paul Stoffregen's Encoder library to be installed in IDE.
38+
#define CTRL_UPDN_TYPE 1
39+
#define ROT_VEL_START 80 //Required if CTRL_UPDN_TYPE==2. If step rate falls below this, kick into high velocity set (x10)
40+
#define ROT_VEL_STOP 500 //Required if CTRL_UPDN_TYPE==2. If encoder step rate rises above this, drop into low velocity set (x1)
41+
42+
// How long (in ms) are the button hold durations?
43+
#define CTRL_HOLD_SHORT_DUR 1000 //for entering setting mode, or hold-setting at low velocity (x1)
44+
#define CTRL_HOLD_LONG_DUR 3000 //for entering options menu, or hold-setting at high velocity (x10)
3945

4046
//What are the signal pin(s) connected to?
41-
const char piezoPin = 10;
42-
const char relayPin = -1; //don't change - not available until UNDB v8
43-
const byte relayMode = 0; //don't change - not available until UNDB v8
44-
const word signalDur = 180; //sec - when pulsed signal is going, pulses are sent once/sec for this period (e.g. 180 = 3min)
45-
const word switchDur = 7200; //sec - when alarm triggers switched relay, it's switched on for this period (e.g. 7200 = 2hr)
46-
const word piezoPulse = 250; //ms - used with piezo via tone()
47-
const word relayPulse = 200; //ms - used with pulsed relay
47+
#define PIEZO_PIN 10
48+
#define RELAY_PIN -1 //don't change - not available until UNDB v9 (or modded v8 - see v9 configs)
49+
#define RELAY_MODE 0 //don't change - not available until UNDB v9 (or modded v8 - see v9 configs)
50+
#define SIGNAL_DUR 180 //sec - when pulsed signal is going, pulses are sent once/sec for this period (e.g. 180 = 3min)
51+
#define SWITCH_DUR 7200 //sec - when alarm triggers switched relay, it's switched on for this period (e.g. 7200 = 2hr)
52+
#define PIEZO_PULSE 250 //ms - used with piezo via tone()
53+
#define RELAY_PULSE 200 //ms - used with pulsed relay
4854

4955
//Soft power switches
50-
const byte enableSoftAlarmSwitch = 1;
56+
#define ENABLE_SOFT_ALARM_SWITCH 1
5157
// 1 = yes. Alarm can be switched on and off when clock is displaying the alarm time (fnIsAlarm).
5258
// 0 = no. Alarm will be permanently on. Use with switched relay if the appliance has its own switch on this relay circuit.
53-
const byte enableSoftPowerSwitch = 0; //don't change - not available until UNDB v8
59+
#define ENABLE_SOFT_POWER_SWITCH 0 //don't change - not available until UNDB v9 (or modded v8 - see v9 configs)
5460

5561
//LED circuit control
56-
const char ledPin = -1; //don't change - not available until UNDB v8
62+
#define LED_PIN -1 //don't change - not available until UNDB v9 (or modded v8 - see v9 configs)
5763

5864
//When display is dim/off, a press will light the tubes for how long?
59-
const byte unoffDur = 10; //sec
60-
61-
// How long (in ms) are the button hold durations?
62-
const word btnShortHold = 1000; //for entering setting mode, or hold-setting at low velocity
63-
const word btnLongHold = 3000; //for entering options menu, or hold-setting at high velocity
64-
const word velThreshold = 0; //ms
65-
// When an adj up/down input (btn or rot) follows another in less than this time, value will change more (10 vs 1).
66-
// 0 to disable. Recommend ~150 for rotaries. If you want to use this feature with buttons, extend to ~300.
65+
#define UNOFF_DUR 10 //sec
6766

6867
// What is the "frame rate" of the tube cleaning and display scrolling? up to 65535 ms
69-
const word cleanSpeed = 200; //ms
70-
const word scrollSpeed = 100; //ms - e.g. scroll-in-and-out date at :30
68+
#define CLEAN_SPEED 200 //ms
69+
#define SCROLL_SPEED 100 //ms - e.g. scroll-in-and-out date at :30
7170

7271
// What are the timeouts for setting and temporarily-displayed functions? up to 65535 sec
73-
const unsigned long timeoutSet = 300; //sec
74-
const unsigned long timeoutTempFn = 5; //sec
72+
#define SETTING_TIMEOUT 300 //sec
73+
#define FN_TEMP_TIMEOUT 5 //sec
74+
#define FN_PAGE_TIMEOUT 3 //sec
7575

7676
//This clock is 2x3 multiplexed: two tubes powered at a time.
7777
//The anode channel determines which two tubes are powered,
7878
//and the two SN74141 cathode driver chips determine which digits are lit.
7979
//4 pins out to each SN74141, representing a binary number with values [1,2,4,8]
80-
const char outA1 = 2;
81-
const char outA2 = 3;
82-
const char outA3 = 4;
83-
const char outA4 = 5;
84-
const char outB1 = 6;
85-
const char outB2 = 7;
86-
const char outB3 = 8;
87-
const char outB4 = 9;
80+
#define OUT_A1 2
81+
#define OUT_A2 3
82+
#define OUT_A3 4
83+
#define OUT_A4 5
84+
#define OUT_B1 6
85+
#define OUT_B2 7
86+
#define OUT_B3 8
87+
#define OUT_B4 9
8888
//3 pins out to anode channel switches
89-
const char anode1 = 11;
90-
const char anode2 = 12;
91-
const char anode3 = 13;
89+
#define ANODE_1 11
90+
#define ANODE_2 12
91+
#define ANODE_3 13
+91
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
//UNDB v5, 6-tube display, with rotary controls
2+
3+
#define DISPLAY_SIZE 6 //number of tubes in display module. Small display adjustments are made for 4-tube clocks
4+
5+
// Which functionality is enabled in this clock?
6+
// Related options will also be enabled in the options menu.
7+
#define ENABLE_DATE_FN true // Date function, optionally including pages below
8+
#define ENABLE_DATE_COUNTER true // Adds date page with an anniversary counter
9+
#define ENABLE_DATE_RISESET true // Adds date pages with sunrise/sunset times. Requires DM Kichi's Dusk2Dawn library to be installed in IDE.
10+
#define ENABLE_ALARM_FN true
11+
#define ENABLE_ALARM_AUTOSKIP true
12+
#define ENABLE_ALARM_FIBONACCI true
13+
#define ENABLE_TIMER_FN true
14+
#define ENABLE_TIME_CHIME true
15+
#define ENABLE_SHUTOFF_NIGHT true // If disabled, tubes will be full brightness all the time.
16+
#define ENABLE_SHUTOFF_AWAY true // Requires night shutoff.
17+
#define ENABLE_TEMP_FN false //Temperature per DS3231 - will read high – leave false for production
18+
#define ENABLE_TUBETEST_FN false //Cycles through all tubes – leave false for production
19+
20+
// These are the UNDB v5 board connections to Arduino analog input pins.
21+
// S1/PL13 = Reset
22+
// S2/PL5 = A1
23+
// S3/PL6 = A0
24+
// S4/PL7 = A6
25+
// S5/PL8 = A3
26+
// S6/PL9 = A2
27+
// S7/PL14 = A7
28+
// A6-A7 are analog-only pins that aren't quite as responsive and require a physical pullup resistor (1K to +5V), and can't be used with rotary encoders because they don't support pin change interrupts.
29+
30+
// What input is associated with each control?
31+
#define CTRL_SEL A2 //main select button - must be equipped
32+
#define CTRL_UP A1 //main up/down buttons or rotary encoder - must be equipped
33+
#define CTRL_DN A0
34+
#define CTRL_ALT 0 //alt select button - if unequipped, set to 0
35+
36+
// What type of up/down controls are equipped?
37+
// 1 = momentary buttons. 2 = quadrature rotary encoder: requires Paul Stoffregen's Encoder library to be installed in IDE.
38+
#define CTRL_UPDN_TYPE 2
39+
#define ROT_VEL_START 80 //Required if CTRL_UPDN_TYPE==2. If step rate falls below this, kick into high velocity set (x10)
40+
#define ROT_VEL_STOP 500 //Required if CTRL_UPDN_TYPE==2. If encoder step rate rises above this, drop into low velocity set (x1)
41+
42+
// How long (in ms) are the button hold durations?
43+
#define CTRL_HOLD_SHORT_DUR 1000 //for entering setting mode, or hold-setting at low velocity (x1)
44+
#define CTRL_HOLD_LONG_DUR 3000 //for entering options menu, or hold-setting at high velocity (x10)
45+
46+
//What are the signal pin(s) connected to?
47+
#define PIEZO_PIN 10
48+
#define RELAY_PIN -1 //don't change - not available until UNDB v9 (or modded v8 - see v9 configs)
49+
#define RELAY_MODE 0 //don't change - not available until UNDB v9 (or modded v8 - see v9 configs)
50+
#define SIGNAL_DUR 180 //sec - when pulsed signal is going, pulses are sent once/sec for this period (e.g. 180 = 3min)
51+
#define SWITCH_DUR 7200 //sec - when alarm triggers switched relay, it's switched on for this period (e.g. 7200 = 2hr)
52+
#define PIEZO_PULSE 250 //ms - used with piezo via tone()
53+
#define RELAY_PULSE 200 //ms - used with pulsed relay
54+
55+
//Soft power switches
56+
#define ENABLE_SOFT_ALARM_SWITCH 1
57+
// 1 = yes. Alarm can be switched on and off when clock is displaying the alarm time (fnIsAlarm).
58+
// 0 = no. Alarm will be permanently on. Use with switched relay if the appliance has its own switch on this relay circuit.
59+
#define ENABLE_SOFT_POWER_SWITCH 0 //don't change - not available until UNDB v9 (or modded v8 - see v9 configs)
60+
61+
//LED circuit control
62+
#define LED_PIN -1 //don't change - not available until UNDB v9 (or modded v8 - see v9 configs)
63+
64+
//When display is dim/off, a press will light the tubes for how long?
65+
#define UNOFF_DUR 10 //sec
66+
67+
// What is the "frame rate" of the tube cleaning and display scrolling? up to 65535 ms
68+
#define CLEAN_SPEED 200 //ms
69+
#define SCROLL_SPEED 100 //ms - e.g. scroll-in-and-out date at :30
70+
71+
// What are the timeouts for setting and temporarily-displayed functions? up to 65535 sec
72+
#define SETTING_TIMEOUT 300 //sec
73+
#define FN_TEMP_TIMEOUT 5 //sec
74+
#define FN_PAGE_TIMEOUT 3 //sec
75+
76+
//This clock is 2x3 multiplexed: two tubes powered at a time.
77+
//The anode channel determines which two tubes are powered,
78+
//and the two SN74141 cathode driver chips determine which digits are lit.
79+
//4 pins out to each SN74141, representing a binary number with values [1,2,4,8]
80+
#define OUT_A1 2
81+
#define OUT_A2 3
82+
#define OUT_A3 4
83+
#define OUT_A4 5
84+
#define OUT_B1 6
85+
#define OUT_B2 7
86+
#define OUT_B3 8
87+
#define OUT_B4 9
88+
//3 pins out to anode channel switches
89+
#define ANODE_1 11
90+
#define ANODE_2 12
91+
#define ANODE_3 13

0 commit comments

Comments
 (0)