Compare commits
6 Commits
main
...
iot-ay2023
Author | SHA1 | Date |
---|---|---|
Siwat Sirichai | f02629be1b | |
Siwat Sirichai | c4c9d8d6ed | |
Siwat Sirichai | 69fc0bc8e6 | |
Siwat Sirichai | 92c120eb6d | |
Siwat Sirichai | 64313dce64 | |
Siwat Sirichai | 81c89dfe7a |
|
@ -1,29 +1,12 @@
|
|||
#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
|
||||
Peripheral Initialization Routine
|
||||
*/
|
||||
void user_pre_init()
|
||||
{
|
||||
nexInit();
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -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) {
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
#pragma once
|
||||
#include <ESPMegaPRO.h>
|
||||
#include <Nextion.h>
|
||||
#include <PubSubClient.h>
|
||||
#include <PubSubClientTools.h>
|
||||
#include "espmega_iot_timer.hpp"
|
||||
|
@ -21,9 +20,9 @@
|
|||
#define AC_MIN_TEMPERATURE 15
|
||||
|
||||
// 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
|
||||
|
@ -37,9 +36,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();
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue