initial headers part

This commit is contained in:
Siwat Sirichai 2024-03-17 14:50:49 +07:00
parent ce06a042cb
commit c176a6ce3e
6 changed files with 237 additions and 11 deletions

View file

@ -1,18 +1,67 @@
#include <Arduino.h>
#include <main.hpp>
/************************************************
* Global Variables *
************************************************/
ESPMegaPRO espmega = ESPMegaPRO();
const char *mode_names[] = AC_MODE_NAMES;
const char *fan_speed_names[] = AC_FAN_SPEED_NAMES;
AirConditioner ac_config = {
.max_temperature = 32,
.min_temperature = 16,
.modes = 4,
.mode_names = mode_names,
.fan_speeds = 4,
.fan_speed_names = fan_speed_names,
.getInfraredCode = &getInfraredCode};
ClimateCard ac = ClimateCard(AC_IR_TX_PIN, ac_config, AC_SENSOR_TYPE, AC_SENSOR_PIN, AC_IR_CHANNEL);
/************************************************
* End of Global Variables *
************************************************/
void setup()
{
// Initialize both displayports
INTERNAL_DISPLAY_UART.begin(INTERNAL_DISPLAY_BAUDRATE);
DISPLAY_UART.begin(DISPLAY_COMMUNICATION_BAUDRATE, SERIAL_8N1, DISPLAY_RX, DISPLAY_TX);
// Reset both display
send_stop_bytes(INTERNAL_DISPLAY_UART);
INTERNAL_DISPLAY_UART.print("rest");
send_stop_bytes(INTERNAL_DISPLAY_UART);
send_stop_bytes(DISPLAY_UART);
DISPLAY_UART.print("rest");
send_stop_bytes(DISPLAY_UART);
// Wait for the display to reset
vTaskDelay(1000 / portTICK_PERIOD_MS);
// Initialize the ESPMegaPRO
espmega.begin();
// Initialize IoT Modules
espmega.enableIotModule();
// Setup Ethernet
ETH.begin();
espmega.iot->bindEthernetInterface(&ETH);
// Connect to Network
espmega.iot->loadNetworkConfig();
espmega.iot->connectNetwork();
// Connect to the MQTT Broker
espmega.iot->loadMqttConfig();
espmega.iot->connectToMqtt();
// Initialize Internal Display
espmega.enableInternalDisplay(&INTERNAL_DISPLAY_UART);
// put function declarations here:
int myFunction(int, int);
void setup() {
// put your setup code here, to run once:
int result = myFunction(2, 3);
}
void loop() {
// put your main code here, to run repeatedly:
void loop()
{
espmega.loop();
}
// put function definitions here:
int myFunction(int x, int y) {
return x + y;
void send_stop_bytes(HardwareSerial &uart)
{
uart.write(0xFF);
uart.write(0xFF);
uart.write(0xFF);
}