Dilbert
Firmware for the Dilbert interactive badge.
 All Classes Files Functions Variables Enumerations Macros Pages
ButtonTestApp.h
Go to the documentation of this file.
1 
3 #ifndef _BUTTONTESTAPP_H_
4 #define _BUTTONTESTAPP_H_
5 
6 #include <App.h>
7 
13 class ButtonTestApp : public App
14 {
15 public:
20  : App("Button Test")
21  {
22  }
23 
24  virtual ~ButtonTestApp()
25  {
26  }
27 
31  virtual void onEntry()
32  {
33  App::onEntry();
34 
35  /* Clear the screen */
36  m_badge->display().fillScreen(ILI9341_BLACK);
37 
38  /* Set font style */
39  /* It is important for each app to do this here */
40  m_badge->display().setCursor(0, 0);
41  m_badge->display().setTextColor(ILI9341_PINK);
42  m_badge->display().setTextSize(2);
43 
44  m_badge->display().println("Button test");
45 
46  m_badge->display().setTextSize(1);
47 
48  m_badge->display().println("Long press B to return to app menu");
49  m_badge->display().println();
50  }
51 
55  virtual bool handleButton(IButton *button)
56  {
57  if (App::handleButton(button))
58  return true;
59 
60  /* Output some details about the buttons */
61  if (button->isActive())
62  {
63  m_badge->display().print("Button ");
64  m_badge->display().print(button->getID());
65  m_badge->display().println(" pressed");
66  }
67  else
68  {
69  m_badge->display().print("Button ");
70  m_badge->display().print(button->getID());
71  m_badge->display().print(" released after ");
72  m_badge->display().print(button->lastActiveDuration());
73  m_badge->display().println("ms.");
74  }
75 
76  return true;
77  }
78 };
79 
80 #endif
Adafruit_ILI9341 & display()
Gets the TFT display driver.
Definition: Dilbert.h:44
virtual void onEntry()
Called when the application is entered.
Definition: App.h:70
ButtonTestApp()
Creates a buton test application.
Definition: ButtonTestApp.h:19
virtual bool handleButton(IButton *button)
Handle button presses.
Definition: App.h:121
virtual void onEntry()
Called when the application is entered.
Definition: ButtonTestApp.h:31
Simple demo/test of the buttons.
Definition: ButtonTestApp.h:13
Dilbert * m_badge
Pointer to badge driver.
Definition: App.h:129
virtual bool handleButton(IButton *button)
Handle button presses.
Definition: ButtonTestApp.h:55
Used to encapsulate an individual application.
Definition: App.h:15