Skip to content

Commit c678212

Browse files
committed
#156 reintroduce MAX_KEYS for upfront switches sizing.
1 parent 8fc1c02 commit c678212

File tree

4 files changed

+12
-4
lines changed

4 files changed

+12
-4
lines changed

library.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"name": "TaskManagerIO"
2626
}
2727
],
28-
"version": "2.3.1",
28+
"version": "2.3.2",
2929
"license": "Apache-2.0",
3030
"frameworks": "arduino, mbed",
3131
"platforms": "*",

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#
55

66
name=IoAbstraction
7-
version=2.3.1
7+
version=2.3.2
88
maintainer=https://www.thecoderscorner.com
99
author=davetcc
1010
category=Other

src/SwitchInput.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ void KeyboardItem::checkAndTrigger(uint8_t buttonState){
121121
}
122122
}
123123

124-
SwitchInput::SwitchInput() : encoder{} {
124+
SwitchInput::SwitchInput() : encoder{}, keys(MAX_KEYS) {
125125
this->ioDevice = nullptr;
126126
this->swFlags = 0;
127127
this->lastSyncStatus = true;

src/SwitchInput.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,14 @@
2222
#ifndef HOLD_THRESHOLD
2323
#define HOLD_THRESHOLD 20
2424
#endif
25+
/*
26+
* If you want more buttons, the library will reallocate as needed, however this is not efficient and in production
27+
* probably better to set this value to about the number of switches needed. Each button adds about 10 bytes of RAM,
28+
* so on a tiny you could adjust downwards for example.
29+
*/
30+
#ifndef MAX_KEYS
31+
#define MAX_KEYS DEFAULT_LIST_SIZE
32+
#endif // MAX_KEYS defined
2533

2634
// START user adjustable section
2735

@@ -364,7 +372,7 @@ class SwitchInput {
364372
* always use the global switches instance.
365373
* @see switches
366374
*/
367-
SwitchInput();
375+
explicit SwitchInput();
368376

369377
/**
370378
* initialise switch input so that it can start managing switches using polling via task manager every 1/20 of a second. If the switches are

0 commit comments

Comments
 (0)