2023-09-29 17:06:49 +00:00
|
|
|
#pragma once
|
|
|
|
#include <ESPMegaPRO.h>
|
2023-09-30 09:29:16 +00:00
|
|
|
#include <Nextion.h>
|
2023-09-30 02:39:36 +00:00
|
|
|
#include <PubSubClient.h>
|
|
|
|
#include <PubSubClientTools.h>
|
2023-09-29 17:37:31 +00:00
|
|
|
#include "espmega_iot_timer.hpp"
|
2023-09-30 09:29:16 +00:00
|
|
|
#include "espmega_iot_external_lcd.hpp"
|
2023-09-29 17:06:49 +00:00
|
|
|
|
2023-11-16 16:30:46 +00:00
|
|
|
// Bus Overclocking Configuration
|
|
|
|
// Do not enable if you are using external I/O cards as it will cause signal integrity issues.
|
|
|
|
// Choose only one mode
|
|
|
|
//#define OVERCLOCK_FM
|
|
|
|
//#define OVERCLOCK_FM2
|
|
|
|
|
2023-12-02 14:06:46 +00:00
|
|
|
// I/O Configuration
|
|
|
|
#define VIRTUAL_INTERRUPT_PRELOAD // Preload Virtual Interrupts buffer
|
|
|
|
|
2023-11-07 13:43:20 +00:00
|
|
|
// Enable Software Module(s)
|
2023-11-30 12:48:52 +00:00
|
|
|
#define ENABLE_INTERNAL_LCD
|
2023-11-07 13:43:20 +00:00
|
|
|
#define ENABLE_IR_MODULE
|
|
|
|
#define ENABLE_CLIMATE_MODULE // Require IR Module
|
2023-11-29 19:18:44 +00:00
|
|
|
#define ENABLE_ANALOG_MODULE
|
2023-11-07 13:43:20 +00:00
|
|
|
#define ENABLE_WEBUI
|
|
|
|
|
2023-11-30 12:50:54 +00:00
|
|
|
// IR Kit Configuration
|
2023-11-07 13:43:20 +00:00
|
|
|
#define IR_RECIEVE_PIN 35
|
|
|
|
#define IR_SEND_PIN 17
|
|
|
|
#define MARK_EXCESS_MICROS 20
|
2023-12-01 18:25:36 +00:00
|
|
|
#define IR_RAW_BUFFER_LENGTH 750
|
2023-11-07 13:43:20 +00:00
|
|
|
#define AC_MAX_TEMPERATURE 30
|
|
|
|
#define AC_MIN_TEMPERATURE 15
|
2023-11-30 12:50:54 +00:00
|
|
|
#define DHT22_PIN 32
|
2023-11-07 13:43:20 +00:00
|
|
|
|
2023-09-29 17:06:49 +00:00
|
|
|
// External LCD Configuration
|
|
|
|
#define ENABLE_EXTERNAL_LCD
|
|
|
|
#define TXD2 4
|
|
|
|
#define RXD2 17
|
|
|
|
|
|
|
|
#ifdef ENABLE_EXTERNAL_LCD
|
2023-09-30 08:42:44 +00:00
|
|
|
#define ESPMega_EXTLCD Serial2
|
2023-09-29 16:18:21 +00:00
|
|
|
#endif
|
2023-09-29 17:06:49 +00:00
|
|
|
|
2023-11-29 19:18:44 +00:00
|
|
|
// Analog Module Configuration
|
|
|
|
#define ANALOG_REPORTING_INTERVAL 500
|
|
|
|
|
2023-09-29 17:06:49 +00:00
|
|
|
// User Defined Functions
|
2023-11-30 13:01:39 +00:00
|
|
|
void timer1_callback();
|
|
|
|
void bt0PopCallback(void *ptr);
|
|
|
|
|
|
|
|
// User Defined IoT Core Callback Functions (Required)
|
|
|
|
void user_mqtt_callback(char* topic, uint8_t topic_length, char* payload, unsigned int payload_length);
|
|
|
|
void user_state_request_callback();
|
|
|
|
void mqtt_connected_user_callback();
|
2023-09-29 16:18:21 +00:00
|
|
|
void user_pre_init();
|
|
|
|
void user_init();
|
|
|
|
void user_loop();
|
2023-09-30 08:42:44 +00:00
|
|
|
void pwm_changed_user_callback(int pin);
|
2023-10-02 11:02:17 +00:00
|
|
|
void ac_changed_user_callback(int mode, int temperature, int fan_speed);
|
2023-09-29 16:18:21 +00:00
|
|
|
void timer_tick_callback();
|
2023-11-30 13:01:39 +00:00
|
|
|
void virtual_interrupt_user_callback(int pin, int state);
|
2023-09-29 17:06:49 +00:00
|
|
|
|
|
|
|
// ESPMega IoT Core Build-in Functions
|
|
|
|
extern void pwm_set_state(int id, int state);
|
|
|
|
extern void pwm_set_value(int id, int value);
|
|
|
|
extern void pwm_toggle(int id);
|
|
|
|
extern void pwm_toggle(int id1, int id2);
|
|
|
|
extern void pwm_cycle_value(int id);
|
|
|
|
extern bool pwm_get_state(int id);
|
|
|
|
extern uint16_t pwm_get_value(int id);
|
|
|
|
extern boolean pwm_group_state(int id1, int id2);
|
|
|
|
extern bool input_get_state(int id);
|
2023-11-30 13:01:39 +00:00
|
|
|
extern bool standalone;
|
|
|
|
extern PubSubClient mqtt;
|
|
|
|
|
|
|
|
// IR Kit Build-in Functions
|
|
|
|
#ifdef ENABLE_IR_MODULE
|
2023-09-29 17:06:49 +00:00
|
|
|
extern void ac_set_state(int mode, int temperature, int fan_speed);
|
|
|
|
extern uint8_t ac_get_temperature();
|
|
|
|
extern uint8_t ac_get_mode();
|
2023-09-29 17:56:25 +00:00
|
|
|
extern uint8_t ac_get_fan_speed();
|
2023-11-30 13:01:39 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
//Analog Expansion Card Build-in Functions
|
|
|
|
#ifdef ENABLE_ANALOG_MODULE
|
|
|
|
extern void dac_set_value(int id, int value);
|
|
|
|
extern void dac_set_state(int id, bool state);
|
|
|
|
extern void enable_adc(int id);
|
|
|
|
extern void disable_adc(int id);
|
|
|
|
extern void enable_dac(int id);
|
|
|
|
extern uint16_t adc_get_value(int id);
|
|
|
|
extern bool adc_get_state(int id);
|
|
|
|
extern uint16_t dac_get_value(int id);
|
|
|
|
extern bool dac_get_state(int id);
|
|
|
|
#endif
|