Skip to content

[Feature] Underline & SetCursorWriteString #104

@RomainDereu

Description

@RomainDereu

Hello there!

I've been using this library a lot for a project of mine. I just wanted to share two additional functions that I've been using a lot and might be worth integrating into the main program. They are very lightweight and don't require modifications.


void ssd1306_SetCursor_WriteString(const char* str, ssd1306_Font_t font,
										 ssd1306_COLOR color,
										 uint8_t x_align,
										 uint8_t y_align){
	ssd1306_SetCursor(x_align, y_align);
	ssd1306_WriteString(str, font , color);
}

Very simple but very effective when writing text to avoid making pairings SetCursor WriteString all the time.

void ssd1306_underline_WriteString(const char* str, ssd1306_Font_t font,
										  ssd1306_COLOR color,
										  uint8_t x_align,
										  uint8_t y_align,
										  uint8_t underlined){

	uint8_t line_height = font.height +1;
	ssd1306_SetCursor(x_align, y_align);
	ssd1306_WriteString(str, font , color);
	if(underlined == 1){
		ssd1306_SetCursor(x_align, y_align +1);
		uint8_t line_length = font.width * strlen(str);
		screen_driver_Line(x_align, y_align + line_height,
						   x_align+ line_length, y_align + line_height, White);

	}
}

This one draws an underline based on the value of an int. Very useful to make menuing for selecting different items.

Hope this helps!

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