diff options
Diffstat (limited to 'firmware/drivers/lcd-1bit-vert.c')
-rw-r--r-- | firmware/drivers/lcd-1bit-vert.c | 224 |
1 files changed, 1 insertions, 223 deletions
diff --git a/firmware/drivers/lcd-1bit-vert.c b/firmware/drivers/lcd-1bit-vert.c index f11fd6fdf9..db8cc6771b 100644 --- a/firmware/drivers/lcd-1bit-vert.c +++ b/firmware/drivers/lcd-1bit-vert.c | |||
@@ -692,226 +692,4 @@ void LCDFN(bitmap)(const unsigned char *src, int x, int y, int width, | |||
692 | LCDFN(bitmap_part)(src, 0, 0, width, x, y, width, height); | 692 | LCDFN(bitmap_part)(src, 0, 0, width, x, y, width, height); |
693 | } | 693 | } |
694 | 694 | ||
695 | /* put a string at a given pixel position, skipping first ofs pixel columns */ | 695 | #include "lcd-bitmap-common.c" |
696 | static void LCDFN(putsxyofs)(int x, int y, int ofs, const unsigned char *str) | ||
697 | { | ||
698 | unsigned short ch; | ||
699 | unsigned short *ucs; | ||
700 | struct font* pf = font_get(current_vp->font); | ||
701 | |||
702 | ucs = bidi_l2v(str, 1); | ||
703 | |||
704 | while ((ch = *ucs++) != 0 && x < current_vp->width) | ||
705 | { | ||
706 | int width; | ||
707 | const unsigned char *bits; | ||
708 | |||
709 | /* get proportional width and glyph bits */ | ||
710 | width = font_get_width(pf, ch); | ||
711 | |||
712 | if (ofs > width) | ||
713 | { | ||
714 | ofs -= width; | ||
715 | continue; | ||
716 | } | ||
717 | |||
718 | bits = font_get_bits(pf, ch); | ||
719 | |||
720 | LCDFN(mono_bitmap_part)(bits, ofs, 0, width, x, y, width - ofs, | ||
721 | pf->height); | ||
722 | |||
723 | x += width - ofs; | ||
724 | ofs = 0; | ||
725 | } | ||
726 | } | ||
727 | /* put a string at a given pixel position */ | ||
728 | void LCDFN(putsxy)(int x, int y, const unsigned char *str) | ||
729 | { | ||
730 | LCDFN(putsxyofs)(x, y, 0, str); | ||
731 | } | ||
732 | |||
733 | /*** Line oriented text output ***/ | ||
734 | |||
735 | /* put a string at a given char position */ | ||
736 | void LCDFN(puts)(int x, int y, const unsigned char *str) | ||
737 | { | ||
738 | LCDFN(puts_style_offset)(x, y, str, STYLE_DEFAULT, 0); | ||
739 | } | ||
740 | |||
741 | void LCDFN(puts_style)(int x, int y, const unsigned char *str, int style) | ||
742 | { | ||
743 | LCDFN(puts_style_offset)(x, y, str, style, 0); | ||
744 | } | ||
745 | |||
746 | void LCDFN(puts_offset)(int x, int y, const unsigned char *str, int offset) | ||
747 | { | ||
748 | LCDFN(puts_style_offset)(x, y, str, STYLE_DEFAULT, offset); | ||
749 | } | ||
750 | |||
751 | /* put a string at a given char position, style, and pixel position, | ||
752 | * skipping first offset pixel columns */ | ||
753 | void LCDFN(puts_style_offset)(int x, int y, const unsigned char *str, | ||
754 | int style, int offset) | ||
755 | { | ||
756 | int xpos,ypos,w,h,xrect; | ||
757 | int lastmode = current_vp->drawmode; | ||
758 | |||
759 | /* make sure scrolling is turned off on the line we are updating */ | ||
760 | LCDFN(scroll_stop_line)(current_vp, y); | ||
761 | |||
762 | if(!str || !str[0]) | ||
763 | return; | ||
764 | |||
765 | LCDFN(getstringsize)(str, &w, &h); | ||
766 | xpos = x*w / utf8length(str); | ||
767 | ypos = y*h; | ||
768 | current_vp->drawmode = (style & STYLE_INVERT) ? | ||
769 | (DRMODE_SOLID|DRMODE_INVERSEVID) : DRMODE_SOLID; | ||
770 | LCDFN(putsxyofs)(xpos, ypos, offset, str); | ||
771 | current_vp->drawmode ^= DRMODE_INVERSEVID; | ||
772 | xrect = xpos + MAX(w - offset, 0); | ||
773 | LCDFN(fillrect)(xrect, ypos, current_vp->width - xrect, h); | ||
774 | current_vp->drawmode = lastmode; | ||
775 | } | ||
776 | |||
777 | /*** scrolling ***/ | ||
778 | |||
779 | void LCDFN(puts_scroll)(int x, int y, const unsigned char *string) | ||
780 | { | ||
781 | LCDFN(puts_scroll_style)(x, y, string, STYLE_DEFAULT); | ||
782 | } | ||
783 | |||
784 | void LCDFN(puts_scroll_style)(int x, int y, const unsigned char *string, | ||
785 | int style) | ||
786 | { | ||
787 | LCDFN(puts_scroll_style_offset)(x, y, string, style, 0); | ||
788 | } | ||
789 | |||
790 | void LCDFN(puts_scroll_offset)(int x, int y, const unsigned char *string, | ||
791 | int offset) | ||
792 | { | ||
793 | LCDFN(puts_scroll_style_offset)(x, y, string, STYLE_DEFAULT, offset); | ||
794 | } | ||
795 | |||
796 | void LCDFN(puts_scroll_style_offset)(int x, int y, const unsigned char *string, | ||
797 | int style, int offset) | ||
798 | { | ||
799 | struct scrollinfo* s; | ||
800 | int w, h; | ||
801 | |||
802 | if ((unsigned)y >= (unsigned)current_vp->height) | ||
803 | return; | ||
804 | |||
805 | /* remove any previously scrolling line at the same location */ | ||
806 | LCDFN(scroll_stop_line)(current_vp, y); | ||
807 | |||
808 | if (LCDFN(scroll_info.lines) >= LCDM(SCROLLABLE_LINES)) return; | ||
809 | |||
810 | s = &LCDFN(scroll_info).scroll[LCDFN(scroll_info).lines]; | ||
811 | |||
812 | s->start_tick = current_tick + LCDFN(scroll_info).delay; | ||
813 | s->style = style; | ||
814 | if (style & STYLE_INVERT) { | ||
815 | LCDFN(puts_style_offset)(x,y,string,STYLE_INVERT,offset); | ||
816 | } | ||
817 | else | ||
818 | LCDFN(puts_offset)(x,y,string,offset); | ||
819 | |||
820 | LCDFN(getstringsize)(string, &w, &h); | ||
821 | |||
822 | if (current_vp->width - x * 8 < w) { | ||
823 | /* prepare scroll line */ | ||
824 | char *end; | ||
825 | |||
826 | memset(s->line, 0, sizeof s->line); | ||
827 | strcpy(s->line, string); | ||
828 | |||
829 | /* get width */ | ||
830 | s->width = LCDFN(getstringsize)(s->line, &w, &h); | ||
831 | |||
832 | /* scroll bidirectional or forward only depending on the string | ||
833 | width */ | ||
834 | if ( LCDFN(scroll_info).bidir_limit ) { | ||
835 | s->bidir = s->width < (current_vp->width) * | ||
836 | (100 + LCDFN(scroll_info).bidir_limit) / 100; | ||
837 | } | ||
838 | else | ||
839 | s->bidir = false; | ||
840 | |||
841 | if (!s->bidir) { /* add spaces if scrolling in the round */ | ||
842 | strcat(s->line, " "); | ||
843 | /* get new width incl. spaces */ | ||
844 | s->width = LCDFN(getstringsize)(s->line, &w, &h); | ||
845 | } | ||
846 | |||
847 | end = strchr(s->line, '\0'); | ||
848 | strlcpy(end, string, current_vp->width/2); | ||
849 | |||
850 | s->vp = current_vp; | ||
851 | s->y = y; | ||
852 | s->len = utf8length(string); | ||
853 | s->offset = offset; | ||
854 | s->startx = x * s->width / s->len; | ||
855 | s->backward = false; | ||
856 | |||
857 | LCDFN(scroll_info).lines++; | ||
858 | } | ||
859 | } | ||
860 | |||
861 | void LCDFN(scroll_fn)(void) | ||
862 | { | ||
863 | struct font* pf; | ||
864 | struct scrollinfo* s; | ||
865 | int index; | ||
866 | int xpos, ypos; | ||
867 | int lastmode; | ||
868 | struct viewport* old_vp = current_vp; | ||
869 | |||
870 | for ( index = 0; index < LCDFN(scroll_info).lines; index++ ) { | ||
871 | s = &LCDFN(scroll_info).scroll[index]; | ||
872 | |||
873 | /* check pause */ | ||
874 | if (TIME_BEFORE(current_tick, s->start_tick)) | ||
875 | continue; | ||
876 | |||
877 | LCDFN(set_viewport)(s->vp); | ||
878 | |||
879 | if (s->backward) | ||
880 | s->offset -= LCDFN(scroll_info).step; | ||
881 | else | ||
882 | s->offset += LCDFN(scroll_info).step; | ||
883 | |||
884 | pf = font_get(current_vp->font); | ||
885 | xpos = s->startx; | ||
886 | ypos = s->y * pf->height; | ||
887 | |||
888 | if (s->bidir) { /* scroll bidirectional */ | ||
889 | if (s->offset <= 0) { | ||
890 | /* at beginning of line */ | ||
891 | s->offset = 0; | ||
892 | s->backward = false; | ||
893 | s->start_tick = current_tick + LCDFN(scroll_info).delay * 2; | ||
894 | } | ||
895 | if (s->offset >= s->width - (current_vp->width - xpos)) { | ||
896 | /* at end of line */ | ||
897 | s->offset = s->width - (current_vp->width - xpos); | ||
898 | s->backward = true; | ||
899 | s->start_tick = current_tick + LCDFN(scroll_info).delay * 2; | ||
900 | } | ||
901 | } | ||
902 | else { | ||
903 | /* scroll forward the whole time */ | ||
904 | if (s->offset >= s->width) | ||
905 | s->offset %= s->width; | ||
906 | } | ||
907 | |||
908 | lastmode = current_vp->drawmode; | ||
909 | current_vp->drawmode = (s->style&STYLE_INVERT) ? | ||
910 | (DRMODE_SOLID|DRMODE_INVERSEVID) : DRMODE_SOLID; | ||
911 | LCDFN(putsxyofs)(xpos, ypos, s->offset, s->line); | ||
912 | current_vp->drawmode = lastmode; | ||
913 | LCDFN(update_viewport_rect)(xpos, ypos, current_vp->width - xpos, pf->height); | ||
914 | } | ||
915 | |||
916 | LCDFN(set_viewport)(old_vp); | ||
917 | } | ||