38 lines
937 B
C++
38 lines
937 B
C++
#pragma once
|
|
|
|
#include <Arduino.h>
|
|
#include "config.h"
|
|
#include "player.h"
|
|
#include "mqtt_client.h"
|
|
#include <MFRC522.h>
|
|
|
|
class Controller {
|
|
private:
|
|
MFRC522* _rfid;
|
|
SPIMaster* _spi;
|
|
MQTTClient* _mqtt_client;
|
|
bool _rfid_enabled = true;
|
|
void _check_rfid();
|
|
void _check_serial();
|
|
void _check_buttons();
|
|
bool _debounce_button(uint8_t index);
|
|
uint32_t _get_rfid_card_uid();
|
|
uint32_t _last_rfid_card_uid = 0;
|
|
uint8_t _no_rfid_card_count = 0;
|
|
Player* _player;
|
|
unsigned long _last_rfid_scan_at = 0;
|
|
String _serial_buffer = String();
|
|
void _execute_serial_command(String cmd);
|
|
void _execute_command_ls(String path);
|
|
void _execute_command_help();
|
|
unsigned long _button_last_pressed_at[NUM_BUTTONS];
|
|
bool _check_button(uint8_t btn);
|
|
unsigned long _last_mqtt_report_at = 0;
|
|
void _send_mqtt_report();
|
|
public:
|
|
Controller(Player* p, SPIMaster* s);
|
|
void set_mqtt_client(MQTTClient* m);
|
|
String get_status_json();
|
|
void loop();
|
|
};
|