Added sleep mode for VS1053, HTTP server, tar upload, JSON status, RFID card removal debouncing, ...
This commit is contained in:
@ -16,6 +16,7 @@ private:
|
||||
void _check_buttons();
|
||||
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();
|
||||
@ -26,5 +27,6 @@ private:
|
||||
bool _check_button(uint8_t btn);
|
||||
public:
|
||||
Controller(Player* p, MCP* m);
|
||||
String rfid_uid() { return String(_last_rfid_card_uid, HEX); }
|
||||
void loop();
|
||||
};
|
||||
|
28
include/http_server.h
Normal file
28
include/http_server.h
Normal file
@ -0,0 +1,28 @@
|
||||
#pragma once
|
||||
#include <ESP8266WebServer.h>
|
||||
#include "spi_master.h"
|
||||
#include "player.h"
|
||||
#include "controller.h"
|
||||
#include <SD.h>
|
||||
#include <WiFiClient.h>
|
||||
#include <ESP8266WiFi.h>
|
||||
#include <ESP8266mDNS.h>
|
||||
|
||||
class HTTPServer {
|
||||
private:
|
||||
ESP8266WebServer* _http_server;
|
||||
void _handle_upload();
|
||||
uint16_t _chunk_length;
|
||||
uint8_t* _chunk;
|
||||
uint32_t _file_size;
|
||||
uint32_t _file_size_done;
|
||||
bool _need_header;
|
||||
uint32_t _upload_position;
|
||||
void _handle_index();
|
||||
void _handle_status();
|
||||
Player* _player;
|
||||
Controller* _controller;
|
||||
public:
|
||||
HTTPServer(Player* p, Controller* c);
|
||||
void loop();
|
||||
};
|
@ -10,6 +10,7 @@
|
||||
#define SCI_STATUS 0x01
|
||||
#define SCI_CLOCKF 0x03
|
||||
#define SCI_DECODE_TIME 0x04
|
||||
#define SCI_AUDATA 0x05
|
||||
#define SCI_VOL 0x0B
|
||||
#define SCI_WRAMADDR 0x07
|
||||
#define SCI_WRAM 0x06
|
||||
@ -30,7 +31,8 @@
|
||||
class Player {
|
||||
private:
|
||||
enum state { uninitialized, idle, playing, stopping,
|
||||
system_sound_while_playing, system_sound_while_stopped };
|
||||
system_sound_while_playing, system_sound_while_stopped,
|
||||
sleeping };
|
||||
struct album_state {
|
||||
uint8_t index;
|
||||
uint32_t position;
|
||||
@ -51,12 +53,15 @@ private:
|
||||
void _flush(uint count, int8_t fill_byte);
|
||||
void _set_last_track(const char* album, uint8_t track, uint32_t position);
|
||||
std::map<String, album_state> _last_tracks;
|
||||
String _random_album();
|
||||
void _play_file(String filename, uint32_t offset);
|
||||
uint32_t _id3_tag_offset(File f);
|
||||
void _finish_playing();
|
||||
void _finish_stopping();
|
||||
void _mute();
|
||||
void _unmute();
|
||||
void _sleep();
|
||||
void _wakeup();
|
||||
|
||||
SPISettings _spi_settings_slow = SPISettings(250000, MSBFIRST, SPI_MODE0);
|
||||
SPISettings _spi_settings_fast = SPISettings(4000000, MSBFIRST, SPI_MODE0);
|
||||
@ -75,18 +80,25 @@ private:
|
||||
uint16_t _stop_delay;
|
||||
uint32_t _skip_to;
|
||||
MCP* _mcp;
|
||||
unsigned long _stopped_at;
|
||||
public:
|
||||
Player(MCP* m);
|
||||
void vol_up();
|
||||
void vol_down();
|
||||
void track_next();
|
||||
void track_prev();
|
||||
bool is_playing();
|
||||
|
||||
bool play_album(String album);
|
||||
void play_random_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);
|
||||
std::list<String> ls(String path);
|
||||
std::list<String> ls(String path, bool withFiles=true, bool withDirs=true, bool withHidden=false);
|
||||
String album() { return _playing_album; }
|
||||
uint8_t track() { return _playing_index; }
|
||||
uint32_t position() { return _current_play_position; }
|
||||
uint8_t volume() { return _volume; }
|
||||
};
|
||||
|
Reference in New Issue
Block a user