Start Wifi after initializing VS1053 - faster bootup when multiple tries setting up VS1053 are needed.

This commit is contained in:
Fabian Schlenz 2019-09-03 06:06:51 +02:00
parent 8d67061428
commit 178683fe6c
2 changed files with 8 additions and 4 deletions

View File

@ -30,7 +30,8 @@ private:
unsigned long _last_mqtt_report_at = 0;
void _send_mqtt_report();
public:
Controller(Player* p, MCP* m, MQTTClient* mqtt);
Controller(Player* p, MCP* m);
void set_mqtt_client(MQTTClient* m);
String get_status_json();
void loop();
};

View File

@ -1,10 +1,9 @@
#include "controller.h"
#include "spi_master.h"
Controller::Controller(Player* p, MCP* m, MQTTClient* mqtt) {
Controller::Controller(Player* p, MCP* m) {
_player = p;
_mcp = m;
_mqtt_client = mqtt;
_rfid = new MFRC522(PIN_RC522_CS, MFRC522::UNUSED_PIN);
SPIMaster::enable(PIN_MCP);
@ -25,6 +24,10 @@ Controller::Controller(Player* p, MCP* m, MQTTClient* mqtt) {
for (uint8_t i=0; i<NUM_BUTTONS; i++) _button_last_pressed_at[i]=0;
}
void Controller::set_mqtt_client(MQTTClient* m) {
_mqtt_client = m;
}
void Controller::loop() {
unsigned long now = millis();
if ((_last_rfid_scan_at < now - RFID_SCAN_INTERVAL) || (now < _last_rfid_scan_at)) {
@ -33,7 +36,7 @@ void Controller::loop() {
}
_check_serial();
_check_buttons();
if ((_last_mqtt_report_at < now - MQTT_REPORT_INTERVAL) || (now < _last_mqtt_report_at)) {
_send_mqtt_report();
_last_mqtt_report_at = now;