Die Position in einer Playlist beilbt beibehalten, solange die Papabox nicht neu gestartet wird.
This commit is contained in:
@ -15,6 +15,7 @@ class Controller {
|
||||
bool is_rfid_present = false;
|
||||
unsigned long last_rfid_check = 0;
|
||||
unsigned long last_button_check = 0;
|
||||
unsigned long last_position_save = 0;
|
||||
uint8_t button_pressed = 0;
|
||||
unsigned long button_pressed_since = 0;
|
||||
bool button_already_processed = false;
|
||||
|
9
include/persisted_playlist.h
Normal file
9
include/persisted_playlist.h
Normal file
@ -0,0 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
|
||||
struct PersistedPlaylist {
|
||||
String dir;
|
||||
uint16_t file = 0;
|
||||
uint32_t position = 0;
|
||||
PersistedPlaylist(String s="") : dir(s) {}
|
||||
};
|
@ -2,17 +2,19 @@
|
||||
|
||||
#include <vector>
|
||||
#include <Arduino.h>
|
||||
#include "persisted_playlist.h"
|
||||
|
||||
class Playlist {
|
||||
private:
|
||||
std::vector<String> files;
|
||||
uint8_t current_file = 0;
|
||||
uint32_t current_time = 0;
|
||||
void set_current_position(uint8_t file, uint32_t position=0);
|
||||
String rfid_id;
|
||||
PersistedPlaylist* pp;
|
||||
|
||||
public:
|
||||
Playlist(String rfid_id="");
|
||||
Playlist();
|
||||
Playlist(String rfid_id, PersistedPlaylist* p);
|
||||
void add_file(String filename);
|
||||
void sort();
|
||||
String get_rfid_id();
|
||||
@ -23,4 +25,6 @@ class Playlist {
|
||||
void set_current_time(uint32_t time);
|
||||
uint32_t get_current_time();
|
||||
void shuffle();
|
||||
void set_current_position(uint8_t file, uint32_t position=0);
|
||||
void save_current_position(uint32_t position=0);
|
||||
};
|
||||
|
@ -4,6 +4,9 @@
|
||||
#include <map>
|
||||
#include <Arduino.h>
|
||||
#include "playlist.h"
|
||||
#include "persisted_playlist.h"
|
||||
|
||||
class Playlist;
|
||||
|
||||
class PlaylistManager {
|
||||
private:
|
||||
@ -13,9 +16,10 @@ class PlaylistManager {
|
||||
|
||||
public:
|
||||
PlaylistManager();
|
||||
std::map<String, String> map;
|
||||
std::map<String, PersistedPlaylist> map;
|
||||
Playlist get_playlist(String rfid_id);
|
||||
bool has_playlist(String rfid_id);
|
||||
Playlist current_playlist;
|
||||
void set_audio_current_time(uint32_t time);
|
||||
String pp_to_String();
|
||||
};
|
Reference in New Issue
Block a user