Skip to content

Commit cc5ff2e

Browse files
committed
Test sketch for modified v8.0 boards
1 parent ddc1d04 commit cc5ff2e

File tree

6 files changed

+247
-5
lines changed

6 files changed

+247
-5
lines changed

sixtube_lm/configs/v5-6tube-red.h

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
const byte displaySize = 6; //number of tubes in display module. Small display adjustments are made for 4-tube clocks
2+
3+
// available clock functions, and unique IDs (between 0 and 200)
4+
const byte fnIsTime = 0;
5+
const byte fnIsDate = 1;
6+
const byte fnIsAlarm = 2;
7+
const byte fnIsTimer = 3;
8+
const byte fnIsDayCount = 4;
9+
const byte fnIsTemp = 5;
10+
const byte fnIsTubeTester = 6; //cycles all digits on all tubes 1/second, similar to anti-cathode-poisoning cleaner
11+
// functions enabled in this clock, in their display order. Only fnIsTime is required
12+
const byte fnsEnabled[] = {fnIsTime, fnIsDate, fnIsAlarm, fnIsTimer, fnIsDayCount}; //, fnIsTemp, fnIsTubeTester
13+
// To control which of these display persistently vs. switch back to Time after a few seconds, search "Temporary-display mode timeout"
14+
15+
// These are the UNDB v5 board connections to Arduino analog input pins.
16+
// S1/PL13 = Reset
17+
// S2/PL5 = A1
18+
// S3/PL6 = A0
19+
// S4/PL7 = A6
20+
// S5/PL8 = A3
21+
// S6/PL9 = A2
22+
// S7/PL14 = A7
23+
// 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.
24+
25+
// What input is associated with each control?
26+
const byte mainSel = A1; //main select button - must be equipped
27+
const byte mainAdjUp = A6; //main up/down buttons or rotary encoder - must be equipped
28+
const byte mainAdjDn = A2;
29+
const byte altSel = 0; //alt select button - if unequipped, set to 0
30+
31+
// What type of adj controls are equipped?
32+
// 1 = momentary buttons. 2 = quadrature rotary encoder.
33+
const byte mainAdjType = 1;
34+
35+
// In normal running mode, what do the controls do?
36+
// -1 = nothing/switch, -2 = cycle through functions, fn in fnsEnabled[] = go to that function
37+
// If using soft alarm/power switch per below, the control(s) set to -1 will do the switching.
38+
const char mainSelFn = -2;
39+
const char mainAdjFn = -1;
40+
const byte altSelFn = -1;
41+
42+
//What are the signal pin(s) connected to?
43+
const char piezoPin = 10;
44+
const char relayPin = -1; //don't change - not available until UNDB v8
45+
const byte relayMode = 0; //don't change - not available until UNDB v8
46+
const word signalDur = 180; //sec - when pulsed signal is going, pulses are sent once/sec for this period (e.g. 180 = 3min)
47+
const word switchDur = 7200; //sec - when alarm triggers switched relay, it's switched on for this period (e.g. 7200 = 2hr)
48+
const word piezoPulse = 500; //ms - used with piezo via tone()
49+
const word relayPulse = 200; //ms - used with pulsed relay
50+
51+
//Soft power switches
52+
const byte enableSoftAlarmSwitch = 1;
53+
// 1 = yes. Alarm can be switched on and off when clock is displaying the alarm time (fnIsAlarm).
54+
// 0 = no. Alarm will be permanently on. Use with switched relay if the appliance has its own switch on this relay circuit.
55+
const byte enableSoftPowerSwitch = 0; //don't change - not available until UNDB v8
56+
57+
//LED circuit control
58+
const char ledPin = -1; //don't change - not available until UNDB v8
59+
60+
//When display is dim/off, a press will light the tubes for how long?
61+
const byte unoffDur = 10; //sec
62+
63+
// How long (in ms) are the button hold durations?
64+
const word btnShortHold = 1000; //for setting the displayed feataure
65+
const word btnLongHold = 3000; //for for entering options menu
66+
const byte velThreshold = 150; //ms
67+
// When an adj up/down input (btn or rot) follows another in less than this time, value will change more (10 vs 1).
68+
// Recommend ~150 for rotaries. If you want to use this feature with buttons, extend to ~400.
69+
70+
// What is the "frame rate" of the tube cleaning and display scrolling? up to 65535 ms
71+
const word cleanSpeed = 200; //ms
72+
const word scrollSpeed = 100; //ms - e.g. scroll-in-and-out date at :30 - to give the illusion of a slow scroll that doesn't pause, use (timeoutTempFn*1000)/(displaySize+1) - e.g. 714 for displaySize=6 and timeoutTempFn=5
73+
74+
// What are the timeouts for setting and temporarily-displayed functions? up to 65535 sec
75+
const unsigned long timeoutSet = 120; //sec
76+
const unsigned long timeoutTempFn = 5; //sec

sixtube_lm/configs/v5-6tube-rotary.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ const byte altSel = 0; //alt select button - if unequipped, set to 0
3030

3131
// What type of adj controls are equipped?
3232
// 1 = momentary buttons. 2 = quadrature rotary encoder.
33-
const byte mainAdjType = 1;
33+
const byte mainAdjType = 2;
3434

3535
// In normal running mode, what do the controls do?
3636
// -1 = nothing/switch, -2 = cycle through functions, fn in fnsEnabled[] = go to that function

sixtube_lm/configs/v5-6tube.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ const byte altSel = 0; //alt select button - if unequipped, set to 0
3030

3131
// What type of adj controls are equipped?
3232
// 1 = momentary buttons. 2 = quadrature rotary encoder.
33-
const byte mainAdjType = 2;
33+
const byte mainAdjType = 1;
3434

3535
// In normal running mode, what do the controls do?
3636
// -1 = nothing/switch, -2 = cycle through functions, fn in fnsEnabled[] = go to that function

sixtube_lm/configs/v8-4tube.h

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
const byte displaySize = 4; //number of tubes in display module. Small display adjustments are made for 4-tube clocks
2+
3+
// available clock functions, and unique IDs (between 0 and 200)
4+
const byte fnIsTime = 0;
5+
const byte fnIsDate = 1;
6+
const byte fnIsAlarm = 2;
7+
const byte fnIsTimer = 3;
8+
const byte fnIsDayCount = 4;
9+
const byte fnIsTemp = 5;
10+
const byte fnIsTubeTester = 6; //cycles all digits on all tubes 1/second, similar to anti-cathode-poisoning cleaner
11+
// functions enabled in this clock, in their display order. Only fnIsTime is required
12+
const byte fnsEnabled[] = {fnIsTime, fnIsDate, fnIsAlarm, fnIsTimer, fnIsDayCount}; //, fnIsTemp, fnIsTubeTester
13+
// To control which of these display persistently vs. switch back to Time after a few seconds, search "Temporary-display mode timeout"
14+
15+
// These are the RLB board connections to Arduino analog input pins.
16+
// S1/PL13 = Reset
17+
// S2/PL5 = A1
18+
// S3/PL6 = A0
19+
// S4/PL7 = A6
20+
// S5/PL8 = A3
21+
// S6/PL9 = A2
22+
// S7/PL14 = A7
23+
// 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.
24+
25+
// What input is associated with each control?
26+
const byte mainSel = A1; //main select button - must be equipped
27+
const byte mainAdjUp = A2; //main up/down buttons or rotary encoder - must be equipped
28+
const byte mainAdjDn = A3;
29+
const byte altSel = A0; //alt select button - if unequipped, set to 0
30+
31+
// What type of adj controls are equipped?
32+
// 1 = momentary buttons. 2 = quadrature rotary encoder.
33+
const byte mainAdjType = 1;
34+
35+
// In normal running mode, what do the controls do?
36+
// -1 = nothing/switch, -2 = cycle through functions, fn in fnsEnabled[] = go to that function
37+
// If using soft alarm/power switch per below, the control(s) set to -1 will do the switching.
38+
const char mainSelFn = -2;
39+
const char mainAdjFn = -1;
40+
const byte altSelFn = fnIsAlarm; //go straight to alarm
41+
42+
//What are the signal pin(s) connected to?
43+
const char piezoPin = 10;
44+
const char relayPin = -1;
45+
// -1 to disable feature (no relay item equipped); A3 if equipped (UNDB v8)
46+
const byte relayMode = 0; //If relay is equipped, what does it do?
47+
// 0 = switched mode: the relay will be switched to control an appliance like a radio or light fixture. If used with timer, it will switch on while timer is running (like a "sleep" function). If used with alarm, it will switch on when alarm trips; specify duration of this in switchDur.
48+
// 1 = pulsed mode: the relay will be pulsed, like the beeper is, to control an intermittent signaling device like a solenoid or indicator lamp. Specify pulse duration in relayPulse.
49+
const word signalDur = 180; //sec - when pulsed signal is going, pulses are sent once/sec for this period (e.g. 180 = 3min)
50+
const word switchDur = 7200; //sec - when alarm triggers switched relay, it's switched on for this period (e.g. 7200 = 2hr)
51+
const word piezoPulse = 500; //ms - used with piezo via tone()
52+
const word relayPulse = 200; //ms - used with pulsed relay
53+
54+
//Soft power switches
55+
const byte enableSoftAlarmSwitch = 1;
56+
// 1 = yes. Alarm can be switched on and off when clock is displaying the alarm time (fnIsAlarm).
57+
// 0 = no. Alarm will be permanently on. Use with switched relay if the appliance has its own switch on this relay circuit.
58+
const byte enableSoftPowerSwitch = 1; //works with switched relay only
59+
// 1 = yes. Relay can be switched on and off directly when clock is displaying time of day (fnIsTime). This is useful if connecting an appliance (e.g. radio) that doesn't have its own switch, or if replacing the clock unit in a clock radio where the clock does all the switching (e.g. Telechron).
60+
// 0 = no. Use if the connected appliance has its own power switch (independent of this relay circuit) or does not need to be manually switched.
61+
62+
//LED circuit control
63+
const char ledPin = -1;
64+
// -1 to disable feature; A2 if equipped (UNDB v8)
65+
66+
//When display is dim/off, a press will light the tubes for how long?
67+
const byte unoffDur = 10; //sec
68+
69+
// How long (in ms) are the button hold durations?
70+
const word btnShortHold = 1000; //for setting the displayed feataure
71+
const word btnLongHold = 3000; //for for entering options menu
72+
const byte velThreshold = 150; //ms
73+
// When an adj up/down input (btn or rot) follows another in less than this time, value will change more (10 vs 1).
74+
// Recommend ~150 for rotaries. If you want to use this feature with buttons, extend to ~400.
75+
76+
// What is the "frame rate" of the tube cleaning and display scrolling? up to 65535 ms
77+
const word cleanSpeed = 200; //ms
78+
const word scrollSpeed = 100; //ms - e.g. scroll-in-and-out date at :30 - to give the illusion of a slow scroll that doesn't pause, use (timeoutTempFn*1000)/(displaySize+1) - e.g. 714 for displaySize=6 and timeoutTempFn=5
79+
80+
// What are the timeouts for setting and temporarily-displayed functions? up to 65535 sec
81+
const unsigned long timeoutSet = 120; //sec
82+
const unsigned long timeoutTempFn = 5; //sec

sixtube_lm/sixtube_lm.ino

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,13 @@
99
//Include the config file that matches your hardware setup. If needed, duplicate an existing one.
1010

1111
//#include "configs/v5-6tube.h" //UNDB v5, 6 tubes
12+
//#include "configs/v5-6tube-red.h" //UNDB v5, 6 tubes, red case (weird buttons)
1213
//#include "configs/v5-6tube-rotary.h" //UNDB v5, 6 tubes, rotary encoder instead of buttons
1314
//#include "configs/v5-4tube.h" //UNDB v5, 4 tubes
14-
#include "configs/v8-6tube.h" //UNDB v8 before modification, no LED or relay support
15-
//#include "configs/v8a-6tube-relayswitch.h" //UNDB v8 after modification A (Select=A1, Adj=A6/A7, Alt=A0, LED=A2, Relay=A3)
16-
//#include "configs/v8b-6tube-relayswitch.h" //UNDB v8 after modification A (Select=A6, Adj=A0/A1, Alt=A7, LED=A2, Relay=A3)
15+
//#include "configs/v8-6tube.h" //UNDB v8 before modification, no LED or relay support
16+
//#include "configs/v8-4tube.h" //UNDB v8 before modification, no LED or relay support
17+
#include "configs/v8a-6tube-relayswitch.h" //UNDB v8 after modification A (Select=A1, Adj=A6/A7, Alt=A0, LED=A2, Relay=A3)
18+
//#include "configs/v8b-6tube-relayswitch.h" //UNDB v8 after modification B (Select=A6, Adj=A0/A1, Alt=A7, LED=A2, Relay=A3)
1719

1820

1921
////////// Other includes, global consts, and vars //////////
@@ -928,6 +930,8 @@ void updateDisplay(){
928930
} else blankDisplay(mspos,mspos+1,true);
929931
//display second (in relative position). Leading zero if t>=1m.
930932
editDisplay(timerRemain%60,mspos+2,mspos+3,(timerRemain>=60?true:false),true);
933+
//just in case 4-digit code is run on a 6-digit clock
934+
if(displaySize<6) blankDisplay(4,5,false);
931935
break;
932936
case fnIsTemp: //thermometer
933937
int temp; temp = ds3231.getTemperature()*100;

v8mod_test/v8mod_test.ino

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
//For testing mods to the v8.0 board
2+
3+
const byte btnSel = A1;
4+
const byte btnAlt = A0;
5+
const byte btnUp = A6;
6+
const byte btnDn = A7;
7+
const byte pinLED = A2;
8+
const byte pinRelay = A3;
9+
10+
byte btnCur = 0; //Momentary button currently in use - only one allowed at a time
11+
12+
void setup(){
13+
Serial.begin(9600);
14+
//0 and 1: set as digital input
15+
pinMode(A0, INPUT_PULLUP);
16+
pinMode(A1, INPUT_PULLUP);
17+
//2 and 3: set as digital output
18+
pinMode(A2, OUTPUT);
19+
pinMode(A3, OUTPUT);
20+
//4 and 5: for I2C
21+
//6 and 7: input, but analog pins with hardware pullup resistors, so nothing to do
22+
digitalWrite(pinLED,0); //0 = LEDs off
23+
digitalWrite(pinRelay,1); //1 = connected device off
24+
Serial.println(F("Ready for input"));
25+
}
26+
27+
void loop(){
28+
checkInputs();
29+
delay(10); //in case of switch bounce?
30+
}
31+
32+
void checkInputs(){
33+
checkBtn(btnSel);
34+
checkBtn(btnAlt);
35+
checkBtn(btnUp);
36+
checkBtn(btnDn);
37+
}
38+
bool readInput(byte pin){
39+
if(pin==A6 || pin==A7) return analogRead(pin)<100?0:1; //analog-only pins
40+
else return digitalRead(pin);
41+
}
42+
void checkBtn(byte btn){
43+
//Changes in momentary buttons, LOW = pressed.
44+
//When a button event has occurred, will call ctrlEvt
45+
bool bnow = readInput(btn);
46+
//If the button has just been pressed, and no other buttons are in use...
47+
if(btnCur==0 && bnow==LOW) {
48+
btnCur = btn;
49+
Serial.println();
50+
switch(btn) {
51+
case btnSel: Serial.print(F("btnSel")); break;
52+
case btnAlt: Serial.print(F("btnAlt")); break;
53+
case btnUp: Serial.print(F("btnUp")); break;
54+
case btnDn: Serial.print(F("btnDn")); break;
55+
default: break;
56+
} //end button printing switch
57+
Serial.println(F(" pressed"));
58+
if(btn==btnUp || btn==btnDn) {
59+
byte curOutput = (btn==btnUp? pinLED: pinRelay);
60+
bool newState = !digitalRead(curOutput);
61+
digitalWrite(curOutput, newState);
62+
Serial.println();
63+
switch(curOutput) {
64+
case pinLED:
65+
if(newState) Serial.println(F("pinLED switched on. LED pins should measure a voltage now."));
66+
else Serial.println(F("pinLED switched off. LED pins should measure NO voltage now."));
67+
break;
68+
case pinRelay:
69+
if(newState) Serial.println(F("pinRelay switched on. Relay pins should measure open circuit now (connected device off)."));
70+
else Serial.println(F("pinRelay switched off. Relay pins should measure closed circuit now (connected device on)."));
71+
break;
72+
default: break;
73+
} //end output printing switch
74+
} //end if btn up/down
75+
} //end if button presed
76+
//If the button has just been released...
77+
if(btnCur==btn && bnow==HIGH) {
78+
btnCur = 0;
79+
}
80+
}

0 commit comments

Comments
 (0)