Compare commits

...

6 Commits

2 changed files with 9 additions and 44 deletions

View File

@ -1,29 +1,12 @@
#include <user_code.hpp> #include <user_code.hpp>
//Timer Components
ESPMega_Timer timer1(0, 50, timer1_callback, 15001);
// Display Componets
// Link with Dual state button object with id 2 on page 1 named bt0
NexDSButton bt0 = NexDSButton(1, 2, "bt0");
// List of Component ID Message to listen to
NexTouch *nex_listen_list[] =
{
&bt0,
NULL};
void bt0PopCallback(void *ptr)
{
pwm_toggle(2);
}
/* /*
This Code will run right after ESPMega PRO's This Code will run right after ESPMega PRO's
Peripheral Initialization Routine Peripheral Initialization Routine
*/ */
void user_pre_init() void user_pre_init()
{ {
nexInit();
} }
/* /*
@ -31,12 +14,7 @@ This code will run after every component is initialized
*/ */
void user_init() void user_init()
{ {
timer1.begin();
ESPMega_EXTLCD.print("page home");
ESPMega_EXTLCD.write(0xFF);
ESPMega_EXTLCD.write(0xFF);
ESPMega_EXTLCD.write(0xFF);
bt0.attachPop(bt0PopCallback, &bt0);
} }
/* /*
@ -44,7 +22,7 @@ This code will run once every event loop
*/ */
void user_loop() void user_loop()
{ {
nexLoop(nex_listen_list);
} }
/* /*
@ -56,11 +34,7 @@ void virtual_interrupt_user_callback(int pin, int state)
void pwm_changed_user_callback(int pin) void pwm_changed_user_callback(int pin)
{ {
if (pin == 2)
{
// inform the lcd when pwm 2 changed
bt0.setValue(pwm_get_state(2));
}
} }
/* /*
@ -68,18 +42,12 @@ This code will run every 15 seconds
*/ */
void timer_tick_callback() void timer_tick_callback()
{ {
if (standalone)
{
timer1.loop();
}
} }
void timer1_callback() void timer1_callback()
{ {
for (int i = 0; i < 16; i++)
{
pwm_set_state(i, 1);
}
} }
void ac_changed_user_callback(int mode, int temperature, int fan_speed) { void ac_changed_user_callback(int mode, int temperature, int fan_speed) {

View File

@ -1,6 +1,5 @@
#pragma once #pragma once
#include <ESPMegaPRO.h> #include <ESPMegaPRO.h>
#include <Nextion.h>
#include <PubSubClient.h> #include <PubSubClient.h>
#include <PubSubClientTools.h> #include <PubSubClientTools.h>
#include "espmega_iot_timer.hpp" #include "espmega_iot_timer.hpp"
@ -21,9 +20,9 @@
#define AC_MIN_TEMPERATURE 15 #define AC_MIN_TEMPERATURE 15
// External LCD Configuration // External LCD Configuration
#define ENABLE_EXTERNAL_LCD //#define ENABLE_EXTERNAL_LCD
#define TXD2 4 //#define TXD2 4
#define RXD2 17 //#define RXD2 17
#ifdef ENABLE_EXTERNAL_LCD #ifdef ENABLE_EXTERNAL_LCD
#define ESPMega_EXTLCD Serial2 #define ESPMega_EXTLCD Serial2
@ -37,9 +36,7 @@ void virtual_interrupt_user_callback(int pin, int state);
void pwm_changed_user_callback(int pin); void pwm_changed_user_callback(int pin);
void ac_changed_user_callback(int mode, int temperature, int fan_speed); void ac_changed_user_callback(int mode, int temperature, int fan_speed);
void timer_tick_callback(); void timer_tick_callback();
void timer1_callback();
void mqtt_connected_user_callback(); void mqtt_connected_user_callback();
void bt0PopCallback(void *ptr);
void user_state_request_callback(); void user_state_request_callback();