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.

45 lines
1.4 KiB

3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
  1. #include "key.h"
  2. #include "esp_log.h"
  3. #include "driver/gpio.h"
  4. static key_ble_cb_t s_ble_gattc_write_char;
  5. void key_init()
  6. {
  7. gpio_config_t gpio_grb_led_structer;
  8. gpio_grb_led_structer.intr_type = GPIO_INTR_DISABLE;
  9. gpio_grb_led_structer.mode = GPIO_MODE_INPUT;
  10. gpio_grb_led_structer.pin_bit_mask = GPIO_KEY_INPUT_PIN_SEL;
  11. gpio_grb_led_structer.pull_down_en = 0;
  12. gpio_grb_led_structer.pull_up_en = 0;
  13. gpio_config(&gpio_grb_led_structer);
  14. }
  15. void key_schedule()
  16. {
  17. if (gpio_get_level(KEY_REC) == 0)
  18. {
  19. /* code */
  20. char *send_string = "{ \"order\": \"setPosition\", \"index\": 0, \"speedLevel\": 0, \"position\": 180, \"direction\": 1 }";
  21. ESP_LOGI("Finny", "KEY_REC level 0");
  22. while (gpio_get_level(KEY_REC) == 0)
  23. {
  24. }
  25. s_ble_gattc_write_char(send_string, strlen(send_string));
  26. ESP_LOGI("Finny", "stop");
  27. }
  28. if (gpio_get_level(KEY_MODE) == 0)
  29. {
  30. char *send_string = "{ \"order\": \"setPosition\", \"index\": 0, \"speedLevel\": 0, \"position\": 360, \"direction\": 1 }";
  31. /* code */
  32. ESP_LOGI("Finny", "KEY_MODE level 0");
  33. while (gpio_get_level(KEY_MODE) == 0)
  34. {
  35. }
  36. s_ble_gattc_write_char(send_string, strlen(send_string));
  37. ESP_LOGI("Finny", "stop");
  38. }
  39. }
  40. void key_ble_send_cmd_reg(key_ble_cb_t cb) { s_ble_gattc_write_char = cb; };