57 lines
1.7 KiB
C++
57 lines
1.7 KiB
C++
|
#include <main.hpp>
|
||
|
|
||
|
ESPMegaPRO espmega = ESPMegaPRO();
|
||
|
|
||
|
void setup()
|
||
|
{
|
||
|
// Initialize both displayports
|
||
|
INTERNAL_DISPLAY_UART.begin(INTERNAL_DISPLAY_BAUDRATE);
|
||
|
ESP_LOGI("OS", "Starting Initialization");
|
||
|
INTERNAL_DISPLAY_UART.write(0xFF);
|
||
|
INTERNAL_DISPLAY_UART.write(0xFF);
|
||
|
INTERNAL_DISPLAY_UART.write(0xFF);
|
||
|
INTERNAL_DISPLAY_UART.print("rest");
|
||
|
INTERNAL_DISPLAY_UART.write(0xFF);
|
||
|
INTERNAL_DISPLAY_UART.write(0xFF);
|
||
|
INTERNAL_DISPLAY_UART.write(0xFF);
|
||
|
// Wait for the display to reset
|
||
|
vTaskDelay(1000 / portTICK_PERIOD_MS);
|
||
|
// Initialize the ESPMegaPRO
|
||
|
ESP_LOGV("OS", "Initializing ESPMegaPRO");
|
||
|
espmega.begin();
|
||
|
espmega.inputs.preloadInputBuffer();
|
||
|
// Initialize IoT Modules
|
||
|
ESP_LOGV("OS", "Initializing IoT Modules");
|
||
|
espmega.setTimezone("ICT-7");
|
||
|
espmega.enableIotModule();
|
||
|
// Setup Ethernet
|
||
|
ESP_LOGV("OS", "Initializing Ethernet");
|
||
|
ETH.begin();
|
||
|
ESP_LOGD("OS", "Binding Ethernet Interface");
|
||
|
espmega.iot->bindEthernetInterface(Ð);
|
||
|
// Connect to Network
|
||
|
ESP_LOGV("OS", "Connecting to Network");
|
||
|
espmega.iot->loadNetworkConfig();
|
||
|
espmega.iot->connectNetwork();
|
||
|
// Connect to the MQTT Broker
|
||
|
ESP_LOGV("OS", "Connecting to MQTT Broker");
|
||
|
espmega.iot->loadMqttConfig();
|
||
|
vTaskDelay(3000 / portTICK_PERIOD_MS); // Wait for the network to stabilize
|
||
|
espmega.iot->connectToMqtt();
|
||
|
// Enable Web Server
|
||
|
ESP_LOGV("OS", "Enabling Web Server");
|
||
|
espmega.enableWebServer(80);
|
||
|
|
||
|
ESP_LOGV("OS", "Initializing Internal Display");
|
||
|
espmega.enableInternalDisplay(&INTERNAL_DISPLAY_UART);
|
||
|
// Register all cards with iot
|
||
|
ESP_LOGV("OS", "Registering Cards with IoT");
|
||
|
espmega.iot->registerCard(0);
|
||
|
espmega.iot->registerCard(1);
|
||
|
}
|
||
|
|
||
|
void loop()
|
||
|
{
|
||
|
espmega.loop();
|
||
|
}
|