# HG changeset patch # User JeanDo # Date 1305982087 -7200 # Node ID 797e2ac42d24d1331f453e951701b4a11af8ebd0 # Parent 6bdf80d7276c44a400b248ce20bb60d198db7d45# Parent d5240792be51833db2cb6211b892310ddb95f326 MERGE with 1.91 main trunk. diff -r d5240792be51 -r 797e2ac42d24 code_part1/OSTC_code_asm_part1/MAIN.ASM --- a/code_part1/OSTC_code_asm_part1/MAIN.ASM Sat May 21 14:38:56 2011 +0200 +++ b/code_part1/OSTC_code_asm_part1/MAIN.ASM Sat May 21 14:48:07 2011 +0200 @@ -89,6 +89,7 @@ #include oled_samsung.asm ; Attached in 80-System 8-Bit Mode #include aa_wordprocessor.asm ; New antialiased word processor and fonts #include color_processor.asm ; Color image drawing. +#include dump_screen.asm ; Copy screen contains to serial interface #include valconv.asm ; outputs to POSTINC2 #include eeprom_rs232.asm ; Internal EEPROM and RS232 Interface #include menu_custom.asm ; Menu "Custom FunctionsI" and "Custom FunctionsII" diff -r d5240792be51 -r 797e2ac42d24 code_part1/OSTC_code_asm_part1/altimeter.asm --- a/code_part1/OSTC_code_asm_part1/altimeter.asm Sat May 21 14:38:56 2011 +0200 +++ b/code_part1/OSTC_code_asm_part1/altimeter.asm Sat May 21 14:48:07 2011 +0200 @@ -304,6 +304,9 @@ bcf switch_right alt_menu_loop1: ; Wait for button. + btfsc uart_dump_screen ; Asked to dump screen contains ? + call dump_screen ; Yes! + btfsc switch_right ; [[MENU]] button bra alt_menu_next diff -r d5240792be51 -r 797e2ac42d24 code_part1/OSTC_code_asm_part1/definitions.asm --- a/code_part1/OSTC_code_asm_part1/definitions.asm Sat May 21 14:38:56 2011 +0200 +++ b/code_part1/OSTC_code_asm_part1/definitions.asm Sat May 21 14:48:07 2011 +0200 @@ -387,8 +387,8 @@ #DEFINE win_flip_screen win_flags,0 ; 180° rotation of the OLED screen. ; Flags -#DEFINE tts_extra_time flag1,0 ; Show Futur TTS in customview -#DEFINE FLAG_2 flag1,1 ; unused +#DEFINE tts_extra_time flag1,0 ; Showing "Future TTS" customview +#DEFINE uart_dump_screen flag1,1 ; Screen copy to USB. #DEFINE pre_zero_flag flag1,2 ; leading zeros #DEFINE neg_flag flag1,3 ; e.g. Sub_16 (sub_c = sub_a - sub_b) #DEFINE FLAG_3 flag1,4 ; unused diff -r d5240792be51 -r 797e2ac42d24 code_part1/OSTC_code_asm_part1/divemode.asm --- a/code_part1/OSTC_code_asm_part1/divemode.asm Sat May 21 14:38:56 2011 +0200 +++ b/code_part1/OSTC_code_asm_part1/divemode.asm Sat May 21 14:48:07 2011 +0200 @@ -157,15 +157,21 @@ btfsc toggle_customview ; Next view? call customview_toggle ; Yes, show next customview (and delete this flag) - btfsc menubit ; Sleep only with inactive menu... - bra diveloop_loop4 + btfsc simulatormode_active ; Is Simualtor mode active ? + bra diveloop_loop4 ; YES: don't sleep - btfsc simulatormode_active ; Do not sleep in Simualtor mode - bra diveloop_loop4 + btfsc menubit ; Sleep only with inactive menu... + bra diveloop_loop5 sleep nop -diveloop_loop4: + bra diveloop_loop ; Loop the divemode + +diveloop_loop4: ; And test screen dumps too! + btfsc uart_dump_screen ; Asked to dump screen contains ? + call dump_screen ; Yes! + +diveloop_loop5: bra diveloop_loop ; Loop the divemode timeout_premenu_divemode: diff -r d5240792be51 -r 797e2ac42d24 code_part1/OSTC_code_asm_part1/divemode_menu.asm --- a/code_part1/OSTC_code_asm_part1/divemode_menu.asm Sat May 21 14:38:56 2011 +0200 +++ b/code_part1/OSTC_code_asm_part1/divemode_menu.asm Sat May 21 14:48:07 2011 +0200 @@ -24,6 +24,9 @@ test_switches_divemode: ; checks switches in divemode + btfsc uart_dump_screen ; Asked to dump screen contains ? + call dump_screen ; Yes! + btfsc switch_left bra test_switches_divemode2 @@ -103,6 +106,9 @@ return test_switches_divemode_menu: + btfsc uart_dump_screen ; Asked to dump screen contains ? + call dump_screen ; Yes! + btfsc switch_left bra test_switches_divemode_menu3 btfss switch_right diff -r d5240792be51 -r 797e2ac42d24 code_part1/OSTC_code_asm_part1/dump_screen.asm --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/code_part1/OSTC_code_asm_part1/dump_screen.asm Sat May 21 14:48:07 2011 +0200 @@ -0,0 +1,216 @@ +;============================================================================= +; +; File dump_screen.asm +; +; Dump screen contains to the serial interface. +; +; This program is free software: you can redistribute it and/or modify +; it under the terms of the GNU General Public License as published by +; the Free Software Foundation, either version 3 of the License, or +; (at your option) any later version. +; +; This program is distributed in the hope that it will be useful, +; but WITHOUT ANY WARRANTY; without even the implied warranty of +; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +; GNU General Public License for more details. +; +; You should have received a copy of the GNU General Public License +; along with this program. If not, see . +; +; Copyright (c) 2011, JD Gascuel. +;============================================================================= +; HISTORY +; 2011-05-08 : [jDG] Creation. +; +; BUGS : +; * ... +;============================================================================= + CBLOCK 0x000 + ds_line ; Current line (0..239). + ds_column ; Current columnx2 (0..159) + ds_pixel:2 ; Current pixel color. + ds_count ; Repetition count. + ENDC +;============================================================================= + +; Manage interface to the OSTC platform: +dump_screen: + bcf uart_dump_screen ; clear flag! + + movlw 'l' + movwf TXREG ; Send command echo. + bsf no_sensor_int ; No Sensor Interrupt + bcf PIE1,RCIE ; no interrupt for UART + bcf PIR1,RCIF ; clear flag + bsf LED_blue ; LEDusb ON + call rs232_wait_tx ; wait for UART + + call dump_screen_0 + + bcf no_sensor_int ; Restore Sensor Interrupt + bcf LED_blue ; Clear led + bcf LED_red ; Clear led + bsf PIE1,RCIE ; Interrupt for RS232 + return + +;============================================================================= +; Dump screen contains to the UART + +dump_screen_0: + + ;---- Send OLED box command for the full screen window ------------------- + mullw 0 ; PRODH:L <- 0 + + AA_CMD_WRITE 0x35 ; VerticalStartAddress HIGH:LOW + AA_DATA_WRITE_PROD ; 00:00 + + AA_CMD_WRITE 0x36 ; VerticalEndAddress HIGH:LOW + AA_DATA_WRITE 0x01 + AA_DATA_WRITE 0x3F + + AA_CMD_WRITE 0x37 ; HorizontalAddress START:END + AA_DATA_WRITE 0x00 + AA_DATA_WRITE 0xEF + + AA_CMD_WRITE 0x20 ; Start Address Horizontal (.0 - .239) + AA_DATA_WRITE_PROD ; 00:00 + + AA_CMD_WRITE 0x21 ; Start Address Vertical (.0 - .319) + AA_DATA_WRITE_PROD ; 00:00 + + AA_CMD_WRITE 0x22 ; Start reading. + rcall PLED_DataRead ; Dummy pixel to skip. + rcall PLED_DataRead ; Dummy pixel to skip. + + movlw .160 ; 160x2 columns + movwf ds_column + rcall dump_screen_pixel_reset + +dump_screen_1: + btg LED_red ; LEDactivity toggle + + AA_CMD_WRITE 0x22 ; Re-sync data. + + setf TRISD ; PortD as input. + + ; Dump even column + movlw .240 ; 240 lines, once. + movwf ds_line +dump_screen_2: + rcall PLED_DataRead ; read pixel-high byte + movwf PRODH + rcall PLED_DataRead ; read pixel-low byte + movwf PRODL + rcall dump_screen_pixel + + decfsz ds_line,F + bra dump_screen_2 + rcall dump_screen_pixel_flush + + ; Dump odd column + movlw .240 ; 240 lines, twice. + movwf ds_line +dump_screen_3: + rcall PLED_DataRead ; read pixel-high byte + movwf PRODH + rcall PLED_DataRead ; read pixel-low byte + movwf PRODL + rcall dump_screen_pixel + + decfsz ds_line,F + bra dump_screen_3 + rcall dump_screen_pixel_flush + + clrf TRISD ; Back to normal (PortD as output) + + decfsz ds_column,F + bra dump_screen_1 + + AA_CMD_WRITE 0x00 ; NOP, to stop Address Update Counter + return + +;============================================================================= +; Pixel compression +; +; Input: PRODH:L = pixel. +; Output: Compressed stream on output. +; Compressed format: +; 0ccccccc : BLACK pixel, repeated ccccccc+1 times (1..128). +; 11cccccc : WHITE pixel, repeated cccccc+1 times (1..64). +; 10cccccc HIGH LOW : color pixel (H:L) repeated ccccc+1 times (1..64). +; +dump_screen_pixel: + movf PRODH,W ; Compare pixel-high + xorwf ds_pixel+1,W + bnz dump_screen_pixel_1 ; Different -> dump. + + movf PRODL,W ; Compare pixel-low + xorwf ds_pixel+0,W + bnz dump_screen_pixel_1 ; Different -> dump. + + incf ds_count,F ; Same color: just increment. + return + +dump_screen_pixel_1: ; Send (pixel,count) tuple + movf ds_count,W ; Is count zero ? + bz dump_screen_pixel_2 ; Yes: skip sending. + + movf ds_pixel+1,W ; This is a BLACK pixel ? + iorwf ds_pixel+0,W + bz dump_screen_pix_black ; YES. + + movf ds_pixel+1,W ; This is a white pixel ? + andwf ds_pixel+0,W + incf WREG + bz dump_screen_pix_white ; YES. + + ; No: write the pixel itself... + movlw .64 ; Max color pixel on a single byte. + cpfsgt ds_count ; Skip if count > 64 + movf ds_count,W ; W <- min(64,count) + subwf ds_count,F ; ds_count <- ds_count-W + decf WREG ; Save as 0..63 + iorlw b'10000000' ; MARK as a color pixel. + + movwf TXREG + call rs232_wait_tx ; wait for UART + movff ds_pixel+1,TXREG + call rs232_wait_tx ; wait for UART + movff ds_pixel+0,TXREG + call rs232_wait_tx ; wait for UART + bra dump_screen_pixel_1 + +dump_screen_pixel_2: + movff PRODH,ds_pixel+1 ; Save new pixel color + movff PRODL,ds_pixel+0 + movlw 1 + movwf ds_count ; And set count=1. + return + +dump_screen_pix_black: + movlw .128 ; Max black pixel on a single byte. + cpfsgt ds_count ; Skip if count > 128 + movf ds_count,W ; W <- min(128,count) + subwf ds_count,F ; ds_count <- ds_count-W + decf WREG ; Save as 0..127 +dump_screen_pix_3: + movwf TXREG + call rs232_wait_tx + bra dump_screen_pixel_1 ; More to dump ? + +dump_screen_pix_white: + movlw .64 ; Max white pixel on a single byte. + cpfsgt ds_count ; Skip if count > 64 + movf ds_count,W ; W <- min(64,count) + subwf ds_count,F ; ds_count <- ds_count-W + decf WREG ; Save as 0..63 + iorlw b'11000000' ; MARK as a compressed white. + bra dump_screen_pix_3 + +dump_screen_pixel_flush: + clrf PRODH + clrf PRODL + rcall dump_screen_pixel_1 ; Send it +dump_screen_pixel_reset: + clrf ds_count ; But clear count. + return \ No newline at end of file diff -r d5240792be51 -r 797e2ac42d24 code_part1/OSTC_code_asm_part1/isr.asm --- a/code_part1/OSTC_code_asm_part1/isr.asm Sat May 21 14:38:56 2011 +0200 +++ b/code_part1/OSTC_code_asm_part1/isr.asm Sat May 21 14:48:07 2011 +0200 @@ -77,7 +77,9 @@ bsf uart_send_int_eeprom2 ; set flag dcfsnz uart1_temp,F ; "k" bsf uart_store_tissue_data ; set flag - + dcfsnz uart1_temp,F ; "l" + bsf uart_dump_screen ; set flag + movlw 0xC1 cpfseq RCREG ; 115200Baud Bootloader request? bra uartint1 ; No @@ -200,7 +202,7 @@ ; ; NOTE: Because there is no atomic 16bits load/stores, we need to check twice ; the read data is correct. Ie. SAFE_2BYTE_COPY is mandatory to get -; amb_pressure, temperaturen or rel_pressure +; amb_pressure, temperature or rel_pressure ; sensor_int: btfsc no_sensor_int ; No sensor interrupt (because it's addressed during sleep) diff -r d5240792be51 -r 797e2ac42d24 code_part1/OSTC_code_asm_part1/menu.asm --- a/code_part1/OSTC_code_asm_part1/menu.asm Sat May 21 14:38:56 2011 +0200 +++ b/code_part1/OSTC_code_asm_part1/menu.asm Sat May 21 14:48:07 2011 +0200 @@ -78,7 +78,10 @@ bra menu_loop -check_switches_menu: ; checks switches +check_switches_menu: ; checks switches + btfsc uart_dump_screen ; Asked to dump screen contains ? + call dump_screen ; Yes! + btfss switch_right bra check_switches_menu2 bsf menubit3 @@ -424,6 +427,9 @@ bcf switch_left bcf switch_right show_rawdata_loop: + btfsc uart_dump_screen ; Asked to dump screen contains ? + call dump_screen ; Yes! + btfsc switch_left ; Ack? bsf menubit2 btfsc switch_right ; Ack? diff -r d5240792be51 -r 797e2ac42d24 code_part1/OSTC_code_asm_part1/menu_custom.asm --- a/code_part1/OSTC_code_asm_part1/menu_custom.asm Sat May 21 14:38:56 2011 +0200 +++ b/code_part1/OSTC_code_asm_part1/menu_custom.asm Sat May 21 14:48:07 2011 +0200 @@ -280,16 +280,16 @@ call PLED_menu_cursor customfunctions_loop: - call check_switches_logbook + call check_switches_logbook - btfsc menubit3 - bra customfunctions2 ; Move cursor or generate next page + btfsc menubit3 + bra customfunctions2 ; Move cursor or generate next page - btfsc menubit2 - bra do_customfunction ; call subfunction + btfsc menubit2 + bra do_customfunction ; call subfunction btfsc divemode - goto restart ; dive started during cf menu + goto restart ; dive started during cf menu btfsc onesecupdate call timeout_surfmode @@ -297,12 +297,12 @@ btfsc onesecupdate call set_dive_modes - bcf onesecupdate ; end of 1sek. tasks + bcf onesecupdate ; end of 1sek. tasks btfsc sleepmode - bra exit_customfunctions + bra exit_customfunctions - bra customfunctions_loop + bra customfunctions_loop customfunctions2: incf menupos,F diff -r d5240792be51 -r 797e2ac42d24 code_part1/OSTC_code_asm_part1/menu_gassetup.asm --- a/code_part1/OSTC_code_asm_part1/menu_gassetup.asm Sat May 21 14:38:56 2011 +0200 +++ b/code_part1/OSTC_code_asm_part1/menu_gassetup.asm Sat May 21 14:48:07 2011 +0200 @@ -179,21 +179,21 @@ cpfseq decodata+0 goto menu_gassetup_list - DISPLAYTEXT .11 ; Exit - call wait_switches ; Waits until switches are released, resets flag if button stays pressed! + DISPLAYTEXT .11 ; Exit + call wait_switches ; Waits until switches are released, resets flag if button stays pressed! call PLED_menu_cursor gassetup_list_loop: call check_switches_logbook btfsc menubit3 - bra gassetup_list2 ; move cursor + bra gassetup_list2 ; move cursor btfsc menubit2 - bra do_gassetup_list; call gas-specific submenu + bra do_gassetup_list ; call gas-specific submenu btfsc divemode - goto restart ; dive started! + goto restart ; dive started! btfsc onesecupdate call timeout_surfmode @@ -201,7 +201,7 @@ btfsc onesecupdate call set_dive_modes - bcf onesecupdate ; 1 sec. functions done + bcf onesecupdate ; 1 sec. functions done btfsc sleepmode bra exit_gassetup_list @@ -780,9 +780,6 @@ bcf onesecupdate ; 1 sec. functions done - btfsc sleepmode - bra exit_gassetup - bra next_gas_page_loop next_gas_page2: diff -r d5240792be51 -r 797e2ac42d24 code_part1/OSTC_code_asm_part1/menu_logbook.asm --- a/code_part1/OSTC_code_asm_part1/menu_logbook.asm Sat May 21 14:38:56 2011 +0200 +++ b/code_part1/OSTC_code_asm_part1/menu_logbook.asm Sat May 21 14:48:07 2011 +0200 @@ -335,7 +335,7 @@ addwfc sim_pressure+1,F movlw LOW d'164000' ; 164pixel*1000 height movwf xC+0 - movlw HIGH d'164000' ; 164pixel*1000 height + movlw HIGH (d'164000' & h'FFFF') ; 164pixel*1000 height movwf xC+1 movlw UPPER d'164000' ; 164pixel*1000 height movwf xC+2 @@ -1066,6 +1066,10 @@ bsf menubit3 btfsc switch_left bsf menubit2 ; Enter + + btfsc uart_dump_screen ; Dumps screen contains ? + call dump_screen ; Yes! + return next_logbook3: diff -r d5240792be51 -r 797e2ac42d24 code_part1/OSTC_code_asm_part1/oled_samsung.asm --- a/code_part1/OSTC_code_asm_part1/oled_samsung.asm Sat May 21 14:38:56 2011 +0200 +++ b/code_part1/OSTC_code_asm_part1/oled_samsung.asm Sat May 21 14:48:07 2011 +0200 @@ -184,6 +184,15 @@ ; bsf oled_rw endm ; +; Input : data as macro parameter. +; Output : NONE +; Trash : WREG +; +AA_DATA_WRITE macro data + movlw data + rcall PLED_DataWrite + endm +; ; Input : PRODH:L as 16bits data. ; Output : NONE ; Trash : NONE @@ -517,6 +526,18 @@ return ; ----------------------------- +; PLED Read data into WREG +; ----------------------------- +; NOTE: you should "setf TRISD" before calling this function, +; to make PortD an input port... +PLED_DataRead: + bsf oled_rs ; Data register. + bcf oled_e_nwr ; Read enable. + movf PORTD,W ; Read byte. + bsf oled_e_nwr ; release bus. + return + +; ----------------------------- ; PLED boot ; ----------------------------- PLED_boot: diff -r d5240792be51 -r 797e2ac42d24 code_part1/OSTC_code_asm_part1/simulator.asm --- a/code_part1/OSTC_code_asm_part1/simulator.asm Sat May 21 14:38:56 2011 +0200 +++ b/code_part1/OSTC_code_asm_part1/simulator.asm Sat May 21 14:48:07 2011 +0200 @@ -197,6 +197,9 @@ bcf switch_left bcf switch_right simulator_show_decoplan2: + btfsc uart_dump_screen ; Asked to dump screen contains ? + call dump_screen ; Yes! + btfss onesecupdate bra simulator_show_decoplan3 @@ -414,18 +417,18 @@ WAITMS d'250' WAITMS d'250' ; Wait for Pressure Sensor to get real pressure again... - movlw d'5' ; Pre-Set Cursor to "Show Decoplan" + movlw d'5' ; Pre-Set Cursor to "Show Decoplan" movwf menupos movff char_I_bottom_time,logbook_temp1 ; Restore bottom time, movff char_I_bottom_depth,logbook_temp2 ; and depth. bra menu_simulator1 ; Done. simulator_save_tissue_data: - bsf restore_deco_data ; Set restore flag - ostc_debug 'S' ; Sends debug-information to screen if debugmode active + bsf restore_deco_data ; Set restore flag + ostc_debug 'S' ; Sends debug-information to screen if debugmode active call deco_push_tissues_to_vault - movlb 0x01 ; Back to RAM Bank1 - ostc_debug 'T' ; Sends debug-information to screen if debugmode active + movlb 0x01 ; Back to RAM Bank1 + ostc_debug 'T' ; Sends debug-information to screen if debugmode active return simulator_restore_tissue_data: diff -r d5240792be51 -r 797e2ac42d24 code_part1/OSTC_code_asm_part1/start.asm --- a/code_part1/OSTC_code_asm_part1/start.asm Sat May 21 14:38:56 2011 +0200 +++ b/code_part1/OSTC_code_asm_part1/start.asm Sat May 21 14:48:07 2011 +0200 @@ -307,6 +307,9 @@ bcf switch_left bcf switch_right screen1_loop: + btfsc uart_dump_screen ; Asked to dump screen contains ? + call dump_screen ; Yes! + btfsc onesecupdate ; do every second tasks? call set_dive_modes ; tests if depth>threshold btfsc onesecupdate ; do every second tasks? @@ -337,6 +340,9 @@ bcf switch_left bcf switch_right screen3_loop: + btfsc uart_dump_screen ; Asked to dump screen contains ? + call dump_screen ; Yes! + btfsc onesecupdate ; do every second tasks? call set_dive_modes ; tests if depth>threshold @@ -354,6 +360,8 @@ return bra screen3_loop ; loop screen +;============================================================================= + first_start: movlw max_custom_number ; Defined in definitions.asm movwf EEDATA diff -r d5240792be51 -r 797e2ac42d24 code_part1/OSTC_code_asm_part1/surfmode.asm --- a/code_part1/OSTC_code_asm_part1/surfmode.asm Sat May 21 14:38:56 2011 +0200 +++ b/code_part1/OSTC_code_asm_part1/surfmode.asm Sat May 21 14:48:07 2011 +0200 @@ -200,6 +200,9 @@ btfsc uart_reset_battery_stats ; Reset Battery stats? goto reset_battery_stats ; Yes! + btfsc uart_dump_screen ; Dumps screen contains ? + call dump_screen ; Yes! + bra surfloop_loop ; loop surfacemode