diff options
Diffstat (limited to 'firmware/drivers')
-rw-r--r-- | firmware/drivers/lcd.c | 138 | ||||
-rw-r--r-- | firmware/drivers/lcd.h | 11 |
2 files changed, 149 insertions, 0 deletions
diff --git a/firmware/drivers/lcd.c b/firmware/drivers/lcd.c index 5a08b55930..5e86647280 100644 --- a/firmware/drivers/lcd.c +++ b/firmware/drivers/lcd.c | |||
@@ -1051,6 +1051,144 @@ void lcd_getfontsize(unsigned int font, int *width, int *height) | |||
1051 | } | 1051 | } |
1052 | } | 1052 | } |
1053 | 1053 | ||
1054 | /* | ||
1055 | * Print a progress bar | ||
1056 | */ | ||
1057 | void lcd_progressbar(int x, int y, int width, int height, int percent, int direction) | ||
1058 | { | ||
1059 | int pos; | ||
1060 | int i,j; | ||
1061 | |||
1062 | /* draw horizontal lines */ | ||
1063 | for(i=x+1;i<=x+width-2;i++) { | ||
1064 | DRAW_PIXEL(i,y); | ||
1065 | DRAW_PIXEL(i,(y+height-1)); | ||
1066 | } | ||
1067 | |||
1068 | /* draw vertical lines */ | ||
1069 | for(i=1;i<height;i++) { | ||
1070 | DRAW_PIXEL(x,(y+i)); | ||
1071 | DRAW_PIXEL((x+width-1),(y+i)); | ||
1072 | } | ||
1073 | |||
1074 | /* clear edge pixels */ | ||
1075 | CLEAR_PIXEL(x,y); | ||
1076 | CLEAR_PIXEL((x+width-1),y); | ||
1077 | CLEAR_PIXEL(x,(y+height-1)); | ||
1078 | CLEAR_PIXEL((x+width-1),(y+height-1)); | ||
1079 | |||
1080 | /* clear pixels in progress bar */ | ||
1081 | for(i=1;i<=width-2;i++) { | ||
1082 | for(j=1;j<=height-2;j++) { | ||
1083 | CLEAR_PIXEL((x+i),(y+j)); | ||
1084 | CLEAR_PIXEL((x+i),(y+j)); | ||
1085 | } | ||
1086 | } | ||
1087 | |||
1088 | /* draw bar */ | ||
1089 | pos=percent; | ||
1090 | if(pos<0) | ||
1091 | pos=0; | ||
1092 | if(pos>100) | ||
1093 | pos=100; | ||
1094 | |||
1095 | switch (direction) | ||
1096 | { | ||
1097 | case BAR_RIGHT: | ||
1098 | pos=(width-2)*pos/100; | ||
1099 | for(i=1;i<=pos;i++) | ||
1100 | for(j=1;j<height-1;j++) | ||
1101 | DRAW_PIXEL((x+i),(y+j)); | ||
1102 | break; | ||
1103 | case BAR_LEFT: | ||
1104 | pos=(width-2)*(100-pos)/100; | ||
1105 | for(i=pos+1;i<=width-2;i++) | ||
1106 | for(j=1;j<height-1;j++) | ||
1107 | DRAW_PIXEL((x+i),(y+j)); | ||
1108 | break; | ||
1109 | case BAR_DOWN: | ||
1110 | pos=(height-2)*pos/100; | ||
1111 | for(i=1;i<=pos;i++) | ||
1112 | for(j=1;j<width-1;j++) | ||
1113 | DRAW_PIXEL((x+j),(y+i)); | ||
1114 | break; | ||
1115 | case BAR_UP: | ||
1116 | pos=(height-2)*(100-pos)/100; | ||
1117 | for(i=pos+1;i<=height-2;i++) | ||
1118 | for(j=1;j<width-1;j++) | ||
1119 | DRAW_PIXEL((x+j),(y+i)); | ||
1120 | break; | ||
1121 | } | ||
1122 | |||
1123 | } | ||
1124 | |||
1125 | |||
1126 | /* | ||
1127 | * Print a slidebar bar | ||
1128 | */ | ||
1129 | void lcd_slidebar(int x, int y, int width, int height, int percent, int direction) | ||
1130 | { | ||
1131 | int pos; | ||
1132 | int i,j; | ||
1133 | |||
1134 | /* draw horizontal lines */ | ||
1135 | for(i=x+1;i<=x+width-2;i++) { | ||
1136 | DRAW_PIXEL(i,y); | ||
1137 | DRAW_PIXEL(i,(y+height-1)); | ||
1138 | } | ||
1139 | |||
1140 | /* draw vertical lines */ | ||
1141 | for(i=1;i<height;i++) { | ||
1142 | DRAW_PIXEL(x,(y+i)); | ||
1143 | DRAW_PIXEL((x+width-1),(y+i)); | ||
1144 | } | ||
1145 | |||
1146 | /* clear edge pixels */ | ||
1147 | CLEAR_PIXEL(x,y); | ||
1148 | CLEAR_PIXEL((x+width-1),y); | ||
1149 | CLEAR_PIXEL(x,(y+height-1)); | ||
1150 | CLEAR_PIXEL((x+width-1),(y+height-1)); | ||
1151 | |||
1152 | /* clear pixels in progress bar */ | ||
1153 | for(i=1;i<=width-2;i++) | ||
1154 | for(j=1;j<=height-2;j++) { | ||
1155 | CLEAR_PIXEL((x+i),(y+j)); | ||
1156 | CLEAR_PIXEL((x+i),(y+j)); | ||
1157 | } | ||
1158 | |||
1159 | /* draw point */ | ||
1160 | pos=percent; | ||
1161 | if(pos<0) | ||
1162 | pos=0; | ||
1163 | if(pos>100) | ||
1164 | pos=100; | ||
1165 | |||
1166 | switch (direction) | ||
1167 | { | ||
1168 | case BAR_RIGHT: | ||
1169 | pos=(width-height-1)*pos/100; | ||
1170 | break; | ||
1171 | case BAR_LEFT: | ||
1172 | pos=(width-height-1)*(100-pos)/100; | ||
1173 | break; | ||
1174 | case BAR_DOWN: | ||
1175 | pos=(height-width-1)*pos/100; | ||
1176 | break; | ||
1177 | case BAR_UP: | ||
1178 | pos=(height-width-1)*(100-pos)/100; | ||
1179 | break; | ||
1180 | } | ||
1181 | |||
1182 | if(direction == BAR_LEFT || direction == BAR_RIGHT) | ||
1183 | for(i=1;i<height;i++) | ||
1184 | for(j=1;j<height;j++) | ||
1185 | DRAW_PIXEL((x+pos+i),(y+j)); | ||
1186 | else | ||
1187 | for(i=1;i<width;i++) | ||
1188 | for(j=1;j<width;j++) | ||
1189 | DRAW_PIXEL((x+i),(y+pos+j)); | ||
1190 | } | ||
1191 | |||
1054 | #else | 1192 | #else |
1055 | /* no LCD defined, no code to use */ | 1193 | /* no LCD defined, no code to use */ |
1056 | #endif | 1194 | #endif |
diff --git a/firmware/drivers/lcd.h b/firmware/drivers/lcd.h index 581ec3461d..c985cb067d 100644 --- a/firmware/drivers/lcd.h +++ b/firmware/drivers/lcd.h | |||
@@ -74,6 +74,15 @@ extern void lcd_double_height (bool on); | |||
74 | #define LCD_WIDTH 112 /* Display width in pixels */ | 74 | #define LCD_WIDTH 112 /* Display width in pixels */ |
75 | #define LCD_HEIGHT 64 /* Display height in pixels */ | 75 | #define LCD_HEIGHT 64 /* Display height in pixels */ |
76 | 76 | ||
77 | /* Directions for progressbar and scrollbar */ | ||
78 | enum | ||
79 | { | ||
80 | BAR_RIGHT = 0, | ||
81 | BAR_LEFT, | ||
82 | BAR_DOWN, | ||
83 | BAR_UP | ||
84 | }; | ||
85 | |||
77 | extern void lcd_putsxy(int x, int y, unsigned char *string, int font); | 86 | extern void lcd_putsxy(int x, int y, unsigned char *string, int font); |
78 | extern void lcd_setfont(int font); | 87 | extern void lcd_setfont(int font); |
79 | extern void lcd_getfontsize(unsigned int font, int *width, int *height); | 88 | extern void lcd_getfontsize(unsigned int font, int *width, int *height); |
@@ -88,6 +97,8 @@ extern void lcd_drawline( int x1, int y1, int x2, int y2 ); | |||
88 | extern void lcd_clearline( int x1, int y1, int x2, int y2 ); | 97 | extern void lcd_clearline( int x1, int y1, int x2, int y2 ); |
89 | extern void lcd_drawpixel(int x, int y); | 98 | extern void lcd_drawpixel(int x, int y); |
90 | extern void lcd_clearpixel(int x, int y); | 99 | extern void lcd_clearpixel(int x, int y); |
100 | extern void lcd_progressbar(int x, int y, int width, int height, int percent, int direction); | ||
101 | extern void lcd_slidebar(int x, int y, int width, int height, int percent, int direction); | ||
91 | 102 | ||
92 | #endif /* CHARCELLS / BITMAP */ | 103 | #endif /* CHARCELLS / BITMAP */ |
93 | 104 | ||