New button template
This commit is contained in:
35
templates/button/__name__/__name__.ino.tmpl
Normal file
35
templates/button/__name__/__name__.ino.tmpl
Normal file
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* {{PROJECT_NAME}}.ino -- Pushbutton input with edge detection
|
||||
*
|
||||
* Detects button presses (rising edge only) and prints to Serial:
|
||||
*
|
||||
* Button pressed! (count: 1)
|
||||
* Button pressed! (count: 2)
|
||||
*
|
||||
* All logic lives in lib/app/{{PROJECT_NAME}}_app.h which depends
|
||||
* on the HAL and Button interfaces, making it fully testable
|
||||
* on the host without hardware.
|
||||
*
|
||||
* Wiring (active-low, no external resistor needed):
|
||||
* Pin 2 -> one leg of the button
|
||||
* GND -> other leg of the button
|
||||
* (uses INPUT_PULLUP internally)
|
||||
*
|
||||
* Serial: 115200 baud
|
||||
*/
|
||||
|
||||
#include <hal_arduino.h>
|
||||
#include <{{PROJECT_NAME}}_app.h>
|
||||
#include <button_digital.h>
|
||||
|
||||
static ArduinoHal hw;
|
||||
static ButtonDigital btn(&hw, 2); // pin 2, active-low (default)
|
||||
static ButtonApp app(&hw, &btn);
|
||||
|
||||
void setup() {
|
||||
app.begin();
|
||||
}
|
||||
|
||||
void loop() {
|
||||
app.update();
|
||||
}
|
||||
Reference in New Issue
Block a user