Update user_code.cpp

This commit is contained in:
Siwat Sirichai 2023-12-26 23:32:11 +07:00
parent 0a93b41845
commit 5d7136928b
1 changed files with 148 additions and 9 deletions

View File

@ -5,11 +5,47 @@ 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");
NexButton light_toggle = NexButton(1,2,"light_toggle");
NexButton row1_master = NexButton(1,11,"row1_master");
NexButton row2_master = NexButton(1,12,"row2_master");
NexButton row3_master = NexButton(1,14,"row3_master");
NexButton row4_master = NexButton(1,13,"row4_master");
NexButton row1_lv1 = NexButton(1,3,"row1_lv1");
NexButton row1_lv2 = NexButton(1,4,"row1_lv2");
NexButton row2_lv1 = NexButton(1,5,"row2_lv1");
NexButton row2_lv2 = NexButton(1,6,"row2_lv2");
NexButton row3_lv1 = NexButton(1,10,"row3_lv1");
NexButton row3_lv2 = NexButton(1,7,"row3_lv2");
NexButton row4_lv1 = NexButton(1,9,"row4_lv1");
NexButton row4_lv2 = NexButton(1,8,"row4_lv2");
NexButton temp_plus = NexButton(1,18,"temp_plus");
NexButton temp_neg = NexButton(1,17,"temp_neg");
NexButton fan = NexButton(1,16,"fan");
NexButton mode = NexButton(1,15,"mode");
NexButton ac_toggle = NexButton(1,1,"ac_toggle");
NexText cur_temp = NexText(1,19,"cur_temp");
// List of Component ID Message to listen to
NexTouch *nex_listen_list[] =
{
&bt0,
&light_toggle,
&row1_master,
&row2_master,
&row3_master,
&row4_master,
&row1_lv1,
&row1_lv2,
&row2_lv1,
&row2_lv2,
&row3_lv1,
&row3_lv2,
&row4_lv1,
&row4_lv2,
&temp_plus,
&temp_neg,
&fan,
&mode,
&ac_toggle,
NULL};
void bt0PopCallback(void *ptr)
@ -26,17 +62,125 @@ void user_pre_init()
nexInit();
}
void light_toggle_pop_callback(void *ptr)
{
Serial.println("light_toggle_pop_callback");
}
void row1_lv1_pop_callback(void *ptr)
{
Serial.println("row1_lv1_pop_callback");
}
void row1_lv2_pop_callback(void *ptr)
{
Serial.println("row1_lv2_pop_callback");
}
void row2_lv1_pop_callback(void *ptr)
{
Serial.println("row2_lv1_pop_callback");
}
void row2_lv2_pop_callback(void *ptr)
{
Serial.println("row2_lv2_pop_callback");
}
void row3_lv1_pop_callback(void *ptr)
{
Serial.println("row3_lv1_pop_callback");
}
void row3_lv2_pop_callback(void *ptr)
{
Serial.println("row3_lv2_pop_callback");
}
void row4_lv1_pop_callback(void *ptr)
{
Serial.println("row4_lv1_pop_callback");
}
void row4_lv2_pop_callback(void *ptr)
{
Serial.println("row4_lv2_pop_callback");
}
void row1_master_pop_callback(void *ptr)
{
Serial.println("row1_master_pop_callback");
}
void row2_master_pop_callback(void *ptr)
{
Serial.println("row2_master_pop_callback");
}
void row3_master_pop_callback(void *ptr)
{
Serial.println("row3_master_pop_callback");
}
void row4_master_pop_callback(void *ptr)
{
Serial.println("row4_master_pop_callback");
}
void temp_plus_pop_callback(void *ptr)
{
Serial.println("temp_plus_pop_callback");
}
void temp_neg_pop_callback(void *ptr)
{
Serial.println("temp_neg_pop_callback");
}
void fan_pop_callback(void *ptr)
{
Serial.println("fan_pop_callback");
}
void mode_pop_callback(void *ptr)
{
Serial.println("mode_pop_callback");
}
void ac_toggle_pop_callback(void *ptr)
{
Serial.println("ac_toggle_pop_callback");
}
/*
This code will run after every component is initialized
*/
void user_init()
{
timer1.begin();
ESPMega_EXTLCD.print("page home");
ESPMega_EXTLCD.print("page main");
ESPMega_EXTLCD.write(0xFF);
ESPMega_EXTLCD.write(0xFF);
ESPMega_EXTLCD.write(0xFF);
bt0.attachPop(bt0PopCallback, &bt0);
light_toggle.attachPop(light_toggle_pop_callback, &light_toggle);
row1_lv1.attachPop(row1_lv1_pop_callback, &row1_lv1);
row1_lv2.attachPop(row1_lv2_pop_callback, &row1_lv2);
row2_lv1.attachPop(row2_lv1_pop_callback, &row2_lv1);
row2_lv2.attachPop(row2_lv2_pop_callback, &row2_lv2);
row3_lv1.attachPop(row3_lv1_pop_callback, &row3_lv1);
row3_lv2.attachPop(row3_lv2_pop_callback, &row3_lv2);
row4_lv1.attachPop(row4_lv1_pop_callback, &row4_lv1);
row4_lv2.attachPop(row4_lv2_pop_callback, &row4_lv2);
row1_master.attachPop(row1_master_pop_callback, &row1_master);
row2_master.attachPop(row2_master_pop_callback, &row2_master);
row3_master.attachPop(row3_master_pop_callback, &row3_master);
row4_master.attachPop(row4_master_pop_callback, &row4_master);
temp_plus.attachPop(temp_plus_pop_callback, &temp_plus);
temp_neg.attachPop(temp_neg_pop_callback, &temp_neg);
fan.attachPop(fan_pop_callback, &fan);
mode.attachPop(mode_pop_callback, &mode);
ac_toggle.attachPop(ac_toggle_pop_callback, &ac_toggle);
}
/*
@ -56,11 +200,6 @@ 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));
}
}
/*