DIY fertilizer mixer and plant watering machine https://www.xythobuz.de/giessomat.html
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

main.cpp 1.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. #include <Arduino.h>
  2. #include "Functionality.h"
  3. #include "WifiStuff.h"
  4. #include "config.h"
  5. #include "config_pins.h"
  6. unsigned long last_led_blink_time = 0;
  7. void setup() {
  8. pinMode(BUILTIN_LED_PIN, OUTPUT);
  9. digitalWrite(BUILTIN_LED_PIN, HIGH);
  10. Serial.begin(115200);
  11. Serial.println("Initializing Giess-o-mat");
  12. Serial.println("Version: " FIRMWARE_VERSION);
  13. #ifdef FUNCTION_UI
  14. Serial.println("Initializing UI");
  15. ui_setup();
  16. #endif // FUNCTION_UI
  17. #ifdef FUNCTION_CONTROL
  18. Serial.println("Initializing Control");
  19. control_setup();
  20. #endif // FUNCTION_CONTROL
  21. #ifdef PLATFORM_ESP
  22. Serial.println("Initializing WiFi");
  23. wifi_setup();
  24. #endif // PLATFORM_ESP
  25. Serial.println("Ready, starting main loop");
  26. digitalWrite(BUILTIN_LED_PIN, LOW);
  27. #ifdef FUNCTION_CONTROL
  28. #ifndef FUNCTION_UI
  29. // give ui unit some time to initialize
  30. Serial.println("Waiting for UI to boot");
  31. delay(3000);
  32. #endif // ! FUNCTION_UI
  33. Serial.println("Starting state machine");
  34. control_begin();
  35. #endif // FUNCTION_CONTROL
  36. }
  37. void loop() {
  38. #ifdef PLATFORM_ESP
  39. wifi_run();
  40. #endif // PLATFORM_ESP
  41. #ifdef FUNCTION_UI
  42. ui_run();
  43. #endif // FUNCTION_UI
  44. #ifdef FUNCTION_CONTROL
  45. control_run();
  46. #endif // FUNCTION_CONTROL
  47. // blink heartbeat LED
  48. if ((millis() - last_led_blink_time) >= LED_BLINK_INTERVAL) {
  49. last_led_blink_time = millis();
  50. digitalWrite(BUILTIN_LED_PIN, !digitalRead(BUILTIN_LED_PIN));
  51. }
  52. }