2023-06-10 21:23:31 +02:00
|
|
|
#include <Arduino.h>
|
|
|
|
#include <config.h>
|
|
|
|
#include <shared.hpp>
|
|
|
|
#include <WiFi.h>
|
|
|
|
#include <WiFiClientSecure.h>
|
2023-06-25 15:06:29 +02:00
|
|
|
// #include <ESP32Time.h>
|
2023-06-10 21:23:31 +02:00
|
|
|
#include <WiFiManager.h>
|
|
|
|
|
|
|
|
#ifdef CONFIG_BT_ENABLED
|
|
|
|
#include "esp_bt.h"
|
|
|
|
#include "esp_bt_main.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "lib/functions.hpp"
|
|
|
|
#include "lib/webserver.hpp"
|
|
|
|
|
|
|
|
#include "screens/time.hpp"
|
|
|
|
#include "screens/blockheight.hpp"
|
|
|
|
#include "screens/ticker.hpp"
|
|
|
|
#include "screens/time.hpp"
|
|
|
|
#include "screens/sats_per_dollar.hpp"
|
|
|
|
#include "screens/halvingcountdown.hpp"
|
|
|
|
|
|
|
|
#include "tasks/ha.hpp"
|
|
|
|
#include "tasks/epd.hpp"
|
|
|
|
#include "tasks/button.hpp"
|
|
|
|
#include "tasks/led_handler.hpp"
|
|
|
|
|
|
|
|
WiFiClient wifiClientInsecure;
|
|
|
|
WiFiClientSecure wifiClient;
|
|
|
|
ESP32Time rtc(3600);
|
|
|
|
|
|
|
|
void setup()
|
|
|
|
{
|
|
|
|
Serial.begin(115200);
|
|
|
|
|
|
|
|
#ifdef ARDUINO_ESP32S3_DEV
|
|
|
|
pinMode(LED_BUILTIN, OUTPUT);
|
|
|
|
digitalWrite(LED_BUILTIN, LOW);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef CONFIG_BT_ENABLED
|
|
|
|
esp_bluedroid_disable();
|
|
|
|
esp_bluedroid_deinit();
|
|
|
|
esp_bt_controller_disable();
|
|
|
|
esp_bt_controller_deinit();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
setupComponents();
|
|
|
|
setupPreferences();
|
|
|
|
#ifndef NO_DISPLAY
|
|
|
|
resetAllDisplays();
|
|
|
|
initDisplays();
|
|
|
|
#endif
|
|
|
|
setupWifi();
|
|
|
|
|
2023-06-25 15:06:29 +02:00
|
|
|
bool slaveMode = preferences.getBool("I2CSlaveMode", false);
|
2023-06-10 21:23:31 +02:00
|
|
|
|
2023-06-25 15:06:29 +02:00
|
|
|
if (!slaveMode)
|
|
|
|
{
|
|
|
|
synchronizeTime();
|
|
|
|
setupWebserver();
|
|
|
|
|
|
|
|
TimeScreen::init();
|
|
|
|
BlockHeightScreen::init();
|
|
|
|
TickerScreen::init();
|
|
|
|
SatsPerDollarScreen::init();
|
2023-06-10 21:23:31 +02:00
|
|
|
|
|
|
|
#ifdef WITH_BUTTONS
|
2023-06-25 15:06:29 +02:00
|
|
|
setupButtonTask();
|
2023-06-10 21:23:31 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef WITH_RGB_LED
|
2023-06-25 15:06:29 +02:00
|
|
|
setLights(0, 0, 0);
|
|
|
|
setupLedHandlerTask();
|
2023-06-10 21:23:31 +02:00
|
|
|
#endif
|
|
|
|
|
2023-06-25 15:06:29 +02:00
|
|
|
registerNewMinuteCallback(TimeScreen::onNewMinute);
|
|
|
|
registerNewBlockCallback(BlockHeightScreen::onNewBlock);
|
|
|
|
registerNewBlockCallback(HalvingCountdownScreen::onNewBlock);
|
|
|
|
registerNewPriceCallback(TickerScreen::onPriceUpdate);
|
|
|
|
registerNewPriceCallback(SatsPerDollarScreen::onPriceUpdate);
|
2023-06-10 21:23:31 +02:00
|
|
|
|
2023-06-25 15:06:29 +02:00
|
|
|
setupDisplays();
|
|
|
|
} else {
|
|
|
|
setupI2C();
|
|
|
|
}
|
2023-06-10 21:23:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void loop()
|
|
|
|
{
|
|
|
|
// put your main code here, to run repeatedly:
|
|
|
|
}
|