add am pm light switch
This commit is contained in:
parent
939619fb12
commit
2680ce405a
1 changed files with 1359 additions and 1345 deletions
|
@ -21,24 +21,24 @@
|
||||||
|
|
||||||
// nodeMCU - uncomment to compile this sketch for nodeMCU 1.0 / ESP8266, make sure to select the proper board
|
// nodeMCU - uncomment to compile this sketch for nodeMCU 1.0 / ESP8266, make sure to select the proper board
|
||||||
// type inside the IDE! This mode is NOT supported and only experimental!
|
// type inside the IDE! This mode is NOT supported and only experimental!
|
||||||
// #define NODEMCU
|
#define NODEMCU
|
||||||
|
|
||||||
// useWiFi - enable WiFi support, WPS setup only! If no WPS support is available on a router check settings
|
// useWiFi - enable WiFi support, WPS setup only! If no WPS support is available on a router check settings
|
||||||
// further down, set useWPS to false and enter ssid/password there
|
// further down, set useWPS to false and enter ssid/password there
|
||||||
// #define USEWIFI
|
#define USEWIFI
|
||||||
|
|
||||||
// useNTP - enable NTPClient, requires NODEMCU and USEWIFI. This will also enforce AUTODST.
|
// useNTP - enable NTPClient, requires NODEMCU and USEWIFI. This will also enforce AUTODST.
|
||||||
// Configure a ntp server further down below!
|
// Configure a ntp server further down below!
|
||||||
// #define USENTP
|
#define USENTP
|
||||||
|
|
||||||
// RTC selection - uncomment the one you're using, comment all others and make sure pin assignemts for
|
// RTC selection - uncomment the one you're using, comment all others and make sure pin assignemts for
|
||||||
// DS1302 are correct in the parameters section further down!
|
// DS1302 are correct in the parameters section further down!
|
||||||
// #define RTC_DS1302
|
// #define RTC_DS1302
|
||||||
// #define RTC_DS1307
|
// #define RTC_DS1307
|
||||||
#define RTC_DS3231
|
//#define RTC_DS3231
|
||||||
|
|
||||||
// autoDST - uncomment to enable automatic DST switching, check Time Change Rules below!
|
// autoDST - uncomment to enable automatic DST switching, check Time Change Rules below!
|
||||||
// #define AUTODST
|
#define AUTODST
|
||||||
|
|
||||||
// FADING - uncomment to enable fading effects for dots/digits, other parameters further down below
|
// FADING - uncomment to enable fading effects for dots/digits, other parameters further down below
|
||||||
// #define FADING
|
// #define FADING
|
||||||
|
@ -101,7 +101,7 @@
|
||||||
|
|
||||||
/* Start WiFi config/parameters------------------------------------------------------------------------- */
|
/* Start WiFi config/parameters------------------------------------------------------------------------- */
|
||||||
#ifdef USEWIFI
|
#ifdef USEWIFI
|
||||||
const bool useWPS = true; // set to false to disable WPS and use credentials below
|
const bool useWPS = false; // set to false to disable WPS and use credentials below
|
||||||
const char* wifiSSID = "maWhyFhy";
|
const char* wifiSSID = "maWhyFhy";
|
||||||
const char* wifiPWD = "5up3r1337r0xX0r!";
|
const char* wifiPWD = "5up3r1337r0xX0r!";
|
||||||
#endif
|
#endif
|
||||||
|
@ -113,8 +113,7 @@
|
||||||
#ifdef USENTP
|
#ifdef USENTP
|
||||||
/* I recommend using a local ntp service (many routers offer them), don't spam public ones with dozens
|
/* I recommend using a local ntp service (many routers offer them), don't spam public ones with dozens
|
||||||
of requests a day, get a rtc! ^^ */
|
of requests a day, get a rtc! ^^ */
|
||||||
//#define NTPHOST "europe.pool.ntp.org"
|
#define NTPHOST "pool.ntp.org"
|
||||||
#define NTPHOST "192.168.2.1"
|
|
||||||
#ifndef AUTODST
|
#ifndef AUTODST
|
||||||
#define AUTODST
|
#define AUTODST
|
||||||
#endif
|
#endif
|
||||||
|
@ -132,12 +131,12 @@
|
||||||
TimeChangeRule *tcr;
|
TimeChangeRule *tcr;
|
||||||
//-----------------------------------------------
|
//-----------------------------------------------
|
||||||
/* US */
|
/* US */
|
||||||
// TimeChangeRule tcr1 = {"tcr1", First, Sun, Nov, 2, -360}; // utc -6h, valid from first sunday of november at 2am
|
TimeChangeRule tcr1 = {"tcr1", First, Sun, Nov, 2, -300}; // utc -5h, valid from first sunday of november at 2am
|
||||||
// TimeChangeRule tcr2 = {"tcr2", Second, Sun, Mar, 2, -300}; // utc -5h, valid from second sunday of march at 2am
|
TimeChangeRule tcr2 = {"tcr2", Second, Sun, Mar, 2, -240}; // utc -4h, valid from second sunday of march at 2am
|
||||||
//-----------------------------------------------
|
//-----------------------------------------------
|
||||||
/* Europe */
|
/* Europe */
|
||||||
TimeChangeRule tcr1 = {"tcr1", Last, Sun, Oct, 3, 60}; // standard/winter time, valid from last sunday of october at 3am, UTC + 1 hour (+60 minutes) (negative value like -300 for utc -5h)
|
// TimeChangeRule tcr1 = {"tcr1", Last, Sun, Oct, 3, 60}; // standard/winter time, valid from last sunday of october at 3am, UTC + 1 hour (+60 minutes) (negative value like -300 for utc -5h)
|
||||||
TimeChangeRule tcr2 = {"tcr2", Last, Sun, Mar, 2, 120}; // daylight/summer time, valid from last sunday of march at 2am, UTC + 2 hours (+120 minutes)
|
// TimeChangeRule tcr2 = {"tcr2", Last, Sun, Mar, 2, 120}; // daylight/summer time, valid from last sunday of march at 2am, UTC + 2 hours (+120 minutes)
|
||||||
//-----------------------------------------------
|
//-----------------------------------------------
|
||||||
Timezone myTimeZone(tcr1, tcr2);
|
Timezone myTimeZone(tcr1, tcr2);
|
||||||
#endif
|
#endif
|
||||||
|
@ -179,9 +178,9 @@ uint16_t lastAvgLDR = 0; // last average LDR value we g
|
||||||
|
|
||||||
|
|
||||||
/* Start basic appearance config------------------------------------------------------------------------ */
|
/* Start basic appearance config------------------------------------------------------------------------ */
|
||||||
const bool dotsBlinking = true; // true = only light up dots on even seconds, false = always on
|
const bool dotsBlinking = false; // true = only light up dots on even seconds, false = always on
|
||||||
const bool leadingZero = false; // true = enable a leading zero, 9:00 -> 09:00, 1:30 -> 01:30...
|
const bool leadingZero = false; // true = enable a leading zero, 9:00 -> 09:00, 1:30 -> 01:30...
|
||||||
uint8_t displayMode = 0; // 0 = 24h mode, 1 = 12h mode ("1" will also override setting that might be written to EEPROM!)
|
uint8_t displayMode = 1; // 0 = 24h mode, 1 = 12h mode ("1" will also override setting that might be written to EEPROM!)
|
||||||
uint8_t colorMode = 0; // different color modes, setting this to anything else than zero will overwrite values written to eeprom, as above
|
uint8_t colorMode = 0; // different color modes, setting this to anything else than zero will overwrite values written to eeprom, as above
|
||||||
uint16_t colorSpeed = 750; // controls how fast colors change, smaller = faster (interval in ms at which color moves inside colorizeOutput();)
|
uint16_t colorSpeed = 750; // controls how fast colors change, smaller = faster (interval in ms at which color moves inside colorizeOutput();)
|
||||||
const bool colorPreview = true; // true = preview selected palette/colorMode using "8" on all positions for 3 seconds
|
const bool colorPreview = true; // true = preview selected palette/colorMode using "8" on all positions for 3 seconds
|
||||||
|
@ -255,7 +254,7 @@ uint8_t brightness = brightnessLevels[0]; // default brig
|
||||||
|
|
||||||
#define LED_PWR_LIMIT 500 // 500mA - Power limit in mA (voltage is set in setup() to 5v)
|
#define LED_PWR_LIMIT 500 // 500mA - Power limit in mA (voltage is set in setup() to 5v)
|
||||||
#define LED_DIGITS 4 // 4 or 6 digits, HH:MM or HH:MM:SS
|
#define LED_DIGITS 4 // 4 or 6 digits, HH:MM or HH:MM:SS
|
||||||
#define LED_COUNT 103 // Total number of leds, 103 on Retro 7 Segment Clock v3 - The Final One(s) - 3 LEDs/segment
|
#define LED_COUNT 64 // Total number of leds, 103 on Retro 7 Segment Clock v3 - The Final One(s) - 3 LEDs/segment
|
||||||
#if ( LED_DIGITS == 6 )
|
#if ( LED_DIGITS == 6 )
|
||||||
#define LED_COUNT 157 // leds on the 6 digit version
|
#define LED_COUNT 157 // leds on the 6 digit version
|
||||||
#endif
|
#endif
|
||||||
|
@ -320,7 +319,7 @@ digitsLAM -> LED_ACCESS_MODE per digit
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// defining access modes for each digit individually
|
// defining access modes for each digit individually
|
||||||
uint8_t digitsLAM[6] = { 1, 1, 1, 1, 1, 1 };
|
uint8_t digitsLAM[6] = { 0, 0, 0, 0, 0, 0 };
|
||||||
|
|
||||||
#if ( LED_DIGITS == 4 )
|
#if ( LED_DIGITS == 4 )
|
||||||
const uint8_t digitPositions[4] = { 0, 1, 2, 3 }; // positions of HH:MM (3, 0, 2, 1 on L7-QBE)
|
const uint8_t digitPositions[4] = { 0, 1, 2, 3 }; // positions of HH:MM (3, 0, 2, 1 on L7-QBE)
|
||||||
|
@ -334,37 +333,37 @@ uint8_t digitsLAM[6] = { 1, 1, 1, 1, 1, 1 };
|
||||||
|
|
||||||
/* segments 0-27, 4 digits x 7 segments */
|
/* segments 0-27, 4 digits x 7 segments */
|
||||||
/* digit position 0 */
|
/* digit position 0 */
|
||||||
{ 6, 8 }, // top, a
|
{48, 40}, // top, a
|
||||||
{ 3, 5 }, // top right, b
|
{32, 33}, // top right, b
|
||||||
{ 20, 22 }, // bottom right, c
|
{34, 35}, // bottom right, c
|
||||||
{ 17, 19 }, // bottom, d
|
{43, 51}, // bottom, d
|
||||||
{ 14, 16 }, // bottom left, e
|
{59, 58}, // bottom left, e
|
||||||
{ 9, 11 }, // top left, f
|
{57, 56}, // top left, f
|
||||||
{ 0, 2 }, // center, g
|
{49, 41}, // center, g
|
||||||
/* digit position 1 */
|
/* digit position 1 */
|
||||||
{ 40, 42 }, // top, a
|
{16, 8}, // top, a
|
||||||
{ 37, 39 }, // top right, b
|
{0, 1}, // top right, b
|
||||||
{ 32, 34 }, // bottom right, c
|
{2, 3}, // bottom right, c
|
||||||
{ 29, 31 }, // bottom, d
|
{11, 19}, // bottom, d
|
||||||
{ 26, 28 }, // bottom left, e
|
{27, 26}, // bottom left, e
|
||||||
{ 43, 45 }, // top left, f
|
{25, 24}, // top left, f
|
||||||
{ 46, 48 }, // center, g
|
{17, 9}, // center, g
|
||||||
/* digit position 2 */
|
/* digit position 2 */
|
||||||
{ 60, 62 }, // top, a
|
{52, 44}, // top, a
|
||||||
{ 57, 59 }, // top right, b
|
{36, 37}, // top right, b
|
||||||
{ 74, 76 }, // bottom right, c
|
{38, 39}, // bottom right, c
|
||||||
{ 71, 73 }, // bottom, d
|
{47, 55}, // bottom, d
|
||||||
{ 68, 70 }, // bottom left, e
|
{63, 62}, // bottom left, e
|
||||||
{ 63, 65 }, // top left, f
|
{61, 60}, // top left, f
|
||||||
{ 54, 56 }, // center, g
|
{53, 45}, // center, g
|
||||||
/* digit position 3 */
|
/* digit position 3 */
|
||||||
{ 94, 96 }, // top, a
|
{20, 12}, // top, a
|
||||||
{ 91, 93 }, // top right, b
|
{4, 5}, // top right, b
|
||||||
{ 86, 88 }, // bottom right, c
|
{6, 7}, // bottom right, c
|
||||||
{ 83, 85 }, // bottom, d
|
{23, 15}, // bottom, d
|
||||||
{ 80, 82 }, // bottom left, e
|
{31, 30}, // bottom left, e
|
||||||
{ 97, 99 }, // top left, f
|
{28, 29}, // top left, f
|
||||||
{ 100, 102 } // center, g
|
{21, 13}, // center, g
|
||||||
#if ( LED_DIGITS == 6 ) // add two digits, 14 segments, only used if LED_DIGITS is 6...
|
#if ( LED_DIGITS == 6 ) // add two digits, 14 segments, only used if LED_DIGITS is 6...
|
||||||
/* segments 28-41, 6 digits x 7 segments */
|
/* segments 28-41, 6 digits x 7 segments */
|
||||||
/* (bogus on some models which don't support 6 digits) */
|
/* (bogus on some models which don't support 6 digits) */
|
||||||
|
@ -388,8 +387,8 @@ uint8_t digitsLAM[6] = { 1, 1, 1, 1, 1, 1 };
|
||||||
};
|
};
|
||||||
|
|
||||||
#if ( LED_DIGITS == 4 )
|
#if ( LED_DIGITS == 4 )
|
||||||
const uint16_t upperDots[2] PROGMEM = { 49, 50 }; // leds inside the upper dots (right on L7-QBE)
|
const uint16_t upperDots[2] PROGMEM = { 50}; // leds inside the upper dots (right on L7-QBE)
|
||||||
const uint16_t lowerDots[2] PROGMEM = { 52, 53 }; // leds inside the lower dots (left on L7-QBE)
|
const uint16_t lowerDots[2] PROGMEM = { 42}; // leds inside the lower dots (left on L7-QBE)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if ( LED_DIGITS == 6 )
|
#if ( LED_DIGITS == 6 )
|
||||||
|
@ -397,6 +396,9 @@ uint8_t digitsLAM[6] = { 1, 1, 1, 1, 1, 1 };
|
||||||
const uint16_t lowerDots[4] PROGMEM = { 52, 53, 106, 107 }; // all the leds inside the lower dots (bogus values on some models which don't support 6 digits)
|
const uint16_t lowerDots[4] PROGMEM = { 52, 53, 106, 107 }; // all the leds inside the lower dots (bogus values on some models which don't support 6 digits)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
const uint16_t amLight[1] PROGMEM = { 54};
|
||||||
|
const uint16_t pmLight[1] PROGMEM = { 14};
|
||||||
|
|
||||||
// Using above arrays it's very easy to "talk" to the segments. Simply use 0-6 for the first 7 segments, add 7 (7-13) for the second one, 14-20 for third....
|
// Using above arrays it's very easy to "talk" to the segments. Simply use 0-6 for the first 7 segments, add 7 (7-13) for the second one, 14-20 for third....
|
||||||
const uint8_t digits[21][7] PROGMEM = {
|
const uint8_t digits[21][7] PROGMEM = {
|
||||||
/* Lets define 10 numbers (0-9) with 7 segments each, also adding some letters
|
/* Lets define 10 numbers (0-9) with 7 segments each, also adding some letters
|
||||||
|
@ -1522,6 +1524,7 @@ void displayTime(time_t t) {
|
||||||
} else {
|
} else {
|
||||||
showDots(2);
|
showDots(2);
|
||||||
}
|
}
|
||||||
|
showAmPm(isAM(t));
|
||||||
if ( millis() - lastRefresh >= 25 ) {
|
if ( millis() - lastRefresh >= 25 ) {
|
||||||
colorizeOutput(colorMode);
|
colorizeOutput(colorMode);
|
||||||
FastLED.show();
|
FastLED.show();
|
||||||
|
@ -1599,16 +1602,27 @@ void showSegment(uint8_t segment, uint8_t segDisplay) {
|
||||||
|
|
||||||
|
|
||||||
void showDots(uint8_t dots) {
|
void showDots(uint8_t dots) {
|
||||||
// dots 0 = upper dots, dots 1 = lower dots, dots 2 = all dots (right/left/both on Lazy 7 - Quick Build Edition)
|
// // dots 0 = upper dots, dots 1 = lower dots, dots 2 = all dots (right/left/both on Lazy 7 - Quick Build Edition)
|
||||||
if ( dots == 1 || dots == 2 ) {
|
// if ( dots == 1 || dots == 2 ) {
|
||||||
for ( uint8_t i = 0; i < ( sizeof(upperDots) / sizeof(upperDots[0]) ); i++ ) {
|
// for ( uint8_t i = 0; i < ( sizeof(upperDots) / sizeof(upperDots[0]) ); i++ ) {
|
||||||
leds[pgm_read_word_near(&upperDots[i])].setHSV(markerHSV[0], markerHSV[1], markerHSV[2]);
|
// leds[pgm_read_word_near(&upperDots[i])].setHSV(markerHSV[0], markerHSV[1], markerHSV[2]);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// if ( dots == 0 || dots == 2 ) {
|
||||||
|
// for ( uint8_t i = 0; i < ( sizeof(lowerDots) / sizeof(lowerDots[0]) ); i++ ) {
|
||||||
|
// leds[pgm_read_word_near(&lowerDots[i])].setHSV(markerHSV[0], markerHSV[1], markerHSV[2]);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void showAmPm(bool amFlag){
|
||||||
|
if (amFlag == false)
|
||||||
|
{
|
||||||
|
leds[pgm_read_word_near(&pmLight[0])].setHSV(160, 255, brightness);
|
||||||
}
|
}
|
||||||
if ( dots == 0 || dots == 2 ) {
|
else
|
||||||
for ( uint8_t i = 0; i < ( sizeof(lowerDots) / sizeof(lowerDots[0]) ); i++ ) {
|
{
|
||||||
leds[pgm_read_word_near(&lowerDots[i])].setHSV(markerHSV[0], markerHSV[1], markerHSV[2]);
|
leds[pgm_read_word_near(&amLight[0])].setHSV(64, 255, brightness);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2283,11 +2297,11 @@ uint8_t inputButtons() {
|
||||||
Serial.println(F("Press button A (or send 7 using serial input) to advance to the next step...\n"));
|
Serial.println(F("Press button A (or send 7 using serial input) to advance to the next step...\n"));
|
||||||
#endif
|
#endif
|
||||||
while ( test == 5 ) {
|
while ( test == 5 ) {
|
||||||
if ( second() % 2 == 1 ) {
|
// if ( second() % 2 == 1 ) {
|
||||||
showDots(0);
|
// showDots(0);
|
||||||
} else {
|
// } else {
|
||||||
showDots(1);
|
// showDots(1);
|
||||||
}
|
// }
|
||||||
if ( inputButtons() != 0 ) test++;
|
if ( inputButtons() != 0 ) test++;
|
||||||
FastLED.show();
|
FastLED.show();
|
||||||
delay(20);
|
delay(20);
|
||||||
|
|
Loading…
Reference in a new issue