This commit is contained in:
redfast00 2020-09-09 20:03:03 +02:00
parent 4e745149e4
commit 4bcb6e8395
No known key found for this signature in database
GPG key ID: 5946E0E34FD0553C

View file

@ -2,28 +2,40 @@
// See the LICENSE file for conditions for copying
#include <obus_module.h>
#include <LiquidCrystal.h>
char serial_number[7];
LiquidCrystal lcd(7, 6, 5, 4, 3, 2);
void setup() {
Serial.begin(115200);
// Choose one
// Puzzle: a module that must be solved
obus_module::setup(OBUS_TYPE_PUZZLE, OBUS_PUZZLE_ID_DEVELOPMENT);
// Needy: a module that periodically requires an action not to get strikes
// obus_module::setup(OBUS_TYPE_NEEDY, OBUS_NEEDY_ID_DEVELOPMENT);
obus_module::setup(OBUS_TYPE_INFO, OBUS_INFO_ID_DEVELOPMENT);
info_generator(serial_number);
lcd.begin(16, 2);
lcd.clear();
}
obus_can::message message;
void loop() {
bool is_message_valid = obus_module::loop_puzzle(&message, callback_game_start, callback_game_stop);
// bool bool is_message_valid = obus_module::loop_needy(&message);
bool is_message_valid = obus_module::loopInfo(&message, info_generator);
lcd.home();
for (int i = 0; i < 7; i++) {
lcd.write(serial_number[i]);
}
}
void callback_game_start() {
}
void callback_game_stop() {
int info_generator(char* buffer) {
serial_number[0] = random('A', 'Z');
serial_number[1] = random('A', 'Z');
serial_number[2] = random('A', 'Z');
serial_number[3] = random('0', '9');
serial_number[4] = random('0', '9');
serial_number[5] = random('A', 'Z');
serial_number[6] = random('0', '9');
memcpy(buffer, serial_number, 7);
lcd.clear();
return 7;
}