user code dualstate button demo
This commit is contained in:
		
							parent
							
								
									6ccbc32911
								
							
						
					
					
						commit
						3144214cfe
					
				
					 1 changed files with 13 additions and 9 deletions
				
			
		| 
						 | 
					@ -1,19 +1,19 @@
 | 
				
			||||||
#include <user_code.hpp>
 | 
					#include <user_code.hpp>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
ESPMega_Timer timer1(0, 50, timer1_callback, 15001);
 | 
					ESPMega_Timer timer1(0, 50, timer1_callback, 15001);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
//Display Componets
 | 
					// Display Componets
 | 
				
			||||||
 | 
					// Link with Dual state button object with id 2 on page 1 named bt0
 | 
				
			||||||
NexDSButton bt0 = NexDSButton(1, 2, "bt0");
 | 
					NexDSButton bt0 = NexDSButton(1, 2, "bt0");
 | 
				
			||||||
NexTouch *nex_listen_list[] = 
 | 
					// List of Component ID Message to listen to
 | 
				
			||||||
{
 | 
					NexTouch *nex_listen_list[] =
 | 
				
			||||||
    &bt0,
 | 
					    {
 | 
				
			||||||
    NULL
 | 
					        &bt0,
 | 
				
			||||||
};
 | 
					        NULL};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void bt0PopCallback(void *ptr)
 | 
					void bt0PopCallback(void *ptr)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    Serial.println("BTN0!");
 | 
					    pwm_toggle(2);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/*
 | 
					/*
 | 
				
			||||||
| 
						 | 
					@ -46,7 +46,6 @@ void user_loop()
 | 
				
			||||||
    nexLoop(nex_listen_list);
 | 
					    nexLoop(nex_listen_list);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
/*
 | 
					/*
 | 
				
			||||||
This code will run when an input pin changed state
 | 
					This code will run when an input pin changed state
 | 
				
			||||||
*/
 | 
					*/
 | 
				
			||||||
| 
						 | 
					@ -56,6 +55,11 @@ void virtual_interrupt_user_callback(int pin, int state)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void pwm_changed_user_callback(int pin)
 | 
					void pwm_changed_user_callback(int pin)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
					    if (pin == 2)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        // inform the lcd when pwm 2 changed
 | 
				
			||||||
 | 
					        bt0.setValue(pwm_get_state(2));
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/*
 | 
					/*
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue