ver2.c (2071B)
1 #include "quantum.h" 2 3 #ifdef OLED_ENABLE 4 oled_rotation_t oled_init_kb(oled_rotation_t rotation) { return OLED_ROTATION_180; } 5 6 bool oled_task_kb(void) { 7 if (!oled_task_user()) { 8 return false; 9 } 10 oled_write_P(PSTR("LAYER "), false); 11 oled_write_char(get_highest_layer(layer_state) + 0x30, true); 12 13 led_t led_state = host_keyboard_led_state(); 14 oled_set_cursor(18, 0); 15 oled_write_P(PSTR("NUM"), led_state.num_lock); 16 oled_set_cursor(18, 1); 17 oled_write_P(PSTR("CAP"), led_state.caps_lock); 18 oled_set_cursor(18, 2); 19 oled_write_P(PSTR("SCR"), led_state.scroll_lock); 20 21 uint8_t mod_state = get_mods(); 22 oled_set_cursor(10, 3); 23 oled_write_P(PSTR("S"), mod_state & MOD_MASK_SHIFT); 24 oled_advance_char(); 25 oled_write_P(PSTR("C"), mod_state & MOD_MASK_CTRL); 26 oled_advance_char(); 27 oled_write_P(PSTR("A"), mod_state & MOD_MASK_ALT); 28 oled_advance_char(); 29 oled_write_P(PSTR("G"), mod_state & MOD_MASK_GUI); 30 oled_advance_char(); 31 32 /* Matrix display is 12 x 12 pixels */ 33 #define MATRIX_DISPLAY_X 5 34 #define MATRIX_DISPLAY_Y 18 35 36 // matrix 37 for (uint8_t x = 0; x < MATRIX_ROWS; x++) { 38 for (uint8_t y = 0; y < MATRIX_COLS; y++) { 39 bool on = (matrix_get_row(x) & (1 << y)) > 0; 40 oled_write_pixel(MATRIX_DISPLAY_X + y + 2, MATRIX_DISPLAY_Y + x + 2, on); 41 } 42 } 43 44 // outline 45 for (uint8_t x = 0; x < 19; x++) { 46 oled_write_pixel(MATRIX_DISPLAY_X + x, MATRIX_DISPLAY_Y, true); 47 oled_write_pixel(MATRIX_DISPLAY_X + x, MATRIX_DISPLAY_Y + 9, true); 48 } 49 for (uint8_t y = 0; y < 9; y++) { 50 oled_write_pixel(MATRIX_DISPLAY_X, MATRIX_DISPLAY_Y+y, true); 51 oled_write_pixel(MATRIX_DISPLAY_X + 19, MATRIX_DISPLAY_Y+y, true); 52 } 53 54 // oled location 55 for (uint8_t x = 0; x < 3; x++) { 56 oled_write_pixel(MATRIX_DISPLAY_X + 14 + x, MATRIX_DISPLAY_Y + 2, true); 57 } 58 59 // bodge for layer number left hand side 60 for (uint8_t y = 0; y < 8; y++) { 61 oled_write_pixel(35, 0 + y, true); 62 } 63 return false; 64 } 65 #endif