diff --git a/Core/Src/SSD1306_oled.c b/Core/Src/SSD1306_oled.c index 0b1bed6..c12920c 100644 --- a/Core/Src/SSD1306_oled.c +++ b/Core/Src/SSD1306_oled.c @@ -320,7 +320,7 @@ void SSD1306_write_to_buffer(const uint8_t* bitmap, uint8_t bitmap_width, uint8_ mask_buf |= 0xFF >> (8 - (b.shift % 8)); } - uint8_t shifted_pixels_left = (pos_y + bitmap_height) - b.bitmap_row * 8; + uint8_t shifted_pixels_left = (pos_y%8 + bitmap_height) - b.bitmap_row * 8; if (shifted_pixels_left < 8) { mask_buf |= (0xFF << shifted_pixels_left); } @@ -385,7 +385,7 @@ void SSD1306_clear_buffer(uint8_t width, uint8_t height, int8_t pos_x, int8_t po mask_buf |= 0xFF >> (8 - (b.shift % 8)); } - uint8_t shifted_pixels_left = (pos_y + height) - b.bitmap_row * 8; + uint8_t shifted_pixels_left = (pos_y%8 + height) - b.bitmap_row * 8; if (shifted_pixels_left < 8) { mask_buf |= (0xFF << shifted_pixels_left); } @@ -395,9 +395,9 @@ void SSD1306_clear_buffer(uint8_t width, uint8_t height, int8_t pos_x, int8_t po if (bitmap_idx < b.bitmap_max_idx) { if (pos_y < 0) { - tmp_buf16 |= color >> (b.shift % 8); + tmp_buf16 |= (color >> (b.shift % 8)) & ~(mask_buf); } else { - tmp_buf16 |= color << (b.shift % 8); + tmp_buf16 |= (color << (b.shift % 8)) & ~(mask_buf); } } diff --git a/Core/Src/fonts.c b/Core/Src/fonts.c index afb32a6..be6df9e 100644 --- a/Core/Src/fonts.c +++ b/Core/Src/fonts.c @@ -30,7 +30,7 @@ uint8_t font_print_str(const FONT_INFO * font, uint8_t * text, uint8_t pos_x, ui uint8_t char_nr = actual_char - font->startChar; const FONT_CHAR_INFO *charinfo = &font->charInfo[char_nr]; - ssd1306_write_to_buffer(font->data + charinfo->offset, charinfo->widthBits, height, x, pos_y, WHITE); + SSD1306_write_to_buffer(font->data + charinfo->offset, charinfo->widthBits, height, x, pos_y, BLACK); x += charinfo->widthBits + font->interspacePixels; } diff --git a/Core/Src/main.c b/Core/Src/main.c index 7c054f7..edda01f 100644 --- a/Core/Src/main.c +++ b/Core/Src/main.c @@ -97,8 +97,9 @@ int main(void) SSD1306_display_all(); // fctprintf(_ITM_SendChar, NULL, "This is a test: %X", 0xAA); // ssd1306_write_to_buffer(dualshock_btn[0], 24, 24, 10, 3); - font_print_str(&arial_8ptFontInfo,(uint8_t *) "AgBj0yH", 0, 10); - font_print_str(&arial_8ptFontInfo,(uint8_t *) "gBj0yHa", 0, 0); +// font_print_str(&arial_8ptFontInfo,(uint8_t *) "AgBj0yH", 0, 10); +// font_print_str(&arial_8ptFontInfo,(uint8_t *) "gBj0yHa", 0, 0); + SSD1306_clear_buffer(10, 10, 64, 24, WHITE); SSD1306_display_all(); /* USER CODE END 2 */ diff --git a/oled_fonts Debug.launch b/oled_fonts Debug.launch new file mode 100644 index 0000000..129d3b4 --- /dev/null +++ b/oled_fonts Debug.launch @@ -0,0 +1,73 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +