Power off drops the peripheral rail (PWR_ON low), sleeps the panel and puts the chip into deep sleep with ext1 wake armed on the encoder pins, choosing any-low or any-high from the knob's resting state so a single detent wakes it. The button (GPIO0) is not a wake source on purpose.
38 lines
1.4 KiB
C
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 24
|
|
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);
|