first commit

This commit is contained in:
lewishe
2023-04-11 11:27:36 +08:00
commit daa54b6448
2146 changed files with 915567 additions and 0 deletions
@@ -0,0 +1,66 @@
/*
* A copy of HelloWorld which allows us to measure the size of the AceButton
* library. Set USE_ACE_BUTTON to 1 to include AceButton, 0 to exclude
* AceButton.
*/
#include <AceButton.h>
using namespace ace_button;
// Set this to 0 to disable the AceButton code, so that we can
// figure out how many bytes is consumed by the AceButton library.
#define USE_ACE_BUTTON 1
// Some ESP32 boards have multiple builtin LEDs so don't define LED_BUILTIN.
#if defined(ESP32)
const int LED_PIN = 2;
#else
const int LED_PIN = LED_BUILTIN;
#endif
const int BUTTON_PIN = 2;
const int LED_ON = HIGH;
const int LED_OFF = LOW;
#if USE_ACE_BUTTON == 1
AceButton button(BUTTON_PIN);
void handleEvent(AceButton*, uint8_t, uint8_t);
#endif
void setup() {
delay(2000);
#if defined(ARDUINO_AVR_LEONARDO)
RXLED0; // LED off
TXLED0; // LED off
#endif
pinMode(LED_PIN, OUTPUT);
pinMode(BUTTON_PIN, INPUT_PULLUP);
#if USE_ACE_BUTTON == 1
button.setEventHandler(handleEvent);
#endif
}
void loop() {
#if USE_ACE_BUTTON == 1
button.check();
#endif
}
#if USE_ACE_BUTTON == 1
void handleEvent(AceButton* /* button */, uint8_t eventType,
uint8_t /* buttonState */) {
switch (eventType) {
case AceButton::kEventPressed:
digitalWrite(LED_PIN, LED_ON);
break;
case AceButton::kEventReleased:
digitalWrite(LED_PIN, LED_OFF);
break;
}
}
#endif
@@ -0,0 +1,18 @@
# LibrarySizeBenchmark
A small sketch to determine the size of the AceButton library.
First we compile it with `#define USE_ACE_BUTTON 1` to include the library.
Then we compile it with `#define USE_ACE_BUTTON 0` to exclude the library.
The difference should give us a rough idea of the size of the library.
(The compiler will produce slightly difference results for different programs.)
```
-------------+--------------+---------------+------------+
board | AceButton | w/o AceButton | Difference |
-------------+--------------+---------------+------------+
ATmega328P | 2282/ 55 | 1126 / 41 | 1156/14 |
ESP8266 | 249364/28076 | 248032/28048 | 1332/28 |
ESP32 | 195588/14044 | 194424/14028 | 1164/16 |
Teensy 3.2 | 9852/ 3476 | 8760/ 3460 | 1092/16 |
-------------+--------------+---------------+------------+
```