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.

113 lines
3.9 KiB

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