external nextion display example
This commit is contained in:
		
							parent
							
								
									6edef21351
								
							
						
					
					
						commit
						6ccbc32911
					
				
					 6 changed files with 38 additions and 18 deletions
				
			
		| 
						 | 
					@ -222,8 +222,8 @@ bool nexInit(void)
 | 
				
			||||||
    bool ret1 = false;
 | 
					    bool ret1 = false;
 | 
				
			||||||
    bool ret2 = false;
 | 
					    bool ret2 = false;
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    dbSerialBegin(9600);
 | 
					    //dbSerialBegin(9600);
 | 
				
			||||||
    nexSerial.begin(9600);
 | 
					    nexSerial.begin(115200);
 | 
				
			||||||
    sendCommand("");
 | 
					    sendCommand("");
 | 
				
			||||||
    sendCommand("bkcmd=1");
 | 
					    sendCommand("bkcmd=1");
 | 
				
			||||||
    ret1 = recvRetCommandFinished();
 | 
					    ret1 = recvRetCommandFinished();
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,5 +1,5 @@
 | 
				
			||||||
#include <external_lcd.hpp>
 | 
					#include <espmega_iot_external_lcd.hpp>
 | 
				
			||||||
void ExternalLCD::callTriggerFunction() {
 | 
					void ExternalLCD::callTriggerFunction() {
 | 
				
			||||||
    uint8_t touch_hex = Serial2.read();
 | 
					    uint8_t touch_hex = Serial2.read();
 | 
				
			||||||
    external_lcd_callback(touch_hex);
 | 
					    ext_lcd_callback(touch_hex);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -5,7 +5,11 @@
 | 
				
			||||||
#ifndef EXTERNAL_LCD_LOADED
 | 
					#ifndef EXTERNAL_LCD_LOADED
 | 
				
			||||||
#define EXTERNAL_LCD_LOADED
 | 
					#define EXTERNAL_LCD_LOADED
 | 
				
			||||||
#include "user_code.hpp"
 | 
					#include "user_code.hpp"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					extern void ext_lcd_callback(int id);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class ExternalLCD: public EasyNex {
 | 
					class ExternalLCD: public EasyNex {
 | 
				
			||||||
 | 
					    using EasyNex::EasyNex;
 | 
				
			||||||
    protected:
 | 
					    protected:
 | 
				
			||||||
        void callTriggerFunction();
 | 
					        void callTriggerFunction();
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
| 
						 | 
					@ -1,21 +1,28 @@
 | 
				
			||||||
#include <user_code.hpp>
 | 
					#include <user_code.hpp>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void timer1_callback()
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
    for (int i = 0; i < 16; i++)
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        pwm_set_state(i, 1);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
ESPMega_Timer timer1(0, 50, timer1_callback, 15001);
 | 
					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
 | 
					This Code will run right after ESPMega PRO's
 | 
				
			||||||
Peripheral Initialization Routine
 | 
					Peripheral Initialization Routine
 | 
				
			||||||
*/
 | 
					*/
 | 
				
			||||||
void user_pre_init()
 | 
					void user_pre_init()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
					    nexInit();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/*
 | 
					/*
 | 
				
			||||||
| 
						 | 
					@ -28,7 +35,7 @@ void user_init()
 | 
				
			||||||
    ESPMega_EXTLCD.write(0xFF);
 | 
					    ESPMega_EXTLCD.write(0xFF);
 | 
				
			||||||
    ESPMega_EXTLCD.write(0xFF);
 | 
					    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()
 | 
					void user_loop()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    if(Serial2.available()) {
 | 
					    nexLoop(nex_listen_list);
 | 
				
			||||||
        Serial.println(Serial2.read());
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/*
 | 
					/*
 | 
				
			||||||
This code will run when an input pin changed state
 | 
					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();
 | 
					        timer1.loop();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void timer1_callback()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    for (int i = 0; i < 16; i++)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        pwm_set_state(i, 1);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -1,9 +1,10 @@
 | 
				
			||||||
#pragma once
 | 
					#pragma once
 | 
				
			||||||
#include <ESPMegaPRO.h>
 | 
					#include <ESPMegaPRO.h>
 | 
				
			||||||
#include <EasyNextionLibrary.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"
 | 
				
			||||||
 | 
					#include "espmega_iot_external_lcd.hpp"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// External LCD Configuration
 | 
					// External LCD Configuration
 | 
				
			||||||
#define ENABLE_EXTERNAL_LCD
 | 
					#define ENABLE_EXTERNAL_LCD
 | 
				
			||||||
| 
						 | 
					@ -21,6 +22,7 @@ void user_loop();
 | 
				
			||||||
void virtual_interrupt_user_callback(int pin, int state);
 | 
					void virtual_interrupt_user_callback(int pin, int state);
 | 
				
			||||||
void pwm_changed_user_callback(int pin);
 | 
					void pwm_changed_user_callback(int pin);
 | 
				
			||||||
void timer_tick_callback();
 | 
					void timer_tick_callback();
 | 
				
			||||||
 | 
					void timer1_callback();
 | 
				
			||||||
void bt0PopCallback(void *ptr);
 | 
					void bt0PopCallback(void *ptr);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
										
											Binary file not shown.
										
									
								
							
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue