11 #include "AceButton.h" 15 using namespace ace_button;
55 void setButtonConfig(ButtonConfig* buttonConfig, ButtonConfig::EventHandler eventHandler);
73 pinMode(BUILTIN_LED, OUTPUT);
75 Serial.println(
"Setup start.");
77 Serial.println(
"loadConfig:");
99 Serial.println(
"Setup done.");
107 void setButtonConfig(ButtonConfig* buttonConfig, ButtonConfig::EventHandler eventHandler) {
108 buttonConfig->setEventHandler(eventHandler);
109 buttonConfig->setFeature(ButtonConfig::kFeatureClick);
110 buttonConfig->setFeature(ButtonConfig::kFeatureDoubleClick);
111 buttonConfig->setFeature(ButtonConfig::kFeatureLongPress);
162 Serial.println(
"Entered config mode");
172 Serial.println(
"Save callback.");
197 Serial.println(
"Show Time: " + st.
toString());
200 Serial.println(
"Show Time: LED DISABLED");
209 Serial.println(
"Connect to wifi and update clock.");
231 uint8_t buttonState) {
233 case AceButton::kEventClicked:
234 Serial.println(
"Button One Clicked");
243 case AceButton::kEventLongPressed:
244 Serial.println(
"Button One Long Press");
246 Serial.println(
"Disable LED");
250 Serial.println(
"Enable LED");
265 uint8_t buttonState) {
267 case AceButton::kEventClicked:
268 Serial.println(
"Button Two Clicked");
270 case AceButton::kEventLongPressed:
271 Serial.println(
"Button Two Long Press");
283 uint8_t buttonState) {
285 case AceButton::kEventClicked:
286 Serial.println(
"Button Three Clicked");
288 case AceButton::kEventLongPressed:
289 Serial.println(
"Button Three Long Press");
301 uint8_t buttonState) {
303 case AceButton::kEventClicked:
304 Serial.println(
"Button Four Clicked");
307 case AceButton::kEventLongPressed:
308 Serial.println(
"Button Four Long Press");
Control the LEDs resp show the words and minute dots.
void showTime()
Get Time from RTC and update if it is not correct from NTP.
bool isDateTimeValid()
Either true if rtc time is not valid or the updateInterval is reached.
void setup(void(*configModeCallback)(WiFiManager *myWiFiManager), void(*saveConfig)(void))
Setup WifiManger.
SimpleTime getEnableTime()
Return EnableTime from set Parameters.
const Timezone LOCAL_TIMEZONE(TIME_CHANGE_RULE_DST, TIME_CHANGE_RULE_STD)
NeoPixelBus< NeoGrbwFeature, Neo800KbpsMethod > NeoPixelBusType
void update()
Get current time from NTP server and update RTC.
void showTime(const SimpleTime &simpleTime, const RgbwColor &ledColor=RgbwColor(0, 0, 0, 255))
Show Time with LEDs.
void handleButtonFourEvent(AceButton *, uint8_t, uint8_t)
Handle clicks of 4.
SimpleTime getDisableTime()
Return DisableTime from set Parameters.
const Config loadConfig()
Load config JSON from SPIFF and deserialize it.
bool connect()
Try to connect to presaved Wifi, otherwise go into AP mode.
const long TIME_UPDATE_INTERVAL
void setup()
Setup all Modules.
AceButton buttonOne(new ButtonConfig())
const RgbwColor LED_COLORS[]
void saveConfigCallback()
Gets called when WifiManager when custom parameters have been set AND a connection has been establish...
bool isConnected()
Check if Wifi is connected.
const String NTP_SERVER_NAME
Handling connection to Wifi and setting up Wifi credentials by creating an Access Point.
void disableLeds()
Show on all LEDs black.
ClockModule is handling the RTC and keeps it updated over NTP.
WifiModule wifiModule(DEVICE_NAME)
void updateLedColor()
Apply ambient light by dimming currentLedColor.
const int LED_COLORS_SIZE
ConfigModule configModule(CONFIG_FILE_PATH)
ClockModule clockModule(Wire, LOCAL_TIMEZONE, NTP_SERVER_NAME)
A simple representation of time with hour and minutes.
unsigned long lastShowTime
void handleButtonThreeEvent(AceButton *, uint8_t, uint8_t)
Handle clicks of 3.
SimpleTime getLocalSimpleTime()
Get current time from RTC in local time.
unsigned long lastClockUpdate
RgbwColor currentLedColor
const char *const CONFIG_FILE_PATH
void configModeCallback(WiFiManager *myWiFiManager)
Gets called when WiFiManager enters configuration mode.
void setup(NeoPixelBusType *_pixelStrip)
Setup LEDs in NeoPixel library.
void setButtonConfig(ButtonConfig *buttonConfig, ButtonConfig::EventHandler eventHandler)
Setup Event Handlers of a Button.
AceButton buttonThree(new ButtonConfig())
const int BUTTON_THREE_PIN
void reset()
Delete saved Wifi network credentials.
void showConfigWifi(const RgbwColor &ledColor=RgbwColor(0, 0, 0, 255))
Show that clock is in Wifi configuration mode, in german show Word "Funk".
void updateClock()
Connect to Wifi and update RTC over NTP.
const long CLOCK_UPDATE_INTERVAL
void handleButtonOneEvent(AceButton *, uint8_t, uint8_t)
Handle clicks of 1.
bool saveConfig(const Config &config)
Serialize Config to JSON and save to SPIFF.
Save and Load Config to/from SPIFF of the ESP.
LedControlModule ledControlModule(topo)
const int BUTTON_FOUR_PIN
NeoPixelBusType pixelStrip(PIXEL_COUNT)
AceButton buttonFour(new ButtonConfig())
NeoTopology< MyPanelLayout > topo(PANEL_WIDTH, PANEL_HEIGHT)
void handleButtonTwoEvent(AceButton *, uint8_t, uint8_t)
Handle clicks of 2.
void setupButtons()
Setup all four Buttons.
AceButton buttonTwo(new ButtonConfig())
void setup()
Setup NTP client and RTC connection.