iot-firmware/src/user_code.cpp

78 lines
1.1 KiB
C++
Raw Normal View History

2023-09-29 16:18:21 +00:00
#include <user_code.hpp>
2023-09-29 17:56:25 +00:00
2023-09-29 17:56:36 +00:00
ESPMega_Timer timer1(0, 50, timer1_callback, 15001);
2023-09-29 16:18:21 +00:00
2023-09-30 09:29:16 +00:00
//Display Componets
NexDSButton bt0 = NexDSButton(1, 2, "bt0");
NexTouch *nex_listen_list[] =
{
&bt0,
NULL
};
void bt0PopCallback(void *ptr)
{
Serial.println("BTN0!");
}
2023-09-29 17:06:49 +00:00
/*
This Code will run right after ESPMega PRO's
Peripheral Initialization Routine
*/
2023-09-29 17:37:31 +00:00
void user_pre_init()
{
2023-09-30 09:29:16 +00:00
nexInit();
2023-09-29 16:18:21 +00:00
}
2023-09-29 17:06:49 +00:00
/*
This code will run after every component is initialized
*/
2023-09-29 17:37:31 +00:00
void user_init()
{
2023-09-29 17:56:25 +00:00
timer1.begin();
2023-09-30 08:42:44 +00:00
ESPMega_EXTLCD.print("page home");
ESPMega_EXTLCD.write(0xFF);
ESPMega_EXTLCD.write(0xFF);
ESPMega_EXTLCD.write(0xFF);
2023-09-30 09:29:16 +00:00
bt0.attachPop(bt0PopCallback, &bt0);
2023-09-29 16:18:21 +00:00
}
2023-09-29 17:06:49 +00:00
/*
This code will run once every event loop
*/
2023-09-29 17:37:31 +00:00
void user_loop()
{
2023-09-30 09:29:16 +00:00
nexLoop(nex_listen_list);
2023-09-29 16:18:21 +00:00
}
2023-09-30 09:29:16 +00:00
2023-09-29 17:06:49 +00:00
/*
This code will run when an input pin changed state
*/
2023-09-29 17:37:31 +00:00
void virtual_interrupt_user_callback(int pin, int state)
{
2023-09-29 16:18:21 +00:00
}
2023-09-29 17:06:49 +00:00
2023-09-30 09:29:16 +00:00
void pwm_changed_user_callback(int pin)
{
2023-09-30 08:42:44 +00:00
}
2023-09-29 17:06:49 +00:00
/*
2023-09-29 17:37:31 +00:00
This code will run every 15 seconds
2023-09-29 17:06:49 +00:00
*/
2023-09-29 17:37:31 +00:00
void timer_tick_callback()
{
2023-09-29 17:56:36 +00:00
if (standalone)
{
2023-09-29 17:56:25 +00:00
timer1.loop();
2023-09-29 17:37:31 +00:00
}
2023-09-29 16:18:21 +00:00
}
2023-09-30 09:29:16 +00:00
void timer1_callback()
{
for (int i = 0; i < 16; i++)
{
pwm_set_state(i, 1);
}
}