2019-08-02 21:48:36 +00:00
|
|
|
#pragma once
|
|
|
|
|
2019-08-06 18:50:11 +00:00
|
|
|
#include <Arduino.h>
|
|
|
|
#include "config.h"
|
2019-08-02 21:48:36 +00:00
|
|
|
#include "player.h"
|
2019-08-06 18:50:11 +00:00
|
|
|
#include <MFRC522.h>
|
2019-08-11 15:15:22 +00:00
|
|
|
#include <MCP23S17/MCP23S17.h>
|
2019-08-02 21:48:36 +00:00
|
|
|
|
|
|
|
class Controller {
|
|
|
|
private:
|
2019-08-06 18:50:11 +00:00
|
|
|
MFRC522* _rfid;
|
2019-08-11 15:15:22 +00:00
|
|
|
MCP* _mcp;
|
2019-08-06 18:50:11 +00:00
|
|
|
bool _rfid_enabled = true;
|
|
|
|
void _check_rfid();
|
|
|
|
void _check_serial();
|
2019-08-11 15:15:22 +00:00
|
|
|
void _check_buttons();
|
2019-08-08 04:49:35 +00:00
|
|
|
uint32_t _get_rfid_card_uid();
|
|
|
|
uint32_t _last_rfid_card_uid = 0;
|
2019-08-12 18:15:00 +00:00
|
|
|
uint8_t _no_rfid_card_count = 0;
|
2019-08-02 21:48:36 +00:00
|
|
|
Player* _player;
|
2019-08-08 03:31:27 +00:00
|
|
|
unsigned long _last_rfid_scan_at = 0;
|
2019-08-09 04:27:33 +00:00
|
|
|
String _serial_buffer = String();
|
|
|
|
void _execute_serial_command(String cmd);
|
|
|
|
void _execute_command_ls(String path);
|
|
|
|
void _execute_command_help();
|
2019-08-11 15:15:22 +00:00
|
|
|
unsigned long _button_last_pressed_at[NUM_BUTTONS];
|
|
|
|
bool _check_button(uint8_t btn);
|
2019-08-02 21:48:36 +00:00
|
|
|
public:
|
2019-08-11 15:15:22 +00:00
|
|
|
Controller(Player* p, MCP* m);
|
2019-08-12 18:15:00 +00:00
|
|
|
String rfid_uid() { return String(_last_rfid_card_uid, HEX); }
|
2019-08-06 18:50:11 +00:00
|
|
|
void loop();
|
2019-08-02 21:48:36 +00:00
|
|
|
};
|