Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[wip] add mlego/m65 oled revision #15833

Merged
merged 17 commits into from
Jan 30, 2022
Prev Previous commit
Next Next commit
update oled code..
  • Loading branch information
alin m elena committed Jan 16, 2022
commit cc498f83c4ea57a727c2bd739d259f9c70712a5b
119 changes: 48 additions & 71 deletions keyboards/mlego/m65/keymaps/uk/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,43 +32,14 @@ enum layer_names {
#endif

#ifdef OLED_ENABLE
static uint16_t draw_logo_timer = 0;
static uint16_t show_logo_timer = 0;

static const char PROGMEM m65_logo[] = {
0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa5, 0xa5, 0xa5, 0xa5, 0xa5, 0xa5,
0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f, 0x90, 0x91, 0x92, 0x93, 0x94,
0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf, 0xb0, 0xb1, 0xb2, 0xb3, 0xb4,
0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, 0xd0, 0xd1, 0xd2, 0xd3, 0xd4,
0};

/*
static const char PROGMEM m65_logo[] = {
// 'slon_s', 84x32px
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x40, 0x40, 0xa0, 0xa0, 0xa0, 0xd0, 0xd0, 0xf0, 0xe0, 0xe0,
0xe0, 0xc0, 0xc0, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x0c, 0x03, 0x7c, 0x03, 0x0c, 0x14, 0x1c, 0x04, 0xfe,
0x8f, 0x80, 0x80, 0x81, 0xce, 0x7c, 0x03, 0x03, 0x07, 0x07, 0x06, 0x02, 0x00, 0x0c, 0x04, 0x04,
0x04, 0x04, 0x04, 0x0c, 0x08, 0x18, 0x30, 0x60, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0xf0, 0x9f, 0xe1, 0xb0, 0x4a, 0x09, 0x19, 0x08,
0x04, 0x01, 0x61, 0x1f, 0x07, 0x00, 0x00, 0x80, 0x40, 0x20, 0x20, 0x20, 0x60, 0x40, 0x40, 0x4a,
0x40, 0x40, 0x40, 0x40, 0x40, 0x60, 0x60, 0x00, 0x00, 0x00, 0x10, 0x08, 0x1f, 0x7c, 0xe0, 0x80,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x06, 0x06,
0x06, 0x06, 0x07, 0x07, 0x07, 0x05, 0x05, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x05, 0x00,
0x02, 0x02, 0x02, 0x02, 0x02, 0x03, 0x03, 0x03, 0x03, 0x02, 0x03, 0x03, 0x02, 0x02, 0x02, 0x02,
0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x03, 0x03, 0x07, 0x02, 0x02, 0x02, 0x02,
0x02, 0x00, 0x02, 0x03, 0x07, 0x07, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06,
0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x04, 0x05, 0x01, 0x05, 0x03, 0x00, 0x02, 0x00, 0x00, 0x00,
0x00
};
*/
static uint32_t oled_logo_timer = 0;
static bool clear_logo = true;
static const char PROGMEM m65_logo[] = {
0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa5, 0xa5, 0xa5, 0xa5, 0xa5, 0xa5,
0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f, 0x90, 0x91, 0x92, 0x93, 0x94,
0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf, 0xb0, 0xb1, 0xb2, 0xb3, 0xb4,
0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, 0xd0, 0xd1, 0xd2, 0xd3, 0xd4,
0};
#endif

#ifdef RGBLIGHT_ENABLE
Expand Down Expand Up @@ -220,7 +191,7 @@ altgr shift symbols
/*
lower layer
* ┌───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┐
* │ ` │ │ │ │ │ │ │ │ │ │ │ ⌫ │ = │
* │ ` │MUT│Vup│Vdn│prv│ply│nxt│EXT│SLP│WAK│PSC│ ⌫ │ = │
* ├───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┤
* │ │ σ │ ω │ ε │ ρ │ ϑ │ ℝ │ τ │ ∫ │ ∞ │ π │ [ │ ] │
* ├───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┤
Expand Down Expand Up @@ -287,31 +258,30 @@ raise layer shifted
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_WH_L, KC_WH_D, KC_WH_R),
/*
adj layer
* ┌───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬──────┐
* ││ │ │ │ │ │ │ │ │ │
* ├───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼──────┤
* │ │ │ │ │rst│ │ │ │ │ │ │
* ├───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼──────┤
* │ │ │ │ │ │ │ │ │ │ │ │
* ├───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼──────┤
* │ │ │ │ │ │ │ │ │ │ │ │
* ├───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼──────┤
* │ │ │ │ │ │ │ │ │ │ │
* └───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴──────┘
* ┌───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬────┬────┐
* │MOD│RMOD│ │ │ │ │ │ │ │ │ │M_T │M_SW
* ├───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼────┼────┤
* │HUI│HUD │M_P│ │rst│ │ │ │ │ │ │ │M_SN
* ├───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼────┼────┤
* │SAI│SAD │M_B│ │ │ │ │ │ │ │ │ │M_K
* ├───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼────┼────┤
* │VAI│VAD │M_R│ │ │ │ │ │ │ │ │ │M_X
* ├───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼────┼────┤
* │TOG │ │ │ │ │ │ │ │ │ │M_TW│M_G
* └───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴────┴────┘
*/
[_ADJ] = LAYOUT_ortho_5x13(
RGB_MOD, RGB_RMOD, A(KC_F2), _______, _______, _______, _______, _______, _______, _______, _______, _______ , RGB_M_SW,
RGB_HUI, RGB_HUD , RGB_M_P , _______, RESET , RGB_M_T, _______, _______, _______, _______, _______, _______ , RGB_M_SN,
RGB_MOD, RGB_RMOD, A(KC_F2), _______, _______, _______, _______, _______, _______, _______, _______, RGB_M_T , RGB_M_SW,
RGB_HUI, RGB_HUD , RGB_M_P , _______, RESET , _______, _______, _______, _______, _______, _______, _______ , RGB_M_SN,
RGB_SAI, RGB_SAD , RGB_M_B , _______, _______, _______, _______, _______, _______, _______, _______, _______ , RGB_M_K ,
RGB_VAI, RGB_VAD , RGB_M_R , _______, _______, _______, _______, _______, _______, _______, _______, _______ , RGB_M_X ,
RGB_TOG, _______ , _______ , _______, _______, _______, _______, _______, _______, _______, _______, RGB_M_TW, RGB_M_G),
};
// clang-format on

// let us assume we start with both layers off
bool toggle_lwr = false;
bool toggle_rse = false;
bool is_logo_on = true;
static bool toggle_lwr = false;
static bool toggle_rse = false;

bool led_update_user(led_t led_state) {
// Disable the default LED update code, so that lock LEDs could be reused to show layer status.
Expand Down Expand Up @@ -375,6 +345,10 @@ layer_state_t default_layer_state_set_user(layer_state_t state) {
void keyboard_post_init_user(void) {
// Enable the LED layers
rgblight_layers = my_rgb_layers;
#ifdef OLED_ENABLE
oled_logo_timer = timer_read32();
#endif

#ifdef CONSOLE_ENABLE

debug_enable = true;
Expand Down Expand Up @@ -420,16 +394,14 @@ bool encoder_update_user(uint8_t index, bool clockwise) {
#endif

#ifdef OLED_ENABLE
static void render_logo(void) {

oled_write_P(m65_logo, false);
//oled_write_raw_P(m65_logo, sizeof(m65_logo));
//oled_clear();
}
static void render_logo(void) {
oled_write_P(m65_logo, false);
}

void user_oled_magic(void) {
// Host Keyboard Layer Status
oled_write_P(PSTR("R1: Layer: "), false);
oled_write_P(PSTR("R1: Layer: "), false);

switch (get_highest_layer(layer_state)) {
case _QW:
Expand All @@ -456,24 +428,29 @@ void user_oled_magic(void) {
oled_write_P(led_state.scroll_lock ? PSTR("Raise ") : PSTR(" "), false);
}


oled_rotation_t oled_init_user(oled_rotation_t rotation) {
return rotation;
return OLED_ROTATION_180;
}

#define LOGO_RENDER 50
#define SHOW_LOGO 2000
bool oled_task_user(void) {
void clear_screen(void) {
if (clear_logo){
for (uint8_t i = 0; i < OLED_DISPLAY_HEIGHT; ++i) {
for (uint8_t j = 0; j < OLED_DISPLAY_WIDTH; ++j) {
oled_write_raw_byte(0x0, i*OLED_DISPLAY_WIDTH + j);
}
}
clear_logo = false;
}
}

if ((timer_elapsed(draw_logo_timer) < LOGO_RENDER)){
draw_logo_timer = timer_read();
# define SHOW_LOGO 5000
bool oled_task_user(void) {
if ((timer_elapsed32(oled_logo_timer) < SHOW_LOGO)){
render_logo();
} else if (timer_elapsed(show_logo_timer) > SHOW_LOGO){
show_logo_timer = timer_read();
} else {
}else{
clear_screen();
user_oled_magic();
}

return false;
}

Expand Down