S&B Volcano vaporizer remote control with Pi Pico W
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /*
  2. * mem.h
  3. *
  4. * Copyright (c) 2023 Thomas Buck (thomas@xythobuz.de)
  5. *
  6. * This program is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * See <http://www.gnu.org/licenses/>.
  17. */
  18. #ifndef __MEM_H__
  19. #define __MEM_H__
  20. #include "hardware/flash.h"
  21. #include "pico/btstack_flash_bank.h"
  22. #include <stdint.h>
  23. #include <stdbool.h>
  24. #include "workflow.h"
  25. #include "wifi.h"
  26. /*
  27. * Last two flash pages are used by BTstack.
  28. * So we use the third-last page for our persistent storage.
  29. * This is kept clear by our custom linker script.
  30. */
  31. #define EEPROM_FLASH_OFFSET (PICO_FLASH_BANK_STORAGE_OFFSET - FLASH_SECTOR_SIZE)
  32. // to migrate settings when struct changes between releases
  33. #define MEM_VERSION 0
  34. struct mem_data {
  35. // wifi networks
  36. // should stay at beginning, for bootloader
  37. uint16_t net_count;
  38. struct net_credentials net[WIFI_MAX_NET_COUNT];
  39. // settings
  40. uint16_t backlight;
  41. bool wf_auto_connect;
  42. bool enable_wifi;
  43. // workflows
  44. uint16_t wf_count;
  45. struct workflow wf[WF_MAX_FLOWS];
  46. };
  47. // workflows are assigned in mem_init()
  48. #define MEM_DATA_INIT { \
  49. .backlight = (0xFF00 >> 1), \
  50. .wf_auto_connect = false, \
  51. .enable_wifi = false, \
  52. .wf_count = 0, \
  53. .net_count = 0, \
  54. }
  55. void mem_load(void);
  56. void mem_write(void);
  57. struct mem_data *mem_data(void);
  58. void mem_load_defaults(void);
  59. #endif // __MEM_H__