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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /*
  2. * state_wifi_edit.c
  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. #include <stddef.h>
  19. #include <stdio.h>
  20. #include "config.h"
  21. #include "menu.h"
  22. #include "mem.h"
  23. #include "state.h"
  24. #include "state_string.h"
  25. #include "state_wifi_edit.h"
  26. static uint16_t wifi_index = 0;
  27. static void exit_cb(void) {
  28. state_switch(STATE_SETTINGS);
  29. }
  30. static void enter_cb(int selection) {
  31. switch (selection) {
  32. case 0:
  33. // SSID
  34. state_string_set(mem_data()->net[wifi_index].name,
  35. WIFI_MAX_NAME_LEN, "SSID");
  36. state_string_return(STATE_WIFI_EDIT);
  37. state_switch(STATE_STRING);
  38. break;
  39. case 1:
  40. // Password
  41. state_string_set(mem_data()->net[wifi_index].pass,
  42. WIFI_MAX_NAME_LEN, "Password");
  43. state_string_return(STATE_WIFI_EDIT);
  44. state_switch(STATE_STRING);
  45. break;
  46. default:
  47. exit_cb();
  48. break;
  49. }
  50. }
  51. void state_wifi_edit_index(uint16_t index) {
  52. wifi_index = index;
  53. }
  54. void state_wifi_edit_enter(void) {
  55. menu_init(enter_cb, NULL, NULL, exit_cb);
  56. }
  57. void state_wifi_edit_exit(void) {
  58. menu_deinit();
  59. }
  60. static void draw(struct menu_state *menu) {
  61. int pos = 0;
  62. menu->length = 0;
  63. ADD_STATIC_ELEMENT("SSID: '%s'", mem_data()->net[wifi_index].name);
  64. ADD_STATIC_ELEMENT("Pass: '%s'", mem_data()->net[wifi_index].pass);
  65. ADD_STATIC_ELEMENT("... go back");
  66. if (menu->selection < 0) {
  67. menu->selection = 0;
  68. }
  69. }
  70. void state_wifi_edit_run(void) {
  71. menu_run(draw, false);
  72. }