diff options
author | lokher <lokher@gmail.com> | 2022-09-13 11:24:05 +0800 |
---|---|---|
committer | lokher <lokher@gmail.com> | 2022-09-13 11:24:05 +0800 |
commit | 9581289745736ce068a1040f44cec37a2ca8830d (patch) | |
tree | 24f644715a5fd6cc4d804d9604fb094307808b1b /keyboards/rubi/lib | |
parent | fe13cedf8c09fa34d5cec4e4c624738095176625 (diff) |
Remove non-Keychron keyboards
Diffstat (limited to 'keyboards/rubi/lib')
-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 | 270 | ||||
-rw-r--r-- | keyboards/rubi/lib/oled.h | 32 |
5 files changed, 0 insertions, 924 deletions
diff --git a/keyboards/rubi/lib/calc.c b/keyboards/rubi/lib/calc.c deleted file mode 100644 index 7796a9be45..0000000000 --- a/keyboards/rubi/lib/calc.c +++ /dev/null @@ -1,261 +0,0 @@ -/* -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 deleted file mode 100644 index 06c25ad317..0000000000 --- a/keyboards/rubi/lib/encoder.c +++ /dev/null @@ -1,115 +0,0 @@ -/* -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 deleted file mode 100644 index 1a83ed3edc..0000000000 --- a/keyboards/rubi/lib/glcdfont.c +++ /dev/null @@ -1,246 +0,0 @@ -/* 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 deleted file mode 100644 index 9534cdd9b7..0000000000 --- a/keyboards/rubi/lib/oled.c +++ /dev/null @@ -1,270 +0,0 @@ -/* -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); - break; - case 2: - oled_write_P(layer_2, false); - break; - case 3: - oled_write_P(layer_3, false); - break; - default: - oled_write_P(PSTR("? "), false); - break; - } -} - -void render_encoder_section(void) { - static const char PROGMEM enc_vol[] = {0x88, 0x89, 0x8a, 0x8b, 0}; - static const char PROGMEM enc_med[] = {0xa8, 0xa9, 0xaa, 0xab, 0}; - static const char PROGMEM enc_brt[] = {0x8c, 0x8d, 0x8e, 0x8f, 0}; - - oled_set_cursor(oled_max_chars()-7, 0); - oled_write_P(PSTR("ENC"), false); - switch (encoder_mode) { - default: - case ENC_MODE_VOLUME: - oled_write_P(enc_vol, false); - break; - case ENC_MODE_MEDIA: - oled_write_P(enc_med, false); - break; - case ENC_MODE_BRIGHTNESS: - oled_write_P(enc_brt, false); - break; - } -} - -void render_numlock_section(void) { - static const char PROGMEM num_on[] = {0x80, 0x81, 0x82, 0x83, 0}; - static const char PROGMEM num_off[] = {0xa0, 0xa1, 0xa2, 0xa3, 0}; - static const char PROGMEM cap_on[] = {0x84, 0x85, 0x86, 0x87, 0}; - static const char PROGMEM cap_off[] = {0xa4, 0xa5, 0xa6, 0xa7, 0}; - static const char PROGMEM scr_on[] = {0xba, 0xbb, 0xbc, 0xbd, 0}; - static const char PROGMEM scr_off[] = {0xda, 0xdb, 0xdc, 0xdd, 0}; - - led_t led_state = host_keyboard_led_state(); - - oled_set_cursor(oled_max_chars()-12, 3); - // num lock - oled_write_P(led_state.num_lock ? num_on : num_off, false); - oled_write_P(led_state.caps_lock ? cap_on : cap_off, false); - oled_write_P(led_state.scroll_lock ? scr_on : scr_off, false); -} - -void render_mode_section(void) { - static const char PROGMEM pad_on[] = {0xb0, 0xb1, 0xb2, 0xb3, 0}; - static const char PROGMEM pad_off[] = {0xc4, 0xc5, 0xc6, 0xc7, 0}; - static const char PROGMEM cal_on[] = {0x90, 0x91, 0x92, 0x93, 0}; - static const char PROGMEM cal_off[] = {0xc0, 0xc1, 0xc2, 0xc3, 0}; - - if (oled_mode == OLED_MODE_CALC) { - oled_set_cursor(0, 0); - oled_write_P(pad_off, false); - oled_set_cursor(0, 1); - oled_write_P(cal_on, false); - } else { - oled_set_cursor(0, 0); - oled_write_P(pad_on, false); - oled_set_cursor(0, 1); - oled_write_P(cal_off, false); - } -} - -void render_calc_section(void) { - static const char PROGMEM add_on[] = {0xd4, 0xd5, 0}; - static const char PROGMEM add_off[] = {0x94, 0x95, 0}; - static const char PROGMEM sub_on[] = {0xd6, 0xd7, 0}; - static const char PROGMEM sub_off[] = {0x96, 0x97, 0}; - static const char PROGMEM mul_on[] = {0xd8, 0xd9, 0}; - static const char PROGMEM mul_off[] = {0x9c, 0x9d, 0}; - static const char PROGMEM div_on[] = {0xb8, 0xb9, 0}; - static const char PROGMEM div_off[] = {0x9e, 0x9f, 0}; - static const char PROGMEM sqr_on[] = {0x98, 0x99, 0}; - static const char PROGMEM sqr_off[] = {0xbe, 0xbf, 0}; - static const char PROGMEM rec_on[] = {0x9a, 0x9b, 0}; - static const char PROGMEM rec_off[] = {0xde, 0xdf, 0}; - static const char PROGMEM neg_on[] = {0xb4, 0xb5, 0}; - static const char PROGMEM neg_off[] = {0xb6, 0xb7, 0}; - - - if (oled_mode == OLED_MODE_CALC) { - if (get_highest_layer(layer_state) == 1) { - oled_set_cursor(oled_max_chars()-8, 0); - - switch (calc_operator_display) { - case '+': - oled_write_P(div_off, false); - oled_write_P(mul_off, false); - oled_write_P(sub_off, false); - oled_write_P(add_on, false); - break; - case '-': - oled_write_P(div_off, false); - oled_write_P(mul_off, false); - oled_write_P(sub_on, false); - oled_write_P(add_off, false); - break; - case '*': - oled_write_P(div_off, false); - oled_write_P(mul_on, false); - oled_write_P(sub_off, false); - oled_write_P(add_off, false); - break; - case '/': - oled_write_P(div_on, false); - oled_write_P(mul_off, false); - oled_write_P(sub_off, false); - oled_write_P(add_off, false); - break; - case 's': - case 'r': - case 'n': - layer_on(2); - break; - default: - oled_write_P(div_off, false); - oled_write_P(mul_off, false); - oled_write_P(sub_off, false); - oled_write_P(add_off, false); - break; - } - } else if (get_highest_layer(layer_state) == 2) { - oled_set_cursor(oled_max_chars()-6, 0); - - switch (calc_operator_display) { - case '+': - case '-': - case '*': - case '/': - layer_off(2); - break; - case 's': - oled_write_P(neg_off, false); - oled_write_P(sqr_on, false); - oled_write_P(rec_off, false); - break; - case 'r': - oled_write_P(neg_off, false); - oled_write_P(sqr_off, false); - oled_write_P(rec_on, false); - break; - case 'n': - oled_write_P(neg_on, false); - oled_write_P(sqr_off, false); - oled_write_P(rec_off, false); - break; - default: - oled_write_P(neg_off, false); - oled_write_P(sqr_off, false); - oled_write_P(rec_off, false); - break; - } - } - - if (calc_display_lines == 1) { - oled_set_cursor(oled_max_chars()-strlen(calc_result_display)-2, 3); - oled_write_char(calc_operator_display, false); - } else if (calc_display_lines == 2) { - oled_set_cursor(oled_max_chars()-strlen(calc_status_display), 2); - oled_write(calc_status_display, false); - } - oled_set_cursor(oled_max_chars()-strlen(calc_result_display), 3); - oled_write(calc_result_display, false); - } -} - -static void render_logo(void) { - oled_write_raw_P(raw_logo, sizeof(raw_logo)); -} - -void render_frame(void) { - if (oled_logo_expired) { - if (oled_mode == OLED_MODE_DEFAULT) { - render_mode_section(); - render_layer_section(); - render_encoder_section(); - render_numlock_section(); - } else if (oled_mode == OLED_MODE_CALC) { - render_mode_section(); - render_calc_section(); - } else if (oled_mode == OLED_MODE_OFF) { - if (is_oled_on()) { - oled_off(); - } - } - } else { - render_logo(); - oled_logo_expired = timer_elapsed(oled_logo_timer) > OLED_LOGO_TIMEOUT; - } -} - -bool oled_task_kb(void) { - if (!oled_task_user()) { return false; } - if (timer_elapsed(oled_frame_timer) > OLED_FRAME_TIMEOUT) { - oled_clear(); - oled_frame_timer = timer_read(); - render_frame(); - } - - if (get_highest_layer(layer_state) == 1) { - oled_mode = OLED_MODE_CALC; - } else if (get_highest_layer(layer_state) == 2) { - if (IS_LAYER_ON(1)) { - oled_mode = OLED_MODE_CALC; - } else { - oled_mode = OLED_MODE_DEFAULT; - } - } else if (get_highest_layer(layer_state) == 3) { - oled_mode = OLED_MODE_OFF; - } else { - oled_mode = OLED_MODE_DEFAULT; - } - return false; -} - -oled_rotation_t oled_init_kb(oled_rotation_t rotation) { - oled_logo_timer = timer_read(); - oled_frame_timer = timer_read(); - return rotation; -} diff --git a/keyboards/rubi/lib/oled.h b/keyboards/rubi/lib/oled.h deleted file mode 100644 index 1737541c96..0000000000 --- a/keyboards/rubi/lib/oled.h +++ /dev/null @@ -1,32 +0,0 @@ -/* -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 - -#define OLED_FRAME_TIMEOUT (1000 / 30) // 30 fps -#define OLED_LOGO_TIMEOUT 3000 // 3 sec - -static uint16_t oled_frame_timer = 0; -static uint16_t oled_logo_timer = 0; -static bool oled_logo_expired = false; - -static const char PROGMEM raw_logo[] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,128,128,128,128,128,128, 0, 0, 0, 0, 0, 0, 0,128,128,128,128,128,128,128,128,128,128,128, 0, 0, 0, 0, 0, 0,128,128,128,128, 0, 0, 0, 0, 0, 0,128,128,128,128, 0, 0,128,128,128,128,128,128,128,128,128,128,128, 0, 0, 0, 0, 0,128,128,128,128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,128,224,112,184,220,204,182,123,254,251,187,223,231,203,126,254, 0, 0, 0, 0, 0, 0,255, 0, 0, 0,248, 8, 8, 8, 8, 8,249,225, 2, 12,248, 0, 0,255,255,255,255, 0, 0, 0, 0, 0, 0,255,255,255,255, 0, 0,255,255,255,255,199,199,199,199,199,207,255,255,254,124, 0, 0,255,255,255,255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,127,191,188,211,223,223,247,187,187,252,126,123,247,239,223,190,115,142, 0, 0, 0, 0, 0,255, 0, 0, 0,227, 34, 34, 34, 98,194, 1, 56,236,135, 1, 0, 0, 31, 63,127,255,248,240,240,240,240,248,255,127, 63, 31, 0, 0,255,255,255,255,227,227,227,227,227,243,255,255,127, 62, 0, 0,255,255,255,255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -}; |