Do RFID scans only at specified intervals. System sounds are now supported, as well as more sound formats (.ogg, .mp4...).

This commit is contained in:
2019-08-08 05:31:27 +02:00
parent 815f11591c
commit 393db24175
5 changed files with 95 additions and 54 deletions

View File

@ -1,39 +0,0 @@
This directory is intended for project header files.
A header file is a file containing C declarations and macro definitions
to be shared between several project source files. You request the use of a
header file in your project source file (C, C++, etc) located in `src` folder
by including it, with the C preprocessing directive `#include'.
```src/main.c
#include "header.h"
int main (void)
{
...
}
```
Including a header file produces the same results as copying the header file
into each source file that needs it. Such copying would be time-consuming
and error-prone. With a header file, the related declarations appear
in only one place. If they need to be changed, they can be changed in one
place, and programs that include the header file will automatically use the
new version when next recompiled. The header file eliminates the labor of
finding and changing all the copies as well as the risk that a failure to
find one copy will result in inconsistencies within a program.
In C, the usual convention is to give header files names that end with `.h'.
It is most portable to use only letters, digits, dashes, and underscores in
header file names, and at most one dot.
Read more about using header files in official GCC documentation:
* Include Syntax
* Include Operation
* Once-Only Headers
* Computed Includes
https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html

View File

@ -12,6 +12,7 @@ private:
void _check_rfid();
void _check_serial();
Player* _player;
unsigned long _last_rfid_scan_at = 0;
public:
Controller(Player* p);
void loop();

View File

@ -28,7 +28,8 @@
class Player {
private:
enum state { uninitialized, idle, playing, stopping };
enum state { uninitialized, idle, playing, stopping,
system_sound_while_playing, system_sound_while_stopped };
struct album_state {
uint8_t index;
uint32_t position;
@ -42,10 +43,12 @@ private:
uint16_t _read_wram(uint16_t address);
state _state = state::uninitialized;
void _refill();
bool _refill_needed();
void _flush_and_cancel();
void _flush(uint bytes);
void _set_last_track(const char* album, uint8_t track, uint32_t position);
std::map<String, album_state> _last_tracks;
void _play_file(String filename, uint32_t offset);
void _finish_playing();
void _finish_stopping();
void _mute();
@ -56,6 +59,7 @@ private:
SPISettings* _spi_settings = &_spi_settings_slow;
std::list<String> _files_in_dir(String dir);
String _find_album_dir(String album);
File _file;
uint8_t _buffer[32];
String _playing_album;
@ -74,6 +78,7 @@ public:
bool play_album(String album);
bool play_song(String album, uint8_t song_index, uint32_t offset=0);
void play_system_sound(String filename);
void stop();
bool loop();
void set_volume(uint8_t vol, bool save = true);