Advertisement
jrullan

Untitled

Oct 25th, 2018
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.95 KB | None | 0 0
  1. #include <Canvas_SEEEDTOUCH.h>
  2. #include <Button.h>
  3.  
  4. // Hay dos componentes principales en la librería: El Canvas, y los elementos (Widgets) como los Botones
  5. /*
  6.  * Canvas
  7.  * Parametros:
  8.  * orientación - TFT_LANDSCAPE o TFT_PORTRAIT
  9.  * color de fondo
  10.  */
  11. Canvas_SEEEDTOUCH canvas = Canvas_SEEEDTOUCH(TFT_LANDSCAPE,BLACK);
  12.  
  13. /*
  14.  * Button
  15.  * Parametros:
  16.  * ancho (w)
  17.  * alto (h)
  18.  * bgColor
  19.  * fgColor
  20.  * borderColor
  21.  */
  22. Button btnStartReset = Button(100,40,GRAY1,WHITE,GRAY2);
  23.  
  24.  
  25. void setup() {
  26.   Serial.begin(9600);
  27.   canvas.init();
  28.   btnStartReset.setText("START");
  29.   btnStartReset.setEventHandler(&btnStartResetEventHandler);
  30.   btnStartReset.fontSize = 4;
  31.   canvas.add(&btnStartReset,110,190);
  32. }
  33.  
  34. void loop() {
  35.   canvas.scan();
  36. }
  37.  
  38.  
  39. // Event handler for the button
  40. void btnStartResetEventHandler(Button* btn){
  41.   if(btn->touched){
  42.     btnStartReset.setText("RESET");
  43.   }else{
  44.     btnStartReset.setText("START");
  45.   }
  46.   btn->show();
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement