Mercurial > public > hwos_code
annotate src/menu_processor.asm @ 223:940155e9aefb
PC config, 1.72 release
| author | heinrichsweikamp |
|---|---|
| date | Wed, 14 Jan 2015 11:37:19 +0100 |
| parents | e79bc535ef9e |
| children | e1e5876bd777 |
| rev | line source |
|---|---|
| 0 | 1 ;============================================================================= |
| 2 ; | |
| 3 ; File menu_processor.asm | |
| 4 ; | |
| 5 ; Routines to handle all OSTC3 graphic/text menus. | |
| 6 ; | |
| 7 ; Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved. | |
| 8 ;============================================================================= | |
| 9 ; HISTORY | |
| 10 ; 2012-11-02 : [jDG] Cleanup for OSTC3: removed icons. Added scrolling. | |
| 11 ; But need a font with lower/upper alpha chars... | |
| 12 | |
| 13 #include "convert.inc" | |
| 14 #include "ostc3.inc" | |
| 15 #include "strings.inc" | |
| 16 #include "tft.inc" | |
| 17 #include "varargs.inc" | |
| 18 #include "wait.inc" | |
| 19 #include "start.inc" | |
| 20 #include "surfmode.inc" | |
| 21 #include "divemode.inc" | |
| 22 #include "tft_outputs.inc" | |
| 23 #include "eeprom_rs232.inc" | |
| 62 | 24 #include "adc_lightsensor.inc" |
| 113 | 25 #include "calibrate.inc" |
| 0 | 26 |
| 27 ;NOTE: should be idenric in .inc and .asm ! | |
| 28 #define MENU_LINES_MAX .7 ; Number of lines per screen? | |
| 29 #define MENU_TITLE_FONT WIN_STD ; Font should contains lower/UPPER alpha | |
| 30 #define MENU_LINE_FONT WIN_SMALL ; Font should contains lower/UPPER alpha | |
| 31 #define MENU_LEFT .20 ; Position of first menu item | |
| 32 #define MENU_HEIGHT .27 ; Spacing between menu lines. | |
| 33 #define MENU_VCENTER .125 ; Position on screen. | |
| 34 #define MENU_LINE_MAX_LENGTH .20 ; Length in characters | |
| 35 | |
| 36 ; Other needed references | |
| 37 extern aa_wordprocessor,option_inc,option_draw,comm_mode | |
| 38 | |
| 39 | |
| 40 ;============================================================================= | |
| 41 ; Temporary data. | |
| 42 | |
| 43 CBLOCK tmp+0x20 ; Reserved space for options.asm | |
| 44 menu_flags ; Various flags for menu: | |
| 45 ; bit 0 :dynamic menu | |
| 46 menu_item ; Index of the current item. | |
| 47 start_item ; Index of the first item (scrolling) | |
| 48 item_max ; Number of items in menu. | |
| 49 selected_item ; Index of the current item. | |
| 50 value_type ; Type for vertical menu. | |
| 51 dynamic_item:3 ; Callback addr | |
| 52 menu_block:3 ; Address of the menu block (ie. item 0) | |
| 53 menu_title:3 ; text or proc for dynamic menu. | |
| 54 menu_center ; centering for line menu. | |
| 55 proc_item:3 ; Address of the current proc. | |
| 56 text_item:2 ; Address of the current text. | |
| 57 ; Reserved to tmp+0x35 | |
| 58 ENDC | |
| 59 | |
| 60 #define option_item proc_item | |
| 61 | |
| 62 basic CODE | |
| 63 ;============================================================================= | |
| 64 ; menu handler. | |
| 65 ; | |
| 66 ; Input: TBLPTR = addr of menu block. | |
| 67 global menu_processor | |
| 68 menu_processor: | |
| 69 banksel common ; Bank1 | |
| 70 btfss divemode ; Not in divemode | |
| 71 call speed_fastest ; Make it quick ! | |
| 72 | |
| 73 ;---- Read menu block ------------------------------------------------ | |
| 74 VARARGS_BEGIN ; Read inline PROM data | |
| 75 clrf STKPTR ; Never return, anyway... | |
| 76 VARARGS_GET8 item_max ; Get number of items | |
| 77 VARARGS_GET8 menu_flags ; Get flags | |
| 78 VARARGS_GET24 menu_title ; Get pointer to menu title | |
| 79 VARARGS_GET8 menu_center ; Vertical position | |
| 80 movff TBLPTRL, menu_block+0 ; Save base address for menu_read_item | |
| 81 movff TBLPTRH, menu_block+1 | |
| 82 movff TBLPTRU, menu_block+2 | |
| 83 | |
| 84 extern TFT_clear_divemode_menu | |
| 85 btfss divemode ; In divemode? | |
| 86 bra menu_processor0 ; No | |
| 87 | |
| 88 movlw .1 | |
| 89 cpfsgt menupos ; only if menupos=1... | |
| 90 call TFT_clear_divemode_menu ; ... Clear the menu! | |
|
175
d097e10b383b
CHANGE: Draw a frame around the dive mode menu
heinrichsweikamp
parents:
169
diff
changeset
|
91 |
|
d097e10b383b
CHANGE: Draw a frame around the dive mode menu
heinrichsweikamp
parents:
169
diff
changeset
|
92 ; Draw one frame around the divemode menu |
|
d097e10b383b
CHANGE: Draw a frame around the dive mode menu
heinrichsweikamp
parents:
169
diff
changeset
|
93 extern TFT_divemask_color |
|
d097e10b383b
CHANGE: Draw a frame around the dive mode menu
heinrichsweikamp
parents:
169
diff
changeset
|
94 call TFT_divemask_color |
|
d097e10b383b
CHANGE: Draw a frame around the dive mode menu
heinrichsweikamp
parents:
169
diff
changeset
|
95 WIN_FRAME_COLOR16 divemode_menu_row, divemode_menu_lower, divemode_menu_left ,divemode_menu_right ; top, bottom, left, right |
|
d097e10b383b
CHANGE: Draw a frame around the dive mode menu
heinrichsweikamp
parents:
169
diff
changeset
|
96 call TFT_standard_color |
|
d097e10b383b
CHANGE: Draw a frame around the dive mode menu
heinrichsweikamp
parents:
169
diff
changeset
|
97 |
| 0 | 98 bra menu_processor1 ; Yes, skip some lines here |
| 99 | |
| 100 menu_processor0: | |
| 101 ;---- draw menu title ------------------------------------------------ | |
| 102 clrf CCP1CON ; stop PWM | |
| 103 bcf PORTC,2 ; Pull PWM out to GND | |
| 104 call TFT_ClearScreen | |
| 105 rcall menu_processor_title | |
|
169
dcf3e08f31ac
CHANGE: Improve internal logbook usability
heinrichsweikamp
parents:
125
diff
changeset
|
106 rcall menu_processor_bottom_line |
| 0 | 107 |
|
169
dcf3e08f31ac
CHANGE: Improve internal logbook usability
heinrichsweikamp
parents:
125
diff
changeset
|
108 menu_processor1: |
|
dcf3e08f31ac
CHANGE: Improve internal logbook usability
heinrichsweikamp
parents:
125
diff
changeset
|
109 movlw FT_SMALL |
|
dcf3e08f31ac
CHANGE: Improve internal logbook usability
heinrichsweikamp
parents:
125
diff
changeset
|
110 movff WREG, win_font |
|
dcf3e08f31ac
CHANGE: Improve internal logbook usability
heinrichsweikamp
parents:
125
diff
changeset
|
111 |
|
dcf3e08f31ac
CHANGE: Improve internal logbook usability
heinrichsweikamp
parents:
125
diff
changeset
|
112 ;---- Select menu type ----------------------------------------------- |
|
dcf3e08f31ac
CHANGE: Improve internal logbook usability
heinrichsweikamp
parents:
125
diff
changeset
|
113 bra menu_vertical |
|
dcf3e08f31ac
CHANGE: Improve internal logbook usability
heinrichsweikamp
parents:
125
diff
changeset
|
114 |
|
dcf3e08f31ac
CHANGE: Improve internal logbook usability
heinrichsweikamp
parents:
125
diff
changeset
|
115 global menu_processor_bottom_line |
|
dcf3e08f31ac
CHANGE: Improve internal logbook usability
heinrichsweikamp
parents:
125
diff
changeset
|
116 menu_processor_bottom_line: |
| 0 | 117 ;---- Draw bottomline ------------------------------------------------ |
| 118 TEXT_TINY .5, .240-.16, tNext | |
| 119 TEXT_TINY .160-6*5, .240-.16, tEnter | |
| 120 | |
| 76 | 121 WIN_COLOR color_greenish |
| 122 ; Serial and Firmware Version | |
| 123 WIN_TINY .57,.240-.16 | |
| 124 STRCPY "#" | |
| 125 call TFT_cat_serial | |
| 126 STRCAT " v" | |
| 127 call TFT_cat_firmware | |
| 128 STRCAT_PRINT "" | |
| 129 call TFT_standard_color | |
|
169
dcf3e08f31ac
CHANGE: Improve internal logbook usability
heinrichsweikamp
parents:
125
diff
changeset
|
130 return |
| 0 | 131 |
| 132 ;============================================================================= | |
| 133 ; (re-)draw menu title. | |
| 134 ; | |
| 135 menu_processor_title: | |
| 125 | 136 WIN_BOX_BLACK .2,.23,.0,.160 ; Clear Menu title |
| 137 MENU_TITLE_FONT .0, .2 ; Menu title positionning | |
| 138 | |
| 0 | 139 btfss menu_flags,0 ; Static or dynmic title ? |
| 140 bra menu_processor_static_title | |
| 141 | |
| 142 rcall menu_processor_call_title ; add gas, detail and color. | |
| 143 bra menu_processor_title_1 | |
| 144 | |
| 145 menu_processor_static_title: | |
| 146 movff menu_title+0,FSR1L ; Just copy string. | |
| 147 movff menu_title+1,FSR1H | |
| 148 call strcpy_text | |
| 149 | |
| 150 menu_processor_title_1: | |
| 151 WIN_COLOR color_greenish | |
| 152 movf FSR2L,W ; Get title length | |
| 153 mullw .9 ; Convert to half pixels | |
| 154 bcf STATUS,C ; Clear carry | |
| 155 rrcf PRODL ; /2 | |
| 156 movf PRODL,W ; Back to WREG | |
| 157 sublw .80 ; 80 - width | |
| 158 movwf win_leftx2 ; Aligned to center. | |
| 159 | |
| 160 call aa_wordprocessor | |
| 50 | 161 call TFT_standard_color |
| 0 | 162 return |
| 163 | |
| 164 ;============================================================================= | |
| 165 ; Call dynamic proc for menu title: | |
| 166 | |
| 167 menu_processor_call_title: | |
| 168 movff menu_title+2,PCLATU ; Just execute computed goto. | |
| 169 movff menu_title+1,PCLATH | |
| 170 movf menu_title+0,W | |
| 171 movwf PCL | |
| 172 | |
| 173 ;============================================================================= | |
| 174 ; Restart with first icon/line selected. | |
| 175 global menu_processor_reset | |
| 176 menu_processor_reset: | |
| 177 banksel common | |
| 178 lfsr FSR2,menustack | |
| 179 clrf POSTINC2 | |
| 180 clrf POSTINC2 | |
| 181 clrf POSTINC2 | |
| 182 clrf POSTINC2 | |
| 183 clrf POSTINC2 | |
| 184 clrf selected_item | |
| 185 return | |
| 186 | |
| 187 global menu_processor_pop | |
| 188 menu_processor_pop: | |
| 189 movff menustack+0,selected_item | |
| 190 movff menustack+1,menustack+0 | |
| 191 movff menustack+2,menustack+1 | |
| 192 movff menustack+3,menustack+2 | |
| 193 movff menustack+4,menustack+3 | |
| 194 return | |
| 195 | |
| 196 menu_processor_push: | |
| 197 movff menustack+3,menustack+4 | |
| 198 movff menustack+2,menustack+3 | |
| 199 movff menustack+1,menustack+2 | |
| 200 movff menustack+0,menustack+1 | |
| 201 movff selected_item,menustack+0 | |
| 202 clrf selected_item | |
| 203 return | |
| 204 | |
| 205 ;---- Execute menu selection ------------------------------------------------- | |
| 206 do_menu_item: | |
| 207 bcf switch_right ; Avoid loops. | |
| 208 call speed_normal ; Back to normal speed. | |
| 209 | |
| 210 movf selected_item,W ; Reread proc address from table. | |
| 211 rcall menu_read_item ; (destroy PROD) | |
| 212 | |
| 213 movff selected_item,PRODL ; Pass along selected line | |
| 214 | |
| 215 rcall menu_processor_push ; Remember where we get from. (clears selected_item) | |
| 216 | |
| 217 movff proc_item+2,PCLATU ; Then execute computed goto. | |
| 218 movff proc_item+1,PCLATH | |
| 219 movf proc_item+0,W | |
| 220 movwf PCL | |
| 221 | |
| 222 ;============================================================================= | |
| 223 ; Get current item from table. | |
| 224 ; | |
| 225 ; Input : Item number in WREG, menu_block. | |
| 226 ; | |
| 227 ; Output: icon_large, text_item, proc_item 16bits pointers. | |
| 228 ; | |
| 229 ; Trashed: PROD, WREG | |
| 230 menu_read_item: | |
| 231 mullw .10 ; 10 bytes per item. | |
| 232 movf PRODL,W ; Then do a 24bits add | |
| 233 addwf menu_block+0,W ; with menu_block, and | |
| 234 movwf TBLPTRL ; setup TBLPTR | |
| 235 movf PRODH,W | |
| 236 addwfc menu_block+1,W | |
| 237 movwf TBLPTRH | |
| 238 movlw 0 | |
| 239 addwfc menu_block+2,W | |
| 240 movwf TBLPTRU | |
| 241 | |
| 242 VARARGS_GET8 value_type ; Read 10 bytes of item data | |
| 243 VARARGS_GET24 dynamic_item | |
| 244 VARARGS_GET24 proc_item | |
| 245 VARARGS_GET8 WREG ; Skip dummy byte | |
| 246 VARARGS_GET16 text_item | |
| 247 | |
| 248 return | |
| 249 | |
| 250 ;============================================================================= | |
| 251 ; Vertical menu : set of line/value to choose from. | |
| 252 ; Entry point to update lines already shown. | |
| 253 ; | |
| 254 global menu_vertical | |
| 255 menu_vertical: | |
| 256 btfss divemode ; Not in divemode | |
| 257 clrf timeout_counter2 ; Reset timeout | |
| 258 | |
| 259 menu_vertical_2: | |
| 260 rcall menu_draw_lines ; Always re-draw whole menu | |
| 261 | |
| 262 movlw CCP1CON_VALUE ; See ostc3.inc | |
| 263 btfss divemode ; Not in divemode | |
| 264 movwf CCP1CON ; Power-on backlight | |
| 265 | |
| 266 menu_vertical_1: | |
| 267 movf selected_item,W ; Get current item data | |
| 268 rcall menu_read_item | |
| 269 movf proc_item+0,W ; Check if pro address is NULL ? | |
| 270 iorwf proc_item+1,W | |
| 271 bz next_line_menu ; YES: not selectable ! | |
| 272 | |
| 273 btfss divemode ; Not in divemode | |
| 274 rcall menu_draw_selected_line | |
| 275 | |
| 50 | 276 btfsc in_color_menu ; =1: In the color scheme menu |
| 277 call TFT_show_color_schemes ; Yes, update the color schemes | |
| 278 | |
| 0 | 279 extern rtc_set_rtc |
| 280 btfss settime_setdate ; In the Set Time or Set Date menu? | |
| 281 bra menu_line_loop_pre2 ; no, skip all following | |
| 282 | |
| 283 movff month,lo ; new month | |
| 284 dcfsnz lo,F | |
| 285 movlw .31 | |
| 286 dcfsnz lo,F | |
| 287 movlw .28 | |
| 288 dcfsnz lo,F | |
| 289 movlw .31 | |
| 290 dcfsnz lo,F | |
| 291 movlw .30 | |
| 292 dcfsnz lo,F | |
| 293 movlw .31 | |
| 294 dcfsnz lo,F | |
| 295 movlw .30 | |
| 296 dcfsnz lo,F | |
| 297 movlw .31 | |
| 298 dcfsnz lo,F | |
| 299 movlw .31 | |
| 300 dcfsnz lo,F | |
| 301 movlw .30 | |
| 302 dcfsnz lo,F | |
| 303 movlw .31 | |
| 304 dcfsnz lo,F | |
| 305 movlw .30 | |
| 306 dcfsnz lo,F | |
| 307 movlw .31 | |
| 308 cpfsgt day ; day ok? | |
| 309 bra menu_line_loop_pre1 ; OK! | |
| 310 movlw .1 ; not OK, set to 1st | |
| 311 movwf day | |
| 312 | |
| 313 menu_line_loop_pre1: | |
| 314 btfsc switch_right ; Enter pressed? | |
| 315 call rtc_set_rtc ; Yes, update mins,sec,hours,day,month and year to rtc module | |
| 316 call TFT_show_time_date_menu ; Update clock | |
| 317 | |
| 318 menu_line_loop_pre2: | |
| 319 bcf switch_right | |
| 320 bcf switch_left | |
| 321 btfss divemode ; Not in Divemode | |
| 322 call speed_normal | |
| 323 | |
| 324 menu_line_loop_pre3: | |
| 325 extern divemode_option0_return | |
| 326 btfsc divemode ; In divemode? | |
| 327 goto divemode_option0_return ; Yes, return to it | |
| 328 | |
| 329 menu_line_loop: | |
| 330 btfsc switch_right | |
| 331 bra do_line_menu ; Type dependent | |
| 332 btfsc switch_left | |
| 333 bra next_line_menu | |
| 334 | |
| 113 | 335 btfss quarter_second_update ; 1/4 second? |
| 336 bra menu_line_loop1 ; Not yet... | |
| 337 | |
| 338 call compute_ppo2 ; compute mv_sensorX and ppo2_sensorX arrays | |
| 339 btfsc menu_show_sensors2 ; In the "Calibrate" menu? | |
|
187
669b5d00706d
CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents:
175
diff
changeset
|
340 call TFT_menu_calibrate ; Yes, update mV data |
| 113 | 341 bcf quarter_second_update ; Clear flag |
| 342 | |
| 343 menu_line_loop1: | |
| 0 | 344 btfss onesecupdate ; New second |
| 345 bra menu_line_loop2 ; not yet... | |
| 346 | |
| 347 call timeout_surfmode ; timeout | |
| 348 call set_dive_modes ; check, if divemode must be entered | |
| 113 | 349 call get_battery_voltage ; gets battery voltage |
| 0 | 350 |
| 351 btfsc settime_setdate ; In the Set Time or Set Date menu? | |
| 352 call TFT_show_time_date_menu ; Yes, update clock | |
| 113 | 353 |
| 0 | 354 btfsc menu_show_sensors ; In the "Sensors" menu? |
| 355 call TFT_menu_hud ; Yes, update HUD data | |
| 356 | |
| 357 bcf onesecupdate ; one second updates done | |
| 358 | |
| 359 menu_line_loop2: | |
| 360 btfsc sleepmode ; Timeout? | |
| 361 goto restart ; Yes, back to surfacemode | |
| 362 btfsc divemode | |
| 363 goto restart ; Enter Divemode if required | |
| 364 | |
| 365 btfsc enable_screen_dumps ; =1: Ignore vin_usb, wait for "l" command (Screen dump) | |
| 366 bra menu_line_loop3 | |
| 367 btfsc vusb_in ; USB plugged in? | |
| 113 | 368 call comm_mode ; Start COMM mode |
| 0 | 369 bra menu_line_loop4 |
| 370 menu_line_loop3: | |
| 371 btfss vusb_in ; USB (still) plugged in? | |
| 372 bcf enable_screen_dumps ; No, clear flag | |
| 373 call rs232_get_byte | |
| 374 btfsc rs232_recieve_overflow | |
| 375 bra menu_line_loop4 | |
| 376 movlw "l" | |
| 377 cpfseq RCREG1 | |
| 378 bra menu_line_loop4 | |
| 379 call TFT_dump_screen ; Dump the screen contents | |
| 380 menu_line_loop4: | |
| 381 | |
| 382 bra menu_line_loop | |
| 383 | |
| 384 ;---- Move to menu's next line | |
| 385 next_line_menu: | |
| 386 btfss divemode ; not in divemode | |
| 387 call speed_fastest | |
| 388 bcf switch_left ; Avoid looping. | |
| 389 | |
| 390 incf selected_item,F ; Select next item. | |
| 391 movf selected_item,W ; Index == max ? | |
| 392 cpfseq item_max | |
| 393 bra menu_vertical_1 ; NO: redraw cursor. | |
| 394 | |
| 395 clrf selected_item ; YES: restart for item 0. | |
| 396 bra menu_vertical_1 ; Then redraw cursor. | |
| 397 | |
| 398 global do_line_menu | |
| 399 do_line_menu: | |
| 400 btfss divemode ; not in divemode | |
| 401 call speed_fastest | |
| 402 ; bcf switch_right ; Avoid looping. | |
| 403 | |
| 404 decf menupos,W ; menu_processor needs 0-5... | |
| 405 btfsc divemode ; only in divemode | |
| 406 movwf selected_item | |
| 407 | |
| 408 movf selected_item,W ; Read selected descriptor | |
| 409 rcall menu_read_item | |
| 410 | |
| 411 movf value_type,W ; Switch on data type | |
| 412 bz menu_do_line_call ; CALL | |
| 413 dcfsnz WREG | |
| 414 bra menu_do_line_call ; STRING: do as call | |
| 415 dcfsnz WREG | |
| 416 bra menu_do_line_option ; OPTION | |
| 417 dcfsnz WREG | |
| 418 bra menu_do_line_call ; DYNAMIC: do as call | |
| 419 bra menu_line_loop_pre3 ; else do nothing... | |
| 420 | |
| 421 ;---- CALL | |
| 422 menu_do_line_call: | |
| 423 rcall do_menu_item ; Same as icon menu: calculated goto. | |
| 424 rcall menu_processor_pop ; Back to same line, | |
| 425 bra menu_vertical ; Then continue into menu... | |
| 426 | |
| 427 ;---- Call option specific increment subroutine | |
| 428 menu_do_line_option: | |
| 429 movff option_item+0,FSR0L ; Get option handle | |
| 430 movff option_item+1,FSR0H | |
| 431 call option_inc ; increment | |
| 432 | |
| 433 movff selected_item,PRODL ; Pass selection to callback. | |
| 434 rcall menu_text_call | |
| 435 bra menu_vertical_2 ; redraw all lines... | |
| 436 | |
| 437 ;----------------------------------------------------------------------------- | |
| 438 | |
| 439 menu_draw_lines_divemode: | |
| 440 movlw divemode_menu_item1_row | |
| 441 movff WREG,win_top | |
| 442 movlw divemode_menu_item1_column | |
| 443 movff WREG,win_leftx2 | |
| 444 clrf start_item | |
| 445 movff item_max,menupos4 ; Copy item_max for divemode cursor routine | |
| 446 bra menu_draw_lines_2 | |
| 447 | |
| 448 menu_draw_lines: | |
| 449 btfsc divemode ; in divemode? | |
| 450 bra menu_draw_lines_divemode ; Yes | |
| 451 | |
| 452 btfsc menu_flags,0 ; Dynamic title ? | |
| 453 rcall menu_processor_title ; YES: redraw it then. | |
| 454 | |
| 455 MENU_LINE_FONT MENU_LEFT, 0 ; Init start position/font | |
| 456 movff menu_center,win_top ; computed in menu block. | |
| 457 | |
| 458 ; Does the menu have more than 6 lines ? | |
| 459 movf item_max,W | |
| 460 addlw -(MENU_LINES_MAX+1) ; (max - 7) | |
| 461 bnn menu_draw_long_menu ; bra if (max >= 7) | |
| 462 | |
| 463 clrf start_item | |
| 464 bra menu_draw_lines_2 | |
| 465 | |
| 466 menu_draw_long_menu: | |
| 467 movf selected_item,W ; Start at selected-6 | |
| 468 addlw -(MENU_LINES_MAX-1) | |
| 469 btfsc STATUS,N ; This is <0 ? | |
| 470 clrf WREG ; YES: start from top instead. | |
| 471 movwf start_item | |
| 472 | |
| 473 menu_draw_lines_2: | |
| 474 movff start_item, menu_item | |
| 475 | |
| 476 menu_draw_lines_1: | |
| 50 | 477 call TFT_standard_color ; Restore color after disabled lines. |
| 0 | 478 |
| 479 movf menu_item,W | |
| 480 rcall menu_read_item | |
| 481 | |
| 482 movf value_type,W ; Switch on data type | |
| 483 bz menu_draw_line_call | |
| 484 dcfsnz WREG | |
| 485 bra menu_draw_line_string | |
| 486 dcfsnz WREG | |
| 487 bra menu_draw_line_option | |
| 488 dcfsnz WREG | |
| 489 bra menu_draw_line_dynamic | |
| 490 bra menu_draw_line_none | |
| 491 | |
| 492 menu_draw_line_string: | |
| 493 movff text_item+0,TBLPTRL ; Read not-translated string from PROM. | |
| 494 movff text_item+1,TBLPTRH | |
| 495 call strcpy_prom ; Copy in buffer | |
| 496 bra menu_draw_line_none | |
| 497 | |
| 498 menu_draw_line_call: | |
| 499 movff text_item+0,FSR1L ; Read string from PROM. | |
| 500 movff text_item+1,FSR1H | |
| 501 call strcpy_text ; Copy in buffer | |
| 502 | |
| 503 bra menu_draw_line_none | |
| 504 | |
| 505 menu_draw_line_option: | |
| 506 movff text_item+0,FSR1L ; Read string from PROM. | |
| 507 movff text_item+1,FSR1H | |
| 508 call strcpy_text ; Copy in buffer | |
| 509 | |
| 510 movff option_item+0,FSR0L ; Retrieve option handle. | |
| 511 movff option_item+1,FSR0H | |
| 68 | 512 btfss settime_setdate ; Not in Time/Date menu... |
| 0 | 513 call option_draw |
| 514 bra menu_draw_line_none | |
| 515 | |
| 516 menu_draw_line_dynamic: | |
| 517 lfsr FSR2,buffer | |
| 518 movff menu_item,PRODL ; Pass item to callback. | |
| 519 rcall menu_text_call ; Push return address. | |
| 520 bra menu_draw_line_none | |
| 521 | |
| 522 ; Computed goto to pointer inside dynamic_item: | |
| 523 menu_text_call: | |
| 524 movf dynamic_item+0,W ; Check if callback is NULL | |
| 525 iorwf dynamic_item+1,W | |
| 526 iorwf dynamic_item+2,W | |
| 527 btfsc STATUS,Z | |
| 528 return ; YES: don't call it. | |
| 529 | |
| 530 movff dynamic_item+2,PCLATU ; Prepare... | |
| 531 movff dynamic_item+1,PCLATH | |
| 532 movf dynamic_item+0,W | |
| 533 movwf PCL ; And jump ! | |
| 534 | |
| 535 menu_draw_line_none: | |
| 536 extern TFT_fillup_with_spaces | |
| 537 | |
| 538 btfsc divemode ; In divemode? | |
| 539 bra menu_draw_line_none_divemode ; Yes | |
| 540 | |
| 541 movlw MENU_LINE_MAX_LENGTH | |
| 542 call TFT_fillup_with_spaces ; Fillup FSR2 with spaces (Total string length in #WREG) | |
| 543 clrf WREG | |
| 544 movff WREG,buffer+MENU_LINE_MAX_LENGTH;No ; Make sure won't be longer than MENU_LINE_MAX_LENGTH ch | |
| 545 call aa_wordprocessor | |
| 546 movlw MENU_HEIGHT ; No, Move to next line | |
| 547 addwf win_top,F | |
| 548 incf menu_item,F ; inc loop counter | |
| 549 | |
| 550 movf start_item,W ; First line (scrolled) | |
| 551 subwf menu_item,W ; current - first | |
| 552 xorlw MENU_LINES_MAX ; Already done 6 lines ? | |
| 553 btfsc STATUS,Z | |
| 554 return ; YES | |
| 555 menu_draw_line_none2: | |
| 556 movf menu_item,W ; Done item_max lines ? | |
| 557 xorwf item_max,W | |
| 558 btfss STATUS,Z | |
| 559 bra menu_draw_lines_1 ; No: loop... | |
| 560 return | |
| 561 | |
| 562 menu_draw_line_none_divemode: | |
| 563 movlw .10 | |
| 564 call TFT_fillup_with_spaces ; Fillup FSR2 with spaces (Total string length in #WREG) | |
| 565 clrf WREG | |
| 566 movff WREG,buffer+.10 | |
| 567 | |
| 568 call aa_wordprocessor ; Draw the line! | |
| 569 | |
|
189
e79bc535ef9e
ignore un-calibrated sensors even if they become valid
heinrichsweikamp
parents:
187
diff
changeset
|
570 banksel common |
|
e79bc535ef9e
ignore un-calibrated sensors even if they become valid
heinrichsweikamp
parents:
187
diff
changeset
|
571 bcf win_invert ; Reset invert flag |
|
e79bc535ef9e
ignore un-calibrated sensors even if they become valid
heinrichsweikamp
parents:
187
diff
changeset
|
572 banksel win_top |
| 0 | 573 |
| 574 movlw .24 ; Divemode menu spacing | |
| 575 addwf win_top,F | |
| 576 incf menu_item,F ; inc loop counter | |
| 577 | |
| 578 movlw .3 | |
| 579 cpfseq menu_item ; At pos 4? | |
| 580 bra menu_draw_line_none2 ; No | |
| 581 | |
| 582 movlw divemode_menu_item4_row | |
| 583 movff WREG,win_top ; Reset row | |
| 584 movlw divemode_menu_item4_column | |
| 585 movff WREG,win_leftx2 ; New column | |
| 586 bra menu_draw_line_none2 ; Done. | |
| 587 | |
| 588 ;----------------------------------------------------------------------------- | |
| 589 ; Put a mark in front of the current line | |
| 590 menu_draw_selected_line: | |
| 591 clrf timeout_counter2 ; Reset timeout | |
| 592 WIN_BOX_BLACK .34,.221,MENU_LEFT-8,MENU_LEFT-2 ; Clear left column | |
| 593 | |
| 50 | 594 call TFT_standard_color |
| 0 | 595 WIN_SMALL MENU_LEFT-8, 0 ; Arrow symbol only in small font |
| 596 movf start_item,W ; First line (scrolled) | |
| 597 subwf selected_item,W ; selected - first | |
| 598 mullw MENU_HEIGHT ; 30 pixel by line | |
| 599 movf PRODL,W ; result | |
| 600 addwf menu_center,W ; added to first line | |
| 601 movwf win_top ; and stored to pos. | |
| 602 STRCPY_PRINT "\xb7" ; print cursor | |
| 603 | |
| 604 return | |
| 605 | |
| 606 END |
