fix byte offset

This commit is contained in:
Elias Ahokas
2025-10-17 23:25:26 +03:00
parent e1aa89982d
commit 77d2aa09ec

View File

@@ -149,10 +149,16 @@ void lvgl_flush_callback(lv_display_t *disp, const lv_area_t *area, uint8_t *px_
uint8_t page_x = 0;
uint8_t page_y = 0;
for (uint16_t i = 1; i <= bytes; i++)
px_map += 8;
for (uint16_t i = 0; i <= bytes; i++)
{
uint8_t byte = px_map[i];
if(i < 8){
printf("0x%02X ", (unsigned int)byte);
}
for (int bit = 7; bit >= 0; bit--)
{
if (byte & (1 << bit))
@@ -161,16 +167,20 @@ void lvgl_flush_callback(lv_display_t *disp, const lv_area_t *area, uint8_t *px_
}
++page_x;
}
if (i % bytes_per_row == 0 && i != 0)
if ((i+1) % bytes_per_row == 0 && i+1 != 0)
{
page_y++;
page_x = 0;
}
if(i% bytes_per_page == 0 && i != 0){
if((i+1)% bytes_per_page == 0 && i+1 != 0){
i2c_disp_send_cmd(0x21);
i2c_disp_send_cmd(0);
i2c_disp_send_cmd(127);
i2c_disp_send_cmd(0x22);
i2c_disp_send_cmd(page);
i2c_disp_send_cmd(page);
i2c_disp_send_data(buf, sizeof(buf));
memset(buf, 0, sizeof(buf));
page++;
@@ -290,8 +300,8 @@ void counter_task(void *arg){
void create_counter(void){
lv_obj_t *scr = lv_scr_act();
lv_obj_set_style_bg_color(scr, lv_color_black(), 0);
lv_obj_set_style_bg_opa(scr, LV_OPA_COVER, 0);
//lv_obj_set_style_bg_color(scr, lv_color_black(), 0);
//lv_obj_set_style_bg_opa(scr, LV_OPA_COVER, 0);
/*
lv_obj_t *box = lv_obj_create(scr);
@@ -403,20 +413,25 @@ void app_main(void){
init_display();
vTaskDelay(pdMS_TO_TICKS(200));
clear_display();
vTaskDelay(pdMS_TO_TICKS(200));
init_graphics();
vTaskDelay(pdMS_TO_TICKS(500));
clear_display();
vTaskDelay(pdMS_TO_TICKS(200));
create_counter();
vTaskDelay(pdMS_TO_TICKS(500));
xTaskCreate(lv_tick_task, "lv_tick", 4096, NULL, 1, NULL);
xTaskCreate(lv_task, "lv_task", 8192, NULL, 5, NULL);
vTaskDelay(pdMS_TO_TICKS(200));
create_counter();
/*while(1){
clear_display();