diff --git a/layouts/community/split_3x6_3/bbaserdem/config.h b/layouts/community/split_3x6_3/bbaserdem/config.h index 03473c5ae72..adf707d1bab 100644 --- a/layouts/community/split_3x6_3/bbaserdem/config.h +++ b/layouts/community/split_3x6_3/bbaserdem/config.h @@ -34,11 +34,6 @@ # undef USE_I2C # undef SSD1306OLED - // Add state info transmission -# define SPLIT_LAYER_STATE_ENABLE -# define SPLIT_MODS_ENABLE -# define SPLIT_WPM_ENABLE - // Audio output on pin A5 (actualy will be output on B1 using keymap init) # ifdef AUDIO_ENABLE # define AUDIO_PIN A5 @@ -68,8 +63,7 @@ # define WS2812_DMA_CHANNEL 3 // OLED related code -# ifdef OLED_DRIVER_ENABLE -# define OLED_TIMEOUT 50000 +# ifdef OLED_ENABLE # define OLED_UPDATE_INTERVAL 100 # endif diff --git a/users/bbaserdem/bb-oled-extra.c b/users/bbaserdem/bb-oled-extra.c index 69cfe520e7f..b52c4b335a8 100644 --- a/users/bbaserdem/bb-oled-extra.c +++ b/users/bbaserdem/bb-oled-extra.c @@ -570,6 +570,7 @@ void render_layout(uint8_t row, uint8_t col, uint8_t mods, bool isLeft) { },{ 0x00,0x00,0x00,0x00,0x00,0x00,0xf8,0x08,0xf8,0x08,0xf0,0x00,0x70,0x88, 0x88,0x88,0x71,0x00,0x70,0x88,0x88,0x48,0xff,0x00,0x70,0xa8,0xa8,0xa8, 0xb0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xce,0xe7,0x00,0x00}}; + uint8_t this_layout = userspace_config.layout % 3; // Render the requested image on the given column and row // Don't grab highest layer; instead compare from top to bottom. @@ -582,7 +583,7 @@ void render_layout(uint8_t row, uint8_t col, uint8_t mods, bool isLeft) { } else if (layer_state_cmp(layer_state, _FUNC)) { draw_image(row, col, func7_L); } else if (layer_state_cmp(layer_state, _NUMB)) { - switch (userspace_config.layout % 3) { + switch (this_layout) { case 0: // Dvorak if (mods & MOD_MASK_SHIFT) { draw_image(row, col, numb6_L_dvor_shift); @@ -618,7 +619,7 @@ void render_layout(uint8_t row, uint8_t col, uint8_t mods, bool isLeft) { } else if (layer_state_cmp(layer_state, _CHAR)) { draw_image(row, col, char1_L); } else { - switch (userspace_config.layout % 3) { + switch (this_layout) { case 0: // Dvorak if (mods & MOD_MASK_SHIFT) { draw_image(row, col, base0_L_dvor_shift); @@ -654,7 +655,7 @@ void render_layout(uint8_t row, uint8_t col, uint8_t mods, bool isLeft) { if (layer_state_cmp(layer_state, _MUSI)) { draw_image(row, col, musi9_R); } else if (layer_state_cmp(layer_state, _SYMB)) { - switch (userspace_config.layout % 3) { + switch (this_layout) { case 0: // Dvorak draw_image(row, col, symb5_R_dvor); break; @@ -682,7 +683,7 @@ void render_layout(uint8_t row, uint8_t col, uint8_t mods, bool isLeft) { } else if (layer_state_cmp(layer_state, _CHAR)) { draw_image(row, col, char1_R); } else { - switch (userspace_config.layout % 3) { + switch (this_layout) { case 0: // Dvorak if (mods & MOD_MASK_SHIFT) { draw_image(row, col, base0_R_dvor_shift); diff --git a/users/bbaserdem/bb-rgb.c b/users/bbaserdem/bb-rgb.c index ba8290eb791..bdb7f12bbd1 100644 --- a/users/bbaserdem/bb-rgb.c +++ b/users/bbaserdem/bb-rgb.c @@ -22,10 +22,6 @@ */ // Allow hooking into the RGB matrix indications using keymap code -// Allow to turn off global handling -__attribute__ ((weak)) bool rgb_matrix_indicators_advanced_keymap(uint8_t led_min, uint8_t led_max) { - return false; -} // Modulates the brightness of indicator RGB helper_dimmer(uint8_t r, uint8_t g, uint8_t b) { @@ -62,6 +58,10 @@ void helper_painter(uint8_t led_min, uint8_t led_max, RGB col, uint8_t side) { } } +// Allow to turn off global handling +__attribute__ ((weak)) bool rgb_matrix_indicators_advanced_keymap(uint8_t led_min, uint8_t led_max) { + return false; +} // Set RGB state depending on layer void rgb_matrix_indicators_advanced_user(uint8_t led_min, uint8_t led_max) { uint8_t thisInd = 3; diff --git a/users/bbaserdem/bb-rgb.h b/users/bbaserdem/bb-rgb.h index 62b6da9f2f2..55914a57300 100644 --- a/users/bbaserdem/bb-rgb.h +++ b/users/bbaserdem/bb-rgb.h @@ -22,6 +22,8 @@ // For custom indicators void rgb_matrix_indicators_advanced_user(uint8_t led_min, uint8_t led_max); +// RGB sleep implementation +void housekeeping_task_rgb(void); // Hook into shutdown code void shutdown_rgb(void); void suspend_wakeup_init_rgb(void); diff --git a/users/bbaserdem/bbaserdem.c b/users/bbaserdem/bbaserdem.c index 233bd1793fe..08346c3d64f 100644 --- a/users/bbaserdem/bbaserdem.c +++ b/users/bbaserdem/bbaserdem.c @@ -67,7 +67,7 @@ void userspace_transport_update(void) { } // Initiate the protocol on sync -void userspace_transport_sync(void) { +void userspace_transport_sync(bool force_sync) { if (is_keyboard_master()) { // Keep track of the last state static userspace_config_t last_userspace_config; @@ -79,9 +79,8 @@ void userspace_transport_sync(void) { needs_sync = true; memcpy(&last_userspace_config, &transport_userspace_config, sizeof(transport_userspace_config)); } - // Perform the sync if requested - if (needs_sync) { + if (needs_sync || force_sync) { transaction_rpc_send(RPC_ID_CONFIG_SYNC, sizeof(transport_userspace_config), &transport_userspace_config); needs_sync = false; } @@ -93,7 +92,7 @@ void userspace_transport_sync(void) { } // Perform the sync if requested - if (needs_sync) { + if (needs_sync || force_sync) { transaction_rpc_send(RPC_ID_RUNTIME_SYNC, sizeof(transport_userspace_runtime), &transport_userspace_runtime); needs_sync = false; } @@ -135,14 +134,32 @@ __attribute__ ((weak)) void keyboard_post_init_keymap(void) {} __attribute__ ((weak)) void keyboard_post_init_user(void) { // Fix beginning base layer, in case some other firmware was flashed // set_single_persistent_default_layer(_BASE); - - // Initialize userspace config - userspace_config.raw = eeconfig_read_user(); + + // Unicode mode +# ifdef UNICODEMAP_ENABLE + set_unicode_input_mode(UC_LNX); +# endif // UNICODEMAP_ENABLE // Split keyboard halves communication # ifdef SPLIT_KEYBOARD + // Register the transactions transaction_register_rpc( RPC_ID_CONFIG_SYNC, userspace_config_sync ); transaction_register_rpc(RPC_ID_RUNTIME_SYNC, userspace_runtime_sync); + // Load default config values + if (is_keyboard_master()) { + // If we are main; load from eeconfig + userspace_config.raw = eeconfig_read_user(); + // And update the transport variable + userspace_transport_update(); + // Do one forced transfer to sync halves + userspace_transport_sync(true); + } else { + // Just sync the data received + userspace_transport_update(); + } +# else // SPLIT_KEYBOARD + // If we are not split; just load from eeprom + userspace_config.raw = eeconfig_read_user(); # endif // SPLIT_KEYBOARD // Backlight LED @@ -155,11 +172,6 @@ __attribute__ ((weak)) void keyboard_post_init_user(void) { keyboard_post_init_underglow(); # endif // RGBLIGHT_ENABLE - // Unicode mode -# ifdef UNICODEMAP_ENABLE - set_unicode_input_mode(UC_LNX); -# endif // UNICODEMAP_ENABLE - // Keymap specific stuff keyboard_post_init_keymap(); } @@ -174,24 +186,31 @@ void housekeeping_task_user(void) { // Check eeprom every now and then static userspace_config_t prev_userspace_config; static fast_timer_t throttle_timer = 0; + static bool init_flag = true; - // Do transport stuff -# ifdef SPLIT_KEYBOARD - userspace_transport_update(); - userspace_transport_sync(); -# endif // SPLIT_KEYBOARD + // Read this if we never read it before + if (init_flag) { + init_flag = false; + prev_userspace_config.raw = eeconfig_read_user(); + } - // Throttled tasks + // Throttled tasks here if (timer_elapsed_fast(throttle_timer) >= HOUSEKEEPING_THROTTLE_INTERVAL_MS) { // Refresh timer throttle_timer = timer_read_fast(); // Check userspace config for eeprom updates - if (prev_userspace_config.raw != userspace_config.raw) { + if (memcmp(&prev_userspace_config, &userspace_config, sizeof(userspace_config))) { + memcpy(&prev_userspace_config, &userspace_config, sizeof(userspace_config)); eeconfig_update_user(userspace_config.raw); - prev_userspace_config.raw = userspace_config.raw; } } + // Do transport stuff +# ifdef SPLIT_KEYBOARD + userspace_transport_update(); + userspace_transport_sync(false); +# endif // SPLIT_KEYBOARD + // Hook to keymap code housekeeping_task_keymap(); } diff --git a/users/bbaserdem/bbaserdem.h b/users/bbaserdem/bbaserdem.h index a7c04361166..4792d5c2d77 100644 --- a/users/bbaserdem/bbaserdem.h +++ b/users/bbaserdem/bbaserdem.h @@ -56,7 +56,7 @@ typedef union { uint32_t raw; struct { - bool test; + bool rgb_sleep; }; } userspace_runtime_t; diff --git a/users/bbaserdem/config.h b/users/bbaserdem/config.h index 299e8e2dabb..477378102b3 100644 --- a/users/bbaserdem/config.h +++ b/users/bbaserdem/config.h @@ -120,7 +120,8 @@ // For perkey leds #ifdef RGB_MATRIX_ENABLE -# define RGB_DISABLE_TIMEOUT 1800000 +// This is not working +//# define RGB_DISABLE_TIMEOUT 1800000 # define RGB_DISABLE_WHEN_USB_SUSPENDED true // Start using this mode # define RGB_MATRIX_STARTUP_MODE RGB_MATRIX_RAINBOW_BEACON