zle dziala clear_buffor

This commit is contained in:
2021-05-30 18:17:06 +02:00
parent 2972501cef
commit 476101b0bd
4 changed files with 27 additions and 15 deletions

View File

@@ -340,9 +340,9 @@ void SSD1306_write_to_buffer(const uint8_t* bitmap, uint8_t bitmap_width, uint8_
}
if (pos_y < 0) {
tmp_buf16 |= tmp_bitmap >> (b.shift % 8);
tmp_buf16 |= (tmp_bitmap >> (b.shift % 8)) & ~(mask_buf);
} else {
tmp_buf16 |= tmp_bitmap << (b.shift % 8);
tmp_buf16 |= (tmp_bitmap << (b.shift % 8)) & ~(mask_buf);
}
}
@@ -357,7 +357,8 @@ void SSD1306_clear_buffer(uint8_t width, uint8_t height, int8_t pos_x, int8_t po
if (width + pos_x < 0 || height + pos_y < 0) return;
uint16_t tmp_buf16, bitmap_idx;
uint8_t mask_buf;
uint16_t mask_buf;
uint8_t bitmap_row;
switch(color)
{
@@ -375,17 +376,17 @@ void SSD1306_clear_buffer(uint8_t width, uint8_t height, int8_t pos_x, int8_t po
for(uint8_t col = b.buf_col_first; col < b.buf_col_last; col++, b.bitmap_col++)
{
tmp_buf16 = 0;
b.bitmap_row = b.bitmap_row_first;
for( uint8_t buf_row = b.buf_row_first; buf_row < b.buf_row_last; buf_row++, b.bitmap_row++ )
bitmap_row = b.bitmap_row_first;
for( uint8_t buf_row = b.buf_row_first; buf_row < b.buf_row_last; buf_row++, bitmap_row++ )
{
bitmap_idx = width * b.bitmap_row + b.bitmap_col;
bitmap_idx = width * bitmap_row + b.bitmap_col;
mask_buf = 0;
if (b.bitmap_row == 0 && pos_y > 0) {
if (bitmap_row == 0 && pos_y > 0) {
mask_buf |= 0xFF >> (8 - (b.shift % 8));
}
uint8_t shifted_pixels_left = (pos_y%8 + height) - b.bitmap_row * 8;
uint8_t shifted_pixels_left = (pos_y%8 + height) - bitmap_row * 8;
if (shifted_pixels_left < 8) {
mask_buf |= (0xFF << shifted_pixels_left);
}

View File

@@ -2015,7 +2015,7 @@ const FONT_CHAR_INFO arial_12ptDescriptors[] =
const FONT_INFO arial_12ptFontInfo =
{
16, /* Character height */
'!', /* Start character */
' ', /* Start character */
'~', /* End character */
2, /* Space between chars */
arial_12ptDescriptors, /* Character descriptor array */

View File

@@ -17,7 +17,7 @@ uint8_t font_print_str(const FONT_INFO * font, uint8_t * text, uint8_t pos_x, ui
uint8_t width = font_string_lenght_px(font, text);
SSD1306_clear_buffer(width, height, pos_x, pos_y, WHITE);
SSD1306_clear_buffer(width+2, height+2, pos_x-1, pos_y-1, BLACK);
while(*text)
{
@@ -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, BLACK);
SSD1306_write_to_buffer(font->data + charinfo->offset, charinfo->widthBits, height, x, pos_y, WHITE);
x += charinfo->widthBits + font->interspacePixels;
}

View File

@@ -59,7 +59,8 @@ void _ITM_SendChar(char character, void* arg);
/* Private user code ---------------------------------------------------------*/
/* USER CODE BEGIN 0 */
int8_t counter = 0;
uint8_t tekst[32];
/* USER CODE END 0 */
/**
@@ -98,15 +99,25 @@ int main(void)
// 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);
SSD1306_clear_buffer(10, 10, 64, 24, WHITE);
SSD1306_display_all();
// font_print_str(&arial_8ptFontInfo,(uint8_t *) "BarTooL jest Mistrzem", 0, 20);
// SSD1306_clear_buffer(10, 10, 64, 24, WHITE);
// SSD1306_display_all();
/* USER CODE END 2 */
/* Infinite loop */
/* USER CODE BEGIN WHILE */
while (1)
{
sprintf((char*)tekst, "%3d", counter);
// font_print_str(&arial_12ptFontInfo, tekst, 5, 16);
SSD1306_clear(BLACK);
font_print_str(&arial_8ptFontInfo, tekst, 40, 0);
SSD1306_clear_buffer(24, 12, 0, counter++, WHITE);
if (counter > 64+12){
counter = -16;
}
SSD1306_display_all();
HAL_Delay(100);
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */