1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- #include <Arduino.h>
-
- #include "Functionality.h"
- #include "WifiStuff.h"
- #include "config.h"
- #include "config_pins.h"
-
- unsigned long last_led_blink_time = 0;
-
- void setup() {
- pinMode(BUILTIN_LED_PIN, OUTPUT);
- digitalWrite(BUILTIN_LED_PIN, HIGH);
-
- Serial.begin(115200);
- Serial.println("Initializing Giess-o-mat");
- Serial.println("Version: " FIRMWARE_VERSION);
-
- #ifdef FUNCTION_UI
- Serial.println("Initializing UI");
- ui_setup();
- #endif // FUNCTION_UI
-
- #ifdef FUNCTION_CONTROL
- Serial.println("Initializing Control");
- control_setup();
- #endif // FUNCTION_CONTROL
-
- #ifdef PLATFORM_ESP
- Serial.println("Initializing WiFi");
- wifi_setup();
- #endif // PLATFORM_ESP
-
- Serial.println("Ready, starting main loop");
- digitalWrite(BUILTIN_LED_PIN, LOW);
-
- #ifdef FUNCTION_CONTROL
-
- #ifndef FUNCTION_UI
- // give ui unit some time to initialize
- Serial.println("Waiting for UI to boot");
- delay(3000);
- #endif // ! FUNCTION_UI
-
- Serial.println("Starting state machine");
- control_begin();
-
- #endif // FUNCTION_CONTROL
- }
-
- void loop() {
- #ifdef PLATFORM_ESP
- wifi_run();
- #endif // PLATFORM_ESP
-
- #ifdef FUNCTION_UI
- ui_run();
- #endif // FUNCTION_UI
-
- #ifdef FUNCTION_CONTROL
- control_run();
- #endif // FUNCTION_CONTROL
-
- // blink heartbeat LED
- if ((millis() - last_led_blink_time) >= LED_BLINK_INTERVAL) {
- last_led_blink_time = millis();
- digitalWrite(BUILTIN_LED_PIN, !digitalRead(BUILTIN_LED_PIN));
- }
- }
|