Skip to content

Commit

Permalink
Add OLED support for Riblee F411 (qmk#10778)
Browse files Browse the repository at this point in the history
* Add OLED support for Riblee F422

* Fix typo
  • Loading branch information
riblee authored Nov 2, 2020
1 parent acbd9b5 commit f370eca
Show file tree
Hide file tree
Showing 3 changed files with 94 additions and 7 deletions.
31 changes: 26 additions & 5 deletions layouts/community/ortho_5x12/riblee/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,27 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
* `-----------------------------------------------------------------------------------'
*/
[_QWERTY] = LAYOUT_ortho_5x12(
KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_BSPC,
KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_DEL,
KC_ESC, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT,
KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_ENT,
BACKLIT, KC_LCTL, KC_LALT, KC_LGUI, LOWER, KC_SPC, KC_SPC, RAISE, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT
),

/* Hungarian
* ,-----------------------------------------------------------------------------------.
* | ` | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | Bksp |
* |------+------+------+------+------+------+------+------+------+------+------+------|
* | Tab | Q | W | E | R | T | Y | U | I | O | P | Del |
* |------+------+------+------+------+-------------+------+------+------+------+------|
* | Esc | A | S | D | F | G | H | J | K | L | ; | " |
* |------+------+------+------+------+------|------+------+------+------+------+------|
* | Shift| Z | X | C | V | B | N | M | , | . | / |Enter |
* |------+------+------+------+------+------+------+------+------+------+------+------|
* | Brite| Ctrl | Alt | GUI |Lower |Space |Space |Raise | Left | Down | Up |Right |
* `-----------------------------------------------------------------------------------'
*/
[_HUNGARIAN] = LAYOUT_ortho_5x12(
KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_BSPC,
KC_TAB, KC_Q, KC_W, C_KC_E, KC_R, KC_T, KC_Y, C_KC_U, C_KC_I, C_KC_O, KC_P, KC_DEL,
KC_ESC, C_KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT,
Expand Down Expand Up @@ -153,11 +174,11 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
* `-----------------------------------------------------------------------------------'
*/
[_ADJUST] = LAYOUT_ortho_5x12(
KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12,
_______, RESET, DEBUG, _______, _______, _______, _______, TERM_ON, TERM_OFF,_______, _______, KC_DEL,
_______, _______, MU_MOD, AU_ON, AU_OFF, AG_NORM, AG_SWAP, QWERTY, COLEMAK, DVORAK, _______, _______,
_______, _______, _______, _______, _______, _______, NK_TOGG, LCG_SWP, LCG_NRM, UC_MOD, _______, _______,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______
KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12,
_______, RESET, DEBUG, _______, _______, _______, _______, TERM_ON, TERM_OFF,_______, _______, KC_DEL,
_______, _______, MU_MOD, AU_ON, AU_OFF, AG_NORM, AG_SWAP, QWERTY, COLEMAK, DVORAK, HUNGARIAN, _______,
_______, _______, _______, _______, _______, _______, NK_TOGG, LCG_SWP, LCG_NRM, UC_MOD, _______, _______,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______
)

};
64 changes: 64 additions & 0 deletions users/riblee/riblee.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
*/

#include "riblee.h"
#include "raw_hid.h"
#include <string.h>

const uint8_t shift = MOD_BIT(KC_LSFT) | MOD_BIT(KC_RSFT);

Expand Down Expand Up @@ -150,6 +152,12 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
}
return false;
break;
case HUNGARIAN:
if (record->event.pressed) {
set_single_persistent_default_layer(_HUNGARIAN);
}
return false;
break;
case BACKLIT:
if (record->event.pressed) {
register_code(keycode_config(KC_LGUI));
Expand All @@ -164,3 +172,59 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
}
return true;
};

#ifdef OLED_DRIVER_ENABLE

static char receive_buffer[128] = {};
static uint8_t receive_buffer_length = 0;

void oled_task_user(void) {
// Keyboard Layer Status
oled_write_P(PSTR("Layer: "), false);

switch (get_highest_layer(layer_state)) {
case _QWERTY:
oled_write_P(PSTR("Default\n"), false);
break;
case _LOWER:
oled_write_P(PSTR("Lower\n"), false);
break;
case _RAISE:
oled_write_P(PSTR("Raise\n"), false);
break;
case _ADJUST:
oled_write_P(PSTR("Adjust\n"), false);
break;
default:
oled_write_P(PSTR("Undefined\n"), false);
}

// Print string received via HID RAW
oled_write_ln(receive_buffer, false);
}

#ifdef RAW_ENABLE

void raw_hid_receive(uint8_t *data, uint8_t length) {

// Append data to receive_buffer, without the first byte
memcpy(receive_buffer + receive_buffer_length, data + 1, length - 1);
receive_buffer_length += (length - 1);

// First byte indicate if we will recive more package for the current string
// If it's 1 then this was the last package and we can reset the offset
if (data[0] == 1) {
// Reset the offset for memcpy to the begining of our buffer
receive_buffer_length = 0;
}

// Reset the offset to prevent overwriting memory outside of the buffer
if (receive_buffer_length + 32 >= 128) {
receive_buffer_length = 0;
}

}

#endif

#endif
6 changes: 4 additions & 2 deletions users/riblee/riblee.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,19 @@

#include QMK_KEYBOARD_H

enum preonic_layers {
enum layer_names {
_QWERTY,
_HUNGARIAN,
_COLEMAK,
_DVORAK,
_LOWER,
_RAISE,
_ADJUST
};

enum preonic_keycodes {
enum custom_keycodes {
QWERTY = SAFE_RANGE,
HUNGARIAN,
COLEMAK,
DVORAK,
BACKLIT
Expand Down

0 comments on commit f370eca

Please sign in to comment.