diff --git a/lib/ITEADLIB_Arduino_Nextion-master/NexHardware.cpp b/lib/ITEADLIB_Arduino_Nextion-master/NexHardware.cpp index 153afcf..c2b6788 100644 --- a/lib/ITEADLIB_Arduino_Nextion-master/NexHardware.cpp +++ b/lib/ITEADLIB_Arduino_Nextion-master/NexHardware.cpp @@ -222,8 +222,8 @@ bool nexInit(void) bool ret1 = false; bool ret2 = false; - dbSerialBegin(9600); - nexSerial.begin(9600); + //dbSerialBegin(9600); + nexSerial.begin(115200); sendCommand(""); sendCommand("bkcmd=1"); ret1 = recvRetCommandFinished(); diff --git a/src/external_lcd.cpp b/src/espmega_iot_external_lcd.cpp similarity index 52% rename from src/external_lcd.cpp rename to src/espmega_iot_external_lcd.cpp index cac60f5..34e43dc 100644 --- a/src/external_lcd.cpp +++ b/src/espmega_iot_external_lcd.cpp @@ -1,5 +1,5 @@ -#include +#include void ExternalLCD::callTriggerFunction() { uint8_t touch_hex = Serial2.read(); - external_lcd_callback(touch_hex); + ext_lcd_callback(touch_hex); } \ No newline at end of file diff --git a/src/external_lcd.hpp b/src/espmega_iot_external_lcd.hpp similarity index 77% rename from src/external_lcd.hpp rename to src/espmega_iot_external_lcd.hpp index 3e16ecd..808650a 100644 --- a/src/external_lcd.hpp +++ b/src/espmega_iot_external_lcd.hpp @@ -5,7 +5,11 @@ #ifndef EXTERNAL_LCD_LOADED #define EXTERNAL_LCD_LOADED #include "user_code.hpp" + +extern void ext_lcd_callback(int id); + class ExternalLCD: public EasyNex { + using EasyNex::EasyNex; protected: void callTriggerFunction(); }; diff --git a/src/user_code.cpp b/src/user_code.cpp index f041534..6272b03 100644 --- a/src/user_code.cpp +++ b/src/user_code.cpp @@ -1,21 +1,28 @@ #include -void timer1_callback() -{ - for (int i = 0; i < 16; i++) - { - pwm_set_state(i, 1); - } -} ESPMega_Timer timer1(0, 50, timer1_callback, 15001); +//Display Componets +NexDSButton bt0 = NexDSButton(1, 2, "bt0"); +NexTouch *nex_listen_list[] = +{ + &bt0, + NULL +}; + +void bt0PopCallback(void *ptr) +{ + Serial.println("BTN0!"); +} + /* This Code will run right after ESPMega PRO's Peripheral Initialization Routine */ void user_pre_init() { + nexInit(); } /* @@ -28,7 +35,7 @@ void user_init() ESPMega_EXTLCD.write(0xFF); ESPMega_EXTLCD.write(0xFF); ESPMega_EXTLCD.write(0xFF); - + bt0.attachPop(bt0PopCallback, &bt0); } /* @@ -36,11 +43,10 @@ This code will run once every event loop */ void user_loop() { - if(Serial2.available()) { - Serial.println(Serial2.read()); - } + nexLoop(nex_listen_list); } + /* This code will run when an input pin changed state */ @@ -48,8 +54,8 @@ void virtual_interrupt_user_callback(int pin, int state) { } -void pwm_changed_user_callback(int pin) { - +void pwm_changed_user_callback(int pin) +{ } /* @@ -62,3 +68,11 @@ void timer_tick_callback() timer1.loop(); } } + +void timer1_callback() +{ + for (int i = 0; i < 16; i++) + { + pwm_set_state(i, 1); + } +} \ No newline at end of file diff --git a/src/user_code.hpp b/src/user_code.hpp index e0541f8..d8383cb 100644 --- a/src/user_code.hpp +++ b/src/user_code.hpp @@ -1,9 +1,10 @@ #pragma once #include -#include +#include #include #include #include "espmega_iot_timer.hpp" +#include "espmega_iot_external_lcd.hpp" // External LCD Configuration #define ENABLE_EXTERNAL_LCD @@ -21,6 +22,7 @@ void user_loop(); void virtual_interrupt_user_callback(int pin, int state); void pwm_changed_user_callback(int pin); void timer_tick_callback(); +void timer1_callback(); void bt0PopCallback(void *ptr); diff --git a/user_display/EXTDISP.HMI b/user_display/EXTDISP.HMI index fb654ec..3965a1e 100644 Binary files a/user_display/EXTDISP.HMI and b/user_display/EXTDISP.HMI differ