Compare commits
No commits in common. "576abc1c901fc20af0a89fbe11023765cb87996f" and "bf1de69f242eace57e4f74c6928d71acafb36b56" have entirely different histories.
576abc1c90
...
bf1de69f24
|
@ -336,7 +336,7 @@ void thread_initialization()
|
||||||
eeprom_pwm_updater.onRun(eeprom_pwm_update);
|
eeprom_pwm_updater.onRun(eeprom_pwm_update);
|
||||||
eeprom_pwm_updater.setInterval(1000);
|
eeprom_pwm_updater.setInterval(1000);
|
||||||
user_timer_tick.onRun(timer_tick_callback);
|
user_timer_tick.onRun(timer_tick_callback);
|
||||||
user_timer_tick.setInterval(15000);
|
user_timer_tick.setInterval(5000);
|
||||||
}
|
}
|
||||||
|
|
||||||
void pwm_state_callback(String topic, String message)
|
void pwm_state_callback(String topic, String message)
|
||||||
|
|
|
@ -1,43 +0,0 @@
|
||||||
#include "espmega_iot_timer.hpp"
|
|
||||||
|
|
||||||
void ESPMega_Timer::loop() {
|
|
||||||
rtctime_t curtime = ESPMega_getTime();
|
|
||||||
if(today!=curtime.day) {
|
|
||||||
today=curtime.day;
|
|
||||||
timer_ran_today = false;
|
|
||||||
ESPMega_FRAM.write8(fram_address,timer_ran_today);
|
|
||||||
}
|
|
||||||
if (!timer_ran_today && (hr < curtime.hours || (hr == curtime.hours && min <= curtime.minutes))) {
|
|
||||||
timer_ran_today = true;
|
|
||||||
ESPMega_FRAM.write8(fram_address,timer_ran_today);
|
|
||||||
timer_callback();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ESPMega_Timer::ESPMega_Timer(uint8_t hour,uint8_t minute,void(*timer_callback)(), uint32_t fram_address) {
|
|
||||||
this->hr = hour;
|
|
||||||
this->min = minute;
|
|
||||||
this->timer_callback = timer_callback;
|
|
||||||
this->fram_address = fram_address;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ESPMega_Timer::begin() {
|
|
||||||
rtctime_t curtime = ESPMega_getTime();
|
|
||||||
this-> today = curtime.day;
|
|
||||||
this-> timer_ran_today = ESPMega_FRAM.read8(fram_address);
|
|
||||||
loop();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ESPMega_Timer::set(uint8_t hour,uint8_t minute) {
|
|
||||||
rtctime_t curtime = ESPMega_getTime();
|
|
||||||
if ((hr < curtime.hours || (hr == curtime.hours && min <= curtime.minutes))) {
|
|
||||||
this->timer_ran_today = true;
|
|
||||||
ESPMega_FRAM.write8(fram_address,timer_ran_today);
|
|
||||||
|
|
||||||
} else {
|
|
||||||
this->timer_ran_today = false;
|
|
||||||
ESPMega_FRAM.write8(fram_address,timer_ran_today);
|
|
||||||
}
|
|
||||||
hr = hour;
|
|
||||||
min = minute;
|
|
||||||
}
|
|
|
@ -1,17 +0,0 @@
|
||||||
#pragma once
|
|
||||||
#include <ESPMegaPRO.h>
|
|
||||||
|
|
||||||
class ESPMega_Timer {
|
|
||||||
public:
|
|
||||||
void loop();
|
|
||||||
ESPMega_Timer(uint8_t hour,uint8_t minute,void(*timer_callback)(), uint32_t fram_address);
|
|
||||||
void set(uint8_t hour,uint8_t minute);
|
|
||||||
void begin();
|
|
||||||
private:
|
|
||||||
uint8_t today;
|
|
||||||
uint8_t timer_ran_today;
|
|
||||||
uint8_t hr;
|
|
||||||
uint8_t min;
|
|
||||||
uint32_t fram_address;
|
|
||||||
void (*timer_callback)();
|
|
||||||
};
|
|
|
@ -1,51 +1,37 @@
|
||||||
#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);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
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()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
This code will run after every component is initialized
|
This code will run after every component is initialized
|
||||||
*/
|
*/
|
||||||
void user_init()
|
void user_init() {
|
||||||
{
|
|
||||||
timer1.begin();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
This code will run once every event loop
|
This code will run once every event loop
|
||||||
*/
|
*/
|
||||||
void user_loop()
|
void user_loop() {
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
This code will run when an input pin changed state
|
This code will run when an input pin changed state
|
||||||
*/
|
*/
|
||||||
void virtual_interrupt_user_callback(int pin, int state)
|
void virtual_interrupt_user_callback(int pin, int state) {
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
This code will run every 15 seconds
|
This code will run every 5 seconds
|
||||||
*/
|
*/
|
||||||
void timer_tick_callback()
|
void timer_tick_callback() {
|
||||||
{
|
|
||||||
if(standalone){
|
|
||||||
timer1.loop();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
#include <ESPMegaPRO.h>
|
#include <ESPMegaPRO.h>
|
||||||
#include <EasyNextionLibrary.h>
|
#include <EasyNextionLibrary.h>
|
||||||
#include "espmega_iot_timer.hpp"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// External LCD Configuration
|
// External LCD Configuration
|
||||||
#define ENABLE_EXTERNAL_LCD
|
#define ENABLE_EXTERNAL_LCD
|
||||||
|
@ -35,5 +37,4 @@ extern bool input_get_state(int id);
|
||||||
extern void ac_set_state(int mode, int temperature, int fan_speed);
|
extern void ac_set_state(int mode, int temperature, int fan_speed);
|
||||||
extern uint8_t ac_get_temperature();
|
extern uint8_t ac_get_temperature();
|
||||||
extern uint8_t ac_get_mode();
|
extern uint8_t ac_get_mode();
|
||||||
extern uint8_t ac_get_fan_speed();
|
extern uint8_t ac_get_fan_speed();
|
||||||
extern bool standalone;
|
|
Loading…
Reference in New Issue