summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--stm32/app/font21x32.c19
-rw-r--r--stm32/app/font8x16.c18
-rw-r--r--stm32/app/font8x8.c14
3 files changed, 41 insertions, 10 deletions
diff --git a/stm32/app/font21x32.c b/stm32/app/font21x32.c
index 476af5e..5ac0f53 100644
--- a/stm32/app/font21x32.c
+++ b/stm32/app/font21x32.c
@@ -109,19 +109,30 @@ static const uint8_t font21x32[][84] = {
void
font21x32_put_ch (uint8_t *vram, unsigned ch, unsigned x)
{
+ unsigned xe;
+
if ((ch >= '0') && (ch <= '9'))
ch -= '0' - 1;
else
ch = 0;
+ if (x >= SSD1306_WIDTH) return;
+
+ xe = x + 21;
+
+ if (xe > SSD1306_WIDTH) xe = SSD1306_WIDTH;
+
- oled_blit_strip (vram, x, x + 21, 0xff, 0, font21x32[ch]);
+ oled_blit_strip (vram, x, xe, 0xff, 0, font21x32[ch]);
x += SSD1306_WIDTH;
- oled_blit_strip (vram, x, x + 21, 0xff, 0, &font21x32[ch][21]);
+ xe += SSD1306_WIDTH;
+ oled_blit_strip (vram, x, xe, 0xff, 0, &font21x32[ch][21]);
x += SSD1306_WIDTH;
- oled_blit_strip (vram, x, x + 21, 0xff, 0, &font21x32[ch][42]);
+ xe += SSD1306_WIDTH;
+ oled_blit_strip (vram, x, xe, 0xff, 0, &font21x32[ch][42]);
x += SSD1306_WIDTH;
- oled_blit_strip (vram, x, x + 21, 0xff, 0, &font21x32[ch][63]);
+ xe += SSD1306_WIDTH;
+ oled_blit_strip (vram, x, xe, 0xff, 0, &font21x32[ch][63]);
}
diff --git a/stm32/app/font8x16.c b/stm32/app/font8x16.c
index 4e3b5d6..c015f50 100644
--- a/stm32/app/font8x16.c
+++ b/stm32/app/font8x16.c
@@ -1033,27 +1033,37 @@ font8x16_put_ch (uint8_t *vram, unsigned ch, unsigned x, unsigned y)
unsigned shift = y & 7;
unsigned page = y >> 3;
unsigned mask;
+ unsigned xe;
+
+ if (x >= SSD1306_WIDTH) return;
+
+ xe = x + 8;
+
+ if (xe > SSD1306_WIDTH) xe = SSD1306_WIDTH;
x += page * SSD1306_WIDTH;
+ xe += page * SSD1306_WIDTH;
- oled_blit_strip (vram, x, x + 8, 0xff << shift, shift, font8x16[ch]);
+ oled_blit_strip (vram, x, xe, 0xff << shift, shift, font8x16[ch]);
x += SSD1306_WIDTH;
+ xe += SSD1306_WIDTH;
shift = 8 - shift;
mask = 0xff >> shift;
if (shift)
- oled_blit_strip (vram, x, x + 8, mask, -shift, font8x16[ch]);
+ oled_blit_strip (vram, x, xe, mask, -shift, font8x16[ch]);
shift = y & 7;
- oled_blit_strip (vram, x, x + 8, ~mask & (0xff << shift), shift,
+ oled_blit_strip (vram, x, xe, ~mask & (0xff << shift), shift,
&font8x16[ch][8]);
if (shift) {
x += SSD1306_WIDTH;
+ xe += SSD1306_WIDTH;
shift = 8 - shift;
- oled_blit_strip (vram, x, x + 8, 0xff >> shift, -shift,
+ oled_blit_strip (vram, x, xe, 0xff >> shift, -shift,
&font8x16[ch][8]);
}
diff --git a/stm32/app/font8x8.c b/stm32/app/font8x8.c
index c5c9d05..e9f3d4e 100644
--- a/stm32/app/font8x8.c
+++ b/stm32/app/font8x8.c
@@ -264,15 +264,25 @@ font8x8_put_ch (uint8_t *vram, unsigned ch, unsigned x, unsigned y)
{
unsigned shift = y & 7;
unsigned page = y >> 3;
+ unsigned xe;
+
+ if (x >= SSD1306_WIDTH) return;
+
+ xe = x + 8;
+
+ if (xe > SSD1306_WIDTH) xe = SSD1306_WIDTH;
+
x += page * SSD1306_WIDTH;
+ xe += page * SSD1306_WIDTH;
- oled_blit_strip (vram, x, x + 8, 0xff << shift, shift, font8x8[ch]);
+ oled_blit_strip (vram, x, xe, 0xff << shift, shift, font8x8[ch]);
if (shift) {
x += SSD1306_WIDTH;
+ xe += SSD1306_WIDTH;
shift = 8 - shift;
- oled_blit_strip (vram, x, x + 8, 0xff >> shift, -shift, font8x8[ch]);
+ oled_blit_strip (vram, x, xe, 0xff >> shift, -shift, font8x8[ch]);
}
}