comparison src/compass_ops.asm @ 257:5dd0f39d05d4

minor speed and size improvements for the compass routine
author heinrichsweikamp
date Mon, 23 Mar 2015 18:40:58 +0100
parents 5b4ef0b9090d
children da9074180bff
comparison
equal deleted inserted replaced
256:5b4ef0b9090d 257:5dd0f39d05d4
1054 rcall TFT_dive_compass_dir_lclr ; bearing = heading, no need for direction markers 1054 rcall TFT_dive_compass_dir_lclr ; bearing = heading, no need for direction markers
1055 rcall TFT_dive_compass_dir_rclr 1055 rcall TFT_dive_compass_dir_rclr
1056 bra TFT_dive_compass_text 1056 bra TFT_dive_compass_text
1057 1057
1058 TFT_dive_compass_dir_text_2: 1058 TFT_dive_compass_dir_text_2:
1059 movlw color_green
1060 call TFT_set_color
1059 btfsc compass_bearing_lft 1061 btfsc compass_bearing_lft
1060 bra TFT_dive_compass_dir_ldir ; bearing_lft=1, print the left marker 1062 bra TFT_dive_compass_dir_ldir ; bearing_lft=1, print the left marker
1061 ;TFT_dive_compass_text_rdir: 1063 ;TFT_dive_compass_text_rdir:
1062 movlw color_green
1063 call TFT_set_color
1064 WIN_SMALL dive_compass_rdir_column,dive_compass_head_row 1064 WIN_SMALL dive_compass_rdir_column,dive_compass_head_row
1065 STRCPY_PRINT ">>" 1065 STRCPY_PRINT ">>"
1066 ; do not forget to clear the left 1066 ; do not forget to clear the left
1067 rcall TFT_dive_compass_dir_lclr 1067 rcall TFT_dive_compass_dir_lclr
1068 bra TFT_dive_compass_text 1068 bra TFT_dive_compass_text
1069 1069
1070 TFT_dive_compass_dir_ldir: 1070 TFT_dive_compass_dir_ldir:
1071 movlw color_green
1072 call TFT_set_color
1073 WIN_SMALL dive_compass_ldir_column,dive_compass_head_row 1071 WIN_SMALL dive_compass_ldir_column,dive_compass_head_row
1074 STRCPY_PRINT "<<" 1072 STRCPY_PRINT "<<"
1075 ; do not forget to clear the right 1073 ; do not forget to clear the right
1076 rcall TFT_dive_compass_dir_rclr 1074 rcall TFT_dive_compass_dir_rclr
1077 ;bra TFT_dive_compass_text 1075 ;bra TFT_dive_compass_text
1133 ; don't do a clear if we are at 0 (zero) otherwise it will blink 1131 ; don't do a clear if we are at 0 (zero) otherwise it will blink
1134 ; ?because of the width underflow? 1132 ; ?because of the width underflow?
1135 movlw d'0' 1133 movlw d'0'
1136 cpfsgt lo 1134 cpfsgt lo
1137 bra TFT_dive_compass_label_proc_p 1135 bra TFT_dive_compass_label_proc_p
1138 rcall TFT_dive_compass_clr_label 1136 rcall TFT_dive_compass_clr_label
1139 TFT_dive_compass_label_proc_p: 1137 TFT_dive_compass_label_proc_p:
1140 ; 4. print the SQ on the screen 1138 ; 4. print the SQ on the screen
1141 call TFT_standard_color 1139 call TFT_standard_color
1142 bsf print_compass_label 1140 bsf print_compass_label
1143 rcall TFT_dive_compass_label_print 1141 ;TFT_dive_compass_label_print:
1142 movlw dive_compass_label_row
1143 movff WREG,win_top
1144 movff lo,win_leftx2
1145 movlw FT_SMALL
1146 movff WREG,win_font
1144 ; 6. retain the new display positions 1147 ; 6. retain the new display positions
1145 movff hi,divB ; old-hi will be used by the c_mk : clear+marker printing 1148 movff hi,divB ; old-hi will be used by the c_mk : clear+marker printing
1146 movff lo,hi 1149 movff lo,hi
1147 movff up,WREG 1150 movff up,WREG
1148 addwf hi,1 1151 addwf hi,1
1149 movff lo,xLO 1152 movff lo,xLO
1150 movff hi,xHI 1153 movff hi,xHI
1151 return 1154 return
1152 1155
1153 TFT_dive_compass_label_print:
1154 movlw dive_compass_label_row
1155 movff WREG,win_top
1156 movff lo,win_leftx2
1157 movlw FT_SMALL
1158 movff WREG,win_font
1159 return
1160
1161 TFT_dive_compass_c_mk: 1156 TFT_dive_compass_c_mk:
1162 ; Common task to draw center line and marker 1157 ; Common task to draw center line and marker
1163 ; until a proper implementation make it simple: 1158 ; until a proper implementation make it simple:
1164 rcall TFT_dive_compass_mk 1159 rcall TFT_dive_compass_mk
1165 rcall TFT_dive_compass_cline 1160 rcall TFT_dive_compass_cline
1186 bra TFT_dive_compass_mk_rear 1181 bra TFT_dive_compass_mk_rear
1187 ;TFT_dive_compass_mk_front: 1182 ;TFT_dive_compass_mk_front:
1188 clrf lo 1183 clrf lo
1189 movff xCM,lo 1184 movff xCM,lo
1190 bsf print_compass_label ; set=green marker 1185 bsf print_compass_label ; set=green marker
1191 rcall TFT_dive_compass_mk_print 1186 rcall TFT_dive_compass_mk_print
1192 bcf print_compass_label 1187 bcf print_compass_label
1193 bra TFT_dive_compass_mk_end 1188 bra TFT_dive_compass_mk_end
1194 1189
1195 TFT_dive_compass_mk_rear: 1190 TFT_dive_compass_mk_rear:
1196 clrf lo 1191 clrf lo
1197 movff xCM,lo 1192 movff xCM,lo
1198 bcf print_compass_label ; set=red marker 1193 bcf print_compass_label ; set=red marker
1199 rcall TFT_dive_compass_mk_print 1194 rcall TFT_dive_compass_mk_print
1200 1195
1201 TFT_dive_compass_mk_end: 1196 TFT_dive_compass_mk_end:
1202 movff xA+0,lo 1197 movff xA+0,lo
1203 movff xA+1,hi 1198 movff xA+1,hi
1204 return 1199 return
1207 movlw d'1' 1202 movlw d'1'
1208 cpfsgt lo 1203 cpfsgt lo
1209 bra TFT_dive_compass_mk_print_2 ; lo<1, skip the first line 1204 bra TFT_dive_compass_mk_print_2 ; lo<1, skip the first line
1210 movlw d'2' 1205 movlw d'2'
1211 subwf lo,0 1206 subwf lo,0
1212 movff WREG,win_leftx2 1207 ; movff WREG,win_leftx2
1213 rcall TFT_dive_compass_mk_print_3 1208 rcall TFT_dive_compass_mk_print_3
1214 TFT_dive_compass_mk_print_2: 1209 TFT_dive_compass_mk_print_2:
1215 movlw d'2' 1210 movlw d'2'
1216 addwf lo,0 1211 addwf lo,0
1212 ; rcall TFT_dive_compass_mk_print_3
1213 ; return
1214 TFT_dive_compass_mk_print_3:
1217 movff WREG,win_leftx2 1215 movff WREG,win_leftx2
1218 rcall TFT_dive_compass_mk_print_3
1219 return
1220 TFT_dive_compass_mk_print_3:
1221 movlw dive_compass_label_row 1216 movlw dive_compass_label_row
1222 movff WREG,win_top 1217 movff WREG,win_top
1223 movlw dive_compass_label_height-.2 1218 movlw dive_compass_label_height-.2
1224 movff WREG,win_height 1219 movff WREG,win_height
1225 movlw d'2' 1220 movlw d'2'
1236 TFT_dive_compass_clr_label: 1231 TFT_dive_compass_clr_label:
1237 movlw dive_compass_label_row-.2 ; set top & height 1232 movlw dive_compass_label_row-.2 ; set top & height
1238 movff WREG,win_top 1233 movff WREG,win_top
1239 movlw dive_compass_label_height+.2 1234 movlw dive_compass_label_height+.2
1240 movff WREG,win_height 1235 movff WREG,win_height
1241 rcall TFT_dive_compass_clear 1236 rcall TFT_dive_compass_clear
1242 return 1237 return
1243 1238
1244 TFT_dive_compass_clr_ruler: 1239 TFT_dive_compass_clr_ruler:
1245 ; top tick 1240 ; top tick
1246 movlw dive_compass_tick_top_top ; set top & height 1241 movlw dive_compass_tick_top_top ; set top & height
1251 ;bottom tick 1246 ;bottom tick
1252 movlw dive_compass_tick_bot_top ; set top & height 1247 movlw dive_compass_tick_bot_top ; set top & height
1253 movff WREG,win_top 1248 movff WREG,win_top
1254 movlw dive_compass_tick_height 1249 movlw dive_compass_tick_height
1255 movff WREG,win_height 1250 movff WREG,win_height
1256 rcall TFT_dive_compass_clear 1251 ; rcall TFT_dive_compass_clear
1257 return 1252 ; return
1258
1259 TFT_dive_compass_clear: 1253 TFT_dive_compass_clear:
1260 ; we receive RM in lo and DD in hi 1254 ; we receive RM in lo and DD in hi
1261 ; calculate width = RM-D 1255 ; calculate width = RM-D
1262 movff hi,WREG 1256 movff hi,WREG
1263 subwf lo,0 1257 subwf lo,0
1264 movff WREG,win_width ; RM-DD 1258 movff WREG,win_width ; RM-DD
1265 movff WREG,win_bargraph 1259 movff WREG,win_bargraph
1266 movff hi,win_leftx2 1260 incf hi,W ; +1 pixel to avopid clipping of chars
1261 movff WREG,win_leftx2
1267 movlw color_black 1262 movlw color_black
1268 call TFT_set_color 1263 call TFT_set_color
1269 call TFT_box 1264 call TFT_box
1270 return 1265 return
1271 1266
1284 call TFT_box 1279 call TFT_box
1285 movlw dive_compass_tick_bot_top 1280 movlw dive_compass_tick_bot_top
1286 movff WREG,win_top 1281 movff WREG,win_top
1287 movlw dive_compass_tick_height 1282 movlw dive_compass_tick_height
1288 movff WREG,win_height 1283 movff WREG,win_height
1289 call TFT_standard_color
1290 call TFT_box 1284 call TFT_box
1291 return 1285 return
1292 1286
1293 TFT_dive_compass_cline: 1287 TFT_dive_compass_cline:
1294 movlw color_yellow 1288 movlw color_yellow