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.
 
 
 
 

46 lines
1.4 KiB

#include "key.h"
#include "esp_log.h"
#include "driver/gpio.h"
static key_ble_cb_t s_ble_gattc_write_char;
void key_init()
{
gpio_config_t gpio_grb_led_structer;
gpio_grb_led_structer.intr_type = GPIO_INTR_DISABLE;
gpio_grb_led_structer.mode = GPIO_MODE_INPUT;
gpio_grb_led_structer.pin_bit_mask = GPIO_KEY_INPUT_PIN_SEL;
gpio_grb_led_structer.pull_down_en = 0;
gpio_grb_led_structer.pull_up_en = 0;
gpio_config(&gpio_grb_led_structer);
}
void key_schedule()
{
if (gpio_get_level(KEY_REC) == 0)
{
/* code */
char *send_string = "{ \"order\": \"setPosition\", \"index\": 0, \"speedLevel\": 0, \"position\": 180, \"direction\": 1 }";
ESP_LOGI("Finny", "KEY_REC level 0");
while (gpio_get_level(KEY_REC) == 0)
{
}
s_ble_gattc_write_char(send_string, strlen(send_string));
ESP_LOGI("Finny", "stop");
}
if (gpio_get_level(KEY_MODE) == 0)
{
char *send_string = "{ \"order\": \"setPosition\", \"index\": 0, \"speedLevel\": 0, \"position\": 360, \"direction\": 1 }";
/* code */
ESP_LOGI("Finny", "KEY_MODE level 0");
while (gpio_get_level(KEY_MODE) == 0)
{
}
s_ble_gattc_write_char(send_string, strlen(send_string));
ESP_LOGI("Finny", "stop");
}
}
void key_ble_send_cmd_reg(key_ble_cb_t cb) { s_ble_gattc_write_char = cb; };