Skip to content

Implement: glcd_draw_bitmap_area #8

@ghost

Description

Description

A function to show icons anywhere on the screen.

Motivation

Be able to update icons anywhere on the display without fully refreshing display buffer. Useful for user interfaces with icons.

Status

Figured it's quite complex to calculate out the pixels in the buffer to update. @andygock do you know if there is perhaps a simpler more elegant approach to this ?

This the implementation I started, not complete:

const unsigned char data[] = {
     0x01, 0x00, 0xe0, 0xe0, 0x60, 0x60, 0x60, 0xfc, 0xfe, 0xe2, 0x02, 0x1e, 0x3c, 0x00, 0x00, 0x01, 
     0x80, 0x00, 0x0f, 0x0f, 0x0f, 0x0c, 0x0f, 0x0f, 0x0f, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80,
};
glcd_clear_buffer();
glcd_draw_bitmap_area(0, 0, 16, 16, data);
glcd_write();

void glcd_draw_bitmap_area(uint8_t x, uint8_t y, uint8_t w, uint8_t h, const unsigned char *data)
{
	uint8_t i;

	if (y % 8 == 0) {
		for (i = 0; i < h / 8; i++) {
			memcpy(glcd_buffer_selected + x + i * GLCD_NUMBER_OF_COLS, data + i * w, w);
		}
	}
	else {
		for (i = 0; i < w; i++) {
			glcd_buffer_selected[i + x + (y / 8) * GLCD_NUMBER_OF_COLS] = data[i] & (uint8_t) (0xff << (y % 8));
			glcd_buffer_selected[i + x + (y / 8 + h / 8) * GLCD_NUMBER_OF_COLS] = data[i] & (0xff00 & (0x00ff << (y % 8))) >> 8;
		}
		if (h > 8)
			memcpy(glcd_buffer_selected + x + GLCD_NUMBER_OF_COLS, data + w, (w * h) - w);
	}

	glcd_bbox_reset();
	glcd_update_bbox(x, y, x + w - 1, y + h - 1);
}

Reporter

@silver-kuusik

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions