diff --git a/app/src/lib/stores/featureFlags.ts b/app/src/lib/stores/featureFlags.ts index febbe78..de6ee23 100644 --- a/app/src/lib/stores/featureFlags.ts +++ b/app/src/lib/stores/featureFlags.ts @@ -1,20 +1,21 @@ -import { api } from '$lib/api'; -import { notifications } from '$lib/components/toasts/notifications'; -import { writable, type Writable } from 'svelte/store'; +import { api } from '$lib/api' +import { notifications } from '$lib/components/toasts/notifications' +import { persistentStore } from '$lib/utilities' +import { type Writable } from 'svelte/store' -let featureFlagsStore: Writable>; +let featureFlagsStore: Writable> export function useFeatureFlags() { if (!featureFlagsStore) { - featureFlagsStore = writable>({}); + featureFlagsStore = persistentStore>('FeatureFlags', {}) api.get>('/api/features').then(result => { - if (result.isOk()) featureFlagsStore.set(result.inner); + if (result.isOk()) featureFlagsStore.set(result.inner) else { - notifications.error('Feature flag could not be fetched', 2500); + notifications.error('Feature flag could not be fetched', 2500) } - }); + }) } - return featureFlagsStore; + return featureFlagsStore } diff --git a/esp32/include/features.h b/esp32/include/features.h index b77cbde..3227f44 100644 --- a/esp32/include/features.h +++ b/esp32/include/features.h @@ -79,6 +79,22 @@ static_assert(!(USE_JSON == 1 && USE_MSGPACK == 1), "Cannot set both USE_JSON and USE_MSGPACK to 1 simultaneously"); +#if defined(SPOTMICRO_ESP32) && defined(SPOTMICRO_YERTLE) +#error "Only one kinematics variant must be defined" +#endif + +#if !defined(SPOTMICRO_ESP32) && !defined(SPOTMICRO_YERTLE) +#error "You must define one kinematics variant" +#endif + +#if defined(SPOTMICRO_ESP32) +#define KINEMATICS_VARIANT_STR "SPOTMICRO_ESP32" +#elif defined(SPOTMICRO_YERTLE) +#define KINEMATICS_VARIANT_STR "SPOTMICRO_YERTLE" +#else +#define KINEMATICS_VARIANT_STR "UNKNOWN" +#endif + namespace feature_service { void printFeatureConfiguration(); diff --git a/esp32/src/features.cpp b/esp32/src/features.cpp index 1265fc6..ca6a5dc 100644 --- a/esp32/src/features.cpp +++ b/esp32/src/features.cpp @@ -31,28 +31,30 @@ void printFeatureConfiguration() { ESP_LOGI("Features", "EMBED_WWW: %s", EMBED_WWW ? "enabled" : "disabled"); ESP_LOGI("Features", "ENABLE_CORS: %s", ENABLE_CORS ? "enabled" : "disabled"); ESP_LOGI("Features", "SERVE_CONFIG_FILES: %s", SERVE_CONFIG_FILES ? "enabled" : "disabled"); + ESP_LOGI("Features", "KINEMATICS_VARIANT: %s", KINEMATICS_VARIANT_STR); ESP_LOGI("Features", "=========================================================="); } void features(JsonObject &root) { - root["upload_firmware"] = USE_UPLOAD_FIRMWARE; - root["download_firmware"] = USE_DOWNLOAD_FIRMWARE; - root["sleep"] = USE_SLEEP; - root["camera"] = USE_CAMERA; - root["imu"] = USE_MPU6050 || USE_BNO055; - root["mag"] = USE_HMC5883 || USE_BNO055; - root["bmp"] = USE_BMP180; - root["sonar"] = USE_USS; - root["motion"] = USE_MOTION; - root["servo"] = USE_PCA9685; - root["ws2812"] = USE_WS2812; - root["mdns"] = USE_MDNS; - root["embed_www"] = EMBED_WWW; - root["enable_cors"] = ENABLE_CORS; - root["serve_config_files"] = SERVE_CONFIG_FILES; + root["upload_firmware"] = USE_UPLOAD_FIRMWARE ? true : false; + root["download_firmware"] = USE_DOWNLOAD_FIRMWARE ? true : false; + root["sleep"] = USE_SLEEP ? true : false; + root["camera"] = USE_CAMERA ? true : false; + root["imu"] = (USE_MPU6050 || USE_BNO055) ? true : false; + root["mag"] = (USE_HMC5883 || USE_BNO055) ? true : false; + root["bmp"] = USE_BMP180 ? true : false; + root["sonar"] = USE_USS ? true : false; + root["motion"] = USE_MOTION ? true : false; + root["servo"] = USE_PCA9685 ? true : false; + root["ws2812"] = USE_WS2812 ? true : false; + root["mdns"] = USE_MDNS ? true : false; + root["embed_www"] = EMBED_WWW ? true : false; + root["enable_cors"] = ENABLE_CORS ? true : false; + root["serve_config_files"] = SERVE_CONFIG_FILES ? true : false; root["firmware_version"] = APP_VERSION; root["firmware_name"] = APP_NAME; root["firmware_built_target"] = BUILD_TARGET; + root["variant"] = KINEMATICS_VARIANT_STR; } esp_err_t getFeatures(PsychicRequest *request) {