2019-08-02 21:48:36 +00:00
|
|
|
#include <Arduino.h>
|
2019-08-04 11:42:07 +00:00
|
|
|
#include <SPI.h>
|
2019-08-06 18:50:11 +00:00
|
|
|
#include <SD.h>
|
2019-08-02 21:48:36 +00:00
|
|
|
#include "config.h"
|
|
|
|
#include "controller.h"
|
|
|
|
#include "player.h"
|
2019-08-04 11:42:07 +00:00
|
|
|
#include "spi_master.h"
|
2019-08-02 21:48:36 +00:00
|
|
|
|
|
|
|
Controller* controller;
|
|
|
|
Player* player;
|
|
|
|
|
|
|
|
void setup() {
|
2019-08-06 18:50:11 +00:00
|
|
|
delay(500);
|
2019-08-04 11:42:07 +00:00
|
|
|
Serial.begin(74880);
|
2019-08-09 04:27:33 +00:00
|
|
|
INFO("Starting.\n");
|
|
|
|
INFO("Initializing...\n");
|
2019-08-04 11:42:07 +00:00
|
|
|
|
2019-08-09 04:27:33 +00:00
|
|
|
DEBUG("Setting up SPI...\n");
|
2019-08-04 11:42:07 +00:00
|
|
|
SPI.begin();
|
|
|
|
SPIMaster::init();
|
2019-08-09 04:27:33 +00:00
|
|
|
INFO("SPI initialized.\n");
|
2019-08-04 11:42:07 +00:00
|
|
|
|
2019-08-09 04:27:33 +00:00
|
|
|
DEBUG("Setting up SD card...\n");
|
2019-08-06 18:50:11 +00:00
|
|
|
SPIMaster::enable(PIN_SD_CS);
|
|
|
|
if (SD.begin(PIN_SD_CS)) {
|
2019-08-09 04:27:33 +00:00
|
|
|
INFO("SD card initialized.\n");
|
2019-08-06 18:50:11 +00:00
|
|
|
} else {
|
2019-08-09 04:27:33 +00:00
|
|
|
ERROR("Could not initialize SD card. Halting.\n");
|
2019-08-06 18:50:11 +00:00
|
|
|
while(1);
|
|
|
|
}
|
|
|
|
player = new Player();
|
|
|
|
controller = new Controller(player);
|
2019-08-09 04:27:33 +00:00
|
|
|
|
|
|
|
INFO("Initialization completed.\n");
|
2019-08-02 21:48:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void loop() {
|
2019-08-06 18:50:11 +00:00
|
|
|
bool more_data_needed = player->loop();
|
|
|
|
if (more_data_needed) return;
|
2019-08-02 21:48:36 +00:00
|
|
|
|
2019-08-06 18:50:11 +00:00
|
|
|
controller->loop();
|
2019-08-02 21:48:36 +00:00
|
|
|
}
|