From 81c89dfe7a63687faf0869bc1008022bcc84c59f Mon Sep 17 00:00:00 2001 From: Siwat Sirichai Date: Mon, 6 Nov 2023 14:56:33 +0700 Subject: [PATCH] clean code --- src/user_code.cpp | 42 +++++------------------------------------- src/user_code.hpp | 8 +++----- 2 files changed, 8 insertions(+), 42 deletions(-) diff --git a/src/user_code.cpp b/src/user_code.cpp index 7507243..5ea3f70 100644 --- a/src/user_code.cpp +++ b/src/user_code.cpp @@ -1,22 +1,5 @@ #include -//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 Peripheral Initialization Routine @@ -31,12 +14,7 @@ This code will run after every component is initialized */ 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() { - nexLoop(nex_listen_list); + } /* @@ -56,11 +34,7 @@ void virtual_interrupt_user_callback(int pin, int state) 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() { - if (standalone) - { - timer1.loop(); - } + } 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) { diff --git a/src/user_code.hpp b/src/user_code.hpp index 72cc5a0..3eec6da 100644 --- a/src/user_code.hpp +++ b/src/user_code.hpp @@ -7,9 +7,9 @@ #include "espmega_iot_external_lcd.hpp" // External LCD Configuration -#define ENABLE_EXTERNAL_LCD -#define TXD2 4 -#define RXD2 17 +//#define ENABLE_EXTERNAL_LCD +//#define TXD2 4 +//#define RXD2 17 #ifdef ENABLE_EXTERNAL_LCD #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 ac_changed_user_callback(int mode, int temperature, int fan_speed); void timer_tick_callback(); -void timer1_callback(); void mqtt_connected_user_callback(); -void bt0PopCallback(void *ptr); void user_state_request_callback();