diff options
author | QMK Bot <hello@qmk.fm> | 2021-05-31 04:04:59 +0000 |
---|---|---|
committer | QMK Bot <hello@qmk.fm> | 2021-05-31 04:04:59 +0000 |
commit | c22f4aeb8e96b8434ce17b73fd89ebc553ae2002 (patch) | |
tree | 9a1642756e5dc88489d07b0c4eeb79aac559a8cd | |
parent | 234d37ec16a8e8724805d43ed38cd22ae99d1fc0 (diff) | |
parent | 1a3064afb186328c17c679094b0f92cbd46844b5 (diff) |
Merge remote-tracking branch 'origin/master' into develop
-rw-r--r-- | keyboards/rubi/config.h | 65 | ||||
-rw-r--r-- | keyboards/rubi/info.json | 31 | ||||
-rw-r--r-- | keyboards/rubi/keymaps/default/keymap.c | 58 | ||||
-rw-r--r-- | keyboards/rubi/keymaps/default/readme.md | 4 | ||||
-rw-r--r-- | keyboards/rubi/keymaps/via/keymap.c | 53 | ||||
-rw-r--r-- | keyboards/rubi/keymaps/via/rules.mk | 2 | ||||
-rw-r--r-- | keyboards/rubi/lib/calc.c | 261 | ||||
-rw-r--r-- | keyboards/rubi/lib/encoder.c | 115 | ||||
-rw-r--r-- | keyboards/rubi/lib/glcdfont.c | 246 | ||||
-rw-r--r-- | keyboards/rubi/lib/oled.c | 268 | ||||
-rw-r--r-- | keyboards/rubi/lib/oled.h | 32 | ||||
-rw-r--r-- | keyboards/rubi/readme.md | 23 | ||||
-rw-r--r-- | keyboards/rubi/rubi.c | 108 | ||||
-rw-r--r-- | keyboards/rubi/rubi.h | 102 | ||||
-rw-r--r-- | keyboards/rubi/rules.mk | 28 |
15 files changed, 1396 insertions, 0 deletions
diff --git a/keyboards/rubi/config.h b/keyboards/rubi/config.h new file mode 100644 index 0000000000..5b6b1c4531 --- /dev/null +++ b/keyboards/rubi/config.h @@ -0,0 +1,65 @@ +/* +Copyright 2021 gregorio + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see <http://www.gnu.org/licenses/>. +*/ + +#pragma once + +#include "config_common.h" + +/* USB Device descriptor parameter */ +#define VENDOR_ID 0x4752 +#define PRODUCT_ID 0x5242 +#define DEVICE_VER 0x0001 +#define MANUFACTURER gregorio +#define PRODUCT Rubi + +/* key matrix size */ +#define MATRIX_ROWS 5 +#define MATRIX_COLS 4 + +/* + * Keyboard Matrix Assignments + * + * Change this to how you wired your keyboard + * COLS: AVR pins used for columns, left to right + * ROWS: AVR pins used for rows, top to bottom + * DIODE_DIRECTION: COL2ROW = COL = Anode (+), ROW = Cathode (-, marked on diode) + * ROW2COL = ROW = Anode (+), COL = Cathode (-, marked on diode) + * + */ +#define MATRIX_ROW_PINS { F0, F1, F4, F5, F6 } +#define MATRIX_COL_PINS { B3, B2, B1, F7 } +#define UNUSED_PINS + +#define ENCODERS_PAD_A { D7 } +#define ENCODERS_PAD_B { D6 } + +/* COL2ROW, ROW2COL */ +#define DIODE_DIRECTION COL2ROW + +/* Debounce reduces chatter (unintended double-presses) - set 0 if debouncing is not needed */ +#define DEBOUNCE 5 + +/* Mechanical locking support. Use KC_LCAP, KC_LNUM or KC_LSCR instead in keymap */ +#define LOCKING_SUPPORT_ENABLE +/* Locking resynchronize hack */ +#define LOCKING_RESYNC_ENABLE + +/* disable these deprecated features by default */ +#define NO_ACTION_MACRO +#define NO_ACTION_FUNCTION + +#define OLED_FONT_H "lib/glcdfont.c" diff --git a/keyboards/rubi/info.json b/keyboards/rubi/info.json new file mode 100644 index 0000000000..72b6242fcd --- /dev/null +++ b/keyboards/rubi/info.json @@ -0,0 +1,31 @@ +{ + "keyboard_name": "Rubi", + "url": "https://github.com/ohchiko/qmk_firmware/tree/master/keyboards/rubi", + "maintainer": "gregorio", + "width": 4, + "height": 5, + "layouts": { + "LAYOUT": { + "layout": [ + {"x":3, "y":0}, + {"x":0, "y":1.25}, + {"x":1, "y":1.25}, + {"x":2, "y":1.25}, + {"x":3, "y":1.25}, + {"x":0, "y":2.25}, + {"x":1, "y":2.25}, + {"x":2, "y":2.25}, + {"x":3, "y":2.25, "h":2}, + {"x":0, "y":3.25}, + {"x":1, "y":3.25}, + {"x":2, "y":3.25}, + {"x":0, "y":4.25}, + {"x":1, "y":4.25}, + {"x":2, "y":4.25}, + {"x":3, "y":4.25, "h":2}, + {"x":0, "y":5.25, "w":2}, + {"x":2, "y":5.25} + ] + } + } +}
\ No newline at end of file diff --git a/keyboards/rubi/keymaps/default/keymap.c b/keyboards/rubi/keymaps/default/keymap.c new file mode 100644 index 0000000000..054e3ce232 --- /dev/null +++ b/keyboards/rubi/keymaps/default/keymap.c @@ -0,0 +1,58 @@ +/* Copyright 2020 gregorio + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ +#include QMK_KEYBOARD_H + + +// enum custom_keycodes { +// FIRST = NEW_SAFE_RANGE, +// }; + +// Defines names for use in layer keycodes and the keymap +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + /* Base */ + [0] = LAYOUT( + ENC_PRESS, + KC_NLCK, KC_PSLS, KC_PAST, KC_PMNS, + KC_P7 , KC_P8 , KC_P9 , KC_PPLS, + KC_P4 , KC_P5 , KC_P6 , + KC_P1 , KC_P2 , KC_P3 , KC_PENT, + KC_P0 , LT(2, KC_PDOT) + ), + [1] = LAYOUT( + KC_TRNS, + KC_C , KC_SLSH, CL_STAR, KC_MINS, + KC_7 , KC_8 , KC_9 , CL_PLUS, + KC_4 , KC_5 , KC_6 , + KC_1 , KC_2 , KC_3 , KC_EQL, + KC_0 , KC_DOT + ), + [2] = LAYOUT( + KC_TRNS, + KC_TRNS, KC_N , KC_S , KC_R , + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS + ), + [3] = LAYOUT( + KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, RESET , KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS + ), +}; diff --git a/keyboards/rubi/keymaps/default/readme.md b/keyboards/rubi/keymaps/default/readme.md new file mode 100644 index 0000000000..1e7cbc85f4 --- /dev/null +++ b/keyboards/rubi/keymaps/default/readme.md @@ -0,0 +1,4 @@ +# The default keymap for Rubi + +[KLE](http://www.keyboard-layout-editor.com/#/gists/984e9039971cf4738d507150b4494190) +![Rubi Default Keymap](https://i.imgur.com/bsG8BdW.jpg) diff --git a/keyboards/rubi/keymaps/via/keymap.c b/keyboards/rubi/keymaps/via/keymap.c new file mode 100644 index 0000000000..3003db8886 --- /dev/null +++ b/keyboards/rubi/keymaps/via/keymap.c @@ -0,0 +1,53 @@ +/* Copyright 2020 gregorio + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ +#include QMK_KEYBOARD_H + +// Defines names for use in layer keycodes and the keymap +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + /* Base */ + [0] = LAYOUT( + ENC_PRESS, + KC_NLCK, KC_PSLS, KC_PAST, KC_PMNS, + KC_P7 , KC_P8 , KC_P9 , KC_PPLS, + KC_P4 , KC_P5 , KC_P6 , + KC_P1 , KC_P2 , KC_P3 , KC_PENT, + KC_P0 , LT(2, KC_PDOT) + ), + [1] = LAYOUT( + KC_TRNS, + KC_C , KC_SLSH, CL_STAR, KC_MINS, + KC_7 , KC_8 , KC_9 , CL_PLUS, + KC_4 , KC_5 , KC_6 , + KC_1 , KC_2 , KC_3 , KC_EQL, + KC_0 , KC_DOT + ), + [2] = LAYOUT( + KC_TRNS, + KC_TRNS, KC_N , KC_S , KC_R , + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS + ), + [3] = LAYOUT( + KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, RESET , KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS + ), +}; diff --git a/keyboards/rubi/keymaps/via/rules.mk b/keyboards/rubi/keymaps/via/rules.mk new file mode 100644 index 0000000000..43061db1dd --- /dev/null +++ b/keyboards/rubi/keymaps/via/rules.mk @@ -0,0 +1,2 @@ +VIA_ENABLE = yes +LTO_ENABLE = yes
\ No newline at end of file diff --git a/keyboards/rubi/lib/calc.c b/keyboards/rubi/lib/calc.c new file mode 100644 index 0000000000..7796a9be45 --- /dev/null +++ b/keyboards/rubi/lib/calc.c @@ -0,0 +1,261 @@ +/* +This is the modified version of [calculator by MWWorks](https://github.com/MWWorks/mw_calc_numpad/blob/master/calc.c). Below is the quote from [MWWorks](https://github.com/MWWorks). + + Calculator for QMK-based keyboard by MWWorks, https://mwworks.uk + This is free, usual disclaimers, don't use it to calculate megaton yields, surgery plans, etc + + I did not plan to reinvent the wheel for this - I figured surely somebody somewhere has working calculator code? + Found lots but none that actually work like you expect a calculator to, hence DIYing it + + As such, this is probably a bit janky, especially as I am a bit of a hack at C + Seems to be working well, with occasional glitchs, solved by clearing it + And some occasional floating-point issues - eg get a long decimal rather than the whole number you were expecting + Feel free to fix it! I think it needs to detect the precision of the two operands and then figure out what the precision of the result should be + +*/ +#include "rubi.h" + +static uint8_t calc_current_operand = 0; +static char calc_operand_0[CALC_DIGITS+1] = ""; +static char calc_operand_1[CALC_DIGITS+1] = ""; +char calc_result[CALC_DIGITS+1] = ""; +static char calc_status[CALC_DIGITS+1] = ""; +static char calc_operator = ' '; +static bool calc_reset = false; + + +void calcBegin(void){ +} + +//update display +void calcUpdate(void){ + if (calc_display_lines == 2) { + if((calc_current_operand == 1) || (calc_reset)){ + strcpy(calc_status, calc_operand_0); + if((strlen(calc_operand_0)>0) || (strlen(calc_operand_1)>0)){ + uint8_t len = strlen(calc_status); + if (!(calc_operator == 's' || calc_operator == 'r' || calc_operator == 'n')) { + calc_status[len] = calc_operator; + } + calc_status[len+1] = 0; + if(calc_reset + && !(calc_operator == 's' || calc_operator == 'r' || calc_operator == 'n')){ + strncat(calc_status, calc_operand_1, CALC_DIGITS-strlen(calc_status)); + calc_operator = ' '; + } + } + strcpy(calc_status_display, calc_status); + } + } else if (calc_display_lines == 1) { + if(calc_reset + && !(calc_operator == 's' || calc_operator == 'r' || calc_operator == 'n')){ + calc_operator = ' '; + } + } + calc_operator_display = calc_operator; + strcpy(calc_result_display, calc_result); +} + +//perform calculation on the 2 operands +void calcOperands(void){ + float result = 0; + switch (calc_operator){ + + //standard operators + case '+': + result = strtod(calc_operand_0, NULL) + strtod(calc_operand_1, NULL); + break; + + case '-': + result = strtod(calc_operand_0, NULL) - strtod(calc_operand_1, NULL); + break; + + case '/': + result = strtod(calc_operand_0, NULL) / strtod(calc_operand_1, NULL); + break; + + case '*': + result = strtod(calc_operand_0, NULL) * strtod(calc_operand_1, NULL); + break; + + //single operand operators - these are all in 2 + case 's': + result = sqrt(strtod(calc_operand_0, NULL)); + break; + + case 'r': + result = 1/(strtod(calc_operand_0, NULL)); + break; + + } + + //now convert the float result into a string + //we know the total string size but we need to find the size of the integer component to know how much we have for decimals + uint8_t magnitude = ceil(log10(result)); + uint8_t max_decimals = CALC_DIGITS-magnitude-1; + //but max it at 7 because that seems the useful limit of our floats + if(max_decimals>7){ + max_decimals = 7; + } + dtostrf(result, CALC_DIGITS, max_decimals, calc_result); + + //now to clean up the result - we need it clean as it may be the input of next calculation + //this seems a lot of code to format this string :| note that this c doesn't support float in sprintf + uint8_t i; + + //first find if theres a dot + uint8_t dotpos = CALC_DIGITS+1; + for(i=0; i<strlen(calc_result); i++){ + if(calc_result[i] == '.'){ + dotpos = i; + break; + } + } + + //if there is, work back to it and remove trailing 0 or . + if(dotpos>=0){ + for(i=strlen(calc_result)-1; i>=dotpos; i--){ + if((calc_result[i] == '0') || (calc_result[i] == '.')){ + calc_result[i] = 0; + }else{ + break; + } + } + } + + //now find how many leading spaces + uint8_t spaces = 0; + for(i=0; i<strlen(calc_result); i++){ + if(calc_result[i] == ' '){ + spaces++; + }else{ + break; + } + } + + //and shift the string + for(i=0; i<strlen(calc_result)-spaces; i++){ + calc_result[i] = calc_result[i+spaces]; + } + calc_result[strlen(calc_result)-spaces] = 0; + + calcUpdate(); + //the result is available as the first operand for another calculation + strcpy(calc_operand_0, calc_result); + calc_operand_1[0] = 0; + +} + +void calcInput(char input){ + char *operand = calc_operand_0; + if(calc_current_operand == 1){ + operand = calc_operand_1; + } + uint8_t len = strlen(operand); + + if( + ((input >= 48) && (input <= 57)) || + (input == '.') + ){ + //if this is following an equals, then we start from scratch as if new calculation + if(calc_reset == true){ + calc_reset = false; + calc_current_operand = 0; + calc_operand_0[0] = 0; + calc_operand_1[0] = 0; + operand = calc_operand_0; + len = 0; + } + + if(len<CALC_DIGITS){ + operand[len] = input; + operand[len+1] = 0; + strcpy(calc_result, operand); + calcUpdate(); + } + + //special input to backspace + }else if(input == 'x'){ + operand[len-1] = 0; + strcpy(calc_result, operand); + calcUpdate(); + + //clear + }else if(input == 'c'){ + operand[0] = 0; + calc_operand_0[0] = 0; + calc_operand_1[0] = 0; + calc_operator = ' '; + calc_reset = true; + strcpy(calc_result, operand); + calcUpdate(); + + //special input switch neg/pos + }else if((input == 'n') && (len>0)){ + uint8_t i; + + if(operand[0] == '-'){ + for(i=1; i<=len; i++){ + operand[i-1] = operand[i]; + } + }else if(len<CALC_DIGITS){ + for(i=0; i<=len; i++){ + operand[len-i+1] = operand[len-i]; + } + operand[0] = '-'; + } + calc_operator = input; + strcpy(calc_result, operand); + calcUpdate(); + + + //standard 2 operand operators + }else if((input == '+') || (input == '-') || (input == '*') || (input == '/')){ + + //get ready for second operand + if(calc_current_operand == 0){ + calc_operator = input; + calc_current_operand = 1; + calcUpdate(); + + //we pressed = we now expect a new second operand + }else if(calc_reset){ + calc_operator = input; + calc_reset = false; + calc_operand_1[0] = 0; + calcUpdate(); + + }else { + //if we use this on the second operand, calculate first, then ready for a second operand again + if (strlen(calc_operand_1)>0){ + calcOperands(); + } + calc_operand_1[0] = 0; + calc_operator = input; + calcUpdate(); + } + + + }else if(input == '='){ + //only accept = if we are on the second operand + if(calc_current_operand == 1){ + //keep the second operand for a subsequent press of =; but flag to reset if start entry of new operand + calc_reset = true; + calcOperands(); + } + + //single operands - square root and reciprocal - needs to operate on 0 so it works after a previous = result + }else if((input == 's') || (input == 'r')){ + //but maybe we started entering 1 + if(calc_current_operand == 1 && !calc_reset){ + strcpy(calc_operand_0, calc_operand_1); + } + calc_current_operand = 1; + calc_operand_1[0] = 0; + calc_operator = input; + calc_reset = true; //simulate another = + calcOperands(); + + } + +} diff --git a/keyboards/rubi/lib/encoder.c b/keyboards/rubi/lib/encoder.c new file mode 100644 index 0000000000..06c25ad317 --- /dev/null +++ b/keyboards/rubi/lib/encoder.c @@ -0,0 +1,115 @@ +/* +Copyright 2021 gregorio + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see <http://www.gnu.org/licenses/>. +*/ + +#include "rubi.h" + +void change_encoder_mode(bool reverse) { + if (reverse) { + if (encoder_mode == 0) { + encoder_mode = _NUM_ENCODER_MODES - 1; + } else { + encoder_mode = encoder_mode - 1; + } + } else { + encoder_mode = (encoder_mode + 1) % _NUM_ENCODER_MODES; + } +} + +uint16_t handle_encoder_cw(void) { + uint16_t mapped_code = 0; + + if (oled_mode == OLED_MODE_CALC) { + layer_on(2); + return mapped_code; + } + + switch (encoder_mode) { + default: + case ENC_MODE_VOLUME: + mapped_code = KC_VOLU; + break; + case ENC_MODE_MEDIA: + mapped_code = KC_MEDIA_NEXT_TRACK; + break; + case ENC_MODE_BRIGHTNESS: + mapped_code = KC_BRIGHTNESS_UP; + break; + } + + return mapped_code; +} + +uint16_t handle_encoder_ccw(void) { + uint16_t mapped_code = 0; + + if (oled_mode == OLED_MODE_CALC) { + layer_off(2); + return mapped_code; + } + + switch (encoder_mode) { + default: + case ENC_MODE_VOLUME: + mapped_code = KC_VOLD; + break; + case ENC_MODE_MEDIA: + mapped_code = KC_MEDIA_PREV_TRACK; + break; + case ENC_MODE_BRIGHTNESS: + mapped_code = KC_BRIGHTNESS_DOWN; + break; + } + + return mapped_code; +} + +uint16_t handle_encoder_press(void) { + uint16_t mapped_code = 0; + if (get_highest_layer(layer_state) == 1) { + if (oled_mode == OLED_MODE_CALC) { + layer_on(3); + } + layer_off(1); + return mapped_code; + } else if (get_highest_layer(layer_state) == 2) { + if (oled_mode == OLED_MODE_CALC) { + layer_off(1); + layer_on(3); + } else { + layer_on(1); + } + layer_off(2); + return mapped_code; + } else if (get_highest_layer(layer_state) == 3) { + if (oled_mode == OLED_MODE_OFF) { + layer_off(3); + } + return mapped_code; + } + + switch (encoder_mode) { + default: + case ENC_MODE_VOLUME: + mapped_code = KC_MUTE; + break; + case ENC_MODE_MEDIA: + mapped_code = KC_MEDIA_PLAY_PAUSE; + break; + } + + return mapped_code; +} diff --git a/keyboards/rubi/lib/glcdfont.c b/keyboards/rubi/lib/glcdfont.c new file mode 100644 index 0000000000..1a83ed3edc --- /dev/null +++ b/keyboards/rubi/lib/glcdfont.c @@ -0,0 +1,246 @@ +/* Copyright 2021 gregorio + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ +#pragma once + +#include "progmem.h" + + +const unsigned char font[] PROGMEM = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x3E, 0x5B, 0x4F, 0x5B, 0x3E, 0x00, + 0x3E, 0x6B, 0x4F, 0x6B, 0x3E, 0x00, + 0x1C, 0x3E, 0x7C, 0x3E, 0x1C, 0x00, + 0x18, 0x3C, 0x7E, 0xBC, 0x18, 0x00, + 0x1C, 0x57, 0x7D, 0x57, 0x1C, 0x00, + 0x1C, 0x5E, 0x7F, 0x5E, 0x1C, 0x00, + 0x00, 0x18, 0x3C, 0x18, 0x00, 0x00, + 0xFF, 0xE7, 0xC3, 0xE7, 0xFF, 0x00, + 0x00, 0x18, 0x24, 0x18, 0x00, 0x00, + 0xFF, 0xE7, 0xDB, 0xE7, 0xFF, 0x00, + 0x30, 0x48, 0x3A, 0x06, 0x0E, 0x00, + 0x26, 0x29, 0x79, 0x29, 0x26, 0x00, + 0x40, 0x7F, 0x05, 0x05, 0x07, 0x00, + 0x40, 0x7F, 0x05, 0x25, 0x3F, 0x00, + 0x5A, 0x3C, 0x66, 0x3C, 0x5A, 0x00, + 0x7F, 0x3E, 0x1C, 0x1C, 0x08, 0x00, + 0x08, 0x1C, 0x1C, 0x3E, 0x7F, 0x00, + 0x14, 0x22, 0x7F, 0x22, 0x14, 0x00, + 0x5F, 0x5F, 0x00, 0x5F, 0x5F, 0x00, + 0x06, 0x09, 0x7F, 0x01, 0x7F, 0x00, + 0x00, 0x66, 0x89, 0x95, 0x6A, 0x00, + 0x60, 0x60, 0x60, 0x60, 0x60, 0x00, + 0x94, 0xA2, 0xFF, 0xA2, 0x94, 0x00, + 0x08, 0x04, 0x7E, 0x04, 0x08, 0x00, + 0x10, 0x20, 0x7E, 0x20, 0x10, 0x00, + 0x08, 0x08, 0x2A, 0x1C, 0x08, 0x00, + 0x08, 0x1C, 0x2A, 0x08, 0x08, 0x00, + 0x1E, 0x10, 0x10, 0x10, 0x10, 0x00, + 0x0C, 0x1E, 0x0C, 0x1E, 0x0C, 0x00, + 0x30, 0x38, 0x3E, 0x38, 0x30, 0x00, + 0x06, 0x0E, 0x3E, 0x0E, 0x06, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x5E, 0x00, 0x00, 0x00, + 0x00, 0x06, 0x00, 0x06, 0x00, 0x00, + 0x14, 0x3E, 0x14, 0x3E, 0x14, 0x00, + 0x24, 0x2A, 0x7F, 0x2A, 0x12, 0x00, + 0x26, 0x16, 0x08, 0x34, 0x32, 0x00, + 0x36, 0x4A, 0x56, 0x20, 0x50, 0x00, + 0x00, 0x0A, 0x06, 0x00, 0x00, 0x00, + 0x00, 0x3C, 0x42, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x42, 0x3C, 0x00, 0x00, + 0x14, 0x08, 0x3E, 0x08, 0x14, 0x00, + 0x08, 0x08, 0x3E, 0x08, 0x08, 0x00, + 0x00, 0xA0, 0x60, 0x00, 0x00, 0x00, + 0x08, 0x08, 0x08, 0x08, 0x08, 0x00, + 0x00, 0x00, 0x60, 0x60, 0x00, 0x00, + 0x20, 0x10, 0x08, 0x04, 0x02, 0x00, + 0x3E, 0x41, 0x41, 0x41, 0x3E, 0x00, + 0x00, 0x42, 0x7F, 0x40, 0x00, 0x00, + 0x72, 0x49, 0x49, 0x49, 0x46, 0x00, + 0x21, 0x41, 0x45, 0x45, 0x3B, 0x00, + 0x38, 0x26, 0x21, 0x7F, 0x20, 0x00, + 0x2F, 0x49, 0x49, 0x49, 0x31, 0x00, + 0x3E, 0x49, 0x49, 0x49, 0x31, 0x00, + 0x01, 0x01, 0x61, 0x19, 0x07, 0x00, + 0x36, 0x49, 0x49, 0x49, 0x36, 0x00, + 0x4E, 0x51, 0x51, 0x51, 0x3E, 0x00, + 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, + 0x00, 0x40, 0x34, 0x00, 0x00, 0x00, + 0x00, 0x08, 0x14, 0x22, 0x00, 0x00, + 0x14, 0x14, 0x14, 0x14, 0x14, 0x00, + 0x00, 0x00, 0x22, 0x14, 0x08, 0x00, + 0x00, 0x04, 0x52, 0x0A, 0x04, 0x00, + 0x3E, 0x41, 0x5D, 0x59, 0x4E, 0x00, + 0x7E, 0x09, 0x09, 0x09, 0x7E, 0x00, + 0x7F, 0x49, 0x49, 0x49, 0x36, 0x00, + 0x3E, 0x41, 0x41, 0x41, 0x22, 0x00, + 0x7F, 0x41, 0x41, 0x41, 0x3E, 0x00, + 0x7F, 0x49, 0x49, 0x49, 0x41, 0x00, + 0x7F, 0x09, 0x09, 0x09, 0x01, 0x00, + 0x3E, 0x41, 0x49, 0x49, 0x3A, 0x00, + 0x7F, 0x08, 0x08, 0x08, 0x7F, 0x00, + 0x00, 0x00, 0x7F, 0x00, 0x00, 0x00, + 0x20, 0x41, 0x41, 0x3F, 0x00, 0x00, + 0x7F, 0x08, 0x14, 0x22, 0x41, 0x00, + 0x7F, 0x40, 0x40, 0x40, 0x40, 0x00, + 0x7F, 0x02, 0x04, 0x02, 0x7F, 0x00, + 0x7F, 0x02, 0x04, 0x08, 0x7F, 0x00, + 0x3E, 0x41, 0x41, 0x41, 0x3E, 0x00, + 0x7F, 0x09, 0x09, 0x09, 0x06, 0x00, + 0x3E, 0x41, 0x51, 0x21, 0x5E, 0x00, + 0x7F, 0x09, 0x19, 0x29, 0x46, 0x00, + 0x26, 0x49, 0x49, 0x49, 0x32, 0x00, + 0x01, 0x01, 0x7F, 0x01, 0x01, 0x00, + 0x3F, 0x40, 0x40, 0x40, 0x3F, 0x00, + 0x1F, 0x20, 0x40, 0x20, 0x1F, 0x00, + 0x3F, 0x40, 0x38, 0x40, 0x3F, 0x00, + 0x63, 0x14, 0x08, 0x14, 0x63, 0x00, + 0x07, 0x08, 0x70, 0x08, 0x07, 0x00, + 0x61, 0x51, 0x49, 0x45, 0x43, 0x00, + 0x00, 0x7F, 0x41, 0x41, 0x00, 0x00, + 0x02, 0x04, 0x08, 0x10, 0x20, 0x00, + 0x00, 0x00, 0x41, 0x41, 0x7F, 0x00, + 0x04, 0x02, 0x01, 0x02, 0x04, 0x00, + 0x40, 0x40, 0x40, 0x40, 0x40, 0x00, + 0x00, 0x00, 0x06, 0x0A, 0x00, 0x00, + 0x20, 0x54, 0x54, 0x54, 0x78, 0x00, + 0x7E, 0x48, 0x48, 0x48, 0x30, 0x00, + 0x30, 0x48, 0x48, 0x48, 0x48, 0x00, + 0x30, 0x48, 0x48, 0x48, 0x7E, 0x00, + 0x38, 0x54, 0x54, 0x54, 0x58, 0x00, + 0x00, 0x08, 0x7C, 0x0A, 0x00, 0x00, + 0x98, 0xA4, 0xA4, 0xA4, 0x78, 0x00, + 0x7E, 0x08, 0x08, 0x08, 0x70, 0x00, + 0x00, 0x00, 0x7A, 0x00, 0x00, 0x00, + 0x20, 0x40, 0x40, 0x3A, 0x00, 0x00, + 0x7E, 0x10, 0x28, 0x44, 0x00, 0x00, + 0x00, 0x00, 0x7E, 0x40, 0x00, 0x00, + 0x7C, 0x04, 0x78, 0x04, 0x78, 0x00, + 0x7C, 0x04, 0x04, 0x04, 0x78, 0x00, + 0x38, 0x44, 0x44, 0x44, 0x38, 0x00, + 0xFC, 0x24, 0x24, 0x24, 0x18, 0x00, + 0x18, 0x24, 0x24, 0x24, 0xFC, 0x00, + 0x7C, 0x08, 0x04, 0x04, 0x08, 0x00, + 0x48, 0x54, 0x54, 0x54, 0x24, 0x00, + 0x00, 0x04, 0x7E, 0x44, 0x00, 0x00, + 0x3C, 0x40, 0x40, 0x20, 0x7C, 0x00, + 0x1C, 0x20, 0x40, 0x20, 0x1C, 0x00, + 0x3C, 0x40, 0x30, 0x40, 0x3C, 0x00, + 0x44, 0x28, 0x10, 0x28, 0x44, 0x00, + 0x5C, 0xA0, 0xA0, 0xA0, 0x7C, 0x00, + 0x44, 0x64, 0x54, 0x4C, 0x44, 0x00, + 0x00, 0x08, 0x36, 0x41, 0x00, 0x00, + 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, + 0x00, 0x41, 0x36, 0x08, 0x00, 0x00, + 0x02, 0x01, 0x02, 0x04, 0x02, 0x00, + 0x3C, 0x26, 0x23, 0x26, 0x3C, 0x00, + 0x7E, 0xFF, 0x81, 0xFB, 0xF7, 0xEF, + 0x81, 0xFF, 0xC1, 0xBF, 0xBF, 0xBF, + 0xC1, 0xFF, 0x81, 0xFB, 0xF7, 0xFB, + 0x81, 0xFF, 0x7E, 0x00, 0x00, 0x00, + 0x7E, 0xFF, 0xC3, 0xBD, 0xBD, 0xBD, + 0xDB, 0xFF, 0x83, 0xED, 0xED, 0xED, + 0x83, 0xFF, 0x81, 0xED, 0xED, 0xED, + 0xF3, 0xFF, 0x7E, 0x00, 0x00, 0x00, + 0x7E, 0xFF, 0xE1, 0xDF, 0xBF, 0xDF, + 0xE1, 0xFF, 0xC3, 0xBD, 0xBD, 0xBD, + 0xC3, 0xFF, 0x81, 0xBF, 0xBF, 0xBF, + 0xBF, 0xFF, 0x7E, 0x00, 0x00, 0x00, + 0x7E, 0xFF, 0x81, 0xB5, 0xB5, 0xB5, + 0xCB, 0xFF, 0x81, 0xED, 0xCD, 0xAD, + 0xB3, 0xFF, 0xFD, 0xFD, 0x81, 0xFD, + 0xFD, 0xFF, 0x7E, 0x00, 0x00, 0x00, + 0x7E, 0xFF, 0xC3, 0xBD, 0xBD, 0xBD, + 0xDB, 0xFF, 0x83, 0xED, 0xED, 0xED, + 0x83, 0xFF, 0x81, 0xBF, 0xBF, 0xBF, + 0xBF, 0xFF, 0x7E, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x08, 0x08, 0x3E, + 0x08, 0x08, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x08, 0x08, 0x08, + 0x08, 0x08, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x3E, 0x6F, 0x5F, 0x63, + 0x7B, 0x7B, 0x3E, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x3E, 0x7F, 0x59, 0x6F, + 0x77, 0x7B, 0x3E, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x14, 0x08, 0x3E, + 0x08, 0x14, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x08, 0x08, 0x2A, + 0x08, 0x08, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x7E, 0x04, 0x08, 0x10, + 0x7E, 0x00, 0x3E, 0x40, 0x40, 0x40, + 0x3E, 0x00, 0x7E, 0x04, 0x08, 0x04, + 0x7E, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x3C, 0x42, 0x42, 0x42, + 0x24, 0x00, 0x7C, 0x12, 0x12, 0x12, + 0x7C, 0x00, 0x7E, 0x12, 0x12, 0x12, + 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x7E, 0xFF, 0x81, 0xFB, 0xE7, 0xFB, + 0x81, 0xFF, 0x81, 0xB5, 0xB5, 0xB5, + 0xBD, 0xFF, 0x81, 0xBD, 0xBD, 0xBD, + 0xC3, 0xFF, 0x7E, 0x00, 0x00, 0x00, + 0x7E, 0xFF, 0x81, 0xB5, 0xB5, 0xB5, + 0xCB, 0xFF, 0x81, 0xEF, 0xF7, 0xEB, + 0x9D, 0xFF, 0x81, 0xBF, 0xBF, 0xBF, + 0xBF, 0xFF, 0x7E, 0x00, 0x00, 0x00, + 0x7E, 0xFF, 0x81, 0xED, 0xED, 0xED, + 0xF3, 0xFF, 0x83, 0xED, 0xED, 0xED, + 0x83, 0xFF, 0x81, 0xBD, 0xBD, 0xBD, + 0xC3, 0xFF, 0x7E, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x3E, 0x77, 0x6F, 0x77, + 0x7B, 0x77, 0x3E, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x08, 0x10, 0x08, + 0x04, 0x08, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x3E, 0x77, 0x77, 0x55, + 0x77, 0x77, 0x3E, 0x00, 0x00, 0x00, + 0x7E, 0xFF, 0xB3, 0xAD, 0xAD, 0xAD, + 0xDB, 0xFF, 0xC3, 0xBD, 0xBD, 0xBD, + 0xDB, 0xFF, 0x81, 0xED, 0xCD, 0xAD, + 0xB3, 0xFF, 0x7E, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x10, 0x20, 0x1C, + 0x04, 0x04, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x3C, 0x42, 0x42, 0x42, + 0x24, 0x00, 0x7C, 0x12, 0x12, 0x12, + 0x7C, 0x00, 0x7E, 0x40, 0x40, 0x40, + 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x7E, 0x12, 0x12, 0x12, + 0x0C, 0x00, 0x7C, 0x12, 0x12, 0x12, + 0x7C, 0x00, 0x7E, 0x42, 0x42, 0x42, + 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x7E, 0xFF, 0xC3, 0xBD, 0xBD, 0xBD, + 0xC3, 0xFF, 0x7E, 0x00, 0x00, 0x00, + 0x7E, 0xFF, 0xFF, 0xBB, 0x81, 0xBF, + 0xFF, 0xFF, 0x7E, 0x00, 0x00, 0x00, + 0x7E, 0xFF, 0x9B, 0xAD, 0xAD, 0xAD, + 0xB3, 0xFF, 0x7E, 0x00, 0x00, 0x00, + 0x7E, 0xFF, 0xDD, 0xBD, 0xB5, 0xB5, + 0xC9, 0xFF, 0x7E, 0x00, 0x00, 0x00, + 0x7E, 0xFF, 0xE7, 0xEB, 0xED, 0x81, + 0xFF, 0xFF, 0x7E, 0x00, 0x00, 0x00, + 0x7E, 0xFF, 0xD1, 0xB5, 0xB5, 0xB5, + 0xCD, 0xFF, 0x7E, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x3E, 0x77, 0x77, 0x41, + 0x77, 0x77, 0x3E, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x3E, 0x77, 0x77, 0x77, + 0x77, 0x77, 0x3E, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x3E, 0x6B, 0x77, 0x41, + 0x77, 0x6B, 0x3E, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x4C, 0x52, 0x52, 0x52, + 0x24, 0x00, 0x3C, 0x42, 0x42, 0x42, + 0x24, 0x00, 0x7E, 0x12, 0x32, 0x52, + 0x4C, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x26, 0x10, + 0x08, 0x04, 0x00, 0x00, 0x00, 0x00, +}; diff --git a/keyboards/rubi/lib/oled.c b/keyboards/rubi/lib/oled.c new file mode 100644 index 0000000000..d48d27323c --- /dev/null +++ b/keyboards/rubi/lib/oled.c @@ -0,0 +1,268 @@ +/* +Copyright 2021 gregorio + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see <http://www.gnu.org/licenses/>. +*/ + +#include QMK_KEYBOARD_H +#include "./lib/oled.h" + +bool process_record_user_oled(uint16_t keycode, keyrecord_t *record) { + return process_record_user(keycode, record); +} + +void change_oled_mode(void) { + oled_mode = (oled_mode + 1) % _NUM_OLED_MODES; +} + +void render_layer_section(void) { + // Layer indicators + static const char PROGMEM layer_0[] = {0xc8, 0xc9, 0}; + static const char PROGMEM layer_1[] = {0xca, 0xcb, 0}; + static const char PROGMEM layer_2[] = {0xcc, 0xcd, 0}; + static const char PROGMEM layer_3[] = {0xce, 0xcf, 0}; + + oled_set_cursor(oled_max_chars()-15, 0); + oled_write_P(PSTR("LAYER"), false); + switch (get_highest_layer(layer_state)) { + case 0: + oled_write_P(layer_0, false); + break; + case 1: + oled_write_P(layer_1, false); + |