desktop_settings.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #pragma once
  2. #include <furi_hal.h>
  3. #include <stdint.h>
  4. #include <stdbool.h>
  5. #include <toolbox/saved_struct.h>
  6. #define DESKTOP_SETTINGS_VER (2)
  7. #define DESKTOP_SETTINGS_PATH "/int/desktop.settings"
  8. #define DESKTOP_SETTINGS_MAGIC (0x17)
  9. #define PIN_MAX_LENGTH 12
  10. #define DESKTOP_SETTINGS_RUN_PIN_SETUP_ARG "run_pin_setup"
  11. #define SAVE_DESKTOP_SETTINGS(x) \
  12. saved_struct_save( \
  13. DESKTOP_SETTINGS_PATH, \
  14. (x), \
  15. sizeof(DesktopSettings), \
  16. DESKTOP_SETTINGS_MAGIC, \
  17. DESKTOP_SETTINGS_VER)
  18. #define LOAD_DESKTOP_SETTINGS(x) \
  19. saved_struct_load( \
  20. DESKTOP_SETTINGS_PATH, \
  21. (x), \
  22. sizeof(DesktopSettings), \
  23. DESKTOP_SETTINGS_MAGIC, \
  24. DESKTOP_SETTINGS_VER)
  25. #define MAX_PIN_SIZE 10
  26. #define MIN_PIN_SIZE 4
  27. typedef struct {
  28. InputKey data[MAX_PIN_SIZE];
  29. uint8_t length;
  30. } PinCode;
  31. typedef struct {
  32. uint16_t favorite;
  33. PinCode pin_code;
  34. uint32_t auto_lock_delay_ms;
  35. } DesktopSettings;
  36. static inline bool pins_are_equal(const PinCode* pin_code1, const PinCode* pin_code2) {
  37. furi_assert(pin_code1);
  38. furi_assert(pin_code2);
  39. bool result = false;
  40. if(pin_code1->length == pin_code2->length) {
  41. result = !memcmp(pin_code1->data, pin_code2->data, pin_code1->length);
  42. }
  43. return result;
  44. }