purduesigbots / liblvgl

2 stars 3 forks source link

Replace vex_display_flush and vex_read_touch with simplified screen API's structs/calls. #9

Closed Richard-Stump closed 1 year ago

Richard-Stump commented 2 years ago

In the kernel repo, our LVGL hooks make calls to VexOs directly. These need replaced since the template cannot use the VexOs API. The functions liblvgl_display_flush() and liblvgl_read_touch() need to be updated to use the pros screen API rather than the VexOs api:

static void liblvgl_display_flush(lv_disp_drv_t* disp_drv, const lv_area_t* area, lv_color_t* color) {
    screen_copy_area(area->x1, area->y1, area->x2, area->y2, (uint32_t*)color, area->x2 - area->x1 + 1);
    lv_flush_ready();
}

static bool liblvgl_read_touch(lv_indev_drv_t* _, lv_indev_data_t* data) {
    screen_touch_status_s_t touch_data = screen_touch_status();

    switch (touch_data.touch_status) {
        case E_TOUCH_PRESSED:
        case E_TOUCH_HELD:
            data->state = LV_INDEV_STATE_PR;
            break;
        case E_TOUCH_RELEASED:
            data->state = LV_INDEV_STATE_REL;
            break;
    }
    // return last (x,y) pos in all cases https://doc.littlevgl.com/#Porting and
    // purduesigbots/pros#79
    data->point.x = touch_data.x;
    data->point.y = touch_data.y;
    return false;
}
Richard-Stump commented 2 years ago

Update: These functions appear to be defined in display.c as vex_display_flush and vex_read_touch. The sfuntions should get changed to have the names defined above, and they should use the pros screen api: https://pros.cs.purdue.edu/v5/api/cpp/screen.html