qmk_firmware

QMK firmware for my keyboards (Corne, Sweep Ferris) and trackball (Ploopy Adept)
Log | Files | Refs | Submodules | LICENSE

yampad.c (2280B)


      1 
      2 /* Copyright 2019
      3  *
      4  * This program is free software: you can redistribute it and/or modify
      5  * it under the terms of the GNU General Public License as published by
      6  * the Free Software Foundation, either version 2 of the License, or
      7  * (at your option) any later version.
      8  *
      9  * This program is distributed in the hope that it will be useful,
     10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
     11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     12  * GNU General Public License for more details.
     13  *
     14  * You should have received a copy of the GNU General Public License
     15  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
     16  */
     17 #include "quantum.h"
     18 #include <stdio.h>
     19 
     20 #if defined(OLED_ENABLE)
     21 oled_rotation_t oled_init_kb(oled_rotation_t rotation) {
     22     return OLED_ROTATION_270;
     23 }
     24 
     25 bool oled_task_kb(void) {
     26     if (!oled_task_user()) {
     27         return false;
     28     }
     29   // Host Keyboard Layer Status
     30   oled_write_P(PSTR("Layer"), false);
     31   switch (get_highest_layer(layer_state)) {
     32     case 0:
     33       oled_write_ln_P(PSTR(" BAS"), false);
     34       break;
     35     case 1:
     36       oled_write_ln_P(PSTR(" NAV"), false);
     37       break;
     38     case 2:
     39       oled_write_ln_P(PSTR(" RGB"), false);
     40       break;
     41     default:
     42       // Or use the write_ln shortcut over adding '\n' to the end of your string
     43       oled_write_ln_P(PSTR(" UND"), false);
     44   }
     45 
     46   // Host Keyboard LED Status
     47   led_t led_state = host_keyboard_led_state();
     48   oled_write_P(PSTR("-----"), false);
     49   oled_write_P(PSTR("Stats"), false);
     50   oled_write_P(led_state.num_lock ? PSTR("num:*") : PSTR("num:."), false);
     51   oled_write_P(led_state.caps_lock ? PSTR("cap:*") : PSTR("cap:."), false);
     52   oled_write_P(led_state.scroll_lock ? PSTR("scr:*") : PSTR("scr:."), false);
     53 
     54   // Host Keyboard RGB backlight status
     55   oled_write_P(PSTR("-----"), false);
     56   oled_write_P(PSTR("Light"), false);
     57 
     58   static char led_buf[30];
     59   snprintf(led_buf, sizeof(led_buf) - 1, "RGB:%cM: %2d\nh: %2ds: %2dv: %2d\n",
     60       rgblight_is_enabled() ? '*' : '.', (uint8_t)rgblight_get_mode(),
     61       (uint8_t)(rgblight_get_hue() / RGBLIGHT_HUE_STEP),
     62       (uint8_t)(rgblight_get_sat() / RGBLIGHT_SAT_STEP),
     63       (uint8_t)(rgblight_get_val() / RGBLIGHT_VAL_STEP));
     64   oled_write(led_buf, false);
     65 
     66   return false;
     67 }
     68 #endif