initial commit

This commit is contained in:
Siwat Sirichai 2024-01-10 20:16:43 +07:00
commit dbfb1f5a0f
11 changed files with 466 additions and 0 deletions

31
src/main.cpp Normal file
View file

@ -0,0 +1,31 @@
#include <main.h>
#include <cud_display.hpp>
ESPMegaPRO espmega = ESPMegaPRO();
CUDDisplay external_display = CUDDisplay();
void setup() {
espmega.begin();
espmega.enableIotModule();
ETH.begin();
espmega.iot->bindEthernetInterface(&ETH);
espmega.iot->loadNetworkConfig();
espmega.iot->connectNetwork();
espmega.iot->loadMqttConfig();
espmega.iot->connectToMqtt();
espmega.enableInternalDisplay(&Serial);
espmega.enableWebServer(80);
espmega.inputs.registerCallback(on_pin_change);
}
void loop() {
espmega.loop();
}
void on_pin_change(uint8_t pin, uint8_t value) {
// For pin 0-6, when the pin value changes, toggle the corresponding PWM pin
if (pin < 7) {
bool new_value = !espmega.outputs.getState(pin);
espmega.outputs.digitalWrite(pin, new_value);
}
}