You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

105 lines
3.8 KiB

3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
  1. #include "light.h"
  2. #include "driver/gpio.h"
  3. #include "esp_log.h"
  4. #include "port.h"
  5. #define GPIO_DEBUG_LIGHT 12
  6. #define GPIO_POWER_LIGHT 12
  7. #define GPIO_HEATING_STATE_LIGHT 12
  8. #define GPIO_REACTION_STATE_LIGHT 12
  9. #define GPIO_WIFI_STATE_LIGHT 12
  10. static power_state_light_structer_t *power_state_light_structer_s;
  11. static heating_state_light_structer_t *heating_state_light_structer_s;
  12. static reaction_state_light_structer_t *reaction_state_light_structer_s;
  13. static wifi_state_light_structer_t *wifi_state_light_structer_s;
  14. // Debug light
  15. void T_debug_light_init(void)
  16. {
  17. gpio_config_t gpio_debug_light_init_structer;
  18. gpio_debug_light_init_structer.intr_type = GPIO_INTR_DISABLE;
  19. gpio_debug_light_init_structer.mode = GPIO_MODE_INPUT_OUTPUT;
  20. gpio_debug_light_init_structer.pin_bit_mask = (1ULL << GPIO_DEBUG_LIGHT);
  21. gpio_debug_light_init_structer.pull_down_en = 0;
  22. gpio_debug_light_init_structer.pull_up_en = 0;
  23. gpio_config(&gpio_debug_light_init_structer);
  24. }
  25. void T_debug_light_toggle_level(void)
  26. {
  27. gpio_set_level(GPIO_DEBUG_LIGHT, !gpio_get_level(GPIO_DEBUG_LIGHT));
  28. }
  29. // Power light
  30. void T_power_light_init(power_state_light_structer_t *power_state_light_structer)
  31. {
  32. power_state_light_structer_s = power_state_light_structer;
  33. gpio_config_t gpio_debug_light_init_structer;
  34. gpio_debug_light_init_structer.intr_type = GPIO_INTR_DISABLE;
  35. gpio_debug_light_init_structer.mode = GPIO_MODE_INPUT_OUTPUT;
  36. gpio_debug_light_init_structer.pin_bit_mask = (1ULL << GPIO_POWER_LIGHT);
  37. gpio_debug_light_init_structer.pull_down_en = 0;
  38. gpio_debug_light_init_structer.pull_up_en = 0;
  39. gpio_config(&gpio_debug_light_init_structer);
  40. }
  41. // Heating state light
  42. void T_heating_state_light_init(heating_state_light_structer_t *heating_state_light_structer)
  43. {
  44. heating_state_light_structer_s = heating_state_light_structer;
  45. gpio_config_t gpio_heating_state_light_init_structer;
  46. gpio_heating_state_light_init_structer.intr_type = GPIO_INTR_DISABLE;
  47. gpio_heating_state_light_init_structer.mode = GPIO_MODE_INPUT_OUTPUT;
  48. gpio_heating_state_light_init_structer.pin_bit_mask = (1ULL << GPIO_HEATING_STATE_LIGHT);
  49. gpio_heating_state_light_init_structer.pull_down_en = 0;
  50. gpio_heating_state_light_init_structer.pull_up_en = 0;
  51. gpio_config(&gpio_heating_state_light_init_structer);
  52. }
  53. // Reaction state light
  54. void T_reaction_state_light_init(reaction_state_light_structer_t *reaction_state_light_structer)
  55. {
  56. reaction_state_light_structer_s = reaction_state_light_structer;
  57. gpio_config_t gpio_reaction_state_light_init_structer;
  58. gpio_reaction_state_light_init_structer.intr_type = GPIO_INTR_DISABLE;
  59. gpio_reaction_state_light_init_structer.mode = GPIO_MODE_INPUT_OUTPUT;
  60. gpio_reaction_state_light_init_structer.pin_bit_mask = (1ULL << GPIO_REACTION_STATE_LIGHT);
  61. gpio_reaction_state_light_init_structer.pull_down_en = 0;
  62. gpio_reaction_state_light_init_structer.pull_up_en = 0;
  63. gpio_config(&gpio_reaction_state_light_init_structer);
  64. }
  65. // WIFI state light
  66. void T_wifi_state_light_init(wifi_state_light_structer_t *wifi_state_light_structer)
  67. {
  68. wifi_state_light_structer_s = wifi_state_light_structer;
  69. gpio_config_t gpio_wifi_state_light_init_structer;
  70. gpio_wifi_state_light_init_structer.intr_type = GPIO_INTR_DISABLE;
  71. gpio_wifi_state_light_init_structer.mode = GPIO_MODE_INPUT_OUTPUT;
  72. gpio_wifi_state_light_init_structer.pin_bit_mask = (1ULL << GPIO_WIFI_STATE_LIGHT);
  73. gpio_wifi_state_light_init_structer.pull_down_en = 0;
  74. gpio_wifi_state_light_init_structer.pull_up_en = 0;
  75. gpio_config(&gpio_wifi_state_light_init_structer);
  76. }
  77. void T_debug_light_schedule(void)
  78. {
  79. static uint32_t debug_light_time;
  80. if (port_haspassedms(debug_light_time) > 300)
  81. {
  82. T_debug_light_toggle_level();
  83. debug_light_time = port_get_ticket();
  84. }
  85. }