acid-drop

- Hacking the planet from a LilyGo T-Deck using custom firmware
git clone git://git.acid.vegas/acid-drop.git
Log | Files | Refs | Archive | README | LICENSE

LibrarySizeBenchmark.ino (1383B)

      1 /*
      2  * A copy of HelloWorld which allows us to measure the size of the AceButton
      3  * library. Set USE_ACE_BUTTON to 1 to include AceButton, 0 to exclude
      4  * AceButton.
      5  */
      6 
      7 #include <AceButton.h>
      8 
      9 using namespace ace_button;
     10 
     11 // Set this to 0 to disable the AceButton code, so that we can
     12 // figure out how many bytes is consumed by the AceButton library.
     13 #define USE_ACE_BUTTON 1
     14 
     15 // Some ESP32 boards have multiple builtin LEDs so don't define LED_BUILTIN.
     16 #if defined(ESP32)
     17   const int LED_PIN = 2;
     18 #else
     19   const int LED_PIN = LED_BUILTIN;
     20 #endif
     21 
     22 const int BUTTON_PIN = 2;
     23 const int LED_ON = HIGH;
     24 const int LED_OFF = LOW;
     25 
     26 #if USE_ACE_BUTTON == 1
     27 AceButton button(BUTTON_PIN);
     28 
     29 void handleEvent(AceButton*, uint8_t, uint8_t);
     30 #endif
     31 
     32 void setup() {
     33   delay(2000);
     34 
     35 #if defined(ARDUINO_AVR_LEONARDO)
     36   RXLED0; // LED off
     37   TXLED0; // LED off
     38 #endif
     39 
     40   pinMode(LED_PIN, OUTPUT);
     41   pinMode(BUTTON_PIN, INPUT_PULLUP);
     42 
     43 #if USE_ACE_BUTTON == 1
     44   button.setEventHandler(handleEvent);
     45 #endif
     46 }
     47 
     48 void loop() {
     49 #if USE_ACE_BUTTON == 1
     50   button.check();
     51 #endif
     52 }
     53 
     54 #if USE_ACE_BUTTON == 1
     55 void handleEvent(AceButton* /* button */, uint8_t eventType,
     56     uint8_t /* buttonState */) {
     57   switch (eventType) {
     58     case AceButton::kEventPressed:
     59       digitalWrite(LED_PIN, LED_ON);
     60       break;
     61     case AceButton::kEventReleased:
     62       digitalWrite(LED_PIN, LED_OFF);
     63       break;
     64   }
     65 }
     66 #endif