rotate framebuffer
This commit is contained in:
@@ -29,4 +29,7 @@ fbpos_t fb_7seg_dig(fbpos_t x, fbpos_t y, fbpos_t w, fbpos_t h, fbpos_t th, uint
|
||||
/// \return width taken
|
||||
fbpos_t fb_7seg_period(fbpos_t x, fbpos_t y, fbpos_t w, fbpos_t h, fbpos_t th, fbcolor_t color);
|
||||
|
||||
|
||||
void fb_7seg_number(fbpos_t x, fbpos_t y, fbpos_t w, fbpos_t h, fbpos_t th, fbpos_t spacing, fbcolor_t color, uint16_t num, uint8_t places, uint8_t decimals);
|
||||
|
||||
#endif //FB_7SEG_H
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#define FRAMEBUFFER_CONFIG_H
|
||||
|
||||
/* Tiny framebuffer - size of the big actual OLED */
|
||||
#define FBW 128
|
||||
#define FBH 64
|
||||
#define FBW 64
|
||||
#define FBH 128
|
||||
|
||||
#endif /* FRAMEBUFFER_CONFIG_H */
|
||||
|
||||
+39
-2
@@ -46,8 +46,8 @@ fbpos_t fb_7seg_dig(fbpos_t x, fbpos_t y, fbpos_t w, fbpos_t h, fbpos_t th, uint
|
||||
th,
|
||||
hi, bcolor ^ (bool) (mask & LT));
|
||||
|
||||
fb_rect(x + th + wi,
|
||||
y + hi + th,
|
||||
fb_rect(x,
|
||||
y + hi + th * 2,
|
||||
th,
|
||||
hi, bcolor ^ (bool) (mask & LB));
|
||||
|
||||
@@ -70,3 +70,40 @@ fbpos_t fb_7seg_period(fbpos_t x, fbpos_t y, fbpos_t w, fbpos_t h, fbpos_t th, f
|
||||
fb_rect(x, y + hi * 2 + th * 2, th, th, color);
|
||||
return th;
|
||||
}
|
||||
|
||||
void fb_7seg_number(fbpos_t x, fbpos_t y, fbpos_t w, fbpos_t h, fbpos_t th, fbpos_t spacing, fbcolor_t color, uint16_t num, uint8_t places, uint8_t decimals)
|
||||
{
|
||||
uint8_t digits[5] = {};
|
||||
uint8_t pos = 4;
|
||||
while (num > 0) {
|
||||
uint8_t res = num % 10;
|
||||
num /= 10;
|
||||
digits[pos] = res;
|
||||
pos--;
|
||||
}
|
||||
|
||||
bool drawing = false;
|
||||
for (uint8_t i = 5 - places; i < 5; i++) {
|
||||
uint8_t d = digits[i];
|
||||
|
||||
if (i == 5 - decimals) {
|
||||
fb_7seg_period(x, y, w, h, th, color);
|
||||
x += th + spacing;
|
||||
}
|
||||
|
||||
if (!drawing && d == 0) {
|
||||
if (i == 5 - decimals - 1) {
|
||||
fb_7seg_dig(x, y, w, h, th, d, color);
|
||||
x += w + spacing;
|
||||
drawing = true;
|
||||
} else {
|
||||
fb_7seg_dig(x, y, w, h, th, 8, !color); // clear
|
||||
x += w + spacing;
|
||||
}
|
||||
} else {
|
||||
fb_7seg_dig(x, y, w, h, th, d, color);
|
||||
x += w + spacing;
|
||||
drawing = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user