[Keymap] Improvements to KidBrazil keymap to better handle OLED/LED Matrix timeout. (#7688)
* Added KidBrazil custom keymap for CRKBD -Custom Font -Custom OLED output * Added missing readme * Oled Timeout Update for KidBrazil Keymap (#1) * Setup Oled timeout based on simple timer * Cleaned up comments and added timeout for LEDs * Fixed some small errors * Updated oled timout with matrix scan * Updated oled timout with matrix scan * Update withou eeprom * Update timer code * Use process user instead of keymap * Added ifdef to protect oledtimer * Updated with half timeout state for logo * Removed middle tier timer * Final cleanup of unused files * Updated code as per suggestions & requests * Second round of revisions * Updated keymap to better handle LED timeout - Added boolean to hold LED state - Added init function to set rgb to known state - Modified RGB_TOG to work with noeeprom commands * Finished adding the timeout for OLED and testing on CRKBD * Updated documentation * fixed the timeout logic so it works as intended * Update keyboards/crkbd/keymaps/kidbrazil/README.md
This commit is contained in:
parent
ee70d496f4
commit
fdc144d215
2 changed files with 83 additions and 38 deletions
|
@ -1,6 +1,6 @@
|
||||||
# KidBrazil's custom CRKBD Layout
|
# KidBrazil's custom CRKBD Layout
|
||||||
|
|
||||||
![Crkbd](https://user-images.githubusercontent.com/736191/40575636-6fba63a4-6123-11e8-9ca0-3f990f1f9f4c.jpg)
|
![Loose Transistor Crkbd](https://user-images.githubusercontent.com/4823043/71268460-0862c000-231b-11ea-8f32-2fe8da4d348a.jpg)
|
||||||
|
|
||||||
This is a simple layout that I use for both programming and gaming. It is very
|
This is a simple layout that I use for both programming and gaming. It is very
|
||||||
closely based on the original CRKBD layout with some modifications to the
|
closely based on the original CRKBD layout with some modifications to the
|
||||||
|
@ -45,8 +45,19 @@ customize this with showing layer and USB information. I also tried my best to
|
||||||
get a dormant / sleep state going but it is hit or miss and often only works on
|
get a dormant / sleep state going but it is hit or miss and often only works on
|
||||||
the master hand.
|
the master hand.
|
||||||
|
|
||||||
|
## OLED & RGB Matrix timeout
|
||||||
|
This keymap will set a automated timeout system for the OLED screen and the RGB
|
||||||
|
matrix. After 3 minutes or so the LED screen will display the logo on both
|
||||||
|
halves and 5 minutes after that both the LED and the Matrix will be switched
|
||||||
|
off.
|
||||||
|
|
||||||
|
Once a user hits the keys again, the LED matrix will turn back on unless the
|
||||||
|
user has disabled it via RGB_TOG.
|
||||||
|
|
||||||
|
## Flashing
|
||||||
|
To flash this on your CRKBD simply use the `make crkbd:kidbrazil:flash`
|
||||||
|
command.
|
||||||
|
|
||||||
### TODO
|
### TODO
|
||||||
- Fix OLED and Backlight so they turn off when the computer sleeps, currently
|
|
||||||
only the left hand does that and the LEDs still stay on.
|
|
||||||
- Wait for Spit_common to be implemented in CRKBD and revisit the special color
|
- Wait for Spit_common to be implemented in CRKBD and revisit the special color
|
||||||
layers and animations
|
layers and animations
|
||||||
|
|
|
@ -4,8 +4,10 @@
|
||||||
extern uint8_t is_master;
|
extern uint8_t is_master;
|
||||||
// Oled timer similar to Drashna's
|
// Oled timer similar to Drashna's
|
||||||
static uint32_t oled_timer = 0;
|
static uint32_t oled_timer = 0;
|
||||||
// Boolean to store
|
// Boolean to store LED state
|
||||||
bool eeprom_oled_enabled = false;
|
bool user_led_enabled = true;
|
||||||
|
// Boolean to store the master LED clear so it only runs once.
|
||||||
|
bool master_oled_cleared = false;
|
||||||
|
|
||||||
// [CRKBD layers Init] -------------------------------------------------------//
|
// [CRKBD layers Init] -------------------------------------------------------//
|
||||||
enum crkbd_layers {
|
enum crkbd_layers {
|
||||||
|
@ -54,19 +56,39 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||||
)
|
)
|
||||||
};
|
};
|
||||||
|
|
||||||
//int RGB_current_mode;
|
// [Post Init] --------------------------------------------------------------//
|
||||||
|
void keyboard_post_init_user(void) {
|
||||||
|
// Set RGB to known state
|
||||||
|
rgb_matrix_enable_noeeprom();
|
||||||
|
rgb_matrix_set_color_all(RGB_GREEN);
|
||||||
|
user_led_enabled = true;
|
||||||
|
|
||||||
|
}
|
||||||
// [Process User Input] ------------------------------------------------------//
|
// [Process User Input] ------------------------------------------------------//
|
||||||
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
|
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
|
||||||
// Use process_record_keymap to reset timer on keypress
|
switch (keycode) {
|
||||||
if (record->event.pressed) {
|
case RGB_TOG:
|
||||||
#ifdef OLED_DRIVER_ENABLE
|
if (record->event.pressed) {
|
||||||
oled_timer = timer_read32();
|
// Toggle matrix on key press
|
||||||
#endif
|
user_led_enabled ? rgb_matrix_disable_noeeprom() : rgb_matrix_enable_noeeprom();
|
||||||
// Restore LEDs if they are enabled in eeprom
|
} else {
|
||||||
rgb_matrix_enable_noeeprom();
|
// Flip User_led_enabled variable on key release
|
||||||
|
user_led_enabled = !user_led_enabled;
|
||||||
|
}
|
||||||
|
return false; // Skip all further processing of this key
|
||||||
|
default:
|
||||||
|
// Use process_record_keymap to reset timer on all other keypresses
|
||||||
|
if (record->event.pressed) {
|
||||||
|
#ifdef OLED_DRIVER_ENABLE
|
||||||
|
oled_timer = timer_read32();
|
||||||
|
#endif
|
||||||
|
// Restore LEDs if they are enabled by user
|
||||||
|
if (user_led_enabled) {
|
||||||
|
rgb_matrix_enable_noeeprom();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// [OLED Configuration] ------------------------------------------------------//
|
// [OLED Configuration] ------------------------------------------------------//
|
||||||
|
@ -180,35 +202,47 @@ void render_master_oled(void) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// lave OLED scren (Right Hand)
|
// Slave OLED scren (Right Hand)
|
||||||
void render_slave_oled(void) {
|
void render_slave_oled(void) {
|
||||||
render_logo();
|
render_logo();
|
||||||
}
|
}
|
||||||
|
|
||||||
// {OLED Task} -----------------------------------------------//
|
// {OLED Task} -----------------------------------------------//
|
||||||
void oled_task_user(void) {
|
void oled_task_user(void) {
|
||||||
// Drashna style timeout for LED and OLED Roughly 8mins
|
if (timer_elapsed32(oled_timer) > 80000 && timer_elapsed32(oled_timer) < 479999) {
|
||||||
if (timer_elapsed32(oled_timer) > 480000) {
|
// Render logo on both halves before full timeout
|
||||||
oled_off();
|
if (is_master && !master_oled_cleared) {
|
||||||
rgb_matrix_disable_noeeprom();
|
// Clear master OLED once so the logo renders properly
|
||||||
return;
|
oled_clear();
|
||||||
}
|
master_oled_cleared = true;
|
||||||
else {
|
}
|
||||||
oled_on();
|
render_logo();
|
||||||
}
|
return;
|
||||||
// Show logo when USB dormant
|
}
|
||||||
switch (USB_DeviceState) {
|
// Drashna style timeout for LED and OLED Roughly 8mins
|
||||||
case DEVICE_STATE_Unattached:
|
else if (timer_elapsed32(oled_timer) > 480000) {
|
||||||
case DEVICE_STATE_Powered:
|
oled_off();
|
||||||
case DEVICE_STATE_Suspended:
|
rgb_matrix_disable_noeeprom();
|
||||||
render_logo();
|
return;
|
||||||
break;
|
}
|
||||||
default:
|
else {
|
||||||
if (is_master) {
|
oled_on();
|
||||||
render_master_oled();
|
// Reset OLED Clear flag
|
||||||
} else {
|
master_oled_cleared = false;
|
||||||
render_slave_oled();
|
// Show logo when USB dormant
|
||||||
}
|
switch (USB_DeviceState) {
|
||||||
}
|
case DEVICE_STATE_Unattached:
|
||||||
|
case DEVICE_STATE_Powered:
|
||||||
|
case DEVICE_STATE_Suspended:
|
||||||
|
render_logo();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
if (is_master) {
|
||||||
|
render_master_oled();
|
||||||
|
} else {
|
||||||
|
render_slave_oled();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue