software:firmware
MakAir Firmware
keyboard.h File Reference

Analog buttons related functions. More...

Go to the source code of this file.

Functions

void initKeyboard ()
 Initialize keyboard abstraction. More...
 
void keyboardLoop ()
 Handle button events. More...
 
void calibrateButtons ()
 Helper to calibrate analog values of buttons. More...
 

Detailed Description

Analog buttons related functions.

Author
Makers For Life

This relies on the Analog Buttons library (https://github.com/rlogiacco/AnalogButtons).

Definition in file keyboard.h.

Function Documentation

◆ calibrateButtons()

void calibrateButtons ( )

Helper to calibrate analog values of buttons.

Definition at line 233 of file keyboard.cpp.

233 {}

◆ initKeyboard()

void initKeyboard ( )

Initialize keyboard abstraction.

Warning
It must be called once to be able to use the buttons

Definition at line 78 of file keyboard.cpp.

78  {
79  // define the 3x3 matrix keyboard input and output
80  pinMode(PIN_OUT_COL1, OUTPUT);
81  pinMode(PIN_OUT_COL2, OUTPUT);
82  pinMode(PIN_OUT_COL3, OUTPUT);
83  digitalWrite(PIN_OUT_COL1, LOW);
84  digitalWrite(PIN_OUT_COL2, LOW);
85  digitalWrite(PIN_OUT_COL3, LOW);
86  pinMode(PIN_IN_ROW1, INPUT);
87  pinMode(PIN_IN_ROW2, INPUT);
88  pinMode(PIN_IN_ROW3, INPUT);
89 
90  buttonAlarmOff.attachClick(onAlarmOff);
91  buttonStart.attachClick(onStart);
92  buttonStop.attachClick(onStop);
93 }
void onStart()
Handler of the button to start.
Definition: keyboard.cpp:65
static OneButton buttonAlarmOff(PIN_BTN_ALARM_OFF, false, false)
void onAlarmOff()
Handler of the button to stop alarm.
Definition: keyboard.cpp:62
void onStop()
Handler of the button to stop.
Definition: keyboard.cpp:76
static OneButton buttonStart(PIN_BTN_START, false, false)
static OneButton buttonStop(PIN_BTN_STOP, false, false)
#define PIN_OUT_COL2
Definition: parameters.h:236
#define PIN_IN_ROW3
Definition: parameters.h:240
#define PIN_IN_ROW1
Definition: parameters.h:238
#define PIN_OUT_COL1
Definition: parameters.h:235
#define PIN_IN_ROW2
Definition: parameters.h:239
#define PIN_OUT_COL3
Definition: parameters.h:237

◆ keyboardLoop()

void keyboardLoop ( )

Handle button events.

Warning
It must be called in the program loop

Definition at line 223 of file keyboard.cpp.

223  {
224 #ifndef DISABLE_BUTTONS
225  scanMatrixLoop();
226  buttonAlarmOff.tick();
227  buttonStart.tick();
228  buttonStop.tick();
229 #endif
230 }
void scanMatrixLoop()
Definition: keyboard.cpp:112