It's working more or less...
This commit is contained in:
@ -1,13 +1,25 @@
|
||||
#pragma once
|
||||
|
||||
#include <Arduino.h>
|
||||
#include <MFRC522v2.h>
|
||||
#include <MFRC522Debug.h>
|
||||
#include "esmp3.h"
|
||||
#include "playlist.h"
|
||||
|
||||
class Controller {
|
||||
private:
|
||||
void handle_buttons();
|
||||
void handle_rfid();
|
||||
bool is_button_pressed(uint8_t pin);
|
||||
Playlist current_playlist;
|
||||
bool is_rfid_present = false;
|
||||
unsigned long last_rfid_check = 0;
|
||||
|
||||
public:
|
||||
void handle();
|
||||
|
||||
void next_track();
|
||||
void prev_track();
|
||||
void play();
|
||||
void play(String rfid_id);
|
||||
void stop();
|
||||
};
|
@ -1,11 +1,26 @@
|
||||
#pragma once
|
||||
#include "controller.h"
|
||||
|
||||
#define PIN_CS_SD 16
|
||||
#define PIN_CS_RFID 17
|
||||
#include "controller.h"
|
||||
#include "playlist_manager.h"
|
||||
#include <Audio.h>
|
||||
|
||||
#define PIN_CS_SD 22
|
||||
#define PIN_CS_RFID 21
|
||||
|
||||
#define PIN_BTN_VOL_UP 32
|
||||
#define PIN_BTN_VOL_DOWN 33
|
||||
#define PIN_BTN_TRACK_NEXT 34
|
||||
#define PIN_BTN_TRACK_PREV 35
|
||||
|
||||
#define I2S_DOUT 25
|
||||
#define I2S_BCLK 27
|
||||
#define I2S_LRC 26
|
||||
#define I2S_BCLK 26
|
||||
#define I2S_LRC 27
|
||||
|
||||
extern Controller controller;
|
||||
class Controller;
|
||||
|
||||
extern Controller controller;
|
||||
extern Audio audio;
|
||||
extern PlaylistManager* pm;
|
||||
extern MFRC522* rfid;
|
||||
|
||||
void save_audio_current_time();
|
@ -7,9 +7,19 @@ class Playlist {
|
||||
private:
|
||||
std::vector<String> files;
|
||||
uint8_t current_file = 0;
|
||||
uint16_t current_time = 0;
|
||||
uint32_t current_time = 0;
|
||||
void set_current_position(uint8_t file, uint32_t position=0);
|
||||
String rfid_id;
|
||||
|
||||
public:
|
||||
Playlist(String rfid_id="");
|
||||
void add_file(String filename);
|
||||
void sort();
|
||||
String get_rfid_id();
|
||||
String get_current_file_name();
|
||||
bool next_track();
|
||||
bool prev_track();
|
||||
void restart();
|
||||
void set_current_time(uint32_t time);
|
||||
uint32_t get_current_time();
|
||||
};
|
||||
|
@ -16,6 +16,7 @@ class PlaylistManager {
|
||||
std::vector<String> dirs;
|
||||
std::map<String, String> map;
|
||||
Playlist get_playlist(String rfid_id);
|
||||
bool has_playlist(String rfid_id);
|
||||
Playlist current_playlist;
|
||||
void set_audio_current_time(uint32_t time);
|
||||
};
|
Reference in New Issue
Block a user