Add basic module with two buttons
This commit is contained in:
parent
54a87bb711
commit
36af43b144
2 changed files with 50 additions and 0 deletions
6
src/modules/testmodule_buttons/doc/index.md
Normal file
6
src/modules/testmodule_buttons/doc/index.md
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
## Testmodule buttons
|
||||||
|
|
||||||
|
Don't press the red button. Press the green button to solve the module.
|
||||||
|
|
||||||
|
### Credits
|
||||||
|
Module developed by redfast00.
|
44
src/modules/testmodule_buttons/testmodule_buttons.ino
Normal file
44
src/modules/testmodule_buttons/testmodule_buttons.ino
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
// (c) 2020, redfast00
|
||||||
|
// See the LICENSE file for conditions for copying
|
||||||
|
|
||||||
|
#include <obus_module.h>
|
||||||
|
#include <ezButton.h>
|
||||||
|
|
||||||
|
ezButton red_button(5);
|
||||||
|
ezButton green_button(6);
|
||||||
|
|
||||||
|
void setup() {
|
||||||
|
Serial.begin(115200);
|
||||||
|
// WARNING: do not use 255 for your module
|
||||||
|
obus_module::setup(OBUS_TYPE_PUZZLE, 255);
|
||||||
|
red_button.setDebounceTime(100);
|
||||||
|
green_button.setDebounceTime(100);
|
||||||
|
}
|
||||||
|
|
||||||
|
obus_can::message message;
|
||||||
|
|
||||||
|
void loop() {
|
||||||
|
bool received = obus_module::loop(&message);
|
||||||
|
// TODO handle update frames (not needed for this module, but could be useful as example code)
|
||||||
|
|
||||||
|
red_button.loop();
|
||||||
|
green_button.loop();
|
||||||
|
|
||||||
|
if (red_button.getCount() > 0) {
|
||||||
|
red_button.resetCount();
|
||||||
|
obus_module::strike();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (green_button.getCount() > 0) {
|
||||||
|
green_button.resetCount();
|
||||||
|
obus_module::solve();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void callback_game_start() {
|
||||||
|
// Intentionally emtpy
|
||||||
|
}
|
||||||
|
|
||||||
|
void callback_game_stop() {
|
||||||
|
// Intentionally empty
|
||||||
|
}
|
Loading…
Reference in a new issue