Files
t-embed-insecam-widget/main/settings.h
T
Juli 1ea7b13bc7 50 favourite slots; favourite lists show only used slots
Save-to-slot preselects the first empty slot; the favourites cache lives
in PSRAM.
2026-09-17 03:00:19 +02:00

38 lines
1.4 KiB
C

#pragma once
#include <stdbool.h>
#include <stdint.h>
#include "insecam.h"
// Persistent settings (NVS namespace "widget"); Kconfig supplies first-boot defaults.
typedef enum { LISTING_MIXED = 0, LISTING_RATING, LISTING_NEW } listing_pref_t;
typedef enum { SOURCE_RANDOM = 0, SOURCE_FAVORITES } source_pref_t;
typedef enum { PROVIDER_PREF_INSECAM = 0, PROVIDER_PREF_OPENTOPIA, PROVIDER_PREF_MIXED } provider_pref_t;
typedef struct {
uint16_t interval_s; // 5..300
uint8_t lcd_brightness; // 0..100
uint8_t led_brightness; // 0..255
uint8_t listing; // listing_pref_t
uint8_t source; // source_pref_t
uint8_t caption; // 1 = caption shown
uint8_t provider; // provider_pref_t (appended; older blobs load with the default)
uint8_t version; // SETTINGS_VERSION; lets us tell a pre-provider blob apart
} settings_t;
#define SETTINGS_VERSION 2
extern settings_t settings;
void settings_init(void); // nvs_flash_init + load settings and favourites
void settings_save(void);
// One-shot flag: reboot into the Wi-Fi setup hotspot.
void settings_request_portal(void);
bool settings_take_portal_request(void);
#define FAV_SLOTS 50
const cam_info_t *fav_get(int slot); // NULL when empty
void fav_set(int slot, const cam_info_t *cam);
void fav_clear(int slot);
int fav_find(const cam_info_t *cam); // slot holding this camera (by id), or -1
int fav_count(void);