This commit is contained in:
e2002
2022-04-05 12:18:25 +03:00
parent 864d8f9dcd
commit 40f194ab26
40 changed files with 530 additions and 367 deletions

View File

@@ -11,17 +11,9 @@
#include "controls.h"
#include "mqtt.h"
#if CORE_FOR_LOOP_CONTROLS != 255
TaskHandle_t TaskCore0;
#ifndef CORE_FOR_LOOP_STACK_SIZE
#define CORE_FOR_LOOP_STACK_SIZE 8192
#endif
#endif
void setup() {
Serial.begin(115200);
pinMode(LED_BUILTIN, OUTPUT);
//digitalWrite(LED_BUILTIN, LOW);
config.init();
display.init();
player.init();
@@ -34,57 +26,22 @@ void setup() {
netserver.begin();
telnet.begin();
player.setVol(config.store.volume, true);
if(CORE_FOR_LOOP_CONTROLS == 255){
initControls();
display.start();
}
initControls();
display.start();
#ifdef MQTT_HOST
mqttInit();
#endif
#if CORE_FOR_LOOP_CONTROLS != 255
BaseType_t coreId = xPortGetCoreID();
BaseType_t newCoreId = (CORE_FOR_LOOP_CONTROLS==2)?!coreId:CORE_FOR_LOOP_CONTROLS;
xTaskCreatePinnedToCore(
loopCore0, /* Task function. */
"TaskCore0", /* name of task. */
CORE_FOR_LOOP_STACK_SIZE, /* Stack size of task */
NULL, /* parameter of the task */
1, /* priority of the task */
&TaskCore0, /* Task handle to keep track of created task */
newCoreId); /* pin task to core CORE_FOR_LOOP_CONTROLS */
#endif
delay(500);
if(config.store.smartstart==1) player.play(config.store.lastStation);
if (config.store.smartstart == 1) player.play(config.store.lastStation);
}
#if CORE_FOR_LOOP_CONTROLS != 255
void setupCore0(){
initControls();
display.start();
}
void loopCore0( void * pvParameters ){
setupCore0();
for(;;){
micros();
if (network.status == CONNECTED) {
loopControls();
}
display.loop();
vTaskDelay(10);
}
}
#endif
void loop() {
if (network.status == CONNECTED) {
telnet.loop();
player.loop();
if(CORE_FOR_LOOP_CONTROLS==255) loopControls();
loopControls();
}
if(CORE_FOR_LOOP_CONTROLS==255 || network.status != CONNECTED) display.loop();
display.loop();
netserver.loop();
}