Add basic module with two buttons

This commit is contained in:
redfast00 2020-08-26 23:36:35 +02:00
parent 54a87bb711
commit 36af43b144
No known key found for this signature in database
GPG key ID: 5946E0E34FD0553C
2 changed files with 50 additions and 0 deletions

View 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.

View 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
}