Added MCP23S17 support as well as changed some pins and added more de-bouncing for the buttons.
This commit is contained in:
@ -4,13 +4,16 @@
|
||||
#include "config.h"
|
||||
#include "player.h"
|
||||
#include <MFRC522.h>
|
||||
#include <MCP23S17/MCP23S17.h>
|
||||
|
||||
class Controller {
|
||||
private:
|
||||
MFRC522* _rfid;
|
||||
MCP* _mcp;
|
||||
bool _rfid_enabled = true;
|
||||
void _check_rfid();
|
||||
void _check_serial();
|
||||
void _check_buttons();
|
||||
uint32_t _get_rfid_card_uid();
|
||||
uint32_t _last_rfid_card_uid = 0;
|
||||
Player* _player;
|
||||
@ -19,7 +22,9 @@ private:
|
||||
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);
|
||||
public:
|
||||
Controller(Player* p);
|
||||
Controller(Player* p, MCP* m);
|
||||
void loop();
|
||||
};
|
||||
|
@ -4,6 +4,7 @@
|
||||
#include <SD.h>
|
||||
#include <list>
|
||||
#include <map>
|
||||
#include <MCP23S17/MCP23S17.h>
|
||||
|
||||
#define SCI_MODE 0x00
|
||||
#define SCI_STATUS 0x01
|
||||
@ -72,8 +73,9 @@ private:
|
||||
uint8_t _volume;
|
||||
uint16_t _stop_delay;
|
||||
uint32_t _skip_to;
|
||||
MCP* _mcp;
|
||||
public:
|
||||
Player();
|
||||
Player(MCP* m);
|
||||
void vol_up();
|
||||
void vol_down();
|
||||
void track_next();
|
||||
|
@ -11,18 +11,22 @@ public:
|
||||
pinMode(PIN_SD_CS, OUTPUT);
|
||||
pinMode(PIN_VS1053_XCS, OUTPUT);
|
||||
pinMode(PIN_VS1053_XDCS, OUTPUT);
|
||||
pinMode(PIN_MCP, OUTPUT);
|
||||
}
|
||||
static void enable(uint8_t pin) {
|
||||
digitalWrite(PIN_SD_CS, pin==PIN_SD_CS ? LOW : HIGH);
|
||||
digitalWrite(PIN_VS1053_XCS, pin==PIN_VS1053_XCS ? LOW : HIGH);
|
||||
digitalWrite(PIN_VS1053_XDCS, pin==PIN_VS1053_XDCS ? LOW : HIGH);
|
||||
digitalWrite(PIN_MCP, pin==PIN_MCP ? LOW : HIGH);
|
||||
|
||||
}
|
||||
|
||||
static void printStatus() {
|
||||
Serial.printf("CS state: SD:%d, VS1053_XCS:%d, VS1053_XDCS:%d\n",
|
||||
Serial.printf("CS state: SD:%d, VS1053_XCS:%d, VS1053_XDCS:%d, MCP:%d\n",
|
||||
digitalRead(PIN_SD_CS),
|
||||
digitalRead(PIN_VS1053_XCS),
|
||||
digitalRead(PIN_VS1053_XDCS));
|
||||
digitalRead(PIN_VS1053_XDCS),
|
||||
digitalRead(PIN_MCP));
|
||||
}
|
||||
|
||||
static void disable() {
|
||||
|
Reference in New Issue
Block a user