mirror of
https://github.com/sle118/squeezelite-esp32.git
synced 2025-12-09 04:57:06 +03:00
make targets "loadable"
This commit is contained in:
@@ -1,13 +1,4 @@
|
||||
# This should be made a pure CMake component but as CMake is even
|
||||
# more shitty under Windows, backslash in path screws it all
|
||||
|
||||
if(CONFIG_MUSE)
|
||||
message("Compiling for MUSE")
|
||||
set(src_dirs "muse")
|
||||
else()
|
||||
set(src_dirs ".")
|
||||
endif()
|
||||
|
||||
idf_component_register( SRC_DIRS ${src_dirs}
|
||||
idf_component_register( SRC_DIRS . muse
|
||||
INCLUDE_DIRS .
|
||||
PRIV_REQUIRES services
|
||||
)
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
// weak should do the job but it does not...
|
||||
__attribute__((weak)) void target_init(void) {
|
||||
}
|
||||
@@ -10,6 +10,7 @@
|
||||
//#include <driver/adc.h>
|
||||
#include "driver/rmt.h"
|
||||
#include "monitor.h"
|
||||
#include "targets.h"
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
//*********************** NeoPixels ***************************
|
||||
@@ -44,11 +45,15 @@ static const char TAG[] = "muse";
|
||||
|
||||
static void (*battery_handler_chain)(float value);
|
||||
static void battery_svc(float value);
|
||||
static bool init(void);
|
||||
|
||||
void target_init(void) {
|
||||
const struct target_s target_muse = { "muse", init };
|
||||
|
||||
static bool init(void) {
|
||||
battery_handler_chain = battery_handler_svc;
|
||||
battery_handler_svc = battery_svc;
|
||||
ESP_LOGI(TAG, "Initializing for Muse");
|
||||
return true;
|
||||
}
|
||||
|
||||
static void battery_svc(float value) {
|
||||
|
||||
11
components/targets/targets.c
Normal file
11
components/targets/targets.c
Normal file
@@ -0,0 +1,11 @@
|
||||
#include "string.h"
|
||||
#include "targets.h"
|
||||
|
||||
const struct target_s *target_set[] = { &target_muse, NULL };
|
||||
|
||||
void target_init(char *target) {
|
||||
for (int i = 0; target_set[i]; i++) if (strcasestr(target_set[i]->model, target)) {
|
||||
target_set[i]->init();
|
||||
break;
|
||||
}
|
||||
}
|
||||
22
components/targets/targets.h
Normal file
22
components/targets/targets.h
Normal file
@@ -0,0 +1,22 @@
|
||||
/*
|
||||
* Squeezelite for esp32
|
||||
*
|
||||
* (c) Sebastien 2019
|
||||
* Philippe G. 2019, philippe_44@outlook.com
|
||||
*
|
||||
* This software is released under the MIT License.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "stddef.h"
|
||||
#include "stdbool.h"
|
||||
|
||||
struct target_s {
|
||||
char *model;
|
||||
bool (*init)(void);
|
||||
};
|
||||
|
||||
extern const struct target_s target_muse;
|
||||
Reference in New Issue
Block a user