Skip to content

Commit

Permalink
add adafruit bluefruit le uart support
Browse files Browse the repository at this point in the history
Signed-off-by: Joshua Rubin <[email protected]>
  • Loading branch information
joshuarubin committed Apr 30, 2020
1 parent 4bb5e83 commit 60f8c5a
Show file tree
Hide file tree
Showing 33 changed files with 3,036 additions and 22 deletions.
3 changes: 3 additions & 0 deletions keyboards/bioi/g60ble/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,6 @@

#define KEYBOARD_LOCK_ENABLE
#define MAGIC_KEY_LOCK L
#define AdafruitBleBaud 76800
// #define AdafruitBleBattery
#define OUTPUT_AUTO_ENABLE
3 changes: 2 additions & 1 deletion keyboards/bioi/g60ble/rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ BOOTLOADER = qmk-dfu
# comment out to disable the options.
#
BOOTMAGIC_ENABLE = lite # Virtual DIP switch configuration(+1000)
MOUSEKEY_ENABLE = yes # Mouse keys(+4700)
# MOUSEKEY_ENABLE = yes # Mouse keys(+4700)
EXTRAKEY_ENABLE = yes # Audio control and System control(+450)
# CONSOLE_ENABLE = yes # Console for debug(+400)
COMMAND_ENABLE = yes # Commands for debug and configuration
Expand All @@ -25,5 +25,6 @@ NKRO_ENABLE = yes # USB Nkey Rollover - if this doesn't work, see here:
BACKLIGHT_ENABLE = yes # Enable keyboard backlight functionality
RGBLIGHT_ENABLE = yes
LTO_ENABLE = yes
BLUETOOTH = AdafruitBLEUART

LAYOUTS = 60_ansi 60_iso 60_hhkb 60_ansi_split_bs_rshift 60_tsangan_hhkb
6 changes: 3 additions & 3 deletions keyboards/handwired/promethium/keymaps/default/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ enum planck_keycodes {
#ifndef FAUXCLICKY_ENABLE
FC_TOG,
#endif
#ifndef MODULE_ADAFRUIT_BLE
#ifndef MODULE_ADAFRUIT_BLE_SPI
OUT_BT,
#endif
RGBDEMO,
Expand Down Expand Up @@ -1261,7 +1261,7 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
}

void set_output_user(uint8_t output) {
#ifdef MODULE_ADAFRUIT_BLE
#ifdef MODULE_ADAFRUIT_BLE_SPI
switch(output) {
case OUTPUT_USB:
led_set_output_usb();
Expand All @@ -1285,7 +1285,7 @@ void matrix_init_user() {
#endif

// auto detect output on init
#ifdef MODULE_ADAFRUIT_BLE
#ifdef MODULE_ADAFRUIT_BLE_SPI
uint8_t output = auto_detect_output();
if (output == OUTPUT_USB) {
set_output(OUTPUT_USB);
Expand Down
6 changes: 3 additions & 3 deletions keyboards/handwired/promethium/keymaps/priyadi/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ enum planck_keycodes {
#ifndef FAUXCLICKY_ENABLE
FC_TOG,
#endif
#ifndef MODULE_ADAFRUIT_BLE
#ifndef MODULE_ADAFRUIT_BLE_SPI
OUT_BT,
#endif
RGBDEMO,
Expand Down Expand Up @@ -1264,7 +1264,7 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
}

void set_output_user(uint8_t output) {
#ifdef MODULE_ADAFRUIT_BLE
#ifdef MODULE_ADAFRUIT_BLE_SPI
switch(output) {
case OUTPUT_USB:
led_set_output_usb();
Expand All @@ -1288,7 +1288,7 @@ void matrix_init_user() {
#endif

// auto detect output on init
#ifdef MODULE_ADAFRUIT_BLE
#ifdef MODULE_ADAFRUIT_BLE_SPI
uint8_t output = auto_detect_output();
if (output == OUTPUT_USB) {
set_output(OUTPUT_USB);
Expand Down
8 changes: 8 additions & 0 deletions quantum/rgblight.c
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,14 @@ void rgblight_init(void) {
is_rgblight_initialized = true;
}

void rgblight_restore_from_eeprom(void) {
if (!is_rgblight_initialized) return;
rgblight_config.raw = eeconfig_read_rgblight();
if (rgblight_config.enable) {
rgblight_mode_noeeprom(rgblight_config.mode);
}
}

uint32_t rgblight_read_dword(void) { return rgblight_config.raw; }

void rgblight_update_dword(uint32_t dword) {
Expand Down
10 changes: 10 additions & 0 deletions quantum/rgblight.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
#ifndef RGBLIGHT_H
#define RGBLIGHT_H

#ifdef __cplusplus
extern "C" {
#endif

/***** rgblight_mode(mode)/rgblight_mode_noeeprom(mode) ****
old mode number (before 0.6.117) to new mode name table
Expand Down Expand Up @@ -317,6 +321,7 @@ uint8_t rgblight_get_val(void);

/* === qmk_firmware (core)internal Functions === */
void rgblight_init(void);
void rgblight_restore_from_eeprom(void);
uint32_t rgblight_read_dword(void);
void rgblight_update_dword(uint32_t dword);
uint32_t eeconfig_read_rgblight(void);
Expand Down Expand Up @@ -396,4 +401,9 @@ void rgblight_effect_alternating(animation_status_t *anim);
# endif

#endif // #ifndef RGBLIGHT_H_DUMMY_DEFINE

#ifdef __cplusplus
}
#endif

#endif // RGBLIGHT_H
8 changes: 7 additions & 1 deletion tmk_core/common.mk
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,13 @@ endif

ifeq ($(strip $(BLUETOOTH)), AdafruitBLE)
TMK_COMMON_DEFS += -DBLUETOOTH_ENABLE
TMK_COMMON_DEFS += -DMODULE_ADAFRUIT_BLE
TMK_COMMON_DEFS += -DMODULE_ADAFRUIT_BLE_SPI
TMK_COMMON_DEFS += -DNO_USB_STARTUP_CHECK
endif

ifeq ($(strip $(BLUETOOTH)), AdafruitBLEUART)
TMK_COMMON_DEFS += -DBLUETOOTH_ENABLE
TMK_COMMON_DEFS += -DMODULE_ADAFRUIT_BLE_UART
TMK_COMMON_DEFS += -DNO_USB_STARTUP_CHECK
endif

Expand Down
27 changes: 27 additions & 0 deletions tmk_core/common/command.c
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,33 @@ static void print_eeconfig(void) {
print("\n");
# endif /* BACKLIGHT_ENABLE */

# ifdef RGBLIGHT_ENABLE
rgblight_config_t rgb;
rgb.speed = 0;
rgb.raw = eeconfig_read_rgblight();
print("rgblight_config.raw: ");
print_hex8(rgb.raw);
print("\n");
print(".enable: ");
print_dec(rgb.enable);
print("\n");
print(".mode: ");
print_dec(rgb.mode);
print("\n");
print(".hue: ");
print_dec(rgb.hue);
print("\n");
print(".sat: ");
print_dec(rgb.sat);
print("\n");
print(".val: ");
print_dec(rgb.val);
print("\n");
print(".speed: ");
print_dec(rgb.speed);
print("\n");
# endif /* RGBLIGHT_ENABLE */

#endif /* !NO_PRINT */
}

Expand Down
8 changes: 8 additions & 0 deletions tmk_core/common/uart.h
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
#ifndef _uart_included_h_
#define _uart_included_h_

#ifdef __cplusplus
extern "C" {
#endif

#include <stdint.h>

void uart_init(uint32_t baud);
void uart_putchar(uint8_t c);
uint8_t uart_getchar(void);
uint8_t uart_available(void);

#ifdef __cplusplus
}
#endif

#endif
Loading

0 comments on commit 60f8c5a

Please sign in to comment.