mirror of
https://github.com/qmk/qmk_firmware.git
synced 2025-03-12 06:28:27 +00:00
format smart_blae.c
This commit is contained in:
parent
9b3c02bbd9
commit
871456fdbe
@ -11,47 +11,42 @@
|
||||
#include "smart_ble.h"
|
||||
|
||||
static uint8_t sc_ble_leds(void) {
|
||||
return 0; // TODO: Get LED status BLE
|
||||
return 0; // TODO: Get LED status BLE
|
||||
}
|
||||
|
||||
static void sc_ble_mouse(report_mouse_t *report) {
|
||||
static uint8_t last_report[sizeof(report_mouse_t)]={0};
|
||||
static uint8_t last_report[sizeof(report_mouse_t)] = {0};
|
||||
|
||||
if (!has_mouse_report_changed((report_mouse_t *)last_report, report)) return;
|
||||
memcpy(last_report,report,sizeof(report_mouse_t));
|
||||
memcpy(last_report, report, sizeof(report_mouse_t));
|
||||
uart_write(0x55);
|
||||
uart_write(sizeof(report_mouse_t));
|
||||
uart_transmit(last_report,sizeof(report_mouse_t));
|
||||
uart_transmit(last_report, sizeof(report_mouse_t));
|
||||
}
|
||||
|
||||
|
||||
static void sc_ble_extra(report_extra_t *report) {
|
||||
uart_write(0x55);
|
||||
uart_write(sizeof(report_extra_t));
|
||||
uart_transmit((uint8_t *)report,sizeof(report_extra_t));
|
||||
uart_transmit((uint8_t *)report, sizeof(report_extra_t));
|
||||
}
|
||||
|
||||
static void sc_ble_keyboard(report_keyboard_t *report) {
|
||||
uart_write(0x55);
|
||||
uart_write(0x09);
|
||||
uart_write(0x01);
|
||||
uart_transmit((uint8_t *)report,KEYBOARD_REPORT_SIZE);
|
||||
uart_transmit((uint8_t *)report, KEYBOARD_REPORT_SIZE);
|
||||
}
|
||||
|
||||
static void sc_send_nkro(report_nkro_t *report)
|
||||
{
|
||||
static void sc_send_nkro(report_nkro_t *report) {
|
||||
uart_write(0x55);
|
||||
uart_write(0x12);
|
||||
uart_transmit((uint8_t *)report,0x12);
|
||||
uart_transmit((uint8_t *)report, 0x12);
|
||||
}
|
||||
|
||||
static host_driver_t *last_host_driver = NULL;
|
||||
static host_driver_t sc_ble_driver = {
|
||||
sc_ble_leds, sc_ble_keyboard,sc_send_nkro,sc_ble_mouse, sc_ble_extra
|
||||
};
|
||||
static host_driver_t sc_ble_driver = {sc_ble_leds, sc_ble_keyboard, sc_send_nkro, sc_ble_mouse, sc_ble_extra};
|
||||
|
||||
|
||||
void smart_ble_startup(void) {
|
||||
void smart_ble_startup(void) {
|
||||
if (host_get_driver() == &sc_ble_driver) {
|
||||
return;
|
||||
}
|
||||
@ -68,38 +63,34 @@ void smart_ble_disconnect(void) {
|
||||
host_set_driver(last_host_driver);
|
||||
}
|
||||
|
||||
|
||||
void sc_ble_battary(uint8_t batt_level) {
|
||||
uart_write(0x55);
|
||||
uart_write(0x02);
|
||||
uart_write(0x09);
|
||||
uart_write(batt_level);
|
||||
uart_write(0x55);
|
||||
uart_write(0x02);
|
||||
uart_write(0x09);
|
||||
uart_write(batt_level);
|
||||
}
|
||||
|
||||
void wireless_start(uint32_t mode)
|
||||
{
|
||||
uint8_t ble_command[24];
|
||||
void wireless_start(uint32_t mode) {
|
||||
uint8_t ble_command[24];
|
||||
smart_ble_startup();
|
||||
if(mode<1 || mode>4)
|
||||
{
|
||||
mode=1;
|
||||
if (mode < 1 || mode > 4) {
|
||||
mode = 1;
|
||||
}
|
||||
ble_command[0]=0x55;
|
||||
ble_command[1]=20;
|
||||
ble_command[2]=0;
|
||||
ble_command[3]=mode;
|
||||
strcpy((char * restrict)(ble_command+4),PRODUCT);
|
||||
ble_command[strlen(PRODUCT)+4]='-';
|
||||
ble_command[strlen(PRODUCT)+5]='0' + mode;
|
||||
ble_command[strlen(PRODUCT)+6]= 0;
|
||||
uart_transmit(ble_command,sizeof(ble_command));
|
||||
ble_command[0] = 0x55;
|
||||
ble_command[1] = 20;
|
||||
ble_command[2] = 0;
|
||||
ble_command[3] = mode;
|
||||
strcpy((char *restrict)(ble_command + 4), PRODUCT);
|
||||
ble_command[strlen(PRODUCT) + 4] = '-';
|
||||
ble_command[strlen(PRODUCT) + 5] = '0' + mode;
|
||||
ble_command[strlen(PRODUCT) + 6] = 0;
|
||||
uart_transmit(ble_command, sizeof(ble_command));
|
||||
}
|
||||
|
||||
void wireless_stop(void)
|
||||
{
|
||||
void wireless_stop(void) {
|
||||
smart_ble_disconnect();
|
||||
uart_write(0x55);
|
||||
uart_write(0x02);
|
||||
uart_write(0x55);
|
||||
uart_write(0x02);
|
||||
uart_write(0x00);
|
||||
uart_write(0x00);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user