summaryrefslogtreecommitdiff
path: root/firmware/drivers/lcd-bitmap-common.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/drivers/lcd-bitmap-common.c')
-rw-r--r--firmware/drivers/lcd-bitmap-common.c45
1 files changed, 45 insertions, 0 deletions
diff --git a/firmware/drivers/lcd-bitmap-common.c b/firmware/drivers/lcd-bitmap-common.c
index 0bae790e58..a149e8aaa9 100644
--- a/firmware/drivers/lcd-bitmap-common.c
+++ b/firmware/drivers/lcd-bitmap-common.c
@@ -615,3 +615,48 @@ void LCDFN(bmp)(const struct bitmap* bm, int x, int y)
615} 615}
616 616
617#endif 617#endif
618
619void LCDFN(nine_segment_bmp)(const struct bitmap* bm, int x, int y,
620 int width, int height)
621{
622 int seg_w = bm->width / 3;
623 int seg_h = bm->height / 3;
624 int src_x, src_y, dst_x, dst_y;
625
626 /* top */
627 src_x = seg_w; src_y = 0;
628 dst_x = seg_w; dst_y = 0;
629 for (; dst_x < width - seg_w; dst_x += seg_w)
630 LCDFN(bmp_part)(bm, src_x, src_y, dst_x, dst_y, seg_w, seg_h);
631 /* bottom */
632 src_x = seg_w; src_y = bm->height - seg_h;
633 dst_x = seg_w; dst_y = height - seg_h;
634 for (; dst_x < width - seg_w; dst_x += seg_w)
635 LCDFN(bmp_part)(bm, src_x, src_y, dst_x, dst_y, seg_w, seg_h);
636
637 /* left */
638 src_x = 0; src_y = seg_h;
639 dst_x = 0; dst_y = seg_h;
640 for (; dst_y < height - seg_h; dst_y += seg_h)
641 LCDFN(bmp_part)(bm, src_x, src_y, dst_x, dst_y, seg_w, seg_h);
642 /* right */
643 src_x = bm->width - seg_w; src_y = seg_h;
644 dst_x = width - seg_w; dst_y = seg_h;
645 for (; dst_y < height - seg_h; dst_y += seg_h)
646 LCDFN(bmp_part)(bm, src_x, src_y, dst_x, dst_y, seg_w, seg_h);
647 /* center */
648 dst_y = seg_h; src_y = seg_h; src_x = seg_w;
649 for (; dst_y < height - seg_h; dst_y += seg_h)
650 {
651 dst_x = seg_w;
652 for (; dst_x < width - seg_w; dst_x += seg_w)
653 LCDFN(bmp_part)(bm, src_x, src_y, dst_x, dst_y, seg_w, seg_h);
654 }
655
656 /* 4 corners */
657 LCDFN(bmp_part)(bm, 0, 0, x, y, seg_w, seg_h);
658 LCDFN(bmp_part)(bm, bm->width - seg_w, 0, width - seg_w, 0, seg_w, seg_h);
659 LCDFN(bmp_part)(bm, 0, bm->width - seg_h, 0, height - seg_h, seg_w, seg_h);
660 LCDFN(bmp_part)(bm, bm->width - seg_w, bm->width - seg_h,
661 width - seg_w, height - seg_h, seg_w, seg_h);
662}