clean code

This commit is contained in:
Siwat Sirichai 2023-11-06 14:56:33 +07:00
parent 92aa347d53
commit 81c89dfe7a
2 changed files with 8 additions and 42 deletions

View File

@ -1,22 +1,5 @@
#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
@ -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

@ -7,9 +7,9 @@
#include "espmega_iot_external_lcd.hpp" #include "espmega_iot_external_lcd.hpp"
// 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
@ -23,9 +23,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();