0

I'm working on a keymap for the Lily58 that has a built in Pomodoro timer (repository here).

I'm running into issues showing images on the OLED. I have three bitmaps that represent the different "screens" I want to show. I memcpy the first one into a display buffer in keyboard_post_init_user and then blit that to the OLED using oled_write_raw in oled_task_user. That works fine. I can show all three screens that way.

[Splash Screen[5

Work Screen

Rest Screen

The problem is when I try to switch between the screens. I use an RPC call to update the state of the timer on the slave board and in that function I do another memcpy to load the new bitmap into the display buffer. But as soon as I do that it totally borks both displays, which I don't understand.

Borked OLEDs

Here's the code that does the initial memcpy:

void keyboard_post_init_user(void) {
     transaction_register_rpc(SYNC_POMODORO_STATE, set_slave_pomodoro_state);
     memcpy(header, headerBase, HEADER_SIZE);
     memcpy(statusDisplay, logoBase, STATUS_SIZE);
}

And the code that updates the OLED display:

bool oled_task_user(void) {
    if (is_keyboard_master()) {
        oled_write_ln(read_layer_state(), false);
        oled_write_ln(read_pomodoro_state(), false);
    } else {
        update_pomodoro_display();
    }
    return false;
}

void update_pomodoro_display(void) {
    // oled_clear();
    oled_set_cursor(0, 0);
    oled_write_raw(header, HEADER_SIZE);
    oled_set_cursor(0, 1);
    oled_write_raw(statusDisplay, STATUS_SIZE);
}

This is the code that I'm trying to add, but it messes up the display so I have it commented out.

void set_slave_pomodoro_state(uint8_t in_buflen, const void *in_data, uint8_t out_buflen, void *out_data) {
    state = *(pomo_state*)in_data;
    // if (state == _WORK) {
    //     memcpy(statusDisplay, workBase, STATUS_SIZE);
    // } else if (state == _REST) {
    //     memcpy(statusDisplay, restBase, STATUS_SIZE);
    // }
}

Where should I look?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
CaseyB
  • 24,780
  • 14
  • 77
  • 112

0 Answers0