Skip to content

Commit b636360

Browse files
committed
RGB sync works now
1 parent e9f004b commit b636360

File tree

15 files changed

+69
-29
lines changed

15 files changed

+69
-29
lines changed

keyboards/jorne_ble/jorne_ble.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ void nrfmicro_init(void) {
8383

8484
void eeprom_update(void);
8585

86-
// called everny matrix_scan_user
86+
// called every matrix_scan_user
8787
void nrfmicro_update(void) {
8888
check_ble_switch(false);
8989
eeprom_update(); // important

keyboards/jorne_ble/keymaps/default/keymap.c

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -440,9 +440,19 @@ void matrix_render_user(struct CharacterMatrix *matrix) {
440440
//matrix_write_ln(matrix, read_keylog());
441441

442442
{
443-
char str[32];
444-
sprintf(str, "%s %s", is_master ? "Master" : "Slave", ble_connected() ? "Connected": "Not connected");
445-
matrix_write_ln(matrix, str);
443+
char str[64];
444+
445+
#if (IS_LEFT_HAND)
446+
sprintf (str, "Master: %s%s%s",
447+
get_usb_enabled() && !get_ble_enabled() ? "USB mode":"",
448+
get_ble_enabled() && ble_connected() ? "connected":"",
449+
get_ble_enabled() && !ble_connected() ? "disconnected":""
450+
);
451+
#else
452+
sprintf(str, "Slave: %s", ble_connected() ? "connected" : "disconnected");
453+
#endif
454+
455+
matrix_write_ln(matrix, str);
446456
}
447457

448458
matrix_write_ln(matrix, read_rgb_info());

keyboards/jorne_ble/lib/rgb_state_reader.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,12 @@ extern rgblight_config_t rgblight_config;
77
char rbf_info_str[24];
88
const char *read_rgb_info(void) {
99

10-
snprintf(rbf_info_str, sizeof(rbf_info_str), "RGB %s %02d hsv %02x%02x%02x",
11-
rgblight_config.enable ? "1" : "-", rgblight_config.mode,
12-
rgblight_config.hue, rgblight_config.sat, rgblight_config.val);
10+
if (rgblight_config.enable)
11+
snprintf(rbf_info_str, sizeof(rbf_info_str), "RGB: %-2d HSV: %02x%02x%02x",
12+
rgblight_config.mode, rgblight_config.hue, rgblight_config.sat, rgblight_config.val);
13+
else
14+
snprintf(rbf_info_str, sizeof(rbf_info_str), "RGB: off");
15+
1316
return rbf_info_str;
1417
}
1518
#endif
0 Bytes
Binary file not shown.
512 Bytes
Binary file not shown.

keyboards/jorne_ble/slave/slave.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,10 @@ void matrix_init_user(void) {
6161
} else if (row == 0b10) {
6262
bootloader_flag = true;
6363
}
64+
65+
eeconfig_update_rgblight_default();
66+
rgblight_enable();
67+
rgblight_mode(15);
6468
}
6569

6670
void matrix_scan_user(void) {

tmk_core/protocol/nrf/app_ble_func.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ __WEAK void ble_nus_packetrcv_handler(ble_switch_state_t* buf, uint8_t len);
3131
__WEAK void ble_nus_on_disconnect(void);
3232

3333
uint32_t ble_nus_send_bytes(uint8_t* buf, uint16_t len);
34+
uint32_t ble_nus_recv_bytes(uint8_t* buf, uint16_t len);
35+
uint32_t ble_nus_send_bytes_to_slave(uint8_t* buf, uint16_t len);
3436

3537
void ble_disconnect(void);
3638
void restart_advertising_wo_whitelist(void);

tmk_core/protocol/nrf/ble_master.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,6 @@ void advertising_init(void);
5151
void buttons_leds_init(bool * p_erase_bonds);
5252
void power_manage(void);
5353

54+
uint32_t ble_nus_send_bytes_to_slave(uint8_t* buf, uint16_t len);
55+
5456
#endif /* TMK_CORE_PROTOCOL_NRF_BLE_MAIN_H_ */

tmk_core/protocol/nrf/ble_slave.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,6 @@ void main_task_start(uint8_t interval_ms);
2121
void main_loop(void);
2222

2323
uint32_t ble_nus_send_bytes(uint8_t* buf, uint16_t len);
24+
uint32_t ble_nus_recv_bytes(uint8_t* buf, uint16_t len);
2425

2526
#endif // _BLE_SLAVE_H_

tmk_core/protocol/nrf/main_master.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,13 @@ void raw_hid_task(void);
8686
void console_task(void);
8787
#endif
8888

89+
#ifdef RGBLIGHT_ENABLE
90+
#include "rgblight.h"
91+
rgblight_syncinfo_t rgblight_sync;
92+
#endif
93+
94+
uint32_t ble_nus_send_bytes_to_slave(uint8_t* buf, uint16_t len);
95+
8996
void timer_tick(uint8_t interval);
9097
void main_tasks(void* p_context) {
9198
UNUSED_PARAMETER(p_context);
@@ -104,6 +111,13 @@ void main_tasks(void* p_context) {
104111
#endif
105112
#if defined(RGBLIGHT_ENABLE) && defined(RGBLIGHT_ANIMATIONS)
106113
rgblight_task();
114+
115+
if (rgblight_get_change_flags()) {
116+
rgblight_get_syncinfo(&rgblight_sync);
117+
ble_nus_send_bytes_to_slave((uint8_t*)&rgblight_sync, sizeof(rgblight_sync));
118+
rgblight_clear_change_flags();
119+
}
120+
107121
#endif
108122
}
109123

0 commit comments

Comments
 (0)