comparison code_part1/OSTC_code_asm_part1/altimeter.asm @ 166:80de93d72a17

Allow display of altitude <= 0m
author JeanDo
date Sat, 22 Jan 2011 23:24:12 +0100
parents fdebc43c8372
children 0f7ca37b1412
comparison
equal deleted inserted replaced
165:8b5b848db4cd 166:80de93d72a17
107 WIN_LEFT .90 107 WIN_LEFT .90
108 WIN_INVERT .0 108 WIN_INVERT .0
109 WIN_FONT .0 109 WIN_FONT .0
110 call PLED_standard_color 110 call PLED_standard_color
111 111
112 STRCPY "Alt:" 112 STRCPY "Alt: "
113 113
114 movff altitude+0,lo ; BANK-SAFE read altitude 114 movff altitude+0,lo ; BANK-SAFE read altitude
115 movff altitude+1,hi 115 movff altitude+1,hi
116 movf lo,W ; Is it zero (not computed yet) ? 116 btfss hi,7 ; Is altitude negativ ?
117 iorwf hi,W 117 bra altimeter_2 ; No: just print it
118 bz altimeter_2 118
119 119 PUTC '-' ; Yes: print the minus sign
120 comf hi ; And do a 16bit 2-complement.
121 comf lo
122 infsnz lo
123 incf hi
124
125 altimeter_2:
120 bsf leftbind 126 bsf leftbind
121 output_16 127 output_16
122 bcf leftbind 128 bcf leftbind
123 bra altimeter_3 129
124 130 STRCAT_PRINT "m "
125 altimeter_2:
126 STRCAT "****"
127
128 altimeter_3:
129 STRCAT_PRINT "m "
130 return 131 return
131 132
132 ;============================================================================= 133 ;=============================================================================
133 ; Compute altitude, using the formula: 134 ; Compute altitude, using the formula:
134 ; H(P) = 18.787 log10(P0/P) (Log base 10) 135 ; H(P) = 18.787 log10(P0/P) (Log base 10)
238 altimeter_menu_2: 239 altimeter_menu_2:
239 WIN_FONT .0 ; Reset, because compute erase that... 240 WIN_FONT .0 ; Reset, because compute erase that...
240 WIN_INVERT .0 241 WIN_INVERT .0
241 WIN_LEFT .20 ; First line: 242 WIN_LEFT .20 ; First line:
242 WIN_TOP .35 243 WIN_TOP .35
243 STRCPY "Sea ref:" 244 STRCPY "Sea ref: "
244 245
245 movff pressureRef+0, lo 246 movff pressureRef+0, lo
246 movff pressureRef+1, hi 247 movff pressureRef+1, hi
247 bcf STATUS,C ; Divide ref pressure by 4 248 bcf STATUS,C ; Divide ref pressure by 4
248 rrcf hi ; to get the integer part of it: 249 rrcf hi ; to get the integer part of it:
264 output_99x 265 output_99x
265 266
266 STRCAT_PRINT "mbar " 267 STRCAT_PRINT "mbar "
267 268
268 WIN_TOP .65 ; Second line: 269 WIN_TOP .65 ; Second line:
269 STRCPY "Alt:" 270 STRCPY "Alt: "
270 movff altitude+0, lo 271 movff altitude+0, lo
271 movff altitude+1, hi 272 movff altitude+1, hi
273 btfss hi,7 ; Is altitude negativ ?
274 bra altimeter_menu_3 ; No: just print it
275
276 PUTC '-' ; Yes: print the minus sign
277 comf hi ; And do a 16bit 2-complement.
278 comf lo
279 infsnz lo
280 incf hi
281
282 altimeter_menu_3:
283 bsf leftbind
284 output_16
272 bcf leftbind 285 bcf leftbind
273 output_16
274 STRCAT_PRINT "m " 286 STRCAT_PRINT "m "
275 287
276 WIN_TOP .95 ; Action enable 288 WIN_TOP .95 ; Action enable
277 STRCPY "Enabled: " 289 STRCPY "Enabled: "
278 GETCUSTOM8 .49 290 GETCUSTOM8 .49