Mercurial > public > hwos_code
comparison src/compass_ops.asm @ 582:b455b31ce022
work on 2.97 stable
| author | heinrichsweikamp |
|---|---|
| date | Mon, 26 Feb 2018 16:40:28 +0100 |
| parents | b8f45b57302d |
| children | ca4556fb60b9 |
comparison
equal
deleted
inserted
replaced
| 581:f5de1ff88814 | 582:b455b31ce022 |
|---|---|
| 1 #include "hwos.inc" | 1 ;============================================================================= |
| 2 #include "i2c.inc" | 2 ; |
| 3 #include "tft_outputs.inc" | 3 ; File compass_ops.asm V2.98 |
| 4 #include "isr.inc" | 4 ; |
| 5 ; Compass Operations | |
| 6 ; | |
| 7 ; Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved. | |
| 8 ;============================================================================= | |
| 9 | |
| 10 #include "hwos.inc" | |
| 11 #include "i2c.inc" | |
| 12 #include "tft_outputs.inc" | |
| 13 #include "isr.inc" | |
| 5 #include "tft.inc" | 14 #include "tft.inc" |
| 6 #include "strings.inc" | 15 #include "strings.inc" |
| 7 #include "wait.inc" ; speed_* | 16 #include "wait.inc" ; speed_* |
| 8 #include "surfmode.inc" | 17 #include "surfmode.inc" |
| 9 #include "divemode.inc" | 18 #include "divemode.inc" |
| 10 #include "math.inc" | 19 #include "math.inc" |
| 11 #include "convert.inc" | 20 #include "convert.inc" |
| 12 | 21 |
| 13 | 22 |
| 14 ; Make sure symbols from the .inc are available to the C code: | 23 ; Make sure symbols from the .inc are available to the C code: |
| 15 ; Filtered data | 24 ; Filtered data |
| 16 global compass_DX_f, compass_DY_f, compass_DZ_f | 25 global compass_DX_f |
| 17 global accel_DX_f, accel_DY_f, accel_DZ_f | 26 global compass_DY_f |
| 18 | 27 global compass_DZ_f |
| 19 ; Calibration data | 28 |
| 20 global compass_CX_f | 29 global accel_DX_f |
| 21 global compass_CY_f | 30 global accel_DY_f |
| 22 global compass_CZ_f | 31 global accel_DZ_f |
| 23 | 32 |
| 24 ; Tmp values to pass Q15 arithmetics around | 33 ; Calibration data |
| 25 global compass_a | 34 global compass_CX_f |
| 26 global compass_b | 35 global compass_CY_f |
| 27 | 36 global compass_CZ_f |
| 28 ; Result | 37 |
| 29 global compass_heading; , compass_roll, compass_pitch | 38 ; Tmp values to pass Q15 arithmetics around |
| 30 | 39 global compass_a |
| 31 extern compass | 40 global compass_b |
| 32 extern compass_reset_calibration | 41 |
| 33 extern compass_add_calibration | 42 ; Result |
| 34 extern compass_solve_calibration | 43 global compass_heading |
| 35 | 44 ; global compass_roll |
| 36 extern menu_processor_bottom_line | 45 ; global compass_pitch |
| 46 | |
| 47 | |
| 48 extern compass | |
| 49 extern compass_reset_calibration | |
| 50 extern compass_add_calibration | |
| 51 extern compass_solve_calibration | |
| 52 extern menu_processor_bottom_line | |
| 53 extern option_save_all | |
| 54 extern compass | |
| 55 | |
| 37 | 56 |
| 38 compass_ops code | 57 compass_ops code |
| 58 | |
| 59 ;============================================================================= | |
| 60 | |
| 39 ;----------------------------------------------------------------------------- | 61 ;----------------------------------------------------------------------------- |
| 40 ; Filter compass values | 62 ; Filter compass values |
| 41 ; | 63 ; |
| 42 ; Apply linear filtering to input parameters. | 64 ; Apply linear filtering to input parameters. |
| 43 | 65 |
| 44 ; Apply filtering formula: | 66 ; Apply filtering formula: reg_f += (reg - reg_f) / 4 |
| 45 ; reg_f += (reg - reg_f) / 4 | 67 FILTER16 MACRO reg, reg_f |
| 46 FILTER16 MACRO reg, reg_f | 68 movf reg_f+0,W |
| 47 movf reg_f+0,W | 69 subwf reg+0,W |
| 48 subwf reg+0,W | 70 movwf PRODL |
| 49 movwf PRODL | 71 movf reg_f+1,W |
| 50 movf reg_f+1,W | 72 subwfb reg+1,W |
| 51 subwfb reg+1,W | 73 rcall filter_16_common |
| 52 rcall filter_16_common | 74 addwf reg_f+0,F |
| 53 addwf reg_f+0,F | 75 movf PRODH,W |
| 54 movf PRODH,W | 76 addwfc reg_f+1,F |
| 55 addwfc reg_f+1,F | 77 ENDM |
| 56 ENDM | |
| 57 | 78 |
| 58 filter_16_common: | 79 filter_16_common: |
| 59 movwf PRODH | 80 movwf PRODH |
| 60 | 81 bcf STATUS,C ; Copy sign bit into carry |
| 61 bcf STATUS,C ; Copy sign bit into carry | 82 btfsc PRODH,7 |
| 62 btfsc PRODH,7 | 83 bsf STATUS,C |
| 63 bsf STATUS,C | 84 rrcf PRODH,F ; 16bit shift right |
| 64 rrcf PRODH,F ; 16bit shift right | 85 rrcf PRODL,F |
| 65 rrcf PRODL,F | 86 bcf STATUS,C ; Copy sign bit into carry |
| 66 | 87 btfsc PRODH,7 |
| 67 bcf STATUS,C ; Copy sign bit into carry | 88 bsf STATUS,C |
| 68 btfsc PRODH,7 | 89 rrcf PRODH,F ; 16bit shift right |
| 69 bsf STATUS,C | 90 rrcf PRODL,W |
| 70 rrcf PRODH,F ; 16bit shift right | 91 return |
| 71 rrcf PRODL,W | 92 |
| 72 return | 93 global compass_filter |
| 73 | |
| 74 global compass_filter | |
| 75 compass_filter: | 94 compass_filter: |
| 76 banksel compass_DX | 95 banksel compass_DX |
| 77 | 96 FILTER16 compass_DX, compass_DX_f |
| 78 FILTER16 compass_DX, compass_DX_f | 97 FILTER16 compass_DY, compass_DY_f |
| 79 FILTER16 compass_DY, compass_DY_f | 98 FILTER16 compass_DZ, compass_DZ_f |
| 80 FILTER16 compass_DZ, compass_DZ_f | 99 FILTER16 accel_DX, accel_DX_f |
| 81 FILTER16 accel_DX, accel_DX_f | 100 FILTER16 accel_DY, accel_DY_f |
| 82 FILTER16 accel_DY, accel_DY_f | 101 FILTER16 accel_DZ, accel_DZ_f |
| 83 FILTER16 accel_DZ, accel_DZ_f | 102 banksel common |
| 84 banksel common | 103 return |
| 85 return | |
| 86 | 104 |
| 87 ;----------------------------------------------------------------------------- | 105 ;----------------------------------------------------------------------------- |
| 88 | 106 |
| 89 compass_filter_init: | 107 compass_filter_init: |
| 90 movff compass_DX+0, compass_DX_f+0 | 108 movff compass_DX+0, compass_DX_f+0 |
| 91 movff compass_DX+1, compass_DX_f+1 | 109 movff compass_DX+1, compass_DX_f+1 |
| 92 movff compass_DY+0, compass_DY_f+0 | 110 movff compass_DY+0, compass_DY_f+0 |
| 93 movff compass_DY+1, compass_DY_f+1 | 111 movff compass_DY+1, compass_DY_f+1 |
| 94 movff compass_DZ+0, compass_DZ_f+0 | 112 movff compass_DZ+0, compass_DZ_f+0 |
| 95 movff compass_DZ+1, compass_DZ_f+1 | 113 movff compass_DZ+1, compass_DZ_f+1 |
| 96 movff accel_DX+0, accel_DX_f+0 | 114 movff accel_DX+0, accel_DX_f+0 |
| 97 movff accel_DX+1, accel_DX_f+1 | 115 movff accel_DX+1, accel_DX_f+1 |
| 98 movff accel_DY+0, accel_DY_f+0 | 116 movff accel_DY+0, accel_DY_f+0 |
| 99 movff accel_DY+1, accel_DY_f+1 | 117 movff accel_DY+1, accel_DY_f+1 |
| 100 movff accel_DZ+0, accel_DZ_f+0 | 118 movff accel_DZ+0, accel_DZ_f+0 |
| 101 movff accel_DZ+1, accel_DZ_f+1 | 119 movff accel_DZ+1, accel_DZ_f+1 |
| 102 return | 120 return |
| 103 | 121 |
| 104 ;----------------------------------------------------------------------------- | 122 ;----------------------------------------------------------------------------- |
| 105 ; Q15 fractional numbers: a * b / 2**16 (UNSIGNED) | 123 ; Q15 fractional numbers: a * b / 2**16 (UNSIGNED) |
| 106 ; | 124 ; |
| 107 ; Uses 16x16->16 multiply, for positiv integers, keeping only the most | 125 ; Uses 16x16->16 multiply, for positiv integers, keeping only the most |
| 110 ; Used to multiply two Q15 numbers, in the range 0..1, | 128 ; Used to multiply two Q15 numbers, in the range 0..1, |
| 111 ; represented as 0..32767, that is a / 2**15. | 129 ; represented as 0..32767, that is a / 2**15. |
| 112 ; | 130 ; |
| 113 ; (a/2**15) * (b/2**15) = a*b / 2**30 = (a*b/2**16) / 2**14. | 131 ; (a/2**15) * (b/2**15) = a*b / 2**30 = (a*b/2**16) / 2**14. |
| 114 ; So to get back a Q15 number, we need a shift-left... | 132 ; So to get back a Q15 number, we need a shift-left... |
| 115 global compass_umul | 133 global compass_umul |
| 116 compass_umul: | 134 compass_umul: |
| 117 rcall compass_mul_16 | 135 rcall compass_mul_16 |
| 118 | 136 |
| 119 ; The 2x time, by left-shifting inserting the missing bit: | 137 ; The 2x time, by left-shifting inserting the missing bit: |
| 120 compass_mul_2: | 138 compass_mul_2: |
| 121 rlcf compass_r+2,F ; Missing bit into carry | 139 rlcf compass_r+2,F ; Missing bit into carry |
| 122 rlcf compass_r+0,F | 140 rlcf compass_r+0,F |
| 123 rlcf compass_r+1,F | 141 rlcf compass_r+1,F |
| 124 movff compass_r+0,PRODL ; return value into ProdH:L | 142 movff compass_r+0,PRODL ; return value into ProdH:L |
| 125 movff compass_r+1,PRODH | 143 movff compass_r+1,PRODH |
| 126 return | 144 return |
| 127 | 145 |
| 128 ; The 16x16-> multiply: | 146 ; The 16x16-> multiply: |
| 129 compass_mul_16: | 147 compass_mul_16: |
| 130 banksel compass_a | 148 banksel compass_a |
| 131 | 149 |
| 132 movf compass_a+1,W ; Block ah*bh | 150 movf compass_a+1,W ; Block ah*bh |
| 133 mulwf compass_b+1 | 151 mulwf compass_b+1 |
| 134 movff PRODL,compass_r+0 ; and copy | 152 movff PRODL,compass_r+0 ; and copy |
| 135 movff PRODH,compass_r+1 | 153 movff PRODH,compass_r+1 |
| 136 | 154 |
| 137 movf compass_a+0,W ; Block al*bl | 155 movf compass_a+0,W ; Block al*bl |
| 138 mulwf compass_b+0 | 156 mulwf compass_b+0 |
| 139 movff PRODH,compass_r+2 ; Into fraction byte | 157 movff PRODH,compass_r+2 ; Into fraction byte |
| 140 | 158 |
| 141 movf compass_a+1,W ; Block ah*bl | 159 movf compass_a+1,W ; Block ah*bl |
| 142 mulwf compass_b+0 | 160 mulwf compass_b+0 |
| 143 movf PRODL,W | 161 movf PRODL,W |
| 144 addwf compass_r+2,F ; Fraction part to carry. | 162 addwf compass_r+2,F ; Fraction part to carry. |
| 145 movf PRODH,W ; and add16 | 163 movf PRODH,W ; and add16 |
| 146 addwfc compass_r+0,F | 164 addwfc compass_r+0,F |
| 147 movlw 0 | 165 movlw 0 |
| 148 addwfc compass_r+1,F | 166 addwfc compass_r+1,F |
| 149 | 167 |
| 150 movf compass_a+0,W ; Block al*bh | 168 movf compass_a+0,W ; Block al*bh |
| 151 mulwf compass_b+1 | 169 mulwf compass_b+1 |
| 152 movf PRODL,W | 170 movf PRODL,W |
| 153 addwf compass_r+2,F ; Fraction part to carry. | 171 addwf compass_r+2,F ; Fraction part to carry. |
| 154 movf PRODH,W ; and add16 | 172 movf PRODH,W ; and add16 |
| 155 addwfc compass_r+0,F | 173 addwfc compass_r+0,F |
| 156 movlw 0 | 174 movlw 0 |
| 157 addwfc compass_r+1,F | 175 addwfc compass_r+1,F |
| 158 | 176 |
| 159 return | 177 return |
| 160 | 178 |
| 161 ;----------------------------------------------------------------------------- | 179 ;----------------------------------------------------------------------------- |
| 162 ; Q15 fractional numbers: a * b / 2**16 (SIGNED) | 180 ; Q15 fractional numbers: a * b / 2**16 (SIGNED) |
| 163 | 181 |
| 164 global compass_imul | 182 global compass_imul |
| 165 compass_imul: | 183 compass_imul: |
| 166 rcall compass_mul_16 | 184 rcall compass_mul_16 |
| 167 | 185 |
| 168 btfss compass_b+1,7 | 186 btfss compass_b+1,7 |
| 169 bra compass_mul_3 | 187 bra compass_mul_3 |
| 170 | 188 |
| 171 movf compass_a+0,W | 189 movf compass_a+0,W |
| 172 subwf compass_r+0,F | 190 subwf compass_r+0,F |
| 173 movf compass_a+1,W | 191 movf compass_a+1,W |
| 174 subwfb compass_r+1,F | 192 subwfb compass_r+1,F |
| 175 | 193 |
| 176 compass_mul_3: | 194 compass_mul_3: |
| 177 btfss compass_a+1,7 | 195 btfss compass_a+1,7 |
| 178 bra compass_mul_4 | 196 bra compass_mul_4 |
| 179 | 197 |
| 180 movf compass_b+0,W | 198 movf compass_b+0,W |
| 181 subwf compass_r+0,F | 199 subwf compass_r+0,F |
| 182 movf compass_b+1,W | 200 movf compass_b+1,W |
| 183 subwfb compass_r+1,F | 201 subwfb compass_r+1,F |
| 184 | 202 |
| 185 compass_mul_4: | 203 compass_mul_4: |
| 186 bcf compass_r+1,6 ; Copy bit 7 to 6, so keep it after 2x | 204 bcf compass_r+1,6 ; Copy bit 7 to 6, so keep it after 2x |
| 187 btfsc compass_r+1,7 | 205 btfsc compass_r+1,7 |
| 188 bsf compass_r+1,6 | 206 bsf compass_r+1,6 |
| 189 bra compass_mul_2 | 207 bra compass_mul_2 |
| 190 | 208 |
| 191 global compass_calibration_loop | 209 global compass_calibration_loop |
| 192 compass_calibration_loop: ; Compass calibration | 210 compass_calibration_loop: ; Compass calibration |
| 193 bsf no_sensor_int ; No Sensor ISR | 211 bsf no_sensor_int ; No Sensor ISR |
| 194 call I2C_sleep_accelerometer ; Stop accelerometer | 212 call I2C_sleep_accelerometer ; Stop accelerometer |
| 195 call I2C_sleep_compass ; Stop compass | 213 call I2C_sleep_compass ; Stop compass |
| 196 call TFT_ClearScreen | 214 call TFT_ClearScreen |
| 197 ; Mask | 215 ; Mask |
| 198 WIN_COLOR color_greenish | 216 WIN_COLOR color_greenish |
| 199 WIN_SMALL .16,.0 | 217 WIN_SMALL .16,.0 |
| 200 STRCPY_TEXT_PRINT tCompassMenu | 218 STRCPY_TEXT_PRINT tCompassMenu |
| 201 btfss switch_right2 ; wait until button is released | 219 btfss switch_right2 ; wait until button is released |
| 202 bra $-4 | 220 bra $-4 |
| 203 | 221 |
| 204 call TFT_standard_color | 222 call TFT_standard_color |
| 205 ; WIN_SMALL .0,.215 | 223 ; WIN_SMALL .0,.215 |
| 206 ; STRCPY_TEXT_PRINT tExit | 224 ; STRCPY_TEXT_PRINT tExit |
| 207 WAITMS d'255' | 225 WAITMS d'255' |
| 208 WAITMS d'255' | 226 WAITMS d'255' |
| 209 | 227 |
| 210 movlw .7 ; Gain init | 228 movlw .7 ; Gain init |
| 211 movff WREG,opt_compass_gain | 229 movff WREG,opt_compass_gain |
| 212 compass_calibration_gainset: ; Reduce the gain, set bank here! | 230 compass_calibration_gainset: ; Reduce the gain, set bank here! |
| 213 banksel opt_compass_gain | 231 banksel opt_compass_gain |
| 214 decf opt_compass_gain,F ; Reduce by one | 232 decf opt_compass_gain,F ; Reduce by one |
| 215 btfsc STATUS,N ; <0? | 233 btfsc STATUS,N ; <0? |
| 216 clrf opt_compass_gain ; Yes, keep at zero | 234 clrf opt_compass_gain ; Yes, keep at zero |
| 217 | 235 |
| 218 banksel common | 236 banksel common |
| 219 call I2C_init_accelerometer | 237 call I2C_init_accelerometer |
| 220 call I2C_init_compass | 238 call I2C_init_compass |
| 221 | 239 |
| 222 ; btfsc compass_type ; compass1? | 240 ; btfsc compass_type ; compass1? |
| 223 ; bra compass_calibration_loop1 ; Yes, skip gain stuff | 241 ; bra compass_calibration_loop1 ; Yes, skip gain stuff |
| 224 | 242 |
| 225 rcall TFT_compass_show_gain ; Show the current compass gain | 243 rcall TFT_compass_show_gain ; show the current compass gain |
| 226 | 244 |
| 227 WAITMS d'250' | 245 WAITMS d'250' |
| 228 WAITMS d'250' ; Wait for first reading... | 246 WAITMS d'250' ; wait for first reading... |
| 229 | 247 |
| 230 clrf timeout_counter2 | 248 clrf timeout_counter2 |
| 231 clrf timeout_counter3 | 249 ; clrf timeout_counter3 ; not used / required [rl] |
| 232 | 250 |
| 233 call speed_fastest | 251 call speed_fastest |
| 234 call I2C_RX_compass ; read compass | 252 call I2C_RX_compass ; read compass |
| 235 call I2C_RX_accelerometer ; read Accelerometer | 253 call I2C_RX_accelerometer ; read Accelerometer |
| 236 | 254 |
| 237 ; Test all axes for +4096 (Hi byte=16) | 255 ; Test all axes for +4096 (Hi byte=16) |
| 238 banksel compass_DX+1 | 256 banksel compass_DX+1 |
| 239 movlw .16 | 257 movlw .16 |
| 240 cpfseq compass_DX+1 | 258 cpfseq compass_DX+1 |
| 241 bra $+4 | 259 bra $+4 |
| 242 bra compass_calibration_gainset | 260 bra compass_calibration_gainset |
| 243 cpfseq compass_DY+1 | 261 cpfseq compass_DY+1 |
| 244 bra $+4 | 262 bra $+4 |
| 245 bra compass_calibration_gainset | 263 bra compass_calibration_gainset |
| 246 cpfseq compass_DZ+1 | 264 cpfseq compass_DZ+1 |
| 247 bra $+4 | 265 bra $+4 |
| 248 bra compass_calibration_gainset | 266 bra compass_calibration_gainset |
| 249 | 267 |
| 250 ; Test all axes for -4096 (Hi byte=240) | 268 ; Test all axes for -4096 (Hi byte=240) |
| 251 movlw .240 | 269 movlw .240 |
| 252 cpfseq compass_DX+1 | 270 cpfseq compass_DX+1 |
| 253 bra $+4 | 271 bra $+4 |
| 254 bra compass_calibration_gainset | 272 bra compass_calibration_gainset |
| 255 cpfseq compass_DY+1 | 273 cpfseq compass_DY+1 |
| 256 bra $+4 | 274 bra $+4 |
| 257 bra compass_calibration_gainset | 275 bra compass_calibration_gainset |
| 258 cpfseq compass_DZ+1 | 276 cpfseq compass_DZ+1 |
| 259 bra $+4 | 277 bra $+4 |
| 260 bra compass_calibration_gainset | 278 bra compass_calibration_gainset |
| 261 banksel common | 279 banksel common |
| 262 | 280 |
| 263 compass_calibration_loop1: ; Done with Gain | 281 compass_calibration_loop1: ; Done with Gain |
| 264 rcall compass_filter_init ; set DX_f values | 282 rcall compass_filter_init ; set DX_f values |
| 265 call compass_reset_calibration ; Reset CX_f values | 283 call compass_reset_calibration ; Reset CX_f values |
| 266 banksel common | 284 banksel common |
| 267 | 285 |
| 268 compass_calibration_loop2: | 286 compass_calibration_loop2: |
| 269 call I2C_RX_compass ; read compass | 287 call I2C_RX_compass ; read compass |
| 270 call I2C_RX_accelerometer ; Test Accelerometer | 288 call I2C_RX_accelerometer ; Test Accelerometer |
| 271 rcall compass_filter ; Filter compass raw data | 289 rcall compass_filter ; Filter compass raw data |
| 272 banksel common | 290 banksel common |
| 273 | 291 |
| 274 ; Twice | 292 ; Twice |
| 275 call I2C_RX_compass ; read compass | 293 call I2C_RX_compass ; read compass |
| 276 call I2C_RX_accelerometer ; Test Accelerometer | 294 call I2C_RX_accelerometer ; Test Accelerometer |
| 277 rcall compass_filter ; Filter compass raw data | 295 rcall compass_filter ; Filter compass raw data |
| 278 banksel common | 296 banksel common |
| 279 | 297 |
| 280 ; btfsc compass_type ; compass1? | 298 ; btfsc compass_type ; compass1? |
| 281 ; bra compass_calibration_loop3 ; Yes, skip gain stuff | 299 ; bra compass_calibration_loop3 ; Yes, skip gain stuff |
| 282 | 300 |
| 283 ; Test all axes for +4096 (Hi byte=16) | 301 ; Test all axes for +4096 (Hi byte=16) |
| 284 banksel compass_DX+1 | 302 banksel compass_DX+1 |
| 285 movlw .16 | 303 movlw .16 |
| 286 cpfseq compass_DX+1 | 304 cpfseq compass_DX+1 |
| 287 bra $+4 | 305 bra $+4 |
| 288 bra compass_calibration_gainset | 306 bra compass_calibration_gainset |
| 289 cpfseq compass_DY+1 | 307 cpfseq compass_DY+1 |
| 290 bra $+4 | 308 bra $+4 |
| 291 bra compass_calibration_gainset | 309 bra compass_calibration_gainset |
| 292 cpfseq compass_DZ+1 | 310 cpfseq compass_DZ+1 |
| 293 bra $+4 | 311 bra $+4 |
| 294 bra compass_calibration_gainset | 312 bra compass_calibration_gainset |
| 295 | 313 |
| 296 ; Test all axes for -4096 (Hi byte=240) | 314 ; Test all axes for -4096 (Hi byte=240) |
| 297 movlw .240 | 315 movlw .240 |
| 298 cpfseq compass_DX+1 | 316 cpfseq compass_DX+1 |
| 299 bra $+4 | 317 bra $+4 |
| 300 bra compass_calibration_gainset | 318 bra compass_calibration_gainset |
| 301 cpfseq compass_DY+1 | 319 cpfseq compass_DY+1 |
| 302 bra $+4 | 320 bra $+4 |
| 303 bra compass_calibration_gainset | 321 bra compass_calibration_gainset |
| 304 cpfseq compass_DZ+1 | 322 cpfseq compass_DZ+1 |
| 305 bra $+4 | 323 bra $+4 |
| 306 bra compass_calibration_gainset | 324 bra compass_calibration_gainset |
| 307 banksel common | 325 banksel common |
| 308 ; | 326 ; |
| 309 ; ; Three | 327 ; ; Three |
| 310 ; call I2C_RX_compass ; read compass | 328 ; call I2C_RX_compass ; read compass |
| 311 ; call I2C_RX_accelerometer ; Test Accelerometer | 329 ; call I2C_RX_accelerometer ; Test Accelerometer |
| 312 ; call compass_filter ; Filter compass raw data | 330 ; call compass_filter ; Filter compass raw data |
| 313 ; banksel common | 331 ; banksel common |
| 314 ; | 332 ; |
| 315 ; ; Four times to get cleaner values | 333 ; ; Four times to get cleaner values |
| 316 ; call I2C_RX_compass ; read compass | 334 ; call I2C_RX_compass ; read compass |
| 317 ; call I2C_RX_accelerometer ; Test Accelerometer | 335 ; call I2C_RX_accelerometer ; Test Accelerometer |
| 318 ; call compass_filter ; Filter compass raw data | 336 ; call compass_filter ; Filter compass raw data |
| 319 | 337 |
| 320 compass_calibration_loop3: | 338 compass_calibration_loop3: |
| 321 ; And register only one value out of four: | 339 ; And register only one value out of four: |
| 322 call compass_add_calibration ; check and store new max/min values | 340 call compass_add_calibration ; check and store new max/min values |
| 323 banksel common | 341 banksel common |
| 324 | 342 |
| 325 rcall TFT_compass_fast ; show values | 343 rcall TFT_compass_fast ; show values |
| 326 | 344 |
| 327 btfsc sleepmode ; Sleepmode active? | 345 btfsc sleepmode ; Sleepmode active? |
| 328 bra compass_calibration_exit ; Yes, exit | 346 bra compass_calibration_exit ; Yes, exit |
| 329 | 347 |
| 330 | 348 |
| 331 btfss onesecupdate ; do every second tasks? | 349 btfss onesecupdate ; do every second tasks? |
| 332 bra compass_calibration_loop2 ; no, loop here | 350 bra compass_calibration_loop2 ; no, loop here |
| 333 | 351 |
| 334 movlw .60 | 352 movlw .60 |
| 335 call timeout_testmode ; check timeout | 353 call timeout_testmode ; check timeout |
| 336 movlw .60 | 354 movlw .60 |
| 337 rcall TFT_show_timeout_testmode ; Show the timeout | 355 rcall TFT_show_timeout_testmode ; Show the timeout |
| 338 | 356 |
| 339 bcf onesecupdate ; clear flag | 357 bcf onesecupdate ; clear flag |
| 340 | 358 |
| 341 bra compass_calibration_loop2 ; loop here | 359 bra compass_calibration_loop2 ; loop here |
| 342 | 360 |
| 343 compass_calibration_exit: | 361 compass_calibration_exit: |
| 344 call compass_solve_calibration | 362 call compass_solve_calibration |
| 345 banksel common | 363 banksel common |
| 346 ; Done. | 364 ; Done. |
| 347 extern option_save_all | 365 call option_save_all ; save all settings into EEPROM |
| 348 call option_save_all ; save all settings into EEPROM | 366 bcf sleepmode ; Clear the flag before exiting to surface mode |
| 349 bcf sleepmode ; Clear the flag before exiting to surfacemode | 367 movlw .6 |
| 350 movlw .6 | 368 movff WREG,customview_surfmode ; Set to compass view... |
| 351 movwf customview_surfmode ; Set to compass view... | 369 goto surfloop ; ...and exit |
| 352 goto surfloop ; ...and exit | 370 |
| 353 | 371 global TFT_compass_fast |
| 354 global TFT_compass_fast | |
| 355 TFT_compass_fast: | 372 TFT_compass_fast: |
| 356 WIN_TINY .20,.50 | 373 WIN_TINY .20,.50 |
| 357 STRCPY "X:" | 374 STRCPY "X:" |
| 358 movff compass_DX+0,lo | 375 movff compass_DX+0,lo |
| 359 movff compass_DX+1,hi | 376 movff compass_DX+1,hi |
| 360 call TFT_convert_signed_16bit ; converts lo:hi into signed-short and adds '-' to POSTINC2 if required | 377 call TFT_convert_signed_16bit ; converts lo:hi into signed-short and adds '-' to POSTINC2 if required |
| 361 output_16 | 378 output_16 |
| 362 STRCAT " Y:" | 379 STRCAT " Y:" |
| 363 movff compass_DY+0,lo | 380 movff compass_DY+0,lo |
| 364 movff compass_DY+1,hi | 381 movff compass_DY+1,hi |
| 365 call TFT_convert_signed_16bit ; converts lo:hi into signed-short and adds '-' to POSTINC2 if required | 382 call TFT_convert_signed_16bit ; converts lo:hi into signed-short and adds '-' to POSTINC2 if required |
| 366 output_16 | 383 output_16 |
| 367 STRCAT " Z:" | 384 STRCAT " Z:" |
| 368 movff compass_DZ+0,lo | 385 movff compass_DZ+0,lo |
| 369 movff compass_DZ+1,hi | 386 movff compass_DZ+1,hi |
| 370 call TFT_convert_signed_16bit ; converts lo:hi into signed-short and adds '-' to POSTINC2 if required | 387 call TFT_convert_signed_16bit ; converts lo:hi into signed-short and adds '-' to POSTINC2 if required |
| 371 output_16 | 388 output_16 |
| 372 STRCAT_PRINT " " | 389 STRCAT_PRINT " " |
| 373 return | 390 return |
| 374 | 391 |
| 375 TFT_show_timeout_testmode: ; With timeout in WREG... | 392 TFT_show_timeout_testmode: ; With timeout in WREG... |
| 376 movwf hi | 393 movwf hi |
| 377 WIN_TINY .20,.68 | 394 WIN_TINY .20,.68 |
| 378 STRCPY "T:" | 395 STRCPY "T:" |
| 379 movf timeout_counter2,W ; current timeout | 396 movf timeout_counter2,W ; current timeout |
| 380 subwf hi,W ; subtract from timeout value | 397 subwf hi,W ; subtract from timeout value |
| 381 addlw .1 ; +1 | 398 addlw .1 ; +1 |
| 382 movwf lo | 399 movwf lo |
| 383 bsf leftbind | 400 bsf leftbind |
| 384 output_8 ; Display timeout | 401 output_8 ; Display timeout |
| 385 bcf leftbind | 402 bcf leftbind |
| 386 STRCAT_PRINT "s " | 403 STRCAT_PRINT "s " |
| 387 return | 404 return |
| 388 | 405 |
| 389 | 406 TFT_compass_show_gain: ; Show the current compass gain |
| 390 TFT_compass_show_gain: ; Show the current compass gain | 407 ; movff opt_compass_gain,lo ; 0-7 (230LSB/Gauss to 1370LSB/Gaus) |
| 391 ; movff opt_compass_gain,lo ; 0-7 (230LSB/Gauss to 1370LSB/Gaus) | 408 ; tstfsz lo |
| 392 ; tstfsz lo | 409 ; return ; Do not show unless gain=0 |
| 393 ; return ; Do not show unless gain=0 | 410 WIN_TINY .20,.86 |
| 394 WIN_TINY .20,.86 | 411 STRCPY_TEXT tCompassGain |
| 395 STRCPY_TEXT tCompassGain | 412 movff opt_compass_gain,lo ; 0-7 (230LSB/Gauss to 1370LSB/Gaus) |
| 396 movff opt_compass_gain,lo ; 0-7 (230LSB/Gauss to 1370LSB/Gaus) | 413 bsf leftbind |
| 397 bsf leftbind | 414 output_8 |
| 398 output_8 | 415 bcf leftbind |
| 399 bcf leftbind | 416 STRCAT_PRINT "" |
| 400 STRCAT_PRINT "" | 417 return |
| 401 return | |
| 402 | 418 |
| 403 TFT_surface_compass_bearing: | 419 TFT_surface_compass_bearing: |
| 404 WIN_SMALL surf_compass_bear_column,surf_compass_bear_row | 420 WIN_SMALL surf_compass_bear_column,surf_compass_bear_row |
| 405 movff compass_bearing+0,lo | 421 movff compass_bearing+0,lo |
| 406 movff compass_bearing+1,hi | 422 movff compass_bearing+1,hi |
| 407 PUTC "(" | 423 PUTC "(" |
| 408 bsf leftbind | 424 bsf leftbind |
| 409 output_16dp .2 ; Result is "0.000" | 425 output_16dp .2 ; Result is "0.000" |
| 410 bcf leftbind | 426 bcf leftbind |
| 411 ; rearrange figures to "000" | 427 ; rearrange figures to "000" |
| 412 movff buffer+3,buffer+1 | 428 movff buffer+3,buffer+1 |
| 413 movff buffer+4,buffer+2 | 429 movff buffer+4,buffer+2 |
| 414 movff buffer+5,buffer+3 | 430 movff buffer+5,buffer+3 |
| 415 lfsr FSR2,buffer+4 | 431 lfsr FSR2,buffer+4 |
| 416 STRCAT "° " | 432 STRCAT "° " |
| 417 rcall tft_compass_cardinal ; Add cardinal and ordinal to POSTINC2 | 433 rcall tft_compass_cardinal ; Add cardinal and ordinal to POSTINC2 |
| 418 STRCAT_PRINT ")" | 434 STRCAT_PRINT ")" |
| 419 return | 435 return |
| 420 | 436 |
| 421 global TFT_surface_compass_mask | 437 global TFT_surface_compass_mask |
| 422 TFT_surface_compass_mask: | 438 TFT_surface_compass_mask: |
| 423 WIN_SMALL surf_compass_mask_column,surf_compass_mask_row | 439 WIN_SMALL surf_compass_mask_column,surf_compass_mask_row |
| 424 call TFT_standard_color | 440 call TFT_standard_color |
| 425 STRCPY_TEXT_PRINT tHeading ; Heading: | 441 STRCPY_TEXT_PRINT tHeading ; Heading: |
| 426 return | 442 return |
| 427 | 443 |
| 428 global TFT_dive_compass_mask | 444 global TFT_dive_compass_mask |
| 429 TFT_dive_compass_mask: | 445 TFT_dive_compass_mask: |
| 430 WIN_FRAME_STD dm_custom_compass_graph_row, dm_custom_compass_graph_row+dm_custom_compass_graph_height, .0, .159 | 446 WIN_FRAME_STD dm_custom_compass_graph_row, dm_custom_compass_graph_row+dm_custom_compass_graph_height, .0, .159 |
| 431 return | 447 return |
| 432 | 448 |
| 433 global TFT_surface_compass_heading | 449 global TFT_surface_compass_heading |
| 434 TFT_surface_compass_heading: | 450 TFT_surface_compass_heading: |
| 435 rcall compass_heading_common | 451 rcall compass_heading_common |
| 436 WIN_STD surf_compass_head_column,surf_compass_head_row | 452 WIN_STD surf_compass_head_column,surf_compass_head_row |
| 437 call TFT_standard_color | 453 call TFT_standard_color |
| 438 TFT_surface_compass_heading_com: ; Show "000° N" | 454 TFT_surface_compass_heading_com: ; Show "000° N" |
| 439 movff compass_heading+0,lo | 455 movff compass_heading+0,lo |
| 440 movff compass_heading+1,hi | 456 movff compass_heading+1,hi |
| 441 call TFT_convert_signed_16bit ; converts lo:hi into signed-short and adds '-' to POSTINC2 if required | 457 call TFT_convert_signed_16bit ; converts lo:hi into signed-short and adds '-' to POSTINC2 if required |
| 442 | 458 |
| 443 ; Shown and actual identical? | 459 ; Shown and actual identical? |
| 444 movff compass_heading_shown+0,WREG | 460 movff compass_heading_shown+0,WREG |
| 445 cpfseq lo | 461 cpfseq lo |
| 446 bra TFT_surface_compass_heading_com1 ; Not equal | 462 bra TFT_surface_compass_heading_com1 ; Not equal |
| 447 movff compass_heading_shown+1,WREG | 463 movff compass_heading_shown+1,WREG |
| 448 cpfseq hi | 464 cpfseq hi |
| 449 bra TFT_surface_compass_heading_com1 ; Not equal | 465 bra TFT_surface_compass_heading_com1 ; Not equal |
| 450 bra TFT_surface_compass_heading_com3 ; equal, skip smoothing | 466 bra TFT_surface_compass_heading_com3 ; equal, skip smoothing |
| 451 | 467 |
| 452 TFT_surface_compass_heading_com1: | 468 TFT_surface_compass_heading_com1: |
| 453 movff lo,sub_a+0 | 469 movff lo,sub_a+0 |
| 454 movff hi,sub_a+1 | 470 movff hi,sub_a+1 |
| 455 movff compass_heading_shown+0,sub_b+0 | 471 movff compass_heading_shown+0,sub_b+0 |
| 456 movff compass_heading_shown+1,sub_b+1 | 472 movff compass_heading_shown+1,sub_b+1 |
| 457 call subU16 | 473 call subU16 |
| 458 btfsc neg_flag | 474 btfsc neg_flag |
| 459 bra TFT_surface_compass_heading_com2 ; shown > actual | 475 bra TFT_surface_compass_heading_com2 ; shown > actual |
| 460 ; shown < actual | 476 ; shown < actual |
| 461 banksel compass_heading_shown | 477 banksel compass_heading_shown |
| 462 infsnz compass_heading_shown+0,F | 478 infsnz compass_heading_shown+0,F |
| 463 incf compass_heading_shown+1,F ; +1 | 479 incf compass_heading_shown+1,F ; +1 |
| 464 bra TFT_surface_compass_heading_com3 | 480 bra TFT_surface_compass_heading_com3 |
| 465 | 481 |
| 466 TFT_surface_compass_heading_com2: | 482 TFT_surface_compass_heading_com2: |
| 467 banksel compass_heading_shown | 483 banksel compass_heading_shown |
| 468 movlw d'1' | 484 movlw d'1' |
| 469 subwf compass_heading_shown+0,F | 485 subwf compass_heading_shown+0,F |
| 470 movlw d'0' | 486 movlw d'0' |
| 471 subwfb compass_heading_shown+1,F ; -1 | 487 subwfb compass_heading_shown+1,F ; -1 |
| 472 | 488 |
| 473 TFT_surface_compass_heading_com3: | 489 TFT_surface_compass_heading_com3: |
| 474 banksel common | 490 banksel common |
| 475 movff compass_heading_shown+0,lo | 491 movff compass_heading_shown+0,lo |
| 476 movff compass_heading_shown+1,hi | 492 movff compass_heading_shown+1,hi |
| 477 bsf leftbind | 493 bsf leftbind |
| 478 output_16dp .2 ; Result is "0.000" | 494 output_16dp .2 ; Result is "0.000" |
| 479 bcf leftbind | 495 bcf leftbind |
| 480 ; rearrange figures to "000" | 496 ; rearrange figures to "000" |
| 481 movff buffer+2,buffer+0 | 497 movff buffer+2,buffer+0 |
| 482 movff buffer+3,buffer+1 | 498 movff buffer+3,buffer+1 |
| 483 movff buffer+4,buffer+2 | 499 movff buffer+4,buffer+2 |
| 484 lfsr FSR2,buffer+3 | 500 lfsr FSR2,buffer+3 |
| 485 STRCAT "° " | 501 STRCAT "° " |
| 486 rcall tft_compass_cardinal ; Add cardinal and ordinal to POSTINC2 | 502 rcall tft_compass_cardinal ; Add cardinal and ordinal to POSTINC2 |
| 487 clrf WREG | 503 clrf WREG |
| 488 movff WREG,buffer+.7 ; limit to 7 chars | 504 movff WREG,buffer+.7 ; limit to 7 chars |
| 489 STRCAT_PRINT "" | 505 STRCAT_PRINT "" |
| 490 | 506 |
| 491 btfsc divemode | 507 btfsc divemode |
| 492 return ; Done for divemode. | 508 return ; Done for divemode |
| 493 ; Show bearing on the surface? | 509 ; Show bearing on the surface? |
| 494 btfss compass_bearing_set | 510 btfss compass_bearing_set |
| 495 return ; No, return | 511 return ; No, return |
| 496 btfsc premenu ; "Bearing?" shown? | 512 btfsc premenu ; "Bearing?" shown? |
| 497 return ; Yes, return | 513 return ; Yes, return |
| 498 bra TFT_surface_compass_bearing | 514 bra TFT_surface_compass_bearing |
| 499 | 515 |
| 500 global TFT_dive_compass_heading | 516 global TFT_dive_compass_heading |
| 501 TFT_dive_compass_heading: | 517 TFT_dive_compass_heading: |
| 502 rcall compass_heading_common | 518 rcall compass_heading_common |
| 503 ; ; ToDo - these are for development only, hardcoding the bearing position | 519 ; ; ToDo - these are for development only, hard-coding the bearing position |
| 504 ; ; 244° : SW - W | 520 ; ; 244° : SW - W |
| 505 ; movlw low(d'244') | 521 ; movlw low(d'244') |
| 506 ; movff WREG,compass_bearing+0 | 522 ; movff WREG,compass_bearing+0 |
| 507 ; movlw high(d'244') | 523 ; movlw high(d'244') |
| 508 ; movff WREG,compass_bearing+1 | 524 ; movff WREG,compass_bearing+1 |
| 509 | 525 |
| 510 movff compass_heading_shown+0,xA+0 | 526 movff compass_heading_shown+0,xA+0 |
| 511 movff compass_heading_shown+1,xA+1 | 527 movff compass_heading_shown+1,xA+1 |
| 512 ; xRD and xRDlft | 528 ; xRD and xRDlft |
| 513 ; 1. 160° viewing angle: +360 offset if xA<=292; for non-negative scale | 529 ; 1. 160° viewing angle: +360 offset if xA<=292; for non-negative scale |
| 514 movlw high(d'292') | 530 movlw high(d'292') |
| 515 movff WREG,sub_a+1 | 531 movff WREG,sub_a+1 |
| 516 movlw low(d'292') | 532 movlw low(d'292') |
| 517 movff WREG,sub_a+0 | 533 movff WREG,sub_a+0 |
| 518 movff xA+1,sub_b+1 | 534 movff xA+1,sub_b+1 |
| 519 movff xA+0,sub_b+0 | 535 movff xA+0,sub_b+0 |
| 520 call subU16 ; sub_c = sub_a - sub_b | 536 call subU16 ; sub_c = sub_a - sub_b |
| 521 btfsc neg_flag ; xA>292 | 537 btfsc neg_flag ; xA > 292 ? |
| 522 bra TFT_dive_compass_heading_1 ;yes | 538 bra TFT_dive_compass_heading_1 ; yes |
| 523 ; no, xA<=292 | 539 ; no, xA<=292 |
| 524 movlw high(d'360') | 540 movlw high(d'360') |
| 525 addwf xA+1,1 | 541 addwf xA+1,1 |
| 526 movlw low(d'360') | 542 movlw low(d'360') |
| 527 addwf xA+0,1 | 543 addwf xA+0,1 |
| 528 btfsc STATUS,C | 544 btfsc STATUS,C |
| 529 incf xA+1 | 545 incf xA+1 |
| 530 TFT_dive_compass_heading_1: | 546 TFT_dive_compass_heading_1: |
| 531 ; 2. -80: left pixel offset from the center | 547 ; 2. -80: left pixel offset from the center |
| 532 movlw low( d'80' ) | 548 movlw low( d'80' ) |
| 533 subwf xA+0,1 | 549 subwf xA+0,1 |
| 534 btfss STATUS,C | 550 btfss STATUS,C |
| 535 decf xA+1 | 551 decf xA+1 |
| 536 ; 3. save it to xRD | 552 ; 3. save it to xRD |
| 537 movff xA+0,xRD+0 | 553 movff xA+0,xRD+0 |
| 538 movff xA+1,xRD+1 | 554 movff xA+1,xRD+1 |
| 539 ; 4. add 160 (display px width) | 555 ; 4. add 160 (display px width) |
| 540 movlw high(d'160') | 556 movlw high(d'160') |
| 541 addwf xA+1,1 | 557 addwf xA+1,1 |
| 542 movlw low(d'160') | 558 movlw low(d'160') |
| 543 addwf xA+0,1 | 559 addwf xA+0,1 |
| 544 btfsc STATUS,C | 560 btfsc STATUS,C |
| 545 incf xA+1 | 561 incf xA+1 |
| 546 ; 5. save it to xRDr | 562 ; 5. save it to xRDr |
| 547 movff xA+0,xRDr+0 | 563 movff xA+0,xRDr+0 |
| 548 movff xA+1,xRDr+1 | 564 movff xA+1,xRDr+1 |
| 549 | 565 |
| 550 btfss compass_bearing_set | 566 btfss compass_bearing_set |
| 551 bra TFT_dive_compass_ruler ; no value in the bearing, skip calc | 567 bra TFT_dive_compass_ruler ; no value in the bearing, skip calc |
| 552 | 568 |
| 553 ; we have bearing set, we will need xRD180 calculated | 569 ; we have bearing set, we will need xRD180 calculated |
| 554 ; xRD180 is xRDr-180 | 570 ; xRD180 is xRDr-180 |
| 555 movff xRDr+1,sub_a+1 | 571 movff xRDr+1,sub_a+1 |
| 556 movff xRDr+0,sub_a+0 | 572 movff xRDr+0,sub_a+0 |
| 557 movlw high(d'180') | 573 movlw high(d'180') |
| 558 movff WREG,sub_b+1 | 574 movff WREG,sub_b+1 |
| 559 movlw low(d'180') | 575 movlw low(d'180') |
| 560 movff WREG,sub_b+0 | 576 movff WREG,sub_b+0 |
| 561 call subU16 ; sub_c = sub_a - sub_b | 577 call subU16 ; sub_c = sub_a - sub_b |
| 562 movff sub_c+1,xRD180+1 | 578 movff sub_c+1,xRD180+1 |
| 563 movff sub_c+0,xRD180+0 | 579 movff sub_c+0,xRD180+0 |
| 564 | 580 |
| 565 TFT_dive_compass_bearing_1: | 581 TFT_dive_compass_bearing_1: |
| 566 ; calculate bearing position and visibility (ahead or behind) | 582 ; calculate bearing position and visibility (ahead or behind) |
| 567 bcf compass_bearing_vis ; default is not-visibly | 583 bcf compass_bearing_vis ; default is not-visibly |
| 568 bcf compass_bearing_ahd ; default is behind | 584 bcf compass_bearing_ahd ; default is behind |
| 569 ; get the bearing virtual display offset, store it to divA | 585 ; get the bearing virtual display offset, store it to divA |
| 570 movff compass_bearing+0,xA+0 | 586 movff compass_bearing+0,xA+0 |
| 571 movff compass_bearing+1,xA+1 | 587 movff compass_bearing+1,xA+1 |
| 572 movlw high(d'360') | 588 movlw high(d'360') |
| 573 addwf xA+1,1 | 589 addwf xA+1,1 |
| 574 movlw low(d'360') | 590 movlw low(d'360') |
| 575 addwf xA+0,1 | 591 addwf xA+0,1 |
| 576 btfsc STATUS,C | 592 btfsc STATUS,C |
| 577 incf xA+1 | 593 incf xA+1 |
| 578 ; save it to reuse for upper/lower turns and ahead/behind checks | 594 ; save it to reuse for upper/lower turns and ahead/behind checks |
| 579 movff xA+1,divA+1 | 595 movff xA+1,divA+1 |
| 580 movff xA+0,divA+0 | 596 movff xA+0,divA+0 |
| 581 | 597 |
| 582 ; check if it's ahead | 598 ; check if it's ahead |
| 583 ; load the bearing offset into sub_a | 599 ; load the bearing offset into sub_a |
| 584 movff divA+1,sub_a+1 | 600 movff divA+1,sub_a+1 |
| 585 movff divA+0,sub_a+0 | 601 movff divA+0,sub_a+0 |
| 586 ; load the display offset back to sub_b | 602 ; load the display offset back to sub_b |
| 587 movff xRD+0,sub_b+0 | 603 movff xRD+0,sub_b+0 |
| 588 movff xRD+1,sub_b+1 | 604 movff xRD+1,sub_b+1 |
| 589 rcall TFT_dive_compass_bearing_ap | 605 rcall TFT_dive_compass_bearing_ap |
| 590 ;test if we found it | 606 ;test if we found it |
| 591 btfsc compass_bearing_vis | 607 btfsc compass_bearing_vis |
| 592 bra TFT_dive_compass_bearing_dir | 608 bra TFT_dive_compass_bearing_dir |
| 593 | 609 |
| 594 ; check if it's ahead with an upper turn | 610 ; check if it's ahead with an upper turn |
| 595 ; load the bearing offset into sub_a | 611 ; load the bearing offset into sub_a |
| 596 movff divA+1,sub_a+1 | 612 movff divA+1,sub_a+1 |
| 597 movff divA+0,sub_a+0 | 613 movff divA+0,sub_a+0 |
| 598 ; load the display offset back to sub_b | 614 ; load the display offset back to sub_b |
| 599 movff xRD+0,sub_b+0 | 615 movff xRD+0,sub_b+0 |
| 600 movff xRD+1,sub_b+1 | 616 movff xRD+1,sub_b+1 |
| 601 movlw high(d'360') | 617 movlw high(d'360') |
| 602 addwf sub_b+1,1 | 618 addwf sub_b+1,1 |
| 603 movlw low(d'360') | 619 movlw low(d'360') |
| 604 addwf sub_b+0,1 | 620 addwf sub_b+0,1 |
| 605 btfsc STATUS,C | 621 btfsc STATUS,C |
| 606 incf sub_b+1 | 622 incf sub_b+1 |
| 607 rcall TFT_dive_compass_bearing_ap | 623 rcall TFT_dive_compass_bearing_ap |
| 608 ;test if we found it | 624 ;test if we found it |
| 609 btfsc compass_bearing_vis | 625 btfsc compass_bearing_vis |
| 610 bra TFT_dive_compass_bearing_dir | 626 bra TFT_dive_compass_bearing_dir |
| 611 | 627 |
| 612 ; check if it's ahead with a lower turn | 628 ; check if it's ahead with a lower turn |
| 613 ; load the bearing offset into sub_a | 629 ; load the bearing offset into sub_a |
| 614 movff divA+1,sub_a+1 | 630 movff divA+1,sub_a+1 |
| 615 movff divA+0,sub_a+0 | 631 movff divA+0,sub_a+0 |
| 616 movlw high(d'360') | 632 movlw high(d'360') |
| 617 addwf sub_a+1,1 | 633 addwf sub_a+1,1 |
| 618 movlw low(d'360') | 634 movlw low(d'360') |
| 619 addwf sub_a+0,1 | 635 addwf sub_a+0,1 |
| 620 btfsc STATUS,C | 636 btfsc STATUS,C |
| 621 incf sub_a+1 | 637 incf sub_a+1 |
| 622 ; load the display offset back to sub_b | 638 ; load the display offset back to sub_b |
| 623 movff xRD+0,sub_b+0 | 639 movff xRD+0,sub_b+0 |
| 624 movff xRD+1,sub_b+1 | 640 movff xRD+1,sub_b+1 |
| 625 rcall TFT_dive_compass_bearing_ap | 641 rcall TFT_dive_compass_bearing_ap |
| 626 ;test if we found it | 642 ;test if we found it |
| 627 btfsc compass_bearing_vis | 643 btfsc compass_bearing_vis |
| 628 bra TFT_dive_compass_bearing_dir | 644 bra TFT_dive_compass_bearing_dir |
| 629 | 645 |
| 630 ; marker is not ahead of us, check if it's behind us | 646 ; marker is not ahead of us, check if it's behind us |
| 631 ; use the (160 - (xRD180 - xCM)) formula to see if it's on the display | 647 ; use the (160 - (xRD180 - xCM)) formula to see if it's on the display |
| 632 ; load the display offset back to sub_a | 648 ; load the display offset back to sub_a |
| 633 movff xRD180+0,sub_a+0 | 649 movff xRD180+0,sub_a+0 |
| 634 movff xRD180+1,sub_a+1 | 650 movff xRD180+1,sub_a+1 |
| 635 ; load the marker's offset into sub_b | 651 ; load the marker's offset into sub_b |
| 636 movff divA+0,sub_b+0 | 652 movff divA+0,sub_b+0 |
| 637 movff divA+1,sub_b+1 | 653 movff divA+1,sub_b+1 |
| 638 rcall TFT_dive_compass_bearing_bp | 654 rcall TFT_dive_compass_bearing_bp |
| 639 ;test if we found it | 655 ;test if we found it |
| 640 btfsc compass_bearing_vis | 656 btfsc compass_bearing_vis |
| 641 bra TFT_dive_compass_bearing_dir | 657 bra TFT_dive_compass_bearing_dir |
| 642 | 658 |
| 643 ;check if it's behind with the lower turn | 659 ;check if it's behind with the lower turn |
| 644 movff xRD180+0,sub_a+0 | 660 movff xRD180+0,sub_a+0 |
| 645 movff xRD180+1,sub_a+1 | 661 movff xRD180+1,sub_a+1 |
| 646 movlw high(d'360') | 662 movlw high(d'360') |
| 647 addwf sub_a+1,1 | 663 addwf sub_a+1,1 |
| 648 movlw low(d'360') | 664 movlw low(d'360') |
| 649 addwf sub_a+0,1 | 665 addwf sub_a+0,1 |
| 650 btfsc STATUS,C | 666 btfsc STATUS,C |
| 651 incf sub_a+1 | 667 incf sub_a+1 |
| 652 ; load the marker's offset into sub_b | 668 ; load the marker's offset into sub_b |
| 653 movff divA+0,sub_b+0 | 669 movff divA+0,sub_b+0 |
| 654 movff divA+1,sub_b+1 | 670 movff divA+1,sub_b+1 |
| 655 rcall TFT_dive_compass_bearing_bp | 671 rcall TFT_dive_compass_bearing_bp |
| 656 ;test if we found it | 672 ;test if we found it |
| 657 btfsc compass_bearing_vis | 673 btfsc compass_bearing_vis |
| 658 bra TFT_dive_compass_bearing_dir | 674 bra TFT_dive_compass_bearing_dir |
| 659 | 675 |
| 660 ; check if it's behind with the upper turn | 676 ; check if it's behind with the upper turn |
| 661 movff divA+1,sub_b+1 | 677 movff divA+1,sub_b+1 |
| 662 movff divA+0,sub_b+0 | 678 movff divA+0,sub_b+0 |
| 663 movlw high(d'360') | 679 movlw high(d'360') |
| 664 addwf sub_b+1,1 | 680 addwf sub_b+1,1 |
| 665 movlw low(d'360') | 681 movlw low(d'360') |
| 666 addwf sub_b+0,1 | 682 addwf sub_b+0,1 |
| 667 btfsc STATUS,C | 683 btfsc STATUS,C |
| 668 incf sub_b+1 | 684 incf sub_b+1 |
| 669 rcall TFT_dive_compass_bearing_bp | 685 rcall TFT_dive_compass_bearing_bp |
| 670 bra TFT_dive_compass_bearing_dir | 686 bra TFT_dive_compass_bearing_dir |
| 671 | 687 |
| 672 TFT_dive_compass_bearing_ap: | 688 TFT_dive_compass_bearing_ap: |
| 673 ; xCM received in sub_a | 689 ; xCM received in sub_a |
| 674 ; xRD received in sub_b | 690 ; xRD received in sub_b |
| 675 ; 1/a. check if it's viewable from the left side | 691 ; 1/a. check if it's viewable from the left side |
| 676 call subU16 ; sub_c = sub_a - sub_b | 692 call subU16 ; sub_c = sub_a - sub_b |
| 677 btfsc neg_flag ; xRD>divA | 693 btfsc neg_flag ; xRD>divA |
| 678 return ;no, | 694 return ; no |
| 679 ; yes, store the RO=RP-RD for drawing | 695 ; yes, store the RO=RP-RD for drawing |
| 680 movff sub_c+0,xC+0 | 696 movff sub_c+0,xC+0 |
| 681 movff sub_c+1,xC+1 | 697 movff sub_c+1,xC+1 |
| 682 ; 1/b. check if it's viewable from the right side? | 698 ; 1/b. check if it's viewable from the right side? |
| 683 movlw d'2' ; avoid thin mess on the side of the display | 699 movlw d'2' ; avoid thin mess on the side of the display |
| 684 addwf sub_a+0,1 | 700 addwf sub_a+0,1 |
| 685 btfsc STATUS, C | 701 btfsc STATUS, C |
| 686 incf sub_a+1 | 702 incf sub_a+1 |
| 687 ; load the display offset right side into sub_b | 703 ; load the display offset right side into sub_b |
| 688 movlw high(d'158') | 704 movlw high(d'158') |
| 689 addwf sub_b+1,1 | 705 addwf sub_b+1,1 |
| 690 movlw low(d'158') | 706 movlw low(d'158') |
| 691 addwf sub_b+0,1 | 707 addwf sub_b+0,1 |
| 692 btfsc STATUS,C | 708 btfsc STATUS,C |
| 693 incf sub_b+1 | 709 incf sub_b+1 |
| 694 call subU16 ; sub_c = sub_a - sub_b | 710 call subU16 ; sub_c = sub_a - sub_b |
| 695 btfss neg_flag ; xRDr>xA(+2) | 711 btfss neg_flag ; xRDr > xA(+2) ? |
| 696 return ; no, | 712 return ; no |
| 697 ; print the bearing lines on the screen | 713 ; print the bearing lines on the screen |
| 698 movff xC+0,xCM | 714 movff xC+0,xCM |
| 699 bsf compass_bearing_vis ; set visible | 715 bsf compass_bearing_vis ; set visible |
| 700 bsf compass_bearing_ahd ; set ahead | 716 bsf compass_bearing_ahd ; set ahead |
| 701 return ; done, | 717 return ; done, |
| 702 | 718 |
| 703 TFT_dive_compass_bearing_bp: | 719 TFT_dive_compass_bearing_bp: |
| 704 ; use the (160 - (xRD180 - xCM)) formula to see if it's on the display | 720 ; use the (160 - (xRD180 - xCM)) formula to see if it's on the display |
| 705 ; the marker's offset received in sub_b | 721 ; the marker's offset received in sub_b |
| 706 ; the xRD180 display offset received in sub_a | 722 ; the xRD180 display offset received in sub_a |
| 707 ; xRD180 - xCM | 723 ; xRD180 - xCM |
| 708 call subU16 ; sub_c = sub_a - sub_b | 724 call subU16 ; sub_c = sub_a - sub_b |
| 709 btfsc neg_flag ; CM>xRD180 | 725 btfsc neg_flag ; CM > xRD180 ? |
| 710 return ; no, not on screen | 726 return ; no, not on screen |
| 711 ; 160 - (X) | 727 ; 160 - (X) |
| 712 movlw high(d'158') | 728 movlw high(d'158') |
| 713 movff WREG,sub_a+1 | 729 movff WREG,sub_a+1 |
| 714 movlw low(d'158') | 730 movlw low(d'158') |
| 715 movff WREG,sub_a+0 | 731 movff WREG,sub_a+0 |
| 716 movff sub_c+1,sub_b+1 | 732 movff sub_c+1,sub_b+1 |
| 717 movff sub_c+0,sub_b+0 | 733 movff sub_c+0,sub_b+0 |
| 718 call subU16 ; sub_c = sub_a - sub_b | 734 call subU16 ; sub_c = sub_a - sub_b |
| 719 btfsc neg_flag ; X>160 | 735 btfsc neg_flag ; X>160 |
| 720 return ; no, not on screen | 736 return ; no, not on screen |
| 721 ; check if not overflow - this sounds a double check... | 737 ; check if not overflow - this sounds a double check... |
| 722 movlw d'1' | 738 movlw d'1' |
| 723 cpfslt sub_c+1 | 739 cpfslt sub_c+1 |
| 724 return ; high set, >160 | 740 return ; high set, >160 |
| 725 movlw d'158' | 741 movlw d'158' |
| 726 cpfslt sub_c+0 | 742 cpfslt sub_c+0 |
| 727 return ; low >160 | 743 return ; low >160 |
| 728 ; print the bearing lines on the screen | 744 ; print the bearing lines on the screen |
| 729 movff sub_c+0,xCM | 745 movff sub_c+0,xCM |
| 730 bsf compass_bearing_vis | 746 bsf compass_bearing_vis |
| 731 return ; done | 747 return ; done |
| 732 | 748 |
| 733 TFT_dive_compass_bearing_dir: | 749 TFT_dive_compass_bearing_dir: |
| 734 ; check if bearing to heading, and calculate the direction | 750 ; check if bearing to heading, and calculate the direction |
| 735 bcf compass_bearing_eq | 751 bcf compass_bearing_eq |
| 736 btfss compass_bearing_vis | 752 btfss compass_bearing_vis |
| 737 bra TFT_dive_compass_bearing_lr | 753 bra TFT_dive_compass_bearing_lr |
| 738 btfss compass_bearing_ahd | 754 btfss compass_bearing_ahd |
| 739 bra TFT_dive_compass_bearing_lr | 755 bra TFT_dive_compass_bearing_lr |
| 740 movff xCM,xA+0 | 756 movff xCM,xA+0 |
| 741 movlw d'80' | 757 movlw d'80' |
| 742 cpfseq xA+0 | 758 cpfseq xA+0 |
| 743 bra TFT_dive_compass_bearing_lr | 759 bra TFT_dive_compass_bearing_lr |
| 744 bsf compass_bearing_eq | 760 bsf compass_bearing_eq |
| 745 bra TFT_dive_compass_ruler ; bearing points to heading, no signs are required, go to the ruler | 761 bra TFT_dive_compass_ruler ; bearing points to heading, no signs are required, go to the ruler |
| 746 | 762 |
| 747 TFT_dive_compass_bearing_lr: | 763 TFT_dive_compass_bearing_lr: |
| 748 ; get the bearing virtual display offset | 764 ; get the bearing virtual display offset |
| 749 movff compass_bearing+0,xA+0 | 765 movff compass_bearing+0,xA+0 |
| 750 movff compass_bearing+1,xA+1 | 766 movff compass_bearing+1,xA+1 |
| 751 ; divA =IF (U10>292;U10;U10+360) | 767 ; divA =IF (U10>292;U10;U10+360) |
| 752 movlw high(d'292') | 768 movlw high(d'292') |
| 753 movff WREG,sub_a+1 | 769 movff WREG,sub_a+1 |
| 754 movlw low(d'292') | 770 movlw low(d'292') |
| 755 movff WREG,sub_a+0 | 771 movff WREG,sub_a+0 |
| 756 movff xA+1,sub_b+1 | 772 movff xA+1,sub_b+1 |
| 757 movff xA+0,sub_b+0 | 773 movff xA+0,sub_b+0 |
| 758 call subU16 ; sub_c = sub_a - sub_b | 774 call subU16 ; sub_c = sub_a - sub_b |
| 759 btfsc neg_flag ; xA>292 | 775 btfsc neg_flag ; xA > 292 ? |
| 760 bra TFT_dive_compass_bearing_lr_1 ;yes | 776 bra TFT_dive_compass_bearing_lr_1 ; yes |
| 761 ; no, xA<=292 | 777 ; no, xA <= 292 |
| 762 movlw high(d'360') | 778 movlw high(d'360') |
| 763 addwf xA+1,1 | 779 addwf xA+1,1 |
| 764 movlw low(d'360') | 780 movlw low(d'360') |
| 765 addwf xA+0,1 | 781 addwf xA+0,1 |
| 766 btfsc STATUS,C | 782 btfsc STATUS,C |
| 767 incf xA+1 | 783 incf xA+1 |
| 768 TFT_dive_compass_bearing_lr_1: | 784 TFT_dive_compass_bearing_lr_1: |
| 769 ; 1. calculate whether bearing is to left or to right | 785 ; 1. calculate whether bearing is to left or to right |
| 770 bsf compass_bearing_lft ; to the left by default | 786 bsf compass_bearing_lft ; to the left by default |
| 771 ; xC: save center value to compare the direction to front value | 787 ; xC: save center value to compare the direction to front value |
| 772 movff xA+1,xC+1 | 788 movff xA+1,xC+1 |
| 773 movff xA+0,xC+0 | 789 movff xA+0,xC+0 |
| 774 ; xB: we need the left side for comparism... left = -180 | 790 ; xB: we need the left side for comparison... left = -180 |
| 775 movff xA+1,sub_a+1 | 791 movff xA+1,sub_a+1 |
| 776 movff xA+0,sub_a+0 | 792 movff xA+0,sub_a+0 |
| 777 movlw high(d'180') | 793 movlw high(d'180') |
| 778 movff WREG,sub_b+1 | 794 movff WREG,sub_b+1 |
| 779 movlw low(d'180') | 795 movlw low(d'180') |
| 780 movff WREG,sub_b+0 | 796 movff WREG,sub_b+0 |
| 781 call subU16 ; sub_c = sub_a - sub_b | 797 call subU16 ; sub_c = sub_a - sub_b |
| 782 movff sub_c+1,xB+1 ; xB has the left side of the 180° distance center | 798 movff sub_c+1,xB+1 ; xB has the left side of the 180° distance center |
| 783 movff sub_c+0,xB+0 | 799 movff sub_c+0,xB+0 |
| 784 ; xA = IF(xRD>(xC+100);xRD-280;xRD+80) | 800 ; xA = IF(xRD>(xC+100);xRD-280;xRD+80) |
| 785 movff xC+1,sub_a+1 | 801 movff xC+1,sub_a+1 |
| 786 movff xC+0,sub_a+0 | 802 movff xC+0,sub_a+0 |
| 787 movlw d'100' | 803 movlw d'100' |
| 788 addwf sub_a+0,1 | 804 addwf sub_a+0,1 |
| 789 btfsc STATUS,C | 805 btfsc STATUS,C |
| 790 incf sub_a+1 | 806 incf sub_a+1 |
| 791 movff xRD+1,sub_b+1 | 807 movff xRD+1,sub_b+1 |
| 792 movff xRD+0,sub_b+0 | 808 movff xRD+0,sub_b+0 |
| 793 call subU16 ; sub_c = sub_a - sub_b | 809 call subU16 ; sub_c = sub_a - sub_b |
| 794 btfsc neg_flag ; xRD>xC+100 | 810 btfsc neg_flag ; xRD>xC+100 |
| 795 bra TFT_dive_compass_bearing_lr_2 ; yes, xA=xRD-280 | 811 bra TFT_dive_compass_bearing_lr_2 ; yes, xA=xRD-280 |
| 796 ; no, xA = xRD+80 | 812 ; no, xA = xRD+80 |
| 797 movff xRD+1,xA+1 | 813 movff xRD+1,xA+1 |
| 798 movff xRD+0,xA+0 | 814 movff xRD+0,xA+0 |
| 799 movlw d'80' | 815 movlw d'80' |
| 800 addwf xA+0,1 | 816 addwf xA+0,1 |
| 801 btfsc STATUS,C | 817 btfsc STATUS,C |
| 802 incf xA+1 | 818 incf xA+1 |
| 803 bra TFT_dive_compass_bearing_lr_c | 819 bra TFT_dive_compass_bearing_lr_c |
| 804 | 820 |
| 805 TFT_dive_compass_bearing_lr_2: | 821 TFT_dive_compass_bearing_lr_2: |
| 806 ; xA=xRD-280 | 822 ; xA=xRD-280 |
| 807 movff xRD+1,sub_a+1 | 823 movff xRD+1,sub_a+1 |
| 808 movff xRD+0,sub_a+0 | 824 movff xRD+0,sub_a+0 |
| 809 movlw high(d'280') | 825 movlw high(d'280') |
| 810 movff WREG,sub_b+1 | 826 movff WREG,sub_b+1 |
| 811 movlw low(d'280') | 827 movlw low(d'280') |
| 812 movff WREG,sub_b+0 | 828 movff WREG,sub_b+0 |
| 813 call subU16 ; sub_c = sub_a - sub_b | 829 call subU16 ; sub_c = sub_a - sub_b |
| 814 movff sub_c+1,xA+1 | 830 movff sub_c+1,xA+1 |
| 815 movff sub_c+0,xA+0 | 831 movff sub_c+0,xA+0 |
| 816 ;bra TFT_dive_compass_bearing_lr_c | 832 ;bra TFT_dive_compass_bearing_lr_c |
| 817 | 833 |
| 818 TFT_dive_compass_bearing_lr_c: | 834 TFT_dive_compass_bearing_lr_c: |
| 819 ; xB < xA < xC => right, otherwise left (default) | 835 ; xB < xA < xC => right, otherwise left (default) |
| 820 movff xA+1,sub_b+1 | 836 movff xA+1,sub_b+1 |
| 821 movff xA+0,sub_b+0 | 837 movff xA+0,sub_b+0 |
| 822 movff xB+1,sub_a+1 | 838 movff xB+1,sub_a+1 |
| 823 movff xB+0,sub_a+0 | 839 movff xB+0,sub_a+0 |
| 824 call subU16 ; sub_c = sub_a - sub_b | 840 call subU16 ; sub_c = sub_a - sub_b |
| 825 btfss neg_flag ; xA>xB ? | 841 btfss neg_flag ; xA>xB ? |
| 826 bra TFT_dive_compass_ruler ; No, xB >= xA, keep default left | 842 bra TFT_dive_compass_ruler ; No, xB >= xA, keep default left |
| 827 movff xA+1,sub_a+1 | 843 movff xA+1,sub_a+1 |
| 828 movff xA+0,sub_a+0 | 844 movff xA+0,sub_a+0 |
| 829 movff xC+1,sub_b+1 | 845 movff xC+1,sub_b+1 |
| 830 movff xC+0,sub_b+0 | 846 movff xC+0,sub_b+0 |
| 831 call subU16 ; sub_c = sub_a - sub_b | 847 call subU16 ; sub_c = sub_a - sub_b |
| 832 btfss neg_flag ; xC>xA ? | 848 btfss neg_flag ; xC>xA ? |
| 833 bra TFT_dive_compass_ruler ; No, xA >= xC, keep default left | 849 bra TFT_dive_compass_ruler ; No, xA >= xC, keep default left |
| 834 bcf compass_bearing_lft | 850 bcf compass_bearing_lft |
| 835 | 851 |
| 836 TFT_dive_compass_ruler: | 852 TFT_dive_compass_ruler: |
| 837 ; calculate mod15 for the ticks | 853 ; calculate mod15 for the ticks |
| 838 movff xRD+0,xA+0 | 854 movff xRD+0,xA+0 |
| 839 movff xRD+1,xA+1 | 855 movff xRD+1,xA+1 |
| 840 movlw d'15' | 856 movlw d'15' |
| 841 movwf xB+0 | 857 movwf xB+0 |
| 842 clrf xB+1 | 858 clrf xB+1 |
| 843 call div16x16 ;xA/xB=xC with xA+0 as remainder | 859 call div16x16 ; xA/xB=xC with xA+0 as remainder |
| 844 ; check xA+0, it has the remainder | 860 ; check xA+0, it has the remainder |
| 845 movlw d'0' | 861 movlw d'0' |
| 846 cpfsgt xA+0 ; mod15 > 0 | 862 cpfsgt xA+0 ; mod15 > 0 |
| 847 bra TFT_dive_compass_ruler_1 ; no, RM = 0 | 863 bra TFT_dive_compass_ruler_1 ; no, RM = 0 |
| 848 ; yes RM = 15 - RDmod15 | 864 ; yes RM = 15 - RDmod15 |
| 849 movlw d'15' | 865 movlw d'15' |
| 850 subfwb xA+0,1 | 866 subfwb xA+0,1 |
| 851 TFT_dive_compass_ruler_1: | 867 TFT_dive_compass_ruler_1: |
| 852 ; xA+0 holds the RM, store it to 'lo' | 868 ; xA+0 holds the RM, store it to 'lo' |
| 853 movff xA+0,lo | 869 movff xA+0,lo |
| 854 ; init DD to zero, store it to 'hi' | 870 ; init DD to zero, store it to 'hi' |
| 855 clrf hi | 871 clrf hi |
| 856 | 872 |
| 857 TFT_dive_compass_ruler_loop: | 873 TFT_dive_compass_ruler_loop: |
| 858 ; 1. check if we run of from the display | 874 ; 1. check if we run of from the display |
| 859 movlw d'159' ; Looks like 159 works because TFT_box limits the dispay | 875 movlw d'159' ; Looks like 159 works because TFT_box limits the display |
| 860 cpfslt lo,1 | 876 cpfslt lo,1 |
| 861 bra TFT_dive_compass_ruler_lend ; xRM >= W | 877 bra TFT_dive_compass_ruler_lend ; xRM >= W |
| 862 ; 2. Clear the tick area from DD to RM - in segments to avoid blinking | 878 ; 2. Clear the tick area from DD to RM - in segments to avoid blinking |
| 863 ; don't do a clear if we are at 0 (zero) otherwise it will blink | 879 ; don't do a clear if we are at 0 (zero) otherwise it will blink |
| 864 ; because of the width underflow | 880 ; because of the width underflow |
| 865 movlw d'0' | 881 movlw d'0' |
| 866 cpfsgt lo,1 | 882 cpfsgt lo,1 |
| 867 bra TFT_dive_compass_ruler_loop_zz | 883 bra TFT_dive_compass_ruler_loop_zz |
| 868 rcall TFT_dive_compass_clr_ruler | 884 rcall TFT_dive_compass_clr_ruler |
| 869 TFT_dive_compass_ruler_loop_zz: | 885 TFT_dive_compass_ruler_loop_zz: |
| 870 ; 3. Draw the markers @ RM | 886 ; 3. Draw the markers @ RM |
| 871 ; we receive RM in lo and DD in hi | 887 ; we receive RM in lo and DD in hi |
| 872 movlw dm_custom_compass_tick_top_top | 888 movlw dm_custom_compass_tick_top_top |
| 873 movwf win_top | 889 movwf win_top |
| 874 movlw dm_custom_compass_tick_height | 890 movlw dm_custom_compass_tick_height |
| 875 movwf win_height | 891 movwf win_height |
| 876 movlw d'2' | 892 movlw d'2' |
| 877 movwf win_width+0 | 893 movwf win_width+0 |
| 878 clrf win_width+1 | 894 clrf win_width+1 |
| 879 movwf win_bargraph | 895 movwf win_bargraph |
| 880 movff lo,win_leftx2 ; 0..159 | 896 movff lo,win_leftx2 ; 0..159 |
| 881 call TFT_standard_color | 897 call TFT_standard_color |
| 882 call TFT_box | 898 call TFT_box |
| 883 movlw dm_custom_compass_tick_bot_top | 899 movlw dm_custom_compass_tick_bot_top |
| 884 movwf win_top | 900 movwf win_top |
| 885 movlw dm_custom_compass_tick_height | 901 movlw dm_custom_compass_tick_height |
| 886 movwf win_height | 902 movwf win_height |
| 887 call TFT_standard_color ; color in WREG is trashed, must be set again! | 903 call TFT_standard_color ; color in WREG is trashed, must be set again! |
| 888 call TFT_box | 904 call TFT_box |
| 889 ; 4. If D<82 and RM>79: means we put something over the center line | 905 ; 4. If D<82 and RM>79: means we put something over the center line |
| 890 ; redraw the center line | 906 ; redraw the center line |
| 891 movlw d'82' | 907 movlw d'82' |
| 892 cpfslt hi,1 | 908 cpfslt hi,1 |
| 893 bra TFT_dive_compass_ruler_loop_zz2 | 909 bra TFT_dive_compass_ruler_loop_zz2 |
| 894 movlw d'79' | 910 movlw d'79' |
| 895 cpfsgt lo,1 | 911 cpfsgt lo,1 |
| 896 bra TFT_dive_compass_ruler_loop_zz2 | 912 bra TFT_dive_compass_ruler_loop_zz2 |
| 897 ;enough to print cline as bearing marker is not in the ticker area | 913 ; enough to print cline as bearing marker is not in the ticker area |
| 898 movlw color_yellow | 914 movlw color_yellow |
| 899 WIN_BOX_COLOR dm_custom_compass_tick_top_top, dm_custom_compass_tick_bot_bot,.80,.81 ; center line in yellow | 915 WIN_BOX_COLOR dm_custom_compass_tick_top_top, dm_custom_compass_tick_bot_bot,.80,.81 ; center line in yellow |
| 900 TFT_dive_compass_ruler_loop_zz2: | 916 TFT_dive_compass_ruler_loop_zz2: |
| 901 ; 5. set D = RM + 2 : position after the 2px tick | 917 ; 5. set D = RM + 2 : position after the 2px tick |
| 902 movff lo,hi | 918 movff lo,hi |
| 903 movlw d'2' | 919 movlw d'2' |
| 904 addwf hi,F | 920 addwf hi,F |
| 905 ; 6. set RM = RM + 15 : position to the next tick | 921 ; 6. set RM = RM + 15 : position to the next tick |
| 906 movlw d'15' | 922 movlw d'15' |
| 907 addwf lo,F | 923 addwf lo,F |
| 908 ; 7. loop | 924 ; 7. loop |
| 909 bra TFT_dive_compass_ruler_loop | 925 bra TFT_dive_compass_ruler_loop |
| 910 | 926 |
| 911 TFT_dive_compass_ruler_lend: ; loop end | 927 TFT_dive_compass_ruler_lend: ; loop end |
| 912 ; 8. clear the rest of the tick area if D<160 | 928 ; 8. clear the rest of the tick area if D<160 |
| 913 movlw d'160' | 929 movlw d'160' |
| 914 cpfslt hi | 930 cpfslt hi |
| 915 bra TFT_dive_compass_ruler_lend2 ; D >= W | 931 bra TFT_dive_compass_ruler_lend2 ; D >= W |
| 916 ; 9. position left to end of display to clear the remaining area | 932 ; 9. position left to end of display to clear the remaining area |
| 917 movlw d'159' | 933 movlw d'159' |
| 918 movwf lo | 934 movwf lo |
| 919 ; 10. clear it | 935 ; 10. clear it |
| 920 rcall TFT_dive_compass_clr_ruler | 936 rcall TFT_dive_compass_clr_ruler |
| 921 | 937 |
| 922 TFT_dive_compass_ruler_lend2: | 938 TFT_dive_compass_ruler_lend2: |
| 923 ; done with the compass ruler, put the labels on the screen | 939 ; done with the compass ruler, put the labels on the screen |
| 924 ; get the RD abck to sub_b | 940 ; get the RD abck to sub_b |
| 925 movff xRD+0,sub_b+0 | 941 movff xRD+0,sub_b+0 |
| 926 movff xRD+1,sub_b+1 | 942 movff xRD+1,sub_b+1 |
| 927 ; hi stores the display position | 943 ; hi stores the display position |
| 928 clrf hi | 944 clrf hi |
| 929 clrf xHI | 945 clrf xHI |
| 930 ; lo stores the last item's display position | 946 ; lo stores the last item's display position |
| 931 clrf lo | 947 clrf lo |
| 932 clrf xLO | 948 clrf xLO |
| 933 | 949 |
| 934 movlw low( d'219' ) ; position of the label | 950 movlw low( d'219' ) ; position of the label |
| 935 movwf sub_a+0 | 951 movwf sub_a+0 |
| 936 movlw high( d'219' ) | 952 movlw high( d'219' ) |
| 937 rcall TFT_dive_compass_label_proc ; check if the label should be on screen | 953 rcall TFT_dive_compass_label_proc ; check if the label should be on screen |
| 938 btfss print_compass_label ; Yes? | 954 btfss print_compass_label ; Yes? |
| 939 bra dcr_1 | 955 bra dcr_1 |
| 940 STRCPY_TEXT_PRINT tSW ; yes - print it | 956 STRCPY_TEXT_PRINT tSW ; yes - print it |
| 941 dcr_1: | 957 dcr_1: |
| 942 rcall TFT_dive_compass_c_mk ; check if label is on the center line or the marker | 958 rcall TFT_dive_compass_c_mk ; check if label is on the center line or the marker |
| 943 | 959 movlw low( d'267' ) ; position of the label |
| 944 movlw low( d'267' ) ; position of the label | 960 movwf sub_a+0 |
| 945 movwf sub_a+0 | 961 movlw high( d'267' ) |
| 946 movlw high( d'267' ) | 962 rcall TFT_dive_compass_label_proc ; check if the label should be on screen |
| 947 rcall TFT_dive_compass_label_proc ; check if the label should be on screen | 963 btfss print_compass_label ; Yes? |
| 948 btfss print_compass_label ; Yes? | 964 bra dcr_2 |
| 949 bra dcr_2 | 965 STRCPY_TEXT_PRINT tW ; yes - print it |
| 950 STRCPY_TEXT_PRINT tW ; yes - print it | |
| 951 dcr_2: | 966 dcr_2: |
| 952 rcall TFT_dive_compass_c_mk ; check if label is on the center line or the marker | 967 rcall TFT_dive_compass_c_mk ; check if label is on the center line or the marker |
| 953 | 968 movlw low( d'309' ) ; position of the label |
| 954 movlw low( d'309' ) ; position of the label | 969 movwf sub_a+0 |
| 955 movwf sub_a+0 | 970 movlw high( d'309' ) |
| 956 movlw high( d'309' ) | 971 rcall TFT_dive_compass_label_proc ; check if the label should be on screen |
| 957 rcall TFT_dive_compass_label_proc ; check if the label should be on screen | 972 btfss print_compass_label ; Yes? |
| 958 btfss print_compass_label ; Yes? | 973 bra dcr_3 |
| 959 bra dcr_3 | 974 STRCPY_TEXT_PRINT tNW ; yes - print it |
| 960 STRCPY_TEXT_PRINT tNW ; yes - print it | |
| 961 dcr_3: | 975 dcr_3: |
| 962 rcall TFT_dive_compass_c_mk ; check if label is on the center line or the marker | 976 rcall TFT_dive_compass_c_mk ; check if label is on the center line or the marker |
| 963 | 977 movlw low( d'358' ) ; position of the label |
| 964 movlw low( d'358' ) ; position of the label | 978 movwf sub_a+0 |
| 965 movwf sub_a+0 | 979 movlw high( d'358' ) |
| 966 movlw high( d'358' ) | 980 rcall TFT_dive_compass_label_proc ; check if the label should be on screen |
| 967 rcall TFT_dive_compass_label_proc ; check if the label should be on screen | 981 btfss print_compass_label ; Yes? |
| 968 btfss print_compass_label ; Yes? | 982 bra dcr_4 |
| 969 bra dcr_4 | 983 STRCPY_TEXT_PRINT tN ; yes - print it |
| 970 STRCPY_TEXT_PRINT tN ; yes - print it | |
| 971 dcr_4: | 984 dcr_4: |
| 972 rcall TFT_dive_compass_c_mk ; check if label is on the center line or the marker | 985 rcall TFT_dive_compass_c_mk ; check if label is on the center line or the marker |
| 973 | 986 movlw low( d'399' ) ; position of the label |
| 974 movlw low( d'399' ) ; position of the label | 987 movwf sub_a+0 |
| 975 movwf sub_a+0 | 988 movlw high( d'399' ) |
| 976 movlw high( d'399' ) | 989 rcall TFT_dive_compass_label_proc ; check if the label should be on screen |
| 977 rcall TFT_dive_compass_label_proc ; check if the label should be on screen | 990 btfss print_compass_label ; Yes? |
| 978 btfss print_compass_label ; Yes? | 991 bra dcr_5 |
| 979 bra dcr_5 | 992 STRCPY_TEXT_PRINT tNE ; yes - print it |
| 980 STRCPY_TEXT_PRINT tNE ; yes - print it | |
| 981 dcr_5: | 993 dcr_5: |
| 982 rcall TFT_dive_compass_c_mk ; check if label is on the center line or the marker | 994 rcall TFT_dive_compass_c_mk ; check if label is on the center line or the marker |
| 983 | 995 movlw low( d'448' ) ; position of the label |
| 984 movlw low( d'448' ) ; position of the label | 996 movwf sub_a+0 |
| 985 movwf sub_a+0 | 997 movlw high( d'448' ) |
| 986 movlw high( d'448' ) | 998 rcall TFT_dive_compass_label_proc ; check if the label should be on screen |
| 987 rcall TFT_dive_compass_label_proc ; check if the label should be on screen | 999 btfss print_compass_label ; Yes? |
| 988 btfss print_compass_label ; Yes? | 1000 bra dcr_6 |
| 989 bra dcr_6 | 1001 STRCPY_TEXT_PRINT tE ; yes - print it |
| 990 STRCPY_TEXT_PRINT tE ; yes - print it | |
| 991 dcr_6: | 1002 dcr_6: |
| 992 rcall TFT_dive_compass_c_mk ; check if label is on the center line or the marker | 1003 rcall TFT_dive_compass_c_mk ; check if label is on the center line or the marker |
| 993 | 1004 movlw low( d'489' ) ; position of the label |
| 994 movlw low( d'489' ) ; position of the label | 1005 movwf sub_a+0 |
| 995 movwf sub_a+0 | 1006 movlw high( d'489' ) |
| 996 movlw high( d'489' ) | 1007 rcall TFT_dive_compass_label_proc ; check if the label should be on screen |
| 997 rcall TFT_dive_compass_label_proc ; check if the label should be on screen | 1008 btfss print_compass_label ; Yes? |
| 998 btfss print_compass_label ; Yes? | 1009 bra dcr_7 |
| 999 bra dcr_7 | 1010 STRCPY_TEXT_PRINT tSE ; yes - print it |
| 1000 STRCPY_TEXT_PRINT tSE ; yes - print it | |
| 1001 dcr_7: | 1011 dcr_7: |
| 1002 rcall TFT_dive_compass_c_mk ; check if label is on the center line or the marker | 1012 rcall TFT_dive_compass_c_mk ; check if label is on the center line or the marker |
| 1003 | 1013 movlw low( d'538' ) ; position of the label |
| 1004 movlw low( d'538' ) ; position of the label | 1014 movwf sub_a+0 |
| 1005 movwf sub_a+0 | 1015 movlw high( d'538' ) |
| 1006 movlw high( d'538' ) | 1016 rcall TFT_dive_compass_label_proc ; check if the label should be on screen |
| 1007 rcall TFT_dive_compass_label_proc ; check if the label should be on screen | 1017 btfss print_compass_label ; Yes? |
| 1008 btfss print_compass_label ; Yes? | 1018 bra dcr_8 |
| 1009 bra dcr_8 | 1019 STRCPY_TEXT_PRINT tS ; yes - print it |
| 1010 STRCPY_TEXT_PRINT tS ; yes - print it | |
| 1011 dcr_8: | 1020 dcr_8: |
| 1012 rcall TFT_dive_compass_c_mk ; check if label is on the center line or the marker | 1021 rcall TFT_dive_compass_c_mk ; check if label is on the center line or the marker |
| 1013 | 1022 movlw low( d'579' ) ; position of the label |
| 1014 movlw low( d'579' ) ; position of the label | 1023 movwf sub_a+0 |
| 1015 movwf sub_a+0 | 1024 movlw high( d'579' ) |
| 1016 movlw high( d'579' ) | 1025 rcall TFT_dive_compass_label_proc ; check if the label should be on screen |
| 1017 rcall TFT_dive_compass_label_proc ; check if the label should be on screen | 1026 btfss print_compass_label ; Yes? |
| 1018 btfss print_compass_label ; Yes? | 1027 bra dcr_9 |
| 1019 bra dcr_9 | 1028 STRCPY_TEXT_PRINT tSW ; yes - print it |
| 1020 STRCPY_TEXT_PRINT tSW ; yes - print it | |
| 1021 dcr_9: | 1029 dcr_9: |
| 1022 rcall TFT_dive_compass_c_mk ; check if label is on the center line or the marker | 1030 rcall TFT_dive_compass_c_mk ; check if label is on the center line or the marker |
| 1023 | 1031 movlw low( d'627' ) ; position of the label |
| 1024 movlw low( d'627' ) ; position of the label | 1032 movwf sub_a+0 |
| 1025 movwf sub_a+0 | 1033 movlw high( d'627' ) |
| 1026 movlw high( d'627' ) | 1034 rcall TFT_dive_compass_label_proc ; check if the label should be on screen |
| 1027 rcall TFT_dive_compass_label_proc ; check if the label should be on screen | 1035 btfss print_compass_label ; Yes? |
| 1028 btfss print_compass_label ; Yes? | 1036 bra dcr_10 |
| 1029 bra dcr_10 | 1037 STRCPY_TEXT_PRINT tW ; yes - print it |
| 1030 STRCPY_TEXT_PRINT tW ; yes - print it | |
| 1031 dcr_10: | 1038 dcr_10: |
| 1032 rcall TFT_dive_compass_c_mk ; check if label is on the center line or the marker | 1039 rcall TFT_dive_compass_c_mk ; check if label is on the center line or the marker |
| 1033 | 1040 movlw low( d'669' ) ; position of the label |
| 1034 movlw low( d'669' ) ; position of the label | 1041 movwf sub_a+0 |
| 1035 movwf sub_a+0 | 1042 movlw high( d'669' ) |
| 1036 movlw high( d'669' ) | 1043 rcall TFT_dive_compass_label_proc ; check if the label should be on screen |
| 1037 rcall TFT_dive_compass_label_proc ; check if the label should be on screen | 1044 btfss print_compass_label ; Yes? |
| 1038 btfss print_compass_label ; Yes? | 1045 bra dcr_11 |
| 1039 bra dcr_11 | 1046 STRCPY_TEXT_PRINT tNW ; yes - print it |
| 1040 STRCPY_TEXT_PRINT tNW ; yes - print it | |
| 1041 dcr_11: | 1047 dcr_11: |
| 1042 rcall TFT_dive_compass_c_mk ; check if label is on the center line or the marker | 1048 rcall TFT_dive_compass_c_mk ; check if label is on the center line or the marker |
| 1043 | 1049 |
| 1044 movlw low( d'718' ) ; position of the label | 1050 movlw low( d'718' ) ; position of the label |
| 1045 movwf sub_a+0 | 1051 movwf sub_a+0 |
| 1046 movlw high( d'718' ) | 1052 movlw high( d'718' ) |
| 1047 rcall TFT_dive_compass_label_proc ; check if the label should be on screen | 1053 rcall TFT_dive_compass_label_proc ; check if the label should be on screen |
| 1048 btfss print_compass_label ; Yes? | 1054 btfss print_compass_label ; Yes? |
| 1049 bra dcr_12 | 1055 bra dcr_12 |
| 1050 STRCPY_TEXT_PRINT tN ; yes - print it | 1056 STRCPY_TEXT_PRINT tN ; yes - print it |
| 1051 dcr_12: | 1057 dcr_12: |
| 1052 rcall TFT_dive_compass_c_mk ; check if label is on the center line or the marker | 1058 rcall TFT_dive_compass_c_mk ; check if label is on the center line or the marker |
| 1053 | 1059 |
| 1054 TFT_dive_compass_label_end: | 1060 TFT_dive_compass_label_end: |
| 1055 rcall TFT_dive_compass_c_mk ; check if label is on the center line or the marker | 1061 rcall TFT_dive_compass_c_mk ; check if label is on the center line or the marker |
| 1056 ; restore lo and hi for the final cleanup | 1062 ; restore lo and hi for the final cleanup |
| 1057 movff xLO,lo | 1063 movff xLO,lo |
| 1058 movff xHI,hi | 1064 movff xHI,hi |
| 1059 ; clear the rest of the SQ area if there are more space | 1065 ; clear the rest of the SQ area if there are more space |
| 1060 movlw d'159' | 1066 movlw d'159' |
| 1061 cpfslt hi | 1067 cpfslt hi |
| 1062 bra TFT_dive_compass_label_end2 ; D >= 160, no more space | 1068 bra TFT_dive_compass_label_end2 ; D >= 160, no more space |
| 1063 ; position left to end of display to clear the remaining area | 1069 ; position left to end of display to clear the remaining area |
| 1064 movlw d'158' | 1070 movlw d'158' |
| 1065 movwf lo | 1071 movwf lo |
| 1066 ; clear it | 1072 ; clear it |
| 1067 rcall TFT_dive_compass_clr_label | 1073 rcall TFT_dive_compass_clr_label |
| 1068 TFT_dive_compass_label_end2: | 1074 TFT_dive_compass_label_end2: |
| 1069 rcall TFT_dive_compass_c_mk ; check if label is on the center line or the marker | 1075 rcall TFT_dive_compass_c_mk ; check if label is on the center line or the marker |
| 1070 ; do we have bearing set? | 1076 ; do we have bearing set? |
| 1071 btfsc compass_bearing_set | 1077 btfsc compass_bearing_set |
| 1072 bra TFT_dive_compass_dir_text ; bearing_set=1 - go and print the dir (<< or >>) | 1078 bra TFT_dive_compass_dir_text ; bearing_set=1 - go and print the dir (<< or >>) |
| 1073 rcall TFT_dive_compass_dir_lclr ; no, clear the area (e.g. we had but removed) | 1079 rcall TFT_dive_compass_dir_lclr ; no, clear the area (e.g. we had but removed) |
| 1074 rcall TFT_dive_compass_dir_rclr | 1080 rcall TFT_dive_compass_dir_rclr |
| 1075 bra TFT_dive_compass_text | 1081 bra TFT_dive_compass_text |
| 1076 | 1082 |
| 1077 TFT_dive_compass_dir_text: | 1083 TFT_dive_compass_dir_text: |
| 1078 ; bearing set, but does it point to heading? | 1084 ; bearing set, but does it point to heading? |
| 1079 btfss compass_bearing_eq | 1085 btfss compass_bearing_eq |
| 1080 bra TFT_dive_compass_dir_text_2 ; bearing != heading - go and print the dir | 1086 bra TFT_dive_compass_dir_text_2 ; bearing != heading - go and print the dir |
| 1081 rcall TFT_dive_compass_dir_lclr ; bearing = heading, no need for direction markers | 1087 rcall TFT_dive_compass_dir_lclr ; bearing = heading, no need for direction markers |
| 1082 rcall TFT_dive_compass_dir_rclr | 1088 rcall TFT_dive_compass_dir_rclr |
| 1083 bra TFT_dive_compass_text | 1089 bra TFT_dive_compass_text |
| 1084 | 1090 |
| 1085 TFT_dive_compass_dir_text_2: | 1091 TFT_dive_compass_dir_text_2: |
| 1086 movlw color_green | 1092 movlw color_green |
| 1087 call TFT_set_color | 1093 call TFT_set_color |
| 1088 btfsc compass_bearing_lft | 1094 btfsc compass_bearing_lft |
| 1089 bra TFT_dive_compass_dir_ldir ; bearing_lft=1, print the left marker | 1095 bra TFT_dive_compass_dir_ldir ; bearing_lft=1, print the left marker |
| 1090 ;TFT_dive_compass_text_rdir: | 1096 ;TFT_dive_compass_text_rdir: |
| 1091 WIN_SMALL dm_custom_compass_rdir_column, dm_custom_compass_head_row-.2 | 1097 WIN_SMALL dm_custom_compass_rdir_column, dm_custom_compass_head_row-.2 |
| 1092 STRCPY_PRINT ">>" | 1098 STRCPY_PRINT ">>" |
| 1093 ; do not forget to clear the left | 1099 ; do not forget to clear the left |
| 1094 rcall TFT_dive_compass_dir_lclr | 1100 rcall TFT_dive_compass_dir_lclr |
| 1095 bra TFT_dive_compass_text | 1101 bra TFT_dive_compass_text |
| 1096 | 1102 |
| 1097 TFT_dive_compass_dir_ldir: | 1103 TFT_dive_compass_dir_ldir: |
| 1098 WIN_SMALL dm_custom_compass_ldir_column, dm_custom_compass_head_row-.2 | 1104 WIN_SMALL dm_custom_compass_ldir_column, dm_custom_compass_head_row-.2 |
| 1099 STRCPY_PRINT "<<" | 1105 STRCPY_PRINT "<<" |
| 1100 ; do not forget to clear the right | 1106 ; do not forget to clear the right |
| 1101 rcall TFT_dive_compass_dir_rclr | 1107 rcall TFT_dive_compass_dir_rclr |
| 1102 ;bra TFT_dive_compass_text | 1108 ;bra TFT_dive_compass_text |
| 1103 | 1109 |
| 1104 TFT_dive_compass_text: | 1110 TFT_dive_compass_text: |
| 1105 ; Clear some unused space on the right mH | 1111 ; Clear some unused space on the right mH |
| 1106 WIN_BOX_BLACK dm_custom_compass_tick_top_bot+.1,dm_custom_compass_tick_bot_top-.1,.158,.159 ; top, bottom, left, right | 1112 WIN_BOX_BLACK dm_custom_compass_tick_top_bot+.1,dm_custom_compass_tick_bot_top-.1,.158,.159 ; top, bottom, left, right |
| 1107 | 1113 |
| 1108 ; Text output | 1114 ; Text output |
| 1109 call TFT_standard_color | 1115 call TFT_standard_color |
| 1110 WIN_SMALL dm_custom_compass_head_column, dm_custom_compass_head_row | 1116 WIN_SMALL dm_custom_compass_head_column, dm_custom_compass_head_row |
| 1111 rcall TFT_surface_compass_heading_com ; Show "000° N" | 1117 rcall TFT_surface_compass_heading_com ; Show "000° N" |
| 1112 return | 1118 return |
| 1113 | 1119 |
| 1114 TFT_dive_compass_dir_lclr: | 1120 TFT_dive_compass_dir_lclr: |
| 1115 WIN_SMALL dm_custom_compass_ldir_column, dm_custom_compass_head_row-.2 | 1121 WIN_SMALL dm_custom_compass_ldir_column, dm_custom_compass_head_row-.2 |
| 1116 STRCPY_PRINT " " | 1122 STRCPY_PRINT " " |
| 1117 return | 1123 return |
| 1118 | 1124 |
| 1119 TFT_dive_compass_dir_rclr: | 1125 TFT_dive_compass_dir_rclr: |
| 1120 WIN_SMALL dm_custom_compass_rdir_column, dm_custom_compass_head_row-.2 | 1126 WIN_SMALL dm_custom_compass_rdir_column, dm_custom_compass_head_row-.2 |
| 1121 STRCPY_PRINT " " | 1127 STRCPY_PRINT " " |
| 1122 return | 1128 return |
| 1123 | 1129 |
| 1124 TFT_dive_compass_label_proc: | 1130 TFT_dive_compass_label_proc: |
| 1125 movwf sub_a+1 | 1131 movwf sub_a+1 |
| 1126 movlw d'14' | 1132 movlw d'14' |
| 1127 movwf up ; cardinal width in px | 1133 movwf up ; cardinal width in px |
| 1128 bcf print_compass_label | 1134 bcf print_compass_label |
| 1129 ; 1/a. check if it's viewable ? sub_a(RP) >= sub_b(RD) ? | 1135 ; 1/a. check if it's viewable ? sub_a(RP) >= sub_b(RD) ? |
| 1130 ; set the carry flag if sub_b(xRD) is equal to or greater than sub_a(xRP): | 1136 ; set the carry flag if sub_b(xRD) is equal to or greater than sub_a(xRP): |
| 1131 movff xRD+0,sub_b+0 | 1137 movff xRD+0,sub_b+0 |
| 1132 movff xRD+1,sub_b+1 | 1138 movff xRD+1,sub_b+1 |
| 1133 call subU16 ; sub_c = sub_a - sub_b | 1139 call subU16 ; sub_c = sub_a - sub_b |
| 1134 btfsc neg_flag ; >=0? | 1140 btfsc neg_flag ; >=0? |
| 1135 return ; No | 1141 return ; No |
| 1136 ; store the RO=RP-RD for drawing | 1142 ; store the RO=RP-RD for drawing |
| 1137 movff sub_c+0,xC+0 | 1143 movff sub_c+0,xC+0 |
| 1138 movff sub_c+1,xC+1 | 1144 movff sub_c+1,xC+1 |
| 1139 | 1145 |
| 1140 ; 1/b. check if it's viewable ? sub_a(RP)+up(width) < sub_b(RD)+160 | 1146 ; 1/b. check if it's viewable ? sub_a(RP)+up(width) < sub_b(RD)+160 |
| 1141 ; if already above, no need to process the rest of the labels | 1147 ; if already above, no need to process the rest of the labels |
| 1142 movff up,WREG ; take care about the width | 1148 movff up,WREG ; take care about the width |
| 1143 addwf sub_a+0,1 | 1149 addwf sub_a+0,1 |
| 1144 btfsc STATUS, C | 1150 btfsc STATUS, C |
| 1145 incf sub_a+1 | 1151 incf sub_a+1 |
| 1146 | 1152 |
| 1147 movff xRDr+0,sub_b+0 | 1153 movff xRDr+0,sub_b+0 |
| 1148 movff xRDr+1,sub_b+1 | 1154 movff xRDr+1,sub_b+1 |
| 1149 call subU16 ; sub_c = sub_a - sub_b | 1155 call subU16 ; sub_c = sub_a - sub_b |
| 1150 btfss neg_flag ; ? <0 | 1156 btfss neg_flag ; ? <0 |
| 1151 bra TFT_dive_compass_label_end ; No | 1157 bra TFT_dive_compass_label_end ; No |
| 1152 | 1158 |
| 1153 ; 2. restore RO=RP-RD from 1/a. | 1159 ; 2. restore RO=RP-RD from 1/a. |
| 1154 movff xC+0,lo | 1160 movff xC+0,lo |
| 1155 | 1161 |
| 1156 ; 3. Clear the segment from DD(hi) to lo | 1162 ; 3. Clear the segment from DD(hi) to lo |
| 1157 ; don't do a clear if we are at 0 (zero) otherwise it will blink | 1163 ; don't do a clear if we are at 0 (zero) otherwise it will blink |
| 1158 ; ?because of the width underflow? | 1164 ; ?because of the width underflow? |
| 1159 movlw d'1' | 1165 movlw d'1' |
| 1160 cpfsgt lo | 1166 cpfsgt lo |
| 1161 bra TFT_dive_compass_label_proc_p | 1167 bra TFT_dive_compass_label_proc_p |
| 1162 rcall TFT_dive_compass_clr_label | 1168 rcall TFT_dive_compass_clr_label |
| 1163 TFT_dive_compass_label_proc_p: | 1169 TFT_dive_compass_label_proc_p: |
| 1164 ; 4. print the SQ on the screen | 1170 ; 4. print the SQ on the screen |
| 1165 call TFT_standard_color | 1171 call TFT_standard_color |
| 1166 bsf print_compass_label | 1172 bsf print_compass_label |
| 1167 ;TFT_dive_compass_label_print: | 1173 ;TFT_dive_compass_label_print: |
| 1168 movlw dm_custom_compass_label_row | 1174 movlw dm_custom_compass_label_row |
| 1169 movff WREG,win_top | 1175 movff WREG,win_top |
| 1170 movff lo,win_leftx2 | 1176 movff lo,win_leftx2 |
| 1171 movlw FT_SMALL | 1177 movlw FT_SMALL |
| 1172 movff WREG,win_font | 1178 movff WREG,win_font |
| 1173 ; 6. retain the new display positions | 1179 ; 6. retain the new display positions |
| 1174 movff lo,hi | 1180 movff lo,hi |
| 1175 movff up,WREG | 1181 movff up,WREG |
| 1176 addwf hi,F | 1182 addwf hi,F |
| 1177 movff lo,xLO | 1183 movff lo,xLO |
| 1178 movff hi,xHI | 1184 movff hi,xHI |
| 1179 return | 1185 return |
| 1180 | 1186 |
| 1181 TFT_dive_compass_c_mk: | 1187 TFT_dive_compass_c_mk: |
| 1182 ; Common task to draw center line and marker | 1188 ; Common task to draw center line and marker |
| 1183 ; until a proper implementation make it simple: | 1189 ; until a proper implementation make it simple: |
| 1184 rcall TFT_dive_compass_mk | 1190 rcall TFT_dive_compass_mk |
| 1185 movlw color_yellow | 1191 movlw color_yellow |
| 1186 WIN_BOX_COLOR dm_custom_compass_tick_top_top, dm_custom_compass_tick_bot_bot,.80,.81 ; center line in yellow | 1192 WIN_BOX_COLOR dm_custom_compass_tick_top_top, dm_custom_compass_tick_bot_bot,.80,.81 ; center line in yellow |
| 1187 return | 1193 return |
| 1188 | 1194 |
| 1189 TFT_dive_compass_mk: | 1195 TFT_dive_compass_mk: |
| 1190 ; draw the bearing on the screen if visible and if we just put something over it | 1196 ; draw the bearing on the screen if visible and if we just put something over it |
| 1191 btfss compass_bearing_set | 1197 btfss compass_bearing_set |
| 1192 return ; bearing_set=0 nothing to display | 1198 return ; bearing_set=0 nothing to display |
| 1193 | 1199 |
| 1194 btfss compass_bearing_vis | 1200 btfss compass_bearing_vis |
| 1195 return ; bearing set but not visible | 1201 return ; bearing set but not visible |
| 1196 | 1202 |
| 1197 ; save lo/hi from trashing | 1203 ; save lo/hi from trashing |
| 1198 movff lo,xA+0 | 1204 movff lo,xA+0 |
| 1199 movff hi,xA+1 | 1205 movff hi,xA+1 |
| 1200 | 1206 |
| 1201 ; did we just update the marker's position? | 1207 ; did we just update the marker's position? |
| 1202 ; DD.......DD | 1208 ; DD.......DD |
| 1203 ; CM+2>=DD(old) or CM-2<=DD | 1209 ; CM+2>=DD(old) or CM-2<=DD |
| 1204 ; ToDo | 1210 ; ToDo |
| 1205 | 1211 |
| 1206 btfss compass_bearing_ahd | 1212 btfss compass_bearing_ahd |
| 1207 bra TFT_dive_compass_mk_rear | 1213 bra TFT_dive_compass_mk_rear |
| 1208 ;TFT_dive_compass_mk_front: | 1214 ;TFT_dive_compass_mk_front: |
| 1209 clrf lo | 1215 clrf lo |
| 1210 movff xCM,lo | 1216 movff xCM,lo |
| 1211 bsf print_compass_label ; set=green marker | 1217 bsf print_compass_label ; set=green marker |
| 1212 rcall TFT_dive_compass_mk_print | 1218 rcall TFT_dive_compass_mk_print |
| 1213 bcf print_compass_label | 1219 bcf print_compass_label |
| 1214 bra TFT_dive_compass_mk_end | 1220 bra TFT_dive_compass_mk_end |
| 1215 | 1221 |
| 1216 TFT_dive_compass_mk_rear: | 1222 TFT_dive_compass_mk_rear: |
| 1217 clrf lo | 1223 clrf lo |
| 1218 movff xCM,lo | 1224 movff xCM,lo |
| 1219 bcf print_compass_label ; set=red marker | 1225 bcf print_compass_label ; set=red marker |
| 1220 rcall TFT_dive_compass_mk_print | 1226 rcall TFT_dive_compass_mk_print |
| 1221 | 1227 |
| 1222 TFT_dive_compass_mk_end: | 1228 TFT_dive_compass_mk_end: |
| 1223 movff xA+0,lo | 1229 movff xA+0,lo |
| 1224 movff xA+1,hi | 1230 movff xA+1,hi |
| 1225 return | 1231 return |
| 1226 | 1232 |
| 1227 TFT_dive_compass_mk_print: | 1233 TFT_dive_compass_mk_print: |
| 1228 movlw d'1' | 1234 movlw d'1' |
| 1229 cpfsgt lo | 1235 cpfsgt lo |
| 1230 bra TFT_dive_compass_mk_print_2 ; lo<=1, skip the first line | 1236 bra TFT_dive_compass_mk_print_2 ; lo<=1, skip the first line |
| 1231 movlw d'2' | 1237 movlw d'2' |
| 1232 subwf lo,0 | 1238 subwf lo,0 |
| 1233 ; movff WREG,win_leftx2 | 1239 ; movff WREG,win_leftx2 |
| 1234 rcall TFT_dive_compass_mk_print_3 | 1240 rcall TFT_dive_compass_mk_print_3 |
| 1235 TFT_dive_compass_mk_print_2: | 1241 TFT_dive_compass_mk_print_2: |
| 1236 ; save hi/lo | 1242 ; save hi/lo |
| 1237 movff hi,divA+1 | 1243 movff hi,divA+1 |
| 1238 movff lo,divA+0 | 1244 movff lo,divA+0 |
| 1239 ; clear the middle of the bearing marker | 1245 ; clear the middle of the bearing marker |
| 1240 movff lo,hi | 1246 movff lo,hi |
| 1241 movlw d'2' | 1247 movlw d'2' |
| 1242 addwf lo,1 | 1248 addwf lo,1 |
| 1243 rcall TFT_dive_compass_clr_label | 1249 rcall TFT_dive_compass_clr_label |
| 1244 ; restore hi/lo | 1250 ; restore hi/lo |
| 1245 movff divA+1,hi | 1251 movff divA+1,hi |
| 1246 movff divA+0,lo | 1252 movff divA+0,lo |
| 1247 ; print a dot on the middle | 1253 ; print a dot on the middle |
| 1248 movff lo,WREG | 1254 movff lo,WREG |
| 1249 rcall TFT_dive_compass_mk_print_dot | 1255 rcall TFT_dive_compass_mk_print_dot |
| 1250 ; finally print the right marker line | 1256 ; finally print the right marker line |
| 1251 movlw d'2' | 1257 movlw d'2' |
| 1252 addwf lo,0 | 1258 addwf lo,0 |
| 1253 ; rcall TFT_dive_compass_mk_print_3 | 1259 ; rcall TFT_dive_compass_mk_print_3 |
| 1254 ; return | 1260 ; return |
| 1255 TFT_dive_compass_mk_print_3: | 1261 TFT_dive_compass_mk_print_3: |
| 1256 movwf win_leftx2 | 1262 movwf win_leftx2 |
| 1257 movlw dm_custom_compass_label_row | 1263 movlw dm_custom_compass_label_row |
| 1258 movwf win_top | 1264 movwf win_top |
| 1259 movlw dm_custom_compass_label_height-.2 | 1265 movlw dm_custom_compass_label_height-.2 |
| 1260 movwf win_height | 1266 movwf win_height |
| 1261 bra TFT_dive_compass_mk_print_4 | 1267 bra TFT_dive_compass_mk_print_4 |
| 1262 TFT_dive_compass_mk_print_dot: | 1268 TFT_dive_compass_mk_print_dot: |
| 1263 movwf win_leftx2 | 1269 movwf win_leftx2 |
| 1264 movlw dm_custom_compass_label_row + .9 | 1270 movlw dm_custom_compass_label_row + .9 |
| 1265 movwf win_top | 1271 movwf win_top |
| 1266 movlw d'4' | 1272 movlw d'4' |
| 1267 movwf win_height | 1273 movwf win_height |
| 1268 TFT_dive_compass_mk_print_4: | 1274 TFT_dive_compass_mk_print_4: |
| 1269 movlw .158 | 1275 movlw .158 |
| 1270 cpfslt win_leftx2 | 1276 cpfslt win_leftx2 |
| 1271 bra TFT_dive_compass_mk_print_5 | 1277 bra TFT_dive_compass_mk_print_5 |
| 1272 movlw d'2' | 1278 movlw d'2' |
| 1273 movwf win_width+0 | 1279 movwf win_width+0 |
| 1274 clrf win_width+1 | 1280 clrf win_width+1 |
| 1275 movwf win_bargraph | 1281 movwf win_bargraph |
| 1276 movlw color_green | 1282 movlw color_green |
| 1277 btfss print_compass_label | 1283 btfss print_compass_label |
| 1278 movlw color_red | 1284 movlw color_red |
| 1279 call TFT_set_color | 1285 call TFT_set_color |
| 1280 call TFT_box | 1286 call TFT_box |
| 1281 TFT_dive_compass_mk_print_5: | 1287 TFT_dive_compass_mk_print_5: |
| 1282 banksel common | 1288 banksel common |
| 1283 return | 1289 return |
| 1284 | 1290 |
| 1285 TFT_dive_compass_clr_label: | 1291 TFT_dive_compass_clr_label: |
| 1286 movlw dm_custom_compass_label_row-.2 ; set top & height | 1292 movlw dm_custom_compass_label_row-.2 ; set top & height |
| 1287 movff WREG,win_top | 1293 movff WREG,win_top |
| 1288 movlw dm_custom_compass_label_height+.2 | 1294 movlw dm_custom_compass_label_height+.2 |
| 1289 movff WREG,win_height | 1295 movff WREG,win_height |
| 1290 rcall TFT_dive_compass_clear | 1296 rcall TFT_dive_compass_clear |
| 1291 return | 1297 return |
| 1292 | 1298 |
| 1293 TFT_dive_compass_clr_ruler: | 1299 TFT_dive_compass_clr_ruler: |
| 1294 ; top tick | 1300 ; top tick |
| 1295 movlw dm_custom_compass_tick_top_top ; set top & height | 1301 movlw dm_custom_compass_tick_top_top ; set top & height |
| 1296 movff WREG,win_top | 1302 movff WREG,win_top |
| 1297 movlw dm_custom_compass_tick_height | 1303 movlw dm_custom_compass_tick_height |
| 1298 movff WREG,win_height | 1304 movff WREG,win_height |
| 1299 rcall TFT_dive_compass_clear | 1305 rcall TFT_dive_compass_clear |
| 1300 ;bottom tick | 1306 ;bottom tick |
| 1301 movlw dm_custom_compass_tick_bot_top ; set top & height | 1307 movlw dm_custom_compass_tick_bot_top ; set top & height |
| 1302 movff WREG,win_top | 1308 movff WREG,win_top |
| 1303 movlw dm_custom_compass_tick_height | 1309 movlw dm_custom_compass_tick_height |
| 1304 movff WREG,win_height | 1310 movff WREG,win_height |
| 1305 ; rcall TFT_dive_compass_clear | 1311 ; rcall TFT_dive_compass_clear |
| 1306 ; return | 1312 ; return |
| 1307 TFT_dive_compass_clear: | 1313 TFT_dive_compass_clear: |
| 1308 ; we receive RM in lo and DD in hi | 1314 ; we receive RM in lo and DD in hi |
| 1309 ; calculate width = RM-D | 1315 ; calculate width = RM-D |
| 1310 movff hi,WREG | 1316 movff hi,WREG |
| 1311 subwf lo,W | 1317 subwf lo,W |
| 1312 bz TFT_dive_compass_clear3 ; Do nothing if there is nothing to do | 1318 bz TFT_dive_compass_clear3 ; Do nothing if there is nothing to do |
| 1313 movwf win_width+0 ; RM-DD | 1319 movwf win_width+0 ; RM-DD |
| 1314 movwf win_bargraph | 1320 movwf win_bargraph |
| 1315 clrf win_width+1 | 1321 clrf win_width+1 |
| 1316 movlw .1 | 1322 movlw .1 |
| 1317 cpfsgt win_width+0 | 1323 cpfsgt win_width+0 |
| 1318 bra TFT_dive_compass_clear3 ; Do not clear a single pixel (or less) | 1324 bra TFT_dive_compass_clear3 ; Do not clear a single pixel (or less) |
| 1319 movff hi,win_leftx2 | 1325 movff hi,win_leftx2 |
| 1320 movlw color_black | 1326 movlw color_black |
| 1321 call TFT_set_color | 1327 call TFT_set_color |
| 1322 call TFT_box | 1328 call TFT_box |
| 1323 TFT_dive_compass_clear3: | 1329 TFT_dive_compass_clear3: |
| 1324 return | 1330 return |
| 1325 | 1331 |
| 1326 tft_compass_cardinal: | 1332 tft_compass_cardinal: |
| 1327 btfsc hi,0 ; Heading >255°? | 1333 btfsc hi,0 ; Heading >255°? |
| 1328 bra tft_compass_cardinal2 ; Yes must be W, NW or N | 1334 bra tft_compass_cardinal2 ; Yes must be W, NW or N |
| 1329 ; No, Must be W, SW, S, SE, E, NE or N | 1335 ; No, Must be W, SW, S, SE, E, NE or N |
| 1330 movlw .23 | 1336 movlw .23 |
| 1331 subwf lo,W | 1337 subwf lo,W |
| 1332 btfss STATUS,C | 1338 btfss STATUS,C |
| 1333 bra tft_compass_cardinal_N | 1339 bra tft_compass_cardinal_N |
| 1334 movlw .68 | 1340 movlw .68 |
| 1335 subwf lo,W | 1341 subwf lo,W |
| 1336 btfss STATUS,C | 1342 btfss STATUS,C |
| 1337 bra tft_compass_cardinal_NE | 1343 bra tft_compass_cardinal_NE |
| 1338 movlw .113 | 1344 movlw .113 |
| 1339 subwf lo,W | 1345 subwf lo,W |
| 1340 btfss STATUS,C | 1346 btfss STATUS,C |
| 1341 bra tft_compass_cardinal_E | 1347 bra tft_compass_cardinal_E |
| 1342 movlw .158 | 1348 movlw .158 |
| 1343 subwf lo,W | 1349 subwf lo,W |
| 1344 btfss STATUS,C | 1350 btfss STATUS,C |
| 1345 bra tft_compass_cardinal_SE | 1351 bra tft_compass_cardinal_SE |
| 1346 movlw .203 | 1352 movlw .203 |
| 1347 subwf lo,W | 1353 subwf lo,W |
| 1348 btfss STATUS,C | 1354 btfss STATUS,C |
| 1349 bra tft_compass_cardinal_S | 1355 bra tft_compass_cardinal_S |
| 1350 movlw .248 | 1356 movlw .248 |
| 1351 subwf lo,W | 1357 subwf lo,W |
| 1352 btfss STATUS,C | 1358 btfss STATUS,C |
| 1353 bra tft_compass_cardinal_SW | 1359 bra tft_compass_cardinal_SW |
| 1354 bra tft_compass_cardinal_W | 1360 bra tft_compass_cardinal_W |
| 1355 | 1361 |
| 1356 tft_compass_cardinal2: | 1362 tft_compass_cardinal2: |
| 1357 movlw .37 | 1363 movlw .37 |
| 1358 subwf lo,W | 1364 subwf lo,W |
| 1359 btfss STATUS,C | 1365 btfss STATUS,C |
| 1360 bra tft_compass_cardinal_W | 1366 bra tft_compass_cardinal_W |
| 1361 movlw .82 | 1367 movlw .82 |
| 1362 subwf lo,W | 1368 subwf lo,W |
| 1363 btfss STATUS,C | 1369 btfss STATUS,C |
| 1364 bra tft_compass_cardinal_NW | 1370 bra tft_compass_cardinal_NW |
| 1365 ; bra tft_compass_cardinal_N | 1371 ; bra tft_compass_cardinal_N |
| 1372 | |
| 1366 tft_compass_cardinal_N: | 1373 tft_compass_cardinal_N: |
| 1367 STRCAT_TEXT tN | 1374 STRCAT_TEXT tN |
| 1368 return | 1375 return |
| 1369 tft_compass_cardinal_NE: | 1376 tft_compass_cardinal_NE: |
| 1370 STRCAT_TEXT tNE | 1377 STRCAT_TEXT tNE |
| 1371 return | 1378 return |
| 1372 tft_compass_cardinal_E: | 1379 tft_compass_cardinal_E: |
| 1373 STRCAT_TEXT tE | 1380 STRCAT_TEXT tE |
| 1374 return | 1381 return |
| 1375 tft_compass_cardinal_SE: | 1382 tft_compass_cardinal_SE: |
| 1376 STRCAT_TEXT tSE | 1383 STRCAT_TEXT tSE |
| 1377 return | 1384 return |
| 1378 tft_compass_cardinal_S: | 1385 tft_compass_cardinal_S: |
| 1379 STRCAT_TEXT tS | 1386 STRCAT_TEXT tS |
| 1380 return | 1387 return |
| 1381 tft_compass_cardinal_SW: | 1388 tft_compass_cardinal_SW: |
| 1382 STRCAT_TEXT tSW | 1389 STRCAT_TEXT tSW |
| 1383 return | 1390 return |
| 1384 tft_compass_cardinal_W: | 1391 tft_compass_cardinal_W: |
| 1385 STRCAT_TEXT tW | 1392 STRCAT_TEXT tW |
| 1386 return | 1393 return |
| 1387 tft_compass_cardinal_NW: | 1394 tft_compass_cardinal_NW: |
| 1388 STRCAT_TEXT tNW | 1395 STRCAT_TEXT tNW |
| 1389 return | 1396 return |
| 1390 | 1397 |
| 1391 compass_heading_common: | 1398 compass_heading_common: |
| 1392 call speed_normal | 1399 call speed_normal |
| 1393 movlw compass_averaging ; numbers of extra averaging | 1400 movlw compass_averaging ; numbers of extra averaging |
| 1394 movwf up | 1401 movwf up |
| 1395 compass_heading_common2: | 1402 compass_heading_common2: |
| 1396 rcall TFT_get_compass | 1403 rcall TFT_get_compass |
| 1397 decfsz up,F | 1404 decfsz up,F |
| 1398 bra compass_heading_common2 | 1405 bra compass_heading_common2 |
| 1399 extern compass | 1406 call compass ; Do compass corrections. |
| 1400 call compass ; Do compass corrections. | 1407 banksel common |
| 1401 banksel common | 1408 |
| 1402 | 1409 ; More then compass_fast_treshold? |
| 1403 ; More then compass_fast_treshold? | 1410 movff compass_heading_old+0,sub_a+0 |
| 1404 movff compass_heading_old+0,sub_a+0 | 1411 movff compass_heading_old+1,sub_a+1 |
| 1405 movff compass_heading_old+1,sub_a+1 | 1412 movff compass_heading+0,sub_b+0 |
| 1406 movff compass_heading+0,sub_b+0 | 1413 movff compass_heading+1,sub_b+1 |
| 1407 movff compass_heading+1,sub_b+1 | 1414 call sub16 |
| 1408 call sub16 | 1415 btfss neg_flag ; <0? |
| 1409 btfss neg_flag ; <0? | 1416 bra compass_heading_common3 ; No, test for threshold |
| 1410 bra compass_heading_common3 ; No, test for threshold | 1417 ; Yes, subtract the other way round |
| 1411 ; Yes, subtract the other way round | 1418 movff compass_heading+0,sub_a+0 |
| 1412 movff compass_heading+0,sub_a+0 | 1419 movff compass_heading+1,sub_a+1 |
| 1413 movff compass_heading+1,sub_a+1 | 1420 movff compass_heading_old+0,sub_b+0 |
| 1414 movff compass_heading_old+0,sub_b+0 | 1421 movff compass_heading_old+1,sub_b+1 |
| 1415 movff compass_heading_old+1,sub_b+1 | 1422 call sub16 |
| 1416 call sub16 | |
| 1417 compass_heading_common3: | 1423 compass_heading_common3: |
| 1418 movff compass_heading+0,compass_heading_old+0 ; copy new "old" | 1424 movff compass_heading+0,compass_heading_old+0 ; copy new "old" |
| 1419 movff compass_heading+1,compass_heading_old+1 | 1425 movff compass_heading+1,compass_heading_old+1 |
| 1420 | 1426 |
| 1421 bcf compass_fast_mode | 1427 bcf compass_fast_mode |
| 1422 movlw compass_fast_treshold | 1428 movlw compass_fast_treshold |
| 1423 cpfslt sub_c+0 ; > compass_fast_treshold? | 1429 cpfslt sub_c+0 ; > compass_fast_treshold? |
| 1424 bsf compass_fast_mode ; Yes! | 1430 bsf compass_fast_mode ; Yes! |
| 1425 | 1431 |
| 1426 btfss compass_fast_mode ; In fast mode? | 1432 btfss compass_fast_mode ; In fast mode? |
| 1427 return ; No. | 1433 return ; No. |
| 1428 ; Yes. | 1434 ; Yes. |
| 1429 movff compass_heading+0,lo | 1435 movff compass_heading+0,lo |
| 1430 movff compass_heading+1,hi | 1436 movff compass_heading+1,hi |
| 1431 call TFT_convert_signed_16bit ; converts lo:hi into signed-short and adds '-' to POSTINC2 if required | 1437 call TFT_convert_signed_16bit ; converts lo:hi into signed-short and adds '-' to POSTINC2 if required |
| 1432 movff lo,compass_heading_shown+0 | 1438 movff lo,compass_heading_shown+0 |
| 1433 movff hi,compass_heading_shown+1 | 1439 movff hi,compass_heading_shown+1 |
| 1434 return | 1440 return |
| 1435 | 1441 |
| 1436 TFT_get_compass: | 1442 TFT_get_compass: |
| 1437 call I2C_RX_compass ; Test Compass | 1443 call I2C_RX_compass ; Test Compass |
| 1438 call I2C_RX_accelerometer ; Test Accelerometer | 1444 call I2C_RX_accelerometer ; Test Accelerometer |
| 1439 call compass_filter ; Filter Raw compass + accel readings. | 1445 call compass_filter ; Filter Raw compass + accel readings. |
| 1440 banksel common | 1446 banksel common |
| 1441 return | 1447 return |
| 1442 | 1448 |
| 1443 global TFT_surf_set_bearing | 1449 global TFT_surf_set_bearing |
| 1444 TFT_surf_set_bearing: | 1450 TFT_surf_set_bearing: |
| 1445 btfsc premenu | 1451 btfsc premenu |
| 1446 return ; Already shown, return | 1452 return ; Already shown, return |
| 1447 bsf premenu ; set flag | 1453 bsf premenu ; set flag |
| 1448 WIN_BOX_BLACK surf_compass_bear_row,surf_warning1_row-1, surf_compass_bear_column, surf_decotype_column-.1 ; top, bottom, left, right | 1454 WIN_BOX_BLACK surf_compass_bear_row,surf_warning1_row-1, surf_compass_bear_column, surf_decotype_column-.1 ; top, bottom, left, right |
| 1449 WIN_SMALL surf_compass_bear_column,surf_compass_bear_row | 1455 WIN_SMALL surf_compass_bear_column,surf_compass_bear_row |
| 1450 WIN_COLOR color_yellow | 1456 WIN_COLOR color_yellow |
| 1451 bsf win_invert | 1457 bsf win_invert |
| 1452 STRCPY_TEXT_PRINT tSetHeading ; 7 chars | 1458 STRCPY_TEXT_PRINT tSetHeading ; 7 chars |
| 1453 bcf win_invert | 1459 bcf win_invert |
| 1454 return | 1460 return |
| 1455 | 1461 |
| 1456 END | 1462 END |
