diff options
| author | Reibl János Dániel <janos.daniel.reibl@protonmail.com> | 2020-11-02 22:20:22 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-11-02 21:20:22 +0000 |
| commit | 4ba0cb7ebc7607ba235f34c32a66ccde880ca4a0 (patch) | |
| tree | 5ce269803a0ad3aa29a947e4615c5585fabe13b8 /users/riblee/riblee.c | |
| parent | 4b839db3841f001f78291373b2b6c3eca34582ed (diff) | |
| download | qmk_firmware-4ba0cb7ebc7607ba235f34c32a66ccde880ca4a0.tar.gz qmk_firmware-4ba0cb7ebc7607ba235f34c32a66ccde880ca4a0.zip | |
Add OLED support for Riblee F411 (#10778)
* Add OLED support for Riblee F422
* Fix typo
Diffstat (limited to 'users/riblee/riblee.c')
| -rw-r--r-- | users/riblee/riblee.c | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/users/riblee/riblee.c b/users/riblee/riblee.c index e1fe607ef..6e548f1d8 100644 --- a/users/riblee/riblee.c +++ b/users/riblee/riblee.c | |||
| @@ -15,6 +15,8 @@ | |||
| 15 | */ | 15 | */ |
| 16 | 16 | ||
| 17 | #include "riblee.h" | 17 | #include "riblee.h" |
| 18 | #include "raw_hid.h" | ||
| 19 | #include <string.h> | ||
| 18 | 20 | ||
| 19 | const uint8_t shift = MOD_BIT(KC_LSFT) | MOD_BIT(KC_RSFT); | 21 | const uint8_t shift = MOD_BIT(KC_LSFT) | MOD_BIT(KC_RSFT); |
| 20 | 22 | ||
| @@ -150,6 +152,12 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { | |||
| 150 | } | 152 | } |
| 151 | return false; | 153 | return false; |
| 152 | break; | 154 | break; |
| 155 | case HUNGARIAN: | ||
| 156 | if (record->event.pressed) { | ||
| 157 | set_single_persistent_default_layer(_HUNGARIAN); | ||
| 158 | } | ||
| 159 | return false; | ||
| 160 | break; | ||
| 153 | case BACKLIT: | 161 | case BACKLIT: |
| 154 | if (record->event.pressed) { | 162 | if (record->event.pressed) { |
| 155 | register_code(keycode_config(KC_LGUI)); | 163 | register_code(keycode_config(KC_LGUI)); |
| @@ -164,3 +172,59 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { | |||
| 164 | } | 172 | } |
| 165 | return true; | 173 | return true; |
| 166 | }; | 174 | }; |
| 175 | |||
| 176 | #ifdef OLED_DRIVER_ENABLE | ||
| 177 | |||
| 178 | static char receive_buffer[128] = {}; | ||
| 179 | static uint8_t receive_buffer_length = 0; | ||
| 180 | |||
| 181 | void oled_task_user(void) { | ||
| 182 | // Keyboard Layer Status | ||
| 183 | oled_write_P(PSTR("Layer: "), false); | ||
| 184 | |||
| 185 | switch (get_highest_layer(layer_state)) { | ||
| 186 | case _QWERTY: | ||
| 187 | oled_write_P(PSTR("Default\n"), false); | ||
| 188 | break; | ||
| 189 | case _LOWER: | ||
| 190 | oled_write_P(PSTR("Lower\n"), false); | ||
| 191 | break; | ||
| 192 | case _RAISE: | ||
| 193 | oled_write_P(PSTR("Raise\n"), false); | ||
| 194 | break; | ||
| 195 | case _ADJUST: | ||
| 196 | oled_write_P(PSTR("Adjust\n"), false); | ||
| 197 | break; | ||
| 198 | default: | ||
| 199 | oled_write_P(PSTR("Undefined\n"), false); | ||
| 200 | } | ||
| 201 | |||
| 202 | // Print string received via HID RAW | ||
| 203 | oled_write_ln(receive_buffer, false); | ||
| 204 | } | ||
| 205 | |||
| 206 | #ifdef RAW_ENABLE | ||
| 207 | |||
| 208 | void raw_hid_receive(uint8_t *data, uint8_t length) { | ||
| 209 | |||
| 210 | // Append data to receive_buffer, without the first byte | ||
| 211 | memcpy(receive_buffer + receive_buffer_length, data + 1, length - 1); | ||
| 212 | receive_buffer_length += (length - 1); | ||
| 213 | |||
| 214 | // First byte indicate if we will recive more package for the current string | ||
| 215 | // If it's 1 then this was the last package and we can reset the offset | ||
| 216 | if (data[0] == 1) { | ||
| 217 | // Reset the offset for memcpy to the begining of our buffer | ||
| 218 | receive_buffer_length = 0; | ||
| 219 | } | ||
| 220 | |||
| 221 | // Reset the offset to prevent overwriting memory outside of the buffer | ||
| 222 | if (receive_buffer_length + 32 >= 128) { | ||
| 223 | receive_buffer_length = 0; | ||
| 224 | } | ||
| 225 | |||
| 226 | } | ||
| 227 | |||
| 228 | #endif | ||
| 229 | |||
| 230 | #endif \ No newline at end of file | ||
