changeset 654:75e90cd0c2c3

hwOS sport 10.77 release
author heinrichsweikamp
date Thu, 14 Mar 2024 16:56:46 +0100
parents 8bcd138ab744
children c7b7b8a358cd
files src/aa_fonts.asm src/aa_wordprocessor.asm src/adc_lightsensor.asm src/adc_lightsensor.inc src/calibrate.asm src/color_processor.asm src/comm.asm src/comm.inc src/compass.c src/compass_calib.c src/compass_ops.asm src/configuration.inc src/convert.asm src/convert.inc src/customview.asm src/customview.inc src/divemenu_tree.asm src/divemode.asm src/divemode.inc src/eeprom_rs232.asm src/eeprom_rs232.inc src/external_flash.asm src/external_flash.inc src/gaslist.asm src/gaslist.inc src/ghostwriter.asm src/ghostwriter.inc src/hwos.asm src/hwos.inc src/i2c.asm src/i2c.inc src/icons.asm src/isr.asm src/isr.inc src/logbook.asm src/logbook.inc src/math.asm src/math.inc src/mcp.asm src/mcp.inc src/menu_processor.asm src/menu_processor.inc src/menu_tree.asm src/ms5541.asm src/ms5541.inc src/option_table.asm src/options.asm src/p2_deco.c src/p2_definitions.h src/ports.inc src/rtc.asm src/rtc.inc src/rx_firmware-1-39.inc src/rx_firmware.asm src/rx_ops.asm src/rx_ops.inc src/simulator.asm src/sleepmode.asm src/sleepmode.inc src/start.asm src/start.inc src/strings.asm src/strings.inc src/surfmode.asm src/surfmode.inc src/text_english.inc src/text_french.inc src/text_german.inc src/text_italian.inc src/text_multilang.asm src/text_multilang.inc src/tft.asm src/tft.inc src/tft_outputs.asm src/tft_outputs.inc src/varargs.inc src/wait.asm src/wait.inc
diffstat 78 files changed, 780 insertions(+), 183 deletions(-) [+]
line wrap: on
line diff
--- a/src/aa_fonts.asm	Fri Aug 11 15:53:49 2023 +0200
+++ b/src/aa_fonts.asm	Thu Mar 14 16:56:46 2024 +0100
@@ -4,7 +4,7 @@
 ;
 ;   Font-data for the anti-aliased word processor
 ;
-;   Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved.
+;   Copyright (c) 2011, JD Gascuel, heinrichs weikamp gmbh, all right reserved.
 ;=============================================================================
 ; HISTORY
 ;  2010-11-23 : [jDG] Creation for OSTC 1.72, with the original fonts repacked
--- a/src/aa_wordprocessor.asm	Fri Aug 11 15:53:49 2023 +0200
+++ b/src/aa_wordprocessor.asm	Thu Mar 14 16:56:46 2024 +0100
@@ -4,7 +4,7 @@
 ;
 ;   Anti-aliased word processor
 ;
-;   Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved.
+;   Copyright (c) 2011, JD Gascuel, heinrichs weikamp gmbh, all right reserved.
 ;=============================================================================
 ; HISTORY
 ;  2010-11-22 : [jDG] Creation
@@ -432,7 +432,7 @@
 	btfsc	screen_type3			; display 3 ?
 	bra		aa_decode_3_display3	; YES
 
-	; Screen 1 or 0
+	; Screen 1 or 0 or 4
 	btfsc	less_io_cpu				; less I/O CPU?
 	bra	aa_decode_3_display0and1_less_io	; YES
 
@@ -504,9 +504,11 @@
 	call	TFT_set_color			; compute printing color (16 bit)
 	rcall	aa_string_width			; set win_height and compute win_width:2
 	call	TFT_box_write			; set up output box
-	lfsr	FSR2,buffer				; set FSR2 to the start of the output buffer
-	Index_out	0x22				; DATA block command (macro defined in tft.inc)
-
+	lfsr	FSR2,buffer			; set FSR2 to the start of the output buffer
+	movlw	0x22				; frame memory data write start
+	btfsc	screen_type4
+	movlw	0x2C				; Start Writing Data to GRAM (Display 4)
+	call	TFT_CmdWrite
 aa_wordprocessor_1:
 	movf	POSTINC2,W				; read character from the buffer
 	bz		aa_wordprocessor_99		; done if null byte encountered
@@ -516,7 +518,7 @@
 	bra		aa_wordprocessor_1		; loop
 
 aa_wordprocessor_99:
-	Index_out	0x00				; send end of bloc command
+	Index_out	0x00				; send end of bloc command or NOP for most displays
 	bcf		win_invert				; terminate inverse printing
 	return							; done
 
--- a/src/adc_lightsensor.asm	Fri Aug 11 15:53:49 2023 +0200
+++ b/src/adc_lightsensor.asm	Thu Mar 14 16:56:46 2024 +0100
@@ -3,7 +3,7 @@
 ;   File adc_lightsensor.asm                * combined next generation V3.11.1
 ;
 ;
-;   Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved.
+;   Copyright (c) 2011, JD Gascuel, heinrichs weikamp gmbh, all right reserved.
 ;=============================================================================
 ; HISTORY
 ;  2011-08-08 : [mH] moving from OSTC code
@@ -95,6 +95,13 @@
 	bsf		cv_active						;         - set CV charging status
 	bsf		LEDr							;         - indicate charging
 	call	lt2942_charge_done				;         - reset accumulating registers to 0xFFFF
+	btfsc	lock_cycle_counter				; cycle counted already?
+	bra	charge_cv_active2				; Yes, skip
+	banksel	charge_cycles
+	INCI	charge_cycles					; increase charge_cycles counter by one
+	banksel	common
+	bsf	lock_cycle_counter			; lock cycle counter
+charge_cv_active2:
 	WAITMS	d'10'							;         - wait 10 ms
 	bcf		LEDr							;         - indicate charging
 	bsf		get_bat_volt_counter,0			;         - set counter to 1
--- a/src/adc_lightsensor.inc	Fri Aug 11 15:53:49 2023 +0200
+++ b/src/adc_lightsensor.inc	Thu Mar 14 16:56:46 2024 +0100
@@ -3,7 +3,7 @@
 ;   File adc_lightsensor.inc                  combined next generation V3.03.1
 ;
 ;
-;   Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved.
+;   Copyright (c) 2011, JD Gascuel, heinrichs weikamp gmbh, all right reserved.
 ;=============================================================================
 ; HISTORY
 ;  2011-08-08 : [mH] moving from OSTC code
--- a/src/calibrate.asm	Fri Aug 11 15:53:49 2023 +0200
+++ b/src/calibrate.asm	Thu Mar 14 16:56:46 2024 +0100
@@ -4,7 +4,7 @@
 ;
 ;   o2 sensor calibration subroutines
 ;
-;   Copyright (c) 2014, Heinrichs Weikamp, all right reserved.
+;   Copyright (c) 2014, heinrichs weikamp gmbh, all right reserved.
 ;=============================================================================
 
 #include "hwos.inc"
--- a/src/color_processor.asm	Fri Aug 11 15:53:49 2023 +0200
+++ b/src/color_processor.asm	Thu Mar 14 16:56:46 2024 +0100
@@ -4,7 +4,7 @@
 ;
 ;   Decompress and draw an image
 ;
-;   Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved.
+;   Copyright (c) 2011, JD Gascuel, heinrichs weikamp gmbh, all right reserved.
 ;=============================================================================
 ; HISTORY
 ;  2010-12-13 : [jDG] Creation.
@@ -97,8 +97,10 @@
 	rlcf	win_width+0				; multiply width x 2 to get the true box width
 	rlcf	win_width+1				; ...
 	call	TFT_box_write			; set output box
-	Index_out 0x22					; frame memory data write start
-
+	movlw	0x22				; frame memory data write start
+	btfsc	screen_type4
+	movlw	0x2C				; Start Writing Data to GRAM (Display 4)
+	call	TFT_CmdWrite
 color_image_loop_xy:
 	; prepare to read next pixel count and color
 	clrf	pixel_count+0			; clear number of pixels
@@ -159,7 +161,7 @@
 	btfsc	screen_type3			; display type 3 ?
 	bra		color_image_display3	; YES
 	
-	; Screen 1
+	; Screen 0 or 1 or 4
 	btfsc	less_io_cpu			; less I/O CPU?
 	bra	color_image_pixel1_loop_less_io ; YES
 	    
--- a/src/comm.asm	Fri Aug 11 15:53:49 2023 +0200
+++ b/src/comm.asm	Thu Mar 14 16:56:46 2024 +0100
@@ -4,7 +4,7 @@
 ;
 ;   RS232 via USB
 ;
-;   Copyright (c) 2012, JD Gascuel, HeinrichsWeikamp, all right reserved.
+;   Copyright (c) 2012, JD Gascuel, heinrichs weikamp gmbh, all right reserved.
 ;=============================================================================
 ; HISTORY
 ;  2011-08-22 : [mH] Creation
@@ -133,9 +133,14 @@
 	bra		comm_mode_common_start					; continue with starting message
 
 comm_mode_common_logo2:
+	btfsc	dn_flag
+	bra	comm_mode_common_logo3
 	TFT_WRITE_PROM_IMAGE_BY_ADDR comm_logo_2		; show BT logo / OSTC+
-	;bra	comm_mode_common_start					; continue with starting message
+	bra	comm_mode_common_start					; continue with starting message
 
+comm_mode_common_logo3:
+	TFT_WRITE_PROM_IMAGE_BY_ADDR comm_logo_3		; show BT logo / dn
+	
 comm_mode_common_start:
 	WIN_SMALL comm_status1_column,comm_status1_row	; set position
 	FONT_COLOR_MEMO									; set standard color
--- a/src/comm.inc	Fri Aug 11 15:53:49 2023 +0200
+++ b/src/comm.inc	Thu Mar 14 16:56:46 2024 +0100
@@ -3,7 +3,7 @@
 ;   File comm.inc                            * combined next generation V3.9.4b
 ;
 ;
-;   Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved.
+;   Copyright (c) 2011, JD Gascuel, heinrichs weikamp gmbh, all right reserved.
 ;=============================================================================
 ; HISTORY
 ;  2011-08-22 : [mH] creation
--- a/src/compass.c	Fri Aug 11 15:53:49 2023 +0200
+++ b/src/compass.c	Thu Mar 14 16:56:46 2024 +0100
@@ -2,7 +2,7 @@
 /// compass.c
 /// Compute north direction from magnetic/acceleration measures        V3.02.1
 ///
-/// Copyright (c) 2012-2015, JD Gascuel, HeinrichsWeikamp, all right reserved.
+/// Copyright (c) 2012-2015, JD Gascuel, heinrichs weikamp gmbh, all right reserved.
 //////////////////////////////////////////////////////////////////////////////
 // HISTORY
 //  2012-12-01  [jDG] Creation
--- a/src/compass_calib.c	Fri Aug 11 15:53:49 2023 +0200
+++ b/src/compass_calib.c	Thu Mar 14 16:56:46 2024 +0100
@@ -3,7 +3,7 @@
 // compass_calib.c                                    next generation V3.09.4
 //
 // Calibrate hard-iron for magnetic compass measurements.
-// Copyright (c) 2012-2019, JD Gascuel, HeinrichsWeikamp, all rights reserved.
+// Copyright (c) 2012-2019, JD Gascuel, heinrichs weikamp gmbh, all rights reserved.
 //
 //////////////////////////////////////////////////////////////////////////////
 
--- a/src/compass_ops.asm	Fri Aug 11 15:53:49 2023 +0200
+++ b/src/compass_ops.asm	Thu Mar 14 16:56:46 2024 +0100
@@ -4,7 +4,7 @@
 ;
 ;   Compass Operations
 ;
-;   Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved.
+;   Copyright (c) 2011, JD Gascuel, heinrichs weikamp gmbh, all right reserved.
 ;=============================================================================
 
 #include "hwos.inc"
--- a/src/configuration.inc	Fri Aug 11 15:53:49 2023 +0200
+++ b/src/configuration.inc	Thu Mar 14 16:56:46 2024 +0100
@@ -5,7 +5,7 @@
 ; 
 ;    OSTC hwOS Configuration
 ; 
-;    Copyright (c) 2019, HeinrichsWeikamp, all rights reserved.
+;    Copyright (c) 2019, heinrichs weikamp gmbh, all rights reserved.
 ; ============================================================================
 #endif
 
@@ -23,8 +23,8 @@
 ;
 #endif
 
-#define fw_version_major		.3;0x03
-#define fw_version_minor		.21;0x15
+#define fw_version_major		0x03
+#define fw_version_minor		0x16
 #define fw_version_beta			0x00
 
 
@@ -42,13 +42,13 @@
 ;
 #endif
 
-#define firmware_creation_year	.23;0x18
+#define firmware_creation_year	.24;0x18
 #define firmware_creation_month	.03;0x09
-#define firmware_creation_day	.31;0x06
+#define firmware_creation_day	.11;0x06
 
-#define firmware_expire_year	.25;0x18
-#define firmware_expire_month	.03;0x08
-#define firmware_expire_day	.31;0x1C
+#define firmware_expire_year	.27;0x18
+#define firmware_expire_month	.01;0x08
+#define firmware_expire_day	.10;0x1C
 
 
 #ifdef xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
@@ -64,7 +64,7 @@
 ;                                                                                    122.880 max. available
 #endif
 
-#define _hwos_tech_2_TR
+#define _hwos_sport
 
 
 #ifdef xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
@@ -79,7 +79,7 @@
 ; 
 #endif
 
-#define _language_1		de
+#define _language_1		en
 #define _language_2		none
 
 
@@ -139,8 +139,8 @@
 #define _compass
 #define _helium
 #define _ccr_pscr
-#define _rx_functions
-#define _rx_update
+#define NOT_INCLUDED_rx_functions
+#define NOT_INCLUDED_rx_update
 #define _gauge_mode
 #define _high_ppO2_max
 #define _gas_contingency
@@ -159,8 +159,8 @@
 #define _compass
 #define _helium
 #define _ccr_pscr
-#define _rx_functions
-#define _rx_update
+#define NOT_INCLUDED_rx_functions
+#define NOT_INCLUDED_rx_update
 #define _gauge_mode
 #define _high_ppO2_max
 #define _gas_contingency
--- a/src/convert.asm	Fri Aug 11 15:53:49 2023 +0200
+++ b/src/convert.asm	Thu Mar 14 16:56:46 2024 +0100
@@ -4,7 +4,7 @@
 ;
 ;   Converts register values to string
 ;
-;   Copyright (c) 2011, Matthias Heinrichs, HeinrichsWeikamp, all right reserved.
+;   Copyright (c) 2011, Matthias Heinrichs, heinrichs weikamp gmbh, all right reserved.
 ;=============================================================================
 ; HISTORY
 ;   2007-10-07 : [MH]  Creation for OSTC sources
--- a/src/convert.inc	Fri Aug 11 15:53:49 2023 +0200
+++ b/src/convert.inc	Thu Mar 14 16:56:46 2024 +0100
@@ -4,7 +4,7 @@
 ;
 ;   Converts register values to string
 ;
-;   Copyright (c) 2011, Matthias Heinrichs, HeinrichsWeikamp, all right reserved.
+;   Copyright (c) 2011, Matthias Heinrichs, heinrichs weikamp gmbh, all right reserved.
 ;=============================================================================
 ; HISTORY
 ;   2007-10-07 : [MH]  Creation for OSTC sources
--- a/src/customview.asm	Fri Aug 11 15:53:49 2023 +0200
+++ b/src/customview.asm	Thu Mar 14 16:56:46 2024 +0100
@@ -4,7 +4,7 @@
 ;
 ;   Custom Views in Surface and Dive Mode
 ;
-;   Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved.
+;   Copyright (c) 2011, JD Gascuel, heinrichs weikamp gmbh, all right reserved.
 ;=============================================================================
 ; HISTORY
 ;  2011-08-10 : [mH] moving from OSTC code
@@ -34,7 +34,7 @@
 
 
 #DEFINE num_premenu_items	.12			; overall number of pre-menu items
-#DEFINE num_surface_cv		.10			; overall number of surface custom views
+#DEFINE num_surface_cv		.11			; overall number of surface custom views
 
 
 ;=============================================================================
@@ -172,6 +172,8 @@
 	bra		surf_customview_init_view9	; sensor mV readings
 	dcfsnz	WREG,F						; 10:
 	bra		surf_customview_init_view10	; tank data
+	dcfsnz	WREG,F						; 11:
+	bra		surf_customview_init_view11	; Desat, noFly, CNS screen
 	bra		surf_customview_init_view4	; 0: default view after restart and loading of new firmware
 
 surf_cv_toggle_exit:
@@ -315,6 +317,15 @@
 	bra		surf_customview_toggle		; not available without RX functions compiled in, goto next view
  ENDIF
 
+	; ---- view 11: Desat, NoFly, CNS ----
+	;
+surf_customview_init_view11: 
+    	btfsc	FLAG_gauge_mode				; in gauge mode?
+	bra		surf_customview_toggle		; YES - not available in gauge mode, goto next view
+	btfsc	FLAG_apnoe_mode				; in apnoe mode?
+	bra		surf_customview_toggle		; YES - not available in apnoe mode, goto next view
+	call	TFT_surf_desat_nofly_cns		; Desat, NoFly, CNS
+	bra		surf_cv_toggle_exit			; done
 
 ;=============================================================================
 custview3	CODE
--- a/src/customview.inc	Fri Aug 11 15:53:49 2023 +0200
+++ b/src/customview.inc	Thu Mar 14 16:56:46 2024 +0100
@@ -4,7 +4,7 @@
 ;
 ;   Customview for divemode and surfacemode
 ;
-;   Copyright (c) 2011, Matthias Heinrichs, HeinrichsWeikamp, all right reserved.
+;   Copyright (c) 2011, Matthias Heinrichs, heinrichs weikamp gmbh, all right reserved.
 ;=============================================================================
 ; HISTORY
 ;   2011-08-10 : [mH] Import into hwOS sources
--- a/src/divemenu_tree.asm	Fri Aug 11 15:53:49 2023 +0200
+++ b/src/divemenu_tree.asm	Thu Mar 14 16:56:46 2024 +0100
@@ -4,7 +4,7 @@
 ;
 ;   OSTC dive mode menu
 ;
-;   Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all rights reserved.
+;   Copyright (c) 2011, JD Gascuel, heinrichs weikamp gmbh, all rights reserved.
 ;=============================================================================
 ; HISTORY
 ;   2013-02-02 : [mH] Made out of menu_tree.asm
--- a/src/divemode.asm	Fri Aug 11 15:53:49 2023 +0200
+++ b/src/divemode.asm	Thu Mar 14 16:56:46 2024 +0100
@@ -4,7 +4,7 @@
 ;
 ;   Dive Mode
 ;
-;   Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved.
+;   Copyright (c) 2011, JD Gascuel, heinrichs weikamp gmbh, all right reserved.
 ;=============================================================================
 ; HISTORY
 ;  2011-08-15 : [mH] moving from OSTC code
@@ -627,6 +627,8 @@
 	call	TFT_show_apnoe_max_depth		; YES - show max. depth of last dive
 	btfsc	FLAG_TFT_apnoe_divetime			; shall show apnoe dive time?
 	call	TFT_show_apnoe_times			; YES - show apnoe dive time?
+	btfsc	FLAG_TFT_depth_maximum_apnoe	; shall show max. depth of last dive? (Flag re-used here for #dive)
+	call	TFT_apnoe_divecounter			; YES - show apnoe #dive counter?
 
 	clrf	TFT_output_flags_1				; mark all TFT updates done
 	return									; done
@@ -644,6 +646,7 @@
 	call	TFT_safety_stop_show			; YES - show safety stop
 	btfsc	FLAG_TFT_safety_stop_clear		; shall clear safety stop?
 	call	TFT_safety_stop_clear			; YES - clear safety stop
+	
 	clrf	TFT_output_flags_2				; mark all TFT updates done
 	goto	dive_customview_second			; do every-second tasks for the custom view area (in sync with the dive time) and return
 
@@ -704,6 +707,7 @@
 	return									; NO  - done
 	bcf		apnoe_new_dive					; YES - clear flag
 	bsf		FLAG_TFT_clear_apnoe_surface	;     - clear apnoe mode surface data from screen
+	incf	    apnoe_dive_counter,F			; Increase #dive counter
 	return									;     - done
 
 divemode_apnoe_tasks_surf:					; apnoe mode, at the surface
@@ -1724,7 +1728,7 @@
 	movff	char_O_deco_info,WREG		; NO  - get deco info vector
 	btfss	WREG,deco_stops_norm		;       do we have a deco obligation right now?
 	return								;       NO  - done
-	bsf		deco_locked					;       YES - memorize dive was in deco
+;	bsf		deco_locked					;       YES - memorize dive was in deco
 	movff	char_O_deco_depth+0,WREG	;           - get depth of first stop in meters into WREG
 	addlw	deco_region_distance+.1		;           - add deco region start distance + 1 meter for the negative test to work
 	subwf	depth_meter,W				;           - compute current depth - (first stop depth + deco region distance)
@@ -3378,6 +3382,7 @@
 	clrf	apnoe_surface_secs			; clear apnoe surface time, seconds (8 bit)
 	clrf	apnoe_dive_mins				; clear apnoe dive    time, minutes (8 bit)
 	clrf	apnoe_dive_secs				; clear apnoe dive    time, seconds (8 bit)
+	clrf	apnoe_dive_counter			; clear apnoe #dive counter         (8 bit)
 
 	return								; done with dive mode boot
 
--- a/src/divemode.inc	Fri Aug 11 15:53:49 2023 +0200
+++ b/src/divemode.inc	Thu Mar 14 16:56:46 2024 +0100
@@ -3,7 +3,7 @@
 ;   File divemode.inc                       * combined next generation V3.09.4g
 ;
 ;
-;   Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved.
+;   Copyright (c) 2011, JD Gascuel, heinrichs weikamp gmbh, all right reserved.
 ;=============================================================================
 ; HISTORY
 ;  2011-08-15 : [mH] moving from OSTC code
@@ -535,6 +535,10 @@
 #DEFINE dm_apnoe_surface_time_row				.207							; 207
 #DEFINE dm_apnoe_surface_time_column			.80								;  80
 
+#DEFINE	dm_apnoe_surface_dive_text_col			.60  
+#DEFINE	dm_apnoe_surface_dive_text_row			.170
+#DEFINE	dm_apnoe_surface_divecnt_col			.130
+#DEFINE	dm_apnoe_surface_divecnt_row			.161
 
 ;-----------------------------------------------------------------------------
 ; Bottom content / Gauge mode
--- a/src/eeprom_rs232.asm	Fri Aug 11 15:53:49 2023 +0200
+++ b/src/eeprom_rs232.asm	Thu Mar 14 16:56:46 2024 +0100
@@ -4,7 +4,7 @@
 ;
 ;   Internal EEPROM, RS232
 ;
-;   Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved.
+;   Copyright (c) 2011, JD Gascuel, heinrichs weikamp gmbh, all right reserved.
 ;=============================================================================
 ; HISTORY
 ;  2011-08-06 : [mH] moving from OSTC code
@@ -160,6 +160,7 @@
 	bsf		block_battery_gauge								; suspend ISR from accessing the battery gauge
 	EEPROM_CC_READ eeprom_battery_type, battery_type		; 1 byte read from EEPROM
 	EEPROM_RR_READ eeprom_battery_gauge,battery_gauge,.6	; 6 byte read from EEPROM
+	EEPROM_RR_READ eeprom_charge_cycles,charge_cycles,.2	; 2 byte read from EEPROM
 	bcf		block_battery_gauge								; allow ISR to access the battery gauge again
 	return													; done
 
@@ -169,6 +170,7 @@
 	EEPROM_CC_WRITE battery_type, eeprom_battery_type		; 1 byte write to EEPROM
 update_battery_gauge:
 	EEPROM_RR_WRITE battery_gauge,eeprom_battery_gauge,.6	; 6 byte write to EEPROM
+	EEPROM_RR_WRITE charge_cycles,eeprom_charge_cycles,.2	; 2 byte write to EEPROM
 	bcf		block_battery_gauge								; allow ISR to access the battery gauge again
 	return													; done
 
@@ -366,7 +368,7 @@
 	btfss	speed_is_normal				; speed = normal?
 	bra		enable_rs232_1				; NO  - loop waiting for ISR to have adjusted the speed
 	bsf	TRISC,7
-	bcf		PORTE,0						; YES - switch port to comm
+	bcf		ble_npower						; YES - switch port to comm
 	bsf		PORTJ,2						;     - /Reset (required for very old OSTC sport)
 	movlw	b'00100100'					;     - TX configuration: TX enabled, async, high speed
 	movwf	TXSTA1						;     - ...
@@ -402,7 +404,7 @@
 	clrf	RCSTA1						; disable RX
 	clrf	TXSTA1						; disable TX
 	bcf		PORTC,6						; switch TX pin hard to GND
-	bsf		PORTE,0						; power down BT chip
+	bsf		ble_npower						; power down BT chip
 	bcf		PORTJ,2						; /Reset (required for very old OSTC sport)
 	bcf	TRISC,7
 	bcf		PORTC,7						; switch RX pin hard to GND
--- a/src/eeprom_rs232.inc	Fri Aug 11 15:53:49 2023 +0200
+++ b/src/eeprom_rs232.inc	Thu Mar 14 16:56:46 2024 +0100
@@ -3,7 +3,7 @@
 ;   File eeprom_rs232.inc                   * combined next generation V3.09.4n
 ;
 ;
-;   Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved.
+;   Copyright (c) 2011, JD Gascuel, heinrichs weikamp gmbh, all right reserved.
 ;=============================================================================
 ; HISTORY
 ;  2011-08-03 : [mH] moving from OSTC code
@@ -34,7 +34,7 @@
 #DEFINE eeprom_battery_type				0x00F		; | 1  battery type inside the OSTC
 #DEFINE eeprom_options_version			0x010		;   2  options version identifier
 #DEFINE eeprom_fw_chksum_current		0x012		;   6  checksum of the current firmware *)
-;										0x018		;   2  unused
+#DEFINE	eeprom_charge_cycles			0x018		;   2  16bit charge cycles (Reset with "new battery")
 #DEFINE eeprom_options_storage			0x01A		; 486  backup storage for the options
 
 
--- a/src/external_flash.asm	Fri Aug 11 15:53:49 2023 +0200
+++ b/src/external_flash.asm	Thu Mar 14 16:56:46 2024 +0100
@@ -4,7 +4,7 @@
 ;
 ;   External flash
 ;
-;   Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved.
+;   Copyright (c) 2011, JD Gascuel, heinrichs weikamp gmbh, all right reserved.
 ;=============================================================================
 ; HISTORY
 ;  2011-08-12 : [mH] creation
--- a/src/external_flash.inc	Fri Aug 11 15:53:49 2023 +0200
+++ b/src/external_flash.inc	Thu Mar 14 16:56:46 2024 +0100
@@ -3,7 +3,7 @@
 ;   File external_flash.inc                 * combined next generation V3.09.4e
 ;
 ;
-;   Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved.
+;   Copyright (c) 2011, JD Gascuel, heinrichs weikamp gmbh, all right reserved.
 ;=============================================================================
 ; HISTORY
 ;  2011-08-12 : [mH] creation
--- a/src/gaslist.asm	Fri Aug 11 15:53:49 2023 +0200
+++ b/src/gaslist.asm	Thu Mar 14 16:56:46 2024 +0100
@@ -4,7 +4,7 @@
 ;
 ;   Managing OSTC gas list
 ;
-;   Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved.
+;   Copyright (c) 2011, JD Gascuel, heinrichs weikamp gmbh, all right reserved.
 ;=============================================================================
 ; HISTORY
 ;   2011-08-11 : [jDG] Creation.
--- a/src/gaslist.inc	Fri Aug 11 15:53:49 2023 +0200
+++ b/src/gaslist.inc	Thu Mar 14 16:56:46 2024 +0100
@@ -4,7 +4,7 @@
 ;
 ;   Interface to OSTC gas list management.
 ;
-;   Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved.
+;   Copyright (c) 2011, JD Gascuel, heinrichs weikamp gmbh, all right reserved.
 ;=============================================================================
 ; HISTORY
 ;   2011-08-11 : [jDG] Creation.
--- a/src/ghostwriter.asm	Fri Aug 11 15:53:49 2023 +0200
+++ b/src/ghostwriter.asm	Thu Mar 14 16:56:46 2024 +0100
@@ -4,7 +4,7 @@
 ;
 ;   Ghostwriter (Log profile recorder)
 ;
-;   Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved.
+;   Copyright (c) 2011, JD Gascuel, heinrichs weikamp gmbh, all right reserved.
 ;=============================================================================
 ; HISTORY
 ;  2011-11-27 : [mH] Creation
--- a/src/ghostwriter.inc	Fri Aug 11 15:53:49 2023 +0200
+++ b/src/ghostwriter.inc	Thu Mar 14 16:56:46 2024 +0100
@@ -3,7 +3,7 @@
 ;   File ghostwriter.inc                       combined next generation V3.0.1
 ;
 ;
-;   Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved.
+;   Copyright (c) 2011, JD Gascuel, heinrichs weikamp gmbh, all right reserved.
 ;=============================================================================
 ; HISTORY
 ;  2011-11-27 : [mH] Creation
--- a/src/hwos.asm	Fri Aug 11 15:53:49 2023 +0200
+++ b/src/hwos.asm	Thu Mar 14 16:56:46 2024 +0100
@@ -4,7 +4,7 @@
 ;
 ;   Definition of the hwOS dive computer platform.
 ;
-;   Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved.
+;   Copyright (c) 2011, JD Gascuel, heinrichs weikamp gmbh, all right reserved.
 ;=============================================================================
 ; HISTORY
 ;   2011-05-24 : [jDG] Cleanups from initial Matthias code
@@ -529,6 +529,7 @@
 	global	restore_flash
 restore_flash:
 	banksel	common
+	bcf	INTCON,GIE
 
 	;set start address in internal program FLASH
 	movlw	0x00					; set 0x000000
--- a/src/hwos.inc	Fri Aug 11 15:53:49 2023 +0200
+++ b/src/hwos.inc	Thu Mar 14 16:56:46 2024 +0100
@@ -4,7 +4,7 @@
 ;
 ;   OSTC Platform Definitions
 ;
-;   Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved.
+;   Copyright (c) 2011, JD Gascuel, heinrichs weikamp gmbh, all right reserved.
 ;=============================================================================
 ; HISTORY
 ;   2011-05-24 : [jDG] Cleanups from initial Matthias code
@@ -42,9 +42,10 @@
 
 
 ; ---- Logo Address Vectors
-#DEFINE hw_logo_block			0x01E000	; color image data for heinrichsweikamp logo
+#DEFINE hw_logo_block			0x01E000	; color image data for heinrichs weikamp gmbh logo
 #DEFINE comm_logo_1				0x01EEDE	; color image data for USB or BT logo
 #DEFINE comm_logo_2				0x01EA04	; color image data for BT logo, "+" bootloader
+#DEFINE comm_logo_3				0x01E936	; color image data for BT logo, dn bootloader
 
 
 ;-----------------------------EEPROM DATA ------------------------------------
@@ -308,7 +309,9 @@
 #DEFINE capacity_ur16650				.235		; 2.0Ah/0.085mAh/100 [%]
 #DEFINE offset_ur16650					.42006		; 65536-(2.0Ah/0.085mAh)
 
-
+#DEFINE capacity_404050					.141		; 1.2Ah/0.085mAh/100 [%]
+#DEFINE offset_404050					.51418		; 65536-(1.2Ah/0.085mAh)
+ 
 ; ---- Power Consumption Values
 #DEFINE current_sleepmode				.31
 #DEFINE current_backlight_multi			.115		; * CCPR1L + current_backlight_offset (restricted to  <= 255)
@@ -489,8 +492,8 @@
  ;---- Hardware - OSTC Model Variants2 (stored in access RAM, NOT cleared in restart)
 #DEFINE press_sensor_type		HW_variants2,0		; =1: pressure sensor MS5837, =0: Pressure sensor MS5541
 #DEFINE	less_io_cpu			HW_variants2,1		; =1: OSTC has a CPU with less I/O pins
-;					HW_variants2,2		; --- unused
-;					HW_variants2,3		; --- unused
+#DEFINE screen_type4			HW_variants2,2		; =1: display type 4, =0: display type 0 or 1 or 2 or 3
+#DEFINE	dn_flag				HW_variants2,3		; =1: dn
 ;					HW_variants2,4		; --- unused
 ;					HW_variants2,5		; --- unused
 ;					HW_variants2,6		; --- unused
@@ -520,7 +523,7 @@
 #DEFINE ms5837_state			HW_flags_state3,0	; =1: result of pressure is in the ADC
 #DEFINE	i2c_busy_pressure		HW_flags_state3,1	; =1: Currently updating pressure from MS5837
 #DEFINE	eeprom_write_error_flag		HW_flags_state3,2	; =1: an EEPROM write error occurred (Reset only in a Reboot/POR)
-;					HW_flags_state3,3	; --- unused
+#DEFINE	lock_cycle_counter		HW_flags_state3,3	; =1: Do not count charge cycle (again), cleared when batt_percent<95%
 ;					HW_flags_state3,4	; --- unused
 ;					HW_flags_state3,5	; --- unused
 ;					HW_flags_state3,6	; --- unused
@@ -590,7 +593,7 @@
 
 ;---- Dive Mode - Dive States
 #DEFINE use_aGF					DM_flags_state,0	; =1: use aGF, =0: use GF
-#DEFINE deco_locked				DM_flags_state,1	; =1: in or has been in deco obligation       during the dive
+;#DEFINE deco_locked				DM_flags_state,1	; =1: in or has been in deco obligation       during the dive
 #DEFINE deco_region				DM_flags_state,2	; =1: in or has been in the deco stops region during the dive
 #DEFINE cave_mode				DM_flags_state,3	; =1: cave mode is active                                 (cave mode)
 #DEFINE dive_turned				DM_flags_state,4	; =1: dive is turned                                      (cave mode)
@@ -1334,8 +1337,9 @@
 backtrack_waypoint_turn			res 1		; waypoint number of the turn point
  ENDIF
 
-;---- Dive Mode / apnoe mode (2 byte)
+;---- Dive Mode / apnoe mode (3 byte)
 apnoe_max_pressure				res 2		; max depth over all dives in the series
+apnoe_dive_counter				res 1		; apnoe #dive counter
 
 ;---- Profile Recording (6 byte)
 alarm_type						res 1		; alarm states recording
@@ -1460,7 +1464,7 @@
 pressure_update_lag_counter		res 1		; lag time counter for fast surface pressure display updating
 gp_debug				res 2		; General Purpose debug registers
 
-; 203 byte used, 5 byte free (208 byte total)
+; 204 byte used, 4 byte free (208 byte total)
 
 
 ;-----------------------------------------------------------------------------
@@ -1597,7 +1601,8 @@
 D2_buffer					res 3		; Buffer of D2 (Sensor raw data)					
 
 brightness					res 1		; =0: Eco, =1:Medium, =2:Full
-; 157 byte used, 92 byte free
+charge_cycles					res 2		; 16bit charge cycles counter
+; 159 byte used, 90 byte free
 
 
 ;-----------------------------------------------------------------------------
@@ -1723,7 +1728,8 @@
 opt_fallback					res 1		; unused dummy option for compatibility with 3rd party tools
 opt_conservatism				res 1		; unused dummy option for compatibility with 3rd party tools
 opt_warning_level_divemode			res 1		; warning verbose level (divemode) =0: Less, =1: All				
-
+opt_timeformat					res 1		; =0:24h, =1:12h
+					
 ;---- RX Function Settings
 opt_transmitter_id_1			res 2		; 16 bit transmitter ID for Gas 1
 opt_transmitter_id_2			res 2		; 16 bit transmitter ID for Gas 2
@@ -1740,7 +1746,7 @@
 opt_TR_2nd_pres					res 1		; TR functions - 2nd pressure assignment
 opt_TR_Bail_pres				res 1		; TR functions - bailout pressure assignment
 
-; ==> 193 bytes used - 51 bytes free (244 usable bytes only in bank 14 as the upper 12
+; ==> 194 bytes used - 50 bytes free (244 usable bytes only in bank 14 as the upper 12
 ;                                     bytes are reserved for special function registers)
 
 ;-----------------------------------------------------------------------------
--- a/src/i2c.asm	Fri Aug 11 15:53:49 2023 +0200
+++ b/src/i2c.asm	Thu Mar 14 16:56:46 2024 +0100
@@ -4,7 +4,7 @@
 ;
 ;   I2C Interface
 ;
-;   Copyright (c) 2012, JD Gascuel, HeinrichsWeikamp, all right reserved.
+;   Copyright (c) 2012, JD Gascuel, heinrichs weikamp gmbh, all right reserved.
 ;=============================================================================
 ;
 ;   Compass0
@@ -1136,8 +1136,8 @@
 	movff	xC+3,batt_voltage+1			; ...
 
 	tstfsz	batt_voltage+1				; < 256 mV ?
-	return								; NO  - done
-	bra		lt2942_init					; YES - initialize gauge and return
+	return						; NO  - done
+	bra	lt2942_init_again			; YES - initialize gauge and return
 
 
 ;-----------------------------------------------------------------------------
@@ -1239,6 +1239,9 @@
 	movlw	.100						; max. value is  100 %
 	cpfslt	batt_percent				; batt_percent < 100 % ?
 	movwf	batt_percent				; NO  - limit to 100 %
+	movlw	.95						; < 95 %
+	cpfsgt	batt_percent
+	bcf	lock_cycle_counter			; Yes, unlock cycle counter
 	return								; done
 
 lt2942_set_to_zero_percent:
@@ -1331,6 +1334,9 @@
 	clrf	battery_gauge+3				; ...
 	clrf	battery_gauge+4				; ...
 	clrf	battery_gauge+5				; ...
+	banksel	charge_cycles
+	clrf	charge_cycles+0				; null the charge cycles
+	clrf	charge_cycles+1				; ...
 	banksel	common						; back to bank common
 	goto	eeprom_battery_gauge_write	; update battery registers in EEPROM, unblock ISR and return
 
--- a/src/i2c.inc	Fri Aug 11 15:53:49 2023 +0200
+++ b/src/i2c.inc	Thu Mar 14 16:56:46 2024 +0100
@@ -3,7 +3,7 @@
 ;   File i2c.inc                              combined next generation V3.08.8
 ;
 ;
-;   Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved.
+;   Copyright (c) 2011, JD Gascuel, heinrichs weikamp gmbh, all right reserved.
 ;=============================================================================
 ; HISTORY
 ;  2012-10-24 : [mH] Creation
--- a/src/icons.asm	Fri Aug 11 15:53:49 2023 +0200
+++ b/src/icons.asm	Thu Mar 14 16:56:46 2024 +0100
@@ -4,7 +4,7 @@
 ;
 ;   Tables for all OSTC icons.
 ;
-;   Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved.
+;   Copyright (c) 2011, JD Gascuel, heinrichs weikamp gmbh, all right reserved.
 ;=============================================================================
 ; HISTORY
 ;  2011-05-24 : [jDG] Creation with icons for demo menus.
--- a/src/isr.asm	Fri Aug 11 15:53:49 2023 +0200
+++ b/src/isr.asm	Thu Mar 14 16:56:46 2024 +0100
@@ -4,7 +4,7 @@
 ;
 ;   INTERUPT subroutines
 ;
-;   Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved.
+;   Copyright (c) 2011, JD Gascuel, heinrichs weikamp gmbh, all right reserved.
 ;=============================================================================
 ; HISTORY
 ;  2011-05-24 : [jDG] Cleanups from initial Matthias code.
--- a/src/isr.inc	Fri Aug 11 15:53:49 2023 +0200
+++ b/src/isr.inc	Thu Mar 14 16:56:46 2024 +0100
@@ -3,7 +3,7 @@
 ;   File isr.inc                               combined next generation V3.0.1
 ;
 ;
-;   Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved.
+;   Copyright (c) 2011, JD Gascuel, heinrichs weikamp gmbh, all right reserved.
 ;=============================================================================
 ; HISTORY
 ;  2011-08-06 : [mH] moving from OSTC code
--- a/src/logbook.asm	Fri Aug 11 15:53:49 2023 +0200
+++ b/src/logbook.asm	Thu Mar 14 16:56:46 2024 +0100
@@ -4,7 +4,7 @@
 ;
 ;   Logbook
 ;
-;   Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved.
+;   Copyright (c) 2011, JD Gascuel, heinrichs weikamp gmbh, all right reserved.
 ;=============================================================================
 ; HISTORY
 ;  2011-11-12 : [mH] moving from OSTC code
@@ -393,6 +393,8 @@
 	; show time
 	WIN_SMALL logbook_time_column, logbook_time_row
 	MOVII	header_buffer+index_time,mpr			; get time
+	TSTOSC	opt_timeformat							; =1: Use 12h format
+	call	TFT_convert_lo_into_12h_format					; converts lo (0-23h) into lo (1-12) with PM/AM flag in aux_flag
 	output_99x										; print hour
 	PUTC	':'										; print spacing ":"
 	movff	hi,lo									; print minute
@@ -1590,6 +1592,8 @@
 	call	output_date_short							; print date (day and month)
 	STRCAT	".-"										; print spacing ".-"
 	MOVII	rtc_latched_hour,mpr						; get computed end-of-dive time
+	TSTOSC	opt_timeformat							; =1: Use 12h format
+	call	TFT_convert_lo_into_12h_format					; converts lo (0-23h) into lo (1-12) with PM/AM flag in aux_flag
 	output_99x											; print hour
 	PUTC	':'											; print spacing ":"
 	movff	hi,lo										; print minute
@@ -1783,6 +1787,8 @@
 	call	output_date								; print date
 	PUTC	"-"										; print "-"
 	MOVII	header_buffer+index_time,mpr			; get time
+	TSTOSC	opt_timeformat							; =1: Use 12h format
+	call	TFT_convert_lo_into_12h_format					; converts lo (0-23h) into lo (1-12) with PM/AM flag in aux_flag
 	output_99x										; print hour
 	PUTC	':'										; print spacing ":"
 	movff	hi,lo									; print minute
--- a/src/logbook.inc	Fri Aug 11 15:53:49 2023 +0200
+++ b/src/logbook.inc	Thu Mar 14 16:56:46 2024 +0100
@@ -3,7 +3,7 @@
 ;   File logbook.inc                          combined next generation V3.08.8
 ;
 ;
-;   Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved.
+;   Copyright (c) 2011, JD Gascuel, heinrichs weikamp gmbh, all right reserved.
 ;=============================================================================
 ; HISTORY
 ;  2011-11-12 : [mH] moving from OSTC code
--- a/src/math.asm	Fri Aug 11 15:53:49 2023 +0200
+++ b/src/math.asm	Thu Mar 14 16:56:46 2024 +0100
@@ -4,7 +4,7 @@
 ;
 ;   Math subroutines
 ;
-;   Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved.
+;   Copyright (c) 2011, JD Gascuel, heinrichs weikamp gmbh, all right reserved.
 ;=============================================================================
 ; HISTORY
 ;  2011-08-03 : [mH] moving from OSTC code
--- a/src/math.inc	Fri Aug 11 15:53:49 2023 +0200
+++ b/src/math.inc	Thu Mar 14 16:56:46 2024 +0100
@@ -3,7 +3,7 @@
 ;   File math.inc                           * combined next generation V3.09.4k
 ;
 ;
-;   Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved.
+;   Copyright (c) 2011, JD Gascuel, heinrichs weikamp gmbh, all right reserved.
 ;=============================================================================
 ; HISTORY
 ;  2011-08-03 : [mH] moving from OSTC code
--- a/src/mcp.asm	Fri Aug 11 15:53:49 2023 +0200
+++ b/src/mcp.asm	Thu Mar 14 16:56:46 2024 +0100
@@ -4,7 +4,7 @@
 ;
 ;   Basic routines for RX circuity
 ;
-;   Copyright (c) 2012, JD Gascuel, HeinrichsWeikamp, all right reserved.
+;   Copyright (c) 2012, JD Gascuel, heinrichs weikamp gmbh, all right reserved.
 ;=============================================================================
 ; HISTORY
 ;  2012-08-12 : [mH] Creation
--- a/src/mcp.inc	Fri Aug 11 15:53:49 2023 +0200
+++ b/src/mcp.inc	Thu Mar 14 16:56:46 2024 +0100
@@ -3,7 +3,7 @@
 ;   File mcp.inc                              combined next generation V3.06.1
 ;
 ;
-;   Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved.
+;   Copyright (c) 2011, JD Gascuel, heinrichs weikamp gmbh, all right reserved.
 ;=============================================================================
 ; HISTORY
 ;  2012-09-03 : [mH] creation
--- a/src/menu_processor.asm	Fri Aug 11 15:53:49 2023 +0200
+++ b/src/menu_processor.asm	Thu Mar 14 16:56:46 2024 +0100
@@ -4,7 +4,7 @@
 ;
 ;   Routines to handle all hwOS graphic/text menus.
 ;
-;   Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved.
+;   Copyright (c) 2011, JD Gascuel, heinrichs weikamp gmbh, all right reserved.
 ;=============================================================================
 ; HISTORY
 ;   2012-11-02 : [jDG] Cleanup for hwOS: removed icons. Added scrolling.
--- a/src/menu_processor.inc	Fri Aug 11 15:53:49 2023 +0200
+++ b/src/menu_processor.inc	Thu Mar 14 16:56:46 2024 +0100
@@ -4,7 +4,7 @@
 ;
 ;   Routines to handle all OSTC graphic/text menus.
 ;
-;   Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved.
+;   Copyright (c) 2011, JD Gascuel, heinrichs weikamp gmbh, all right reserved.
 ;=============================================================================
 ; HISTORY
 ;   2011-05-30 : [jDG] Creation.
--- a/src/menu_tree.asm	Fri Aug 11 15:53:49 2023 +0200
+++ b/src/menu_tree.asm	Thu Mar 14 16:56:46 2024 +0100
@@ -4,7 +4,7 @@
 ;
 ;   OSTC Surface Menus
 ;
-;   Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved.
+;   Copyright (c) 2011, JD Gascuel, heinrichs weikamp gmbh, all right reserved.
 ;=============================================================================
 ; HISTORY
 ;   2011-07-11 : [jDG] Creation.
@@ -1294,16 +1294,18 @@
 ;
 do_menu_info2:
  IFNDEF _comm_debug
-	MENU_BEGIN	tInfoMenu, .5
+	MENU_BEGIN	tInfoMenu, .6
 		MENU_DYNAMIC	dyn_show_battery_volts,		0
+		MENU_DYNAMIC	dyn_show_battery_cycles,	0
 		MENU_DYNAMIC	dyn_show_config,			0
 		MENU_DYNAMIC	dyn_show_sensor_calib,		0
 		MENU_DYNAMIC	dyn_show_sensor_offset,		0
 		MENU_CALL		tBack,						do_return_menu_settings_deeper
 	MENU_END
  ELSE
-	MENU_BEGIN	tInfoMenu, .6
+	MENU_BEGIN	tInfoMenu, .7
 		MENU_DYNAMIC	dyn_show_battery_volts,		0
+		MENU_DYNAMIC	dyn_show_battery_cycles,	0
 		MENU_DYNAMIC	dyn_show_config,			0
 		MENU_DYNAMIC	dyn_show_sensor_calib,		0
 		MENU_DYNAMIC	dyn_show_sensor_offset,		0
@@ -1328,7 +1330,16 @@
 	PUTC	")"							; append fix legend
 	return								; done
 
-
+;-----------------------------------------------------------------------------
+; dynamic Title - show Battery charge cycles
+;
+dyn_show_battery_cycles:	
+	STRCAT_TEXT tBatteryCycles				; print text
+	MOVII	charge_cycles,mpr			; get battery cycles
+	bsf		leftbind					; print left-aligned
+	output_65535							; print # cycles
+	return								; done
+    
 ;-----------------------------------------------------------------------------
 ; dynamic Title - show Hardware / Software Configuration
 ;
@@ -1512,10 +1523,11 @@
 	bsf		imprint_time_date			; start imprinting current time & date
 	bcf		block_option_value			; resume displaying of option values
 
-	MENU_BEGIN	tSetTimeDate, .4
+	MENU_BEGIN	tSetTimeDate, .5
 		MENU_CALL		tSetTime,					do_menu_set_time
 		MENU_CALL		tSetDate,					do_menu_set_date
-		MENU_OPT_INC	tDateFormat,				oDateFormat
+		MENU_OPT_INC	tDateFormat,						oDateFormat
+		MENU_OPT_INC	tTimeFormat,						oTimeFormat
 		MENU_CALL		tBack,						do_return_menu_settings
 	MENU_END
 
@@ -2140,6 +2152,9 @@
 	; 0x02:                           ambient sensor                   ---> OSTC Sport (USB model)   YES    NO     1.5V  3.6V disposable  3.6V rechargeable
 	; 0x52: BLE                   and ambient sensor and low volt core ---> OSTC Sport (BLE model)   YES    NO     1.5V  3.6V disposable  3.6V rechargeable
 
+	btfsc	dn_flag
+	bra	use_404050_battery
+	
 	movlw	0x11						; OSTC 2 (2015 model)
 	cpfseq	HW_descriptor
 	bra		$+4
@@ -2309,8 +2324,15 @@
 ;
 use_18650_battery:
 	rcall	setup_new_18650
+	bra	use_batt_exit
+
+;-----------------------------------------------------------------------------
+; Call Function - build-in 404050
+;
+use_404050_battery:
+	rcall	setup_new_404050
 	;bra	use_batt_exit
-
+	
 
 ;-----------------------------------------------------------------------------
 ; Helper Function - finish Battery Selection
@@ -2326,22 +2348,6 @@
 
 
 ;-----------------------------------------------------------------------------
-; Migrate Battery Selection from Firmwares prior 2.09
-;
-	global	use_old_prior_209
-use_old_prior_209:
-	EEPROM_CC_READ eeprom_battery_type,WREG	; read battery type from EEPROM
-	incfsz	WREG,W							; battery type = 0xFF (undefined) ?
-	return									; NO  - done
-	call	lt2942_get_status				; YES - check for gauge IC
-	movlw	.3								;     - default to a 18650 (LiIon 3.7V/3.1Ah)
-	btfss	battery_gauge_available			;     - OSTC 2 or cR hardware?
-	movlw	.1								;     - NO - assume a Saft (disposable 3.6 V)
-	EEPROM_CC_WRITE WREG,eeprom_battery_type;     - write battery type to EEPROM
-	return									;     - done
-
-
-;-----------------------------------------------------------------------------
 ; Retrieve Battery Selection from EEPROM
 ;
 	global	get_battery_data
@@ -2360,6 +2366,8 @@
 	rcall	setup_new_18650				; =3
 	dcfsnz	lo,F
 	rcall	setup_new_16650				; =4
+	dcfsnz	lo,F
+	rcall	setup_new_404050			; =5
 	bcf		use_old_batt_flag			; clear flag
  IFNDEF _screendump
 	bcf		comm_mode_disabled			; re-enable COMM mode again
@@ -2411,6 +2419,8 @@
 	MOVLI	offset_ncr18650,   battery_offset
 	movlw	.3
 	movwf	battery_type
+	btfss	use_old_batt_flag				; In a power-on-reset run?
+	clrf	batt_percent					; YES: Start with 0%
 	return
 
 	; rechargeable internal Lithium-ion
@@ -2422,6 +2432,21 @@
 	MOVLI	offset_ur16650,   battery_offset
 	movlw	.4
 	movwf	battery_type
+	btfss	use_old_batt_flag				; In a power-on-reset run?
+	clrf	batt_percent					; YES: Start with 0%
+	return
+
+	; rechargeable internal Lithium-ion 404050
+setup_new_404050:
+	bcf		charge_disable				; release  charging-inhibit signal
+	bsf		charge_enable				; tristate charging-inhibit signal
+	CLRI	battery_capacity_internal
+	MOVLI	capacity_404050, battery_capacity
+	MOVLI	offset_404050,   battery_offset
+	movlw	.5
+	movwf	battery_type
+	btfss	use_old_batt_flag				; In a power-on-reset run?
+	clrf	batt_percent					; YES: Start with 0%
 	return
 
 ;-----------------------------------------------------------------------------
--- a/src/ms5541.asm	Fri Aug 11 15:53:49 2023 +0200
+++ b/src/ms5541.asm	Thu Mar 14 16:56:46 2024 +0100
@@ -4,7 +4,7 @@
 ;
 ;   Sensor Subroutines
 ;
-;   Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved.
+;   Copyright (c) 2011, JD Gascuel, heinrichs weikamp gmbh, all right reserved.
 ;=============================================================================
 ; HISTORY
 ;  2011-08-03 : [mH] moving from OSTC code
--- a/src/ms5541.inc	Fri Aug 11 15:53:49 2023 +0200
+++ b/src/ms5541.inc	Thu Mar 14 16:56:46 2024 +0100
@@ -3,7 +3,7 @@
 ;   File ms5541.inc                            combined next generation V3.0.1
 ;
 ;
-;   Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved.
+;   Copyright (c) 2011, JD Gascuel, heinrichs weikamp gmbh, all right reserved.
 ;=============================================================================
 ; HISTORY
 ;  2011-08-04 : [mH] moving from OSTC code
--- a/src/option_table.asm	Fri Aug 11 15:53:49 2023 +0200
+++ b/src/option_table.asm	Thu Mar 14 16:56:46 2024 +0100
@@ -4,7 +4,7 @@
 ;
 ;   The Option Table
 ;
-;   Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved.
+;   Copyright (c) 2011, JD Gascuel, heinrichs weikamp gmbh, all right reserved.
 ;=============================================================================
 ; HISTORY
 ;   2014-08-03 : mH creation
@@ -329,12 +329,13 @@
 	OPTION_BOOL     oGasContingencyDive,                                           .0,                       0x106,    0x91,  opt_gas_contingency_dive		; =1: dive mode: switch to alternative gas if best gas is depleted
 	OPTION_BOOL     oGasDensityCheck,                                              .1,                       0x107,    0x92,  opt_gas_density_check			; gas density is checked (effective in CCR / pSCR modes only)
 	OPTION_ENUM8	oWarningLevel,	     .2,                                       .0,      tLess,           0x108,    0x93,  opt_warning_level_divemode		; =0: Less, =1: All
+	OPTION_ENUM8    oTimeFormat,         .2,                                       .0,      tTimeformat,     0x109,    0x94,  opt_timeformat			; =0:24h, =1:12h
 	;	+---------------------------------------------------------------------------------------------------------------------------------------------+
 	;	|  .                                                                                                                                          |
 	;	| /|\                                                                                                                                         |
 	;	|  |  add new options here!                                                                                                                   |
-	;	|  |  EEPROM address  min: 0x012, max: 0x1FF, last used: 0x107, spare: 0x0B7-0x0B9, 0x0F5-0x0F6, disused: 0x0A8, 0x0CE                        |
-	;	|  |  serial address  min:  0x20, max:  0xF9, last used:  0x92, spare: 0x84 (0xFA - 0xFE are reserved for internal use)			      |
+	;	|  |  EEPROM address  min: 0x012, max: 0x1FF, last used: 0x109, spare: 0x0B7-0x0B9, 0x0F5-0x0F6, disused: 0x0A8, 0x0CE                        |
+	;	|  |  serial address  min:  0x20, max:  0xF9, last used:  0x94, spare: 0x84 (0xFA - 0xFE are reserved for internal use)			      |
 	;	+---------------------------------------------------------------------------------------------------------------------------------------------+
 
 	; ppO2 warnings, sorted by ppO2 levels
@@ -348,7 +349,7 @@
 	OPTION_UINT8    oGas6O2,         gaslist_min_o2,    gaslist_max_o2,           .21,      tPercent,     volatile,    0xFA,  opt_gas6_O2_ratio				; O2 % of gas 6
 	OPTION_UINT8    oGas6He,             .0,            gaslist_max_He,            .0,      tPercent,     volatile,    0xFB,  opt_gas6_He_ratio				; He % of gas 6
 	OPTION_UINT8p10 odiveInterval,       .0,                 .240,                 .0,      tMinutes,     volatile,  nocomm,  opt_surface_interval			; additional surface interval for deco calculator
-	OPTION_UINT8p2  obottomTime,         .2,                  .60,                .10,      tMinutes,     volatile,  nocomm,  char_I_bottom_time			; bottom time  for deco calculator
+	OPTION_UINT8p2  obottomTime,         .2,                  .60,                 .2,      tMinutes,     volatile,  nocomm,  char_I_bottom_time			; bottom time  for deco calculator
 	OPTION_UINT8p3d obottomDepth,       .12,                 .120,                .21,      tMeters,      volatile,  nocomm,  char_I_bottom_depth			; bottom depth for deco calculator and simulator
 	OPTION_BOOL     oSimAGF,                                                       .0,                    volatile,  nocomm,  opt_sim_use_aGF				; =1: use GF (no) or aGF (yes) in deco calculator
 	OPTION_ENUM8    oLogOffsetStep,      .4,                                       .0,      tLogOffStep1, volatile,  nocomm,  opt_logoffset_step			; step size when adjusting the log offset
--- a/src/options.asm	Fri Aug 11 15:53:49 2023 +0200
+++ b/src/options.asm	Thu Mar 14 16:56:46 2024 +0100
@@ -4,7 +4,7 @@
 ;
 ;   Manage all options data.
 ;
-;   Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved.
+;   Copyright (c) 2011, JD Gascuel, heinrichs weikamp gmbh, all right reserved.
 ;=============================================================================
 ; HISTORY
 ;   2011-07-12 : [jDG] Creation.
--- a/src/p2_deco.c	Fri Aug 11 15:53:49 2023 +0200
+++ b/src/p2_deco.c	Thu Mar 14 16:56:46 2024 +0100
@@ -2,13 +2,13 @@
 // p2_deco.c                                  combined next generation V3.19.4
 //
 //  Created on: 12.05.2009
-//  Author: heinrichs weikamp, contributions by Ralph Lembcke and others
+//  Author: heinrichs weikamp gmbh, contributions by Ralph Lembcke and others
 //
 // ***************************************************************************
 
 //////////////////////////////////////////////////////////////////////////////
 // OSTC - diving computer code
-// Copyright (C) 2018 HeinrichsWeikamp GmbH
+// Copyright (C) 2018 heinrichs weikamp gmbh GmbH
 //
 //    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
--- a/src/p2_definitions.h	Fri Aug 11 15:53:49 2023 +0200
+++ b/src/p2_definitions.h	Thu Mar 14 16:56:46 2024 +0100
@@ -6,7 +6,7 @@
 
 //////////////////////////////////////////////////////////////////////////////
 // OSTC - diving computer code
-// Copyright (C) 2008 HeinrichsWeikamp GbR
+// Copyright (C) 2008 heinrichs weikamp gmbh
 //
 //    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
--- a/src/ports.inc	Fri Aug 11 15:53:49 2023 +0200
+++ b/src/ports.inc	Thu Mar 14 16:56:46 2024 +0100
@@ -4,7 +4,7 @@
 ;
 ;   Portmap
 ;
-;   Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved.
+;   Copyright (c) 2011, JD Gascuel, heinrichs weikamp gmbh, all right reserved.
 ;=============================================================================
 ; HISTORY
 ;   2012-08-13 : [mH] Creation
@@ -49,7 +49,7 @@
 ; TRIS=b'00100000'
 
 ; PORTE
-#DEFINE	RE0_unused		PORTE,0			; unused
+#DEFINE	ble_npower		PORTE,0			; power supply for ble (inverted)
 #DEFINE	ir_power		PORTE,1			; power supply for IR
 #DEFINE	charge_disable	PORTE,2			; ex. mcp_ncs (RX /CS) (available from hardware rev x.x only)
 #DEFINE	LEDr			PORTE,3			; LED red
--- a/src/rtc.asm	Fri Aug 11 15:53:49 2023 +0200
+++ b/src/rtc.asm	Thu Mar 14 16:56:46 2024 +0100
@@ -3,7 +3,7 @@
 ;   File rtc.asm                            * combined next generation V3.09.4k
 ;
 ;
-;   Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved.
+;   Copyright (c) 2011, JD Gascuel, heinrichs weikamp gmbh, all right reserved.
 ;=============================================================================
 ; HISTORY
 ;  2011-08-08 : [mH] moving from OSTC code
@@ -233,7 +233,7 @@
 	bra		rtc_add_minutes_3		;       NO  - month is ok
 	subwf	rtc_latched_month,F		;       YES - subtract 12 from resulting month (actually sets back to January)
 	incf	rtc_latched_year,F		;           - increment year
-rtc_add_minutes_3
+rtc_add_minutes_3:
 	banksel	common					; back to bank common
 	return							; done
 
--- a/src/rtc.inc	Fri Aug 11 15:53:49 2023 +0200
+++ b/src/rtc.inc	Thu Mar 14 16:56:46 2024 +0100
@@ -3,7 +3,7 @@
 ;   File rtc.inc                              combined next generation V3.08.8
 ;
 ;
-;   Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved.
+;   Copyright (c) 2011, JD Gascuel, heinrichs weikamp gmbh, all right reserved.
 ;=============================================================================
 ; HISTORY
 ;  2011-08-08 : [mH] moving from OSTC code
--- a/src/rx_firmware-1-39.inc	Fri Aug 11 15:53:49 2023 +0200
+++ b/src/rx_firmware-1-39.inc	Thu Mar 14 16:56:46 2024 +0100
@@ -4,7 +4,7 @@
 ;
 ;   Firmware for the RX Co-Processor
 ;
-;   Copyright (c) 2019, HeinrichsWeikamp, all rights reserved.
+;   Copyright (c) 2019, heinrichs weikamp gmbh, all rights reserved.
 ;=============================================================================
 
 
--- a/src/rx_firmware.asm	Fri Aug 11 15:53:49 2023 +0200
+++ b/src/rx_firmware.asm	Thu Mar 14 16:56:46 2024 +0100
@@ -4,7 +4,7 @@
 ;
 ;   Firmware for the RX Co-Processor
 ;
-;   Copyright (c) 2019, HeinrichsWeikamp, all rights reserved.
+;   Copyright (c) 2019, heinrichs weikamp gmbh, all rights reserved.
 ;=============================================================================
 
 
--- a/src/rx_ops.asm	Fri Aug 11 15:53:49 2023 +0200
+++ b/src/rx_ops.asm	Thu Mar 14 16:56:46 2024 +0100
@@ -4,7 +4,7 @@
 ;
 ;   RX (Tank Pressure Transmitter) Routines.
 ;
-;   Copyright (c) 2018, heinrichs weikamp, all right reserved.
+;   Copyright (c) 2018, heinrichs weikamp gmbh, all right reserved.
 ;=============================================================================
 
 #include "hwos.inc"						; mandatory header
--- a/src/rx_ops.inc	Fri Aug 11 15:53:49 2023 +0200
+++ b/src/rx_ops.inc	Thu Mar 14 16:56:46 2024 +0100
@@ -3,7 +3,7 @@
 ;   File rx_ops.inc                            combined next generation V3.0.1
 ;
 ;
-;   Copyright (c) 2018, heinrichs weikamp, all right reserved.
+;   Copyright (c) 2018, heinrichs weikamp gmbh, all right reserved.
 ;=============================================================================
 
  IFDEF _rx_functions
--- a/src/simulator.asm	Fri Aug 11 15:53:49 2023 +0200
+++ b/src/simulator.asm	Thu Mar 14 16:56:46 2024 +0100
@@ -4,7 +4,7 @@
 ;
 ;   Deco Calculator
 ;
-;   Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved.
+;   Copyright (c) 2011, JD Gascuel, heinrichs weikamp gmbh, all right reserved.
 ;=============================================================================
 ; HISTORY
 ; 2011-07-09 : [jDG] Creation...
--- a/src/sleepmode.asm	Fri Aug 11 15:53:49 2023 +0200
+++ b/src/sleepmode.asm	Thu Mar 14 16:56:46 2024 +0100
@@ -4,7 +4,7 @@
 ;
 ;   Sleep Mode
 ;
-;   Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved.
+;   Copyright (c) 2011, JD Gascuel, heinrichs weikamp gmbh, all right reserved.
 ;==============================================================================
 ; HISTORY
 ;  2011-08-12 : [mH] moving from OSTC code
--- a/src/sleepmode.inc	Fri Aug 11 15:53:49 2023 +0200
+++ b/src/sleepmode.inc	Thu Mar 14 16:56:46 2024 +0100
@@ -3,7 +3,7 @@
 ;   File sleepmode.inc                         combined next generation V3.0.1
 ;
 ;
-;   Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved.
+;   Copyright (c) 2011, JD Gascuel, heinrichs weikamp gmbh, all right reserved.
 ;=============================================================================
 ; HISTORY
 ;  2011-08-12 : [mH] moving from OSTC code
--- a/src/start.asm	Fri Aug 11 15:53:49 2023 +0200
+++ b/src/start.asm	Thu Mar 14 16:56:46 2024 +0100
@@ -4,7 +4,7 @@
 ;
 ;   Startup subroutines
 ;
-;   Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved.
+;   Copyright (c) 2011, JD Gascuel, heinrichs weikamp gmbh, all right reserved.
 ;=============================================================================
 ; HISTORY
 ;  2011-08-06 : [mH] moving from OSTC code
@@ -38,7 +38,6 @@
 	extern	rtc_init
 	extern	new_battery_select
 	extern	get_battery_data
-	extern	use_old_prior_209
 	extern	get_first_gas_to_WREG
 
 	extern	oFirmwareMajor
@@ -144,6 +143,7 @@
 	; get screen type (2) from bootloader info
 	bsf		screen_type2					; set flags for later clear of the false one
 	bsf		screen_type3					; ...
+	bsf		screen_type4					; ...
 	movlw	0x80							; set up read from 0x01F780
 	movwf	TBLPTRL							; ...
 	;movlw	0xF7							; high and upper are still at 0x01F7xx
@@ -157,7 +157,14 @@
 	movlw	0x84							; coding for screen type 3
 	cpfseq	TABLAT							; equal?
 	bcf		screen_type3					; NO  -  not screen type 3
+	movlw	0x85							; coding for screen type 4
+	cpfseq	TABLAT							; equal?
+	bcf		screen_type4					; NO  -  not screen type 4
 
+	bcf	dn_flag
+	btfsc	screen_type4
+	bsf	dn_flag
+	
 	; get button polarity from configuration data (EEPROM)
 	EEPROM_CC_READ eeprom_button_polarity,button_polarity
 
@@ -216,8 +223,6 @@
 
 start_common:
 	; check for power-on reset
-	btfsc	RCON,POR						; was this a power-on reset?
-	call	use_old_prior_209				; NO - migrate the last battery status from firmware 2.09 or earlier
 
 	bcf		use_old_batt_flag				; default to no reload of last battery data
 	btfsc	RCON,POR						; was this a power-on reset?
@@ -235,7 +240,7 @@
 start_check_new_firmware:
 	call	TFT_boot						; initialize TFT (includes clear screen & backlight switch-off)
 
-	; show heinrichsweikamp logo
+	; show heinrichs weikamp logo
 	WIN_TOP  .40
 	WIN_LEFT .10
 	TFT_WRITE_PROM_IMAGE_BY_ADDR hw_logo_block
@@ -388,7 +393,7 @@
  IFNDEF _hwos_sport
 	btfsc	vusb_in							; USB power detected?
 	bra		restart3						; YES - no BT then
-	bcf		PORTE,0							; NO  - power up BT chip (if available)
+	bcf		ble_npower							; NO  - power up BT chip (if available)
 	WAITMS	d'5'							;     - wait 5 ms
 	btfss	vusb_in							;     - BT chip detected?
 	bra		restart3						;       NO  - no BT then
@@ -396,6 +401,7 @@
 	bsf		ble_available					;       YES - BT available
 
 restart3:
+    bsf		ble_npower						; power down BT chip (if available)
    IFDEF _external_sensor						; Compiled for external analog interface?
     bsf	    ext_input_s8_ana					;       YES - Set the flag
     call    eeprom_serial_number_read	; read OSTC serial number
@@ -467,7 +473,7 @@
 	call	TFT_boot						; initialize TFT (includes clear screen & backlight switch-off)
 	WIN_TOP  .40							; set position
 	WIN_LEFT .10							; ...
-	TFT_WRITE_PROM_IMAGE_BY_ADDR hw_logo_block ; show heinrichsweikamp logo
+	TFT_WRITE_PROM_IMAGE_BY_ADDR hw_logo_block ; show heinrichs weikamp logo
 	WIN_SMALL .10,.130						; set position
 	STRCAT_PRINT "Updating TR Module..."	; print update message
 	call	TFT_Display_FadeIn				; dimm up backlight to show outputs
--- a/src/start.inc	Fri Aug 11 15:53:49 2023 +0200
+++ b/src/start.inc	Thu Mar 14 16:56:46 2024 +0100
@@ -3,7 +3,7 @@
 ;   File start.inc                             combined next generation V3.0.1
 ;
 ;
-;   Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved.
+;   Copyright (c) 2011, JD Gascuel, heinrichs weikamp gmbh, all right reserved.
 ;=============================================================================
 ; HISTORY
 ;  2011-08-06 : [mH] moving from OSTC code
--- a/src/strings.asm	Fri Aug 11 15:53:49 2023 +0200
+++ b/src/strings.asm	Thu Mar 14 16:56:46 2024 +0100
@@ -4,7 +4,7 @@
 ;
 ;   Implementation code various string functions.
 ;
-;   Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved.
+;   Copyright (c) 2011, JD Gascuel, heinrichs weikamp gmbh, all right reserved.
 ;=============================================================================
 ; HISTORY
 ;  2010-12-02 : [jDG] Creation
--- a/src/strings.inc	Fri Aug 11 15:53:49 2023 +0200
+++ b/src/strings.inc	Thu Mar 14 16:56:46 2024 +0100
@@ -4,7 +4,7 @@
 ;
 ;   Implementation code various string functions
 ;
-;   Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved.
+;   Copyright (c) 2011, JD Gascuel, heinrichs weikamp gmbh, all right reserved.
 ;=============================================================================
 ; HISTORY
 ;   2010-12-02 : [jDG] Creation
--- a/src/surfmode.asm	Fri Aug 11 15:53:49 2023 +0200
+++ b/src/surfmode.asm	Thu Mar 14 16:56:46 2024 +0100
@@ -4,7 +4,7 @@
 ;
 ;   Surface Mode
 ;
-;   Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved.
+;   Copyright (c) 2011, JD Gascuel, heinrichs weikamp gmbh, all right reserved.
 ;=============================================================================
 ; HISTORY
 ; 2011-08-07 : [mH] moving from OSTC code
@@ -78,7 +78,7 @@
 	btfsc	restart_fast				; shall make a fast restart?
 	bra		surfloop_1					; YES
 
-	; show heinrichsweikamp logo
+	; show heinrichs weikamp gmbh logo
 	WIN_TOP  .40
 	WIN_LEFT .10
 	TFT_WRITE_PROM_IMAGE_BY_ADDR hw_logo_block
--- a/src/surfmode.inc	Fri Aug 11 15:53:49 2023 +0200
+++ b/src/surfmode.inc	Thu Mar 14 16:56:46 2024 +0100
@@ -3,7 +3,7 @@
 ;   File surfmode.inc                         combined next generation V3.09.4
 ;
 ;
-;   Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved.
+;   Copyright (c) 2011, JD Gascuel, heinrichs weikamp gmbh, all right reserved.
 ;=============================================================================
 ; HISTORY
 ;  2011-08-07 : [mH] moving from OSTC code
--- a/src/text_english.inc	Fri Aug 11 15:53:49 2023 +0200
+++ b/src/text_english.inc	Thu Mar 14 16:56:46 2024 +0100
@@ -4,7 +4,7 @@
 ;
 ;	English texts reference file.
 ;
-;	Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved.
+;	Copyright (c) 2011, JD Gascuel, heinrichs weikamp gmbh, all right reserved.
 ;=============================================================================
 
 ; Basic texts
@@ -366,7 +366,10 @@
 	TCODE	tDateformat,		"MMDDYY"
 	TCODE	tDateformat1,		"DDMMYY"
 	TCODE	tDateformat2,		"YYMMDD"
-
+; Time
+	TCODE	tTimeFormat,		"24/12h: "
+	TCODE	tTimeformat,		"24h"
+	TCODE	tTimeformat1,		"12h"
 
 ; Simulator menu
 	TCODE	tInter,				"Start Simulator"		; Start Simulator
@@ -406,6 +409,7 @@
 	TCODE	tHardware,			"Hardware: "			; Hardware: (space)
 	TCODE	tSerial,			"Serial  : "			; Serial  : (space)
 	TCODE	tBatteryV,			"Battery : "			; Battery : (space)
+	TCODE	tBatteryCycles,			"Cycles  : "			; Cycles  : (space)
 	TCODE	tSensorC,			"Sensor  : "			; Sensor  : (space)
 	TCODE	tSensorD,			"Offset  : "			; Offset  : (space)
 	TCODE	tUptime,			"Uptime  : "			; Uptime  : (space)
--- a/src/text_french.inc	Fri Aug 11 15:53:49 2023 +0200
+++ b/src/text_french.inc	Thu Mar 14 16:56:46 2024 +0100
@@ -4,7 +4,7 @@
 ;
 ;	French texts translation file.
 ;
-;	Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved.
+;	Copyright (c) 2011, JD Gascuel, heinrichs weikamp gmbh, all right reserved.
 ;=============================================================================
 
 ; Basic texts
@@ -366,6 +366,10 @@
 	TCODE	tDateformat,		"MMJJAA"
 	TCODE	tDateformat1,		"JJMMAA"
 	TCODE	tDateformat2,		"AAMMJJ"
+; Time
+	TCODE	tTimeFormat,		"24/12h: "
+	TCODE	tTimeformat,		"24h"
+	TCODE	tTimeformat1,		"12h"
 
 
 ; Simulator menu
@@ -406,6 +410,7 @@
 	TCODE	tHardware,			"Hardware: "			; Hardware: (space)
 	TCODE	tSerial,			"N. Série: "			; Serial  : (space)
 	TCODE	tBatteryV,			"Batterie: "			; Battery : (space)
+	TCODE	tBatteryCycles,			"Cycles  : "			; Cycles  : (space)
 	TCODE	tSensorC,			"Capteur : "			; Sensor  : (space)
 	TCODE	tSensorD,			"Décalage: "			; Offset  : (space)
 	TCODE	tUptime,			"Mise a Jour:"			; Uptime:
--- a/src/text_german.inc	Fri Aug 11 15:53:49 2023 +0200
+++ b/src/text_german.inc	Thu Mar 14 16:56:46 2024 +0100
@@ -4,7 +4,7 @@
 ;
 ;	German texts translation file.
 ;
-;	Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved.
+;	Copyright (c) 2011, JD Gascuel, heinrichs weikamp gmbh, all right reserved.
 ;=============================================================================
 
 ; Basic texts
@@ -366,6 +366,10 @@
 	TCODE	tDateformat,		"MMTTJJ"
 	TCODE	tDateformat1,		"TTMMJJ"
 	TCODE	tDateformat2,		"JJMMTT"
+; Time
+	TCODE	tTimeFormat,		"24/12h: "
+	TCODE	tTimeformat,		"24h"
+	TCODE	tTimeformat1,		"12h"
 
 
 ; Simulator menu
@@ -406,6 +410,7 @@
 	TCODE	tHardware,			"Hardware: "			; Hardware: (space)
 	TCODE	tSerial,			"Seriennr: "			; Serial  : (space)
 	TCODE	tBatteryV,			"Batterie: "			; Battery : (space)
+	TCODE	tBatteryCycles,			"Zyklen  : "			; Cycles  : (space)
 	TCODE	tSensorC,			"Sensor  : "			; Sensor  : (space)
 	TCODE	tSensorD,			"Offset  : "			; Offset  : (space)
 	TCODE	tUptime,			"Laufzeit: "			; Uptime:
--- a/src/text_italian.inc	Fri Aug 11 15:53:49 2023 +0200
+++ b/src/text_italian.inc	Thu Mar 14 16:56:46 2024 +0100
@@ -4,7 +4,7 @@
 ;
 ;	Italian texts translation file.
 ;
-;	Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved.
+;	Copyright (c) 2011, JD Gascuel, heinrichs weikamp gmbh, all right reserved.
 ;=============================================================================
 
 ; Basic texts
@@ -366,6 +366,10 @@
 	TCODE	tDateformat,		"MMGGAA"
 	TCODE	tDateformat1,		"GGMMAA"
 	TCODE	tDateformat2,		"AAMMGG"
+; Time
+	TCODE	tTimeFormat,		"24/12h: "
+	TCODE	tTimeformat,		"24h"
+	TCODE	tTimeformat1,		"12h"
 
 
 ; Simulator menu
@@ -406,6 +410,7 @@
 	TCODE	tHardware,			"Hardware: "			; Hardware: (space)
 	TCODE	tSerial,			"Seriale : "			; Serial  : (space)
 	TCODE	tBatteryV,			"Batteria: "			; Battery : (space)
+	TCODE	tBatteryCycles,			"Cicli   : "			; Cycles  : (space)
 	TCODE	tSensorC,			"Sensor  : "			; Sensor  : (space)
 	TCODE	tSensorD,			"Offset  : "			; Offset  : (space)
 	TCODE	tUptime,			"Uptime: "				; Uptime: 
--- a/src/text_multilang.asm	Fri Aug 11 15:53:49 2023 +0200
+++ b/src/text_multilang.asm	Thu Mar 14 16:56:46 2024 +0100
@@ -4,7 +4,7 @@
 ;
 ;   Implementation text in various selectable languages.
 ;
-;   Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved.
+;   Copyright (c) 2011, JD Gascuel, heinrichs weikamp gmbh, all right reserved.
 ;=============================================================================
 ; HISTORY
 ;  2011-06-12 : [jDG] Creation
@@ -22,7 +22,7 @@
 ; fast hack **ONLY** for **CHANGING** languages ( en / de / fr / it )
 
 ;#undefine _language_1
-;#define   _language_1 it
+;#define   _language_1 fr
 
 ;#undefine _language_2
 ;#define   _language_2 it
--- a/src/text_multilang.inc	Fri Aug 11 15:53:49 2023 +0200
+++ b/src/text_multilang.inc	Thu Mar 14 16:56:46 2024 +0100
@@ -4,7 +4,7 @@
 ;
 ;    Implementation of texts in various selectable languages
 ;
-;   Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved.
+;   Copyright (c) 2011, JD Gascuel, heinrichs weikamp gmbh, all right reserved.
 ;=============================================================================
 ; HISTORY
 ;  2011-06-12 : [jDG] Creation
--- a/src/tft.asm	Fri Aug 11 15:53:49 2023 +0200
+++ b/src/tft.asm	Thu Mar 14 16:56:46 2024 +0100
@@ -4,7 +4,7 @@
 ;
 ;   low-level Display Outputs
 ;
-;   Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved.
+;   Copyright (c) 2011, JD Gascuel, heinrichs weikamp gmbh, all right reserved.
 ;=============================================================================
 ; HISTORY
 ;  2011-05-24 : [jDG] Cleanups from initial Matthias code.
@@ -71,23 +71,25 @@
 
 	global	TFT_ClearScreen
 TFT_ClearScreen:
+    	btfsc	screen_type4			; screen type 4?
+	bra		TFT_ClearScreen_display4; YES
+	btfsc	screen_type3			; screen type 3?
+	bra		TFT_ClearScreen_display3; YES
 	btfsc	screen_type2			; screen type 2?
 	bra		TFT_ClearScreen_display2; YES
-	btfsc	screen_type3			; screen type 3?
-	bra		TFT_ClearScreen_display3; YES
 
 	Index_out 0x50					; window horizontal start address
-	Parameter_out 0x00, 0x00		; 0-239
+	Parameter_out 0x00, 0x00		; 0
 	Index_out 0x51					; window horizontal end   address
-	Parameter_out 0x00, 0xEF		; 0-239
+	Parameter_out 0x00, 0xEF		; 239
 	Index_out 0x52					; window vertical   start address
-	Parameter_out 0x00, 0x00		; 0-319
+	Parameter_out 0x00, 0x00		; 0
 	Index_out 0x53					; window vertical   end   address
-	Parameter_out 0x01, 0x3F		; 0-319
+	Parameter_out 0x01, 0x3F		; 319
 	Index_out 0x20					; frame memory horizontal address
-	Parameter_out 0x00, 0x00		; 0-239
+	Parameter_out 0x00, 0x00		; 0
 	Index_out 0x21					; frame memory vertical   address
-	Parameter_out 0x01, 0x3F		; 0-319
+	Parameter_out 0x01, 0x3F		; 319
 
 	Index_out 0x22					; frame memory data write start
 
@@ -232,6 +234,61 @@
 	movlw	.107				; 107 x 240 x 6 = 154080 ticks (153600 would be enough)
 	bra		TFT_ClearScreen_display2_loop0
 
+TFT_ClearScreen_display4:
+ ; Column Address start
+	movlw	0x2A
+	rcall	TFT_CmdWrite
+	movlw	0x00
+	rcall	TFT_DataWrite
+	movlw	0x00
+	rcall	TFT_DataWrite
+; Column Address end (d'239')
+	movlw	0x00
+	rcall	TFT_DataWrite
+	movlw	0xEF
+	rcall	TFT_DataWrite
+
+; Row address start
+	movlw	0x2B
+	rcall	TFT_CmdWrite
+	movlw	0x00
+	rcall	TFT_DataWrite
+	movlw	0x00
+	rcall	TFT_DataWrite
+; Row address end   (d'319)
+	movlw	0x01
+	rcall	TFT_DataWrite
+	movlw	0x3F
+	rcall	TFT_DataWrite
+
+	movlw	0x2C                ; Start Writing Data to GRAM
+	rcall	TFT_CmdWrite
+
+	RD_H						; Not Read
+	RS_H						; Data
+	NCS_L						; Not CS
+	clrf	PORTA				; Data Upper
+	clrf	PORTH				; Data Lower
+	bcf		INTCON,GIE
+	movlw	d'10'
+	movwf	tft_temp3
+TFT_ClearScreen_display4_loop1:
+	movlw	d'30'
+	movwf	tft_temp2
+TFT_ClearScreen_display4_loop2:
+	clrf	tft_temp1				; 30*10*256=76800 Pixels -> Clear complete 240*320
+TFT_ClearScreen_display4_loop3:
+	WR_L
+	WR_H							; Tick
+	decfsz	tft_temp1,F
+	bra		TFT_ClearScreen_display4_loop3
+	decfsz	tft_temp2,F
+	bra		TFT_ClearScreen_display4_loop2
+	decfsz	tft_temp3,F
+	bra		TFT_ClearScreen_display4_loop1
+	bsf		INTCON,GIE
+	return
+	
 
 	global	TFT_DisplayOff
 TFT_DisplayOff:
@@ -288,7 +345,6 @@
 
 	clrf	PORTA
 	clrf	PORTH
-
 	RD_L	; LOW
 	nop
 	WR_L
@@ -314,6 +370,9 @@
 	btfsc	screen_type3			; display type 3 ?
 	bra		TFT_boot_screen3		; YES
 
+	btfsc	screen_type4			; display type 4 ?
+	bra		TFT_boot_screen4		; YES
+
 	; Data Transfer Synchronization
 	Parameter_out 0x00, 0x00
 	Parameter_out 0x00, 0x00
@@ -381,7 +440,7 @@
 	rcall	TFT_ClearScreen
 	Index_out 0x07
 	Parameter_out 0x01, 0x33
-	return
+	return					; done TFT_boot
 
 display0_config_table:
 	; Reg, Dat0, Dat1 or 0xFF,0x00,0x00 for end
@@ -489,6 +548,177 @@
 	rcall	TFT_DataWrite			; write configuration
 	bra		display1_init_loop		; loop
 
+TFT_boot_screen4:
+	movlw	0xB0
+	rcall	TFT_CmdWrite
+	movlw	0x00
+	rcall	TFT_DataWrite
+	movlw	0xC4
+	rcall	TFT_DataWrite
+	
+	movlw	0xB1
+	rcall	TFT_CmdWrite
+	movlw	0xC0
+	rcall	TFT_DataWrite
+	
+	movlw	0x3A
+	rcall	TFT_CmdWrite
+	movlw	0x55
+	rcall	TFT_DataWrite
+	
+	movlw	0x36		    ; x/y mirror, see page 125 of ST7789V datasheet
+	rcall	TFT_CmdWrite
+	movlw	0x40		    ; 0x40 (normal orientation)
+	rcall	TFT_DataWrite
+	
+	movlw	0xB0
+	rcall	TFT_CmdWrite
+	movlw	0x00
+	rcall	TFT_DataWrite
+	
+	movlw	0xB2
+	call	TFT_CmdWrite
+	movlw	0x0C
+	rcall	TFT_DataWrite
+	movlw	0x0C
+	rcall	TFT_DataWrite
+	movlw	0x00
+	rcall	TFT_DataWrite
+	movlw	0x33
+	rcall	TFT_DataWrite
+	movlw	0x33
+	rcall	TFT_DataWrite
+	
+	movlw	0xB7
+	rcall	TFT_CmdWrite
+	movlw	0x75
+	rcall	TFT_DataWrite
+	
+	movlw	0xBB
+	rcall	TFT_CmdWrite
+	movlw	0x20
+	rcall	TFT_DataWrite
+	
+	movlw	0xC0
+	rcall	TFT_CmdWrite
+	movlw	0x2C
+	rcall	TFT_DataWrite
+	
+	movlw	0xC2
+	rcall	TFT_CmdWrite
+	movlw	0x01
+	rcall	TFT_DataWrite
+	
+	movlw	0xC3
+	rcall	TFT_CmdWrite
+	movlw	0x19
+	rcall	TFT_DataWrite
+	
+	movlw	0xC4
+	rcall	TFT_CmdWrite
+	movlw	0x20
+	rcall	TFT_DataWrite
+	
+	movlw	0xC6
+	rcall	TFT_CmdWrite
+	movlw	0x0F
+	rcall	TFT_DataWrite
+	
+	movlw	0xD0
+	rcall	TFT_CmdWrite
+	movlw	0xA7
+	rcall	TFT_DataWrite
+	movlw	0xA1
+	rcall	TFT_DataWrite
+	
+	movlw	0xBB
+	rcall	TFT_CmdWrite
+	movlw	0x35
+	rcall	TFT_DataWrite
+	
+	movlw	0xC0
+	rcall	TFT_CmdWrite
+	movlw	0x2C
+	rcall	TFT_DataWrite
+	
+	movlw	0xC2
+	rcall	TFT_CmdWrite
+	movlw	0x01
+	rcall	TFT_DataWrite
+	
+	movlw	0xC3
+	rcall	TFT_CmdWrite
+	movlw	0x11
+	rcall	TFT_DataWrite
+
+	movlw	0xC4
+	rcall	TFT_CmdWrite
+	movlw	0x20
+	rcall	TFT_DataWrite
+
+	movlw	0xC6
+	rcall	TFT_CmdWrite
+	movlw	0x0F
+	rcall	TFT_DataWrite
+	
+	movlw	0xD0
+	rcall	TFT_CmdWrite
+	movlw	0xA7
+	rcall	TFT_DataWrite
+	movlw	0xA1
+	rcall	TFT_DataWrite
+	
+	movlw	0xBB
+	rcall	TFT_CmdWrite
+	movlw	0x35
+	rcall	TFT_DataWrite
+	
+	movlw	0xC0
+	rcall	TFT_CmdWrite
+	movlw	0x2C
+	rcall	TFT_DataWrite
+	
+	movlw	0x2C
+	rcall	TFT_CmdWrite
+	movlw	0x01
+	rcall	TFT_DataWrite
+	
+	movlw	0xC3
+	rcall	TFT_CmdWrite
+	movlw	0x11
+	rcall	TFT_DataWrite
+	
+	movlw	0xC4
+	rcall	TFT_CmdWrite
+	movlw	0x20
+	rcall	TFT_DataWrite
+	
+	movlw	0xC6
+	rcall	TFT_CmdWrite
+	movlw	0x0F
+	rcall	TFT_DataWrite
+	
+	movlw	0xD0
+	rcall	TFT_CmdWrite
+	movlw	0xA4
+	rcall	TFT_DataWrite
+	movlw	0xA1
+	rcall	TFT_DataWrite
+	; gamma
+	movlw	0x11
+	rcall	TFT_CmdWrite
+	
+	movlw	0x21
+	rcall	TFT_CmdWrite
+	WAITMS	d'60'
+	
+	movlw	0x29
+	rcall	TFT_CmdWrite
+	WAITMS	d'50'
+	rcall	TFT_ClearScreen
+	; ToDo: Flip....
+	return			    ; done TFT_boot
+
 
 	global	TFT_CmdWrite
 TFT_CmdWrite:
@@ -706,12 +936,14 @@
 
 	global	pixel_write_col320
 pixel_write_col320:
+    	btfsc	screen_type4			; display type 4 ?
+	bra		pixel_write_col320_d4	; YES
+	btfsc	screen_type3			; display type 3 ?
+	bra		pixel_write_col320_d3	; YES
 	btfsc	screen_type2			; display type 2 ?
 	bra		pixel_write_col320_d2	; YES
 	btfsc	screen_type1			; display type 1 ?
 	bra		pixel_write_col320_d1	; YES
-	btfsc	screen_type3			; display type 3 ?
-	bra		pixel_write_col320_d3	; YES
 									; NO to all - display type 0
 	btfss	flip_screen				; 180° rotation?
 	bra		pixel_write_noflip_H	; NO
@@ -761,6 +993,15 @@
 	rcall	TFT_CmdWrite
 	bra		TFT_DataWrite_PROD		; and return...
 
+pixel_write_col320_d4:
+    	movlw	0x2A
+	rcall	TFT_CmdWrite
+	rcall	TFT_DataWrite_PROD
+	incf	PRODL,F
+	movlw	.0
+	addwfc	PRODH,F					; +1
+	bra	TFT_DataWrite_PROD		; and return...	
+
 ;-----------------------------------------------------------------------------
 ; Write one half-pixel at position (win_top,win_leftx2).
 ; Inputs: win_leftx2, win_top, win_color_1/_2
@@ -771,10 +1012,12 @@
 	movf	win_top,W					; d'0' ... d'239'
 	; Variant with Y position in WREG
 half_pixel_write_1:
+	btfsc	screen_type4				; display type 4 ?
+	bra		half_pixel_write_1_display4	; YES
+        btfsc	screen_type3				; display type 3 ?
+	bra		half_pixel_write_1_display3	; YES
 	btfsc	screen_type2				; display type 2 ?
 	bra		half_pixel_write_1_display2	; YES
-	btfsc	screen_type3				; display type 3 ?
-	bra		half_pixel_write_1_display3	; YES
 
 half_pixel_write_1_display1:
 	btfss	flip_screen				; 180° rotation?
@@ -863,6 +1106,32 @@
 	WR_H							; tick
 	return							; done
 
+half_pixel_write_1_display4:	
+	mullw	1						; copy row to PRODL (PRODH=0)
+	; Row address start
+	movlw	0x2B
+	rcall	TFT_CmdWrite
+	movlw	0x00
+	rcall	TFT_DataWrite
+	movf	PRODL,W
+	rcall	TFT_DataWrite
+
+	incf	PRODL,F		    ; +1
+	movlw	0x00
+	rcall	TFT_DataWrite
+	movf	PRODL,W
+	rcall	TFT_DataWrite
+
+	movlw	0x2C                ; Start Writing Data to GRAM
+	rcall	TFT_CmdWrite
+	RS_H						; data
+	movff	win_color1,PORTA			; upper
+	movff	win_color2,PORTH			; lower
+	WR_L
+	WR_H						; tick
+	bsf		INTCON,GIE
+	return
+
 ;-----------------------------------------------------------------------------
 ; Draw a vertical line of half-pixel at position (win_top,win_leftx2,win_height).
 ; Inputs: win_leftx2, win_top, win_height, win_color_1/_2
@@ -996,10 +1265,12 @@
 	movf	win_leftx2,W			; compute left = 2 * leftx2 --> PROD
 	mullw	.2						; win_leftx2 x 2 -> PRODH:PRODL
 
+	btfsc	screen_type4			; screen type 4 ?
+	bra		TFT_box_write_display4	; YES
+	btfsc	screen_type3			; screen type 3 ?
+	bra		TFT_box_write_display3	; YES
 	btfsc	screen_type2			; screen type 2 ?
 	bra		TFT_box_write_display2	; YES
-	btfsc	screen_type3			; screen type 3 ?
-	bra		TFT_box_write_display3	; YES
 	btfsc	screen_type1			; screen type 1 ?
 	bra		TFT_box_write_display1	; YES
 
@@ -1204,6 +1475,49 @@
 	Index_out	0x20
 	bra		TFT_DataWrite_PROD		; and return...
 
+TFT_box_write_display4:
+    	movlw	0x2B
+	rcall	TFT_CmdWrite
+	movf	PRODH,W
+	rcall	TFT_DataWrite
+	movf	PRODL,W
+	rcall	TFT_DataWrite
+
+	movf	win_width+0,W			; right = left + width - 1
+	addwf	PRODL,F
+	movf	win_width+1,W
+	addwfc	PRODH,F
+	decf	PRODL,F					; decrement result
+	btfss	STATUS,C
+	decf	PRODH,F
+
+	; setup right border
+	movf	PRODH,W
+	rcall	TFT_DataWrite
+	movf	PRODL,W
+	rcall	TFT_DataWrite
+
+	;---- Normal vertical window -----------------------------------------
+	; Output (top) (bottom)
+	movff	win_top,PRODH			; top --> PRODH (first byte)
+	movf	win_height,W
+	addwf	PRODH,W
+	decf	WREG
+	movwf	PRODL					; top+height-1 --> PRODL (second byte)
+
+	movlw	0x2A
+	rcall	TFT_CmdWrite
+	movlw	0x00
+	rcall	TFT_DataWrite
+	movf	PRODH,W
+	rcall	TFT_DataWrite
+	
+	; setup bottom border
+	movlw	0x00
+	rcall	TFT_DataWrite
+	movf	PRODL,W
+	bra	TFT_DataWrite			; ... and return
+
 
 ;-----------------------------------------------------------------------------
 ; TFT_frame : draw a frame around current box with current color
@@ -1270,14 +1584,20 @@
 	rrcf	win_width+0,F
 
 	;---- Fill Window --------------------------------------------------------
-	Index_out 0x22					; frame memory data write start
+	movlw	0x22				; frame memory data write start
+	btfsc	screen_type4
+	movlw	0x2C				; Start Writing Data to GRAM (Display 4)
+	rcall	TFT_CmdWrite
+
 	clrf	PRODH					; column counter
 	RS_H							; data
 
+	btfsc	screen_type4			; display type 4 ?
+	bra		TFT_box_display4		; YES
+	btfsc	screen_type3			; display type 3 ?
+	bra		TFT_box_display3		; YES
 	btfsc	screen_type2			; display type 2 ?
 	bra		TFT_box_display2		; YES
-	btfsc	screen_type3			; display type 3 ?
-	bra		TFT_box_display3		; YES
 
 TFT_box2:							; loop height times
 	movff	win_height,PRODL
@@ -1414,6 +1734,32 @@
 	setf	win_bargraph			; YES - reset bargraph mode
 	return
 
+TFT_box_display4:	
+	; Screen 4
+	clrf	PRODH					; column counter
+TFT_box2_display4:					; loop height times
+	movff	win_height,PRODL
+TFT_box3_display4:					; loop width times
+	movff	win_color1,PORTA
+	movff	win_color2,PORTH
+	WR_L							; tick
+	WR_H							; ...
+	WR_L							; tick
+	WR_H							; ...
+	decfsz	PRODL,F					; row loop finished?
+	bra		TFT_box3_display4		; NO  - loop
+	incf	PRODH,F					; YES - column count ++
+	movf	win_bargraph,W			;     - get bargraph width
+	cpfseq	PRODH					;     - current column = bargraph ?
+	bra		TFT_box4_display4		;       NO
+	clrf	win_color1				;       Yes - switch to black
+	clrf	win_color2				;           - ...
+TFT_box4_display4:
+	movf	win_width+0,W			; get width
+	cpfseq	PRODH					; width loop finished ?
+	bra		TFT_box2_display4		; NO  - loop
+	setf	win_bargraph			; YES - reset bargraph mode
+	return							;     - done
 
 ;-----------------------------------------------------------------------------
 ; Convert 8 bit RGB b'RRRGGGBB' into 16 bit RGB    b'RRRRRGGGGGGBBBBB'
--- a/src/tft.inc	Fri Aug 11 15:53:49 2023 +0200
+++ b/src/tft.inc	Thu Mar 14 16:56:46 2024 +0100
@@ -4,7 +4,7 @@
 ;
 ;   Declaring interfaces to the TFT screen and its Oxxx controler
 ;
-;   Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved.
+;   Copyright (c) 2011, JD Gascuel, heinrichs weikamp gmbh, all right reserved.
 ;=============================================================================
 ; HISTORY
 ;  2011-05-24 : [jDG] Cleanups from initial Matthias code.
@@ -24,7 +24,8 @@
 ;	extern	pixel_write				; draw two half-pixels at position         (win_top,win_leftx2 )
 	extern	pixel_write_col320		; draw two half-pixels at position         (win_top,PRODH:PRODL)
 	extern	half_vertical_line		; draw a vertical   line of half-pixels at (win_top,win_leftx2,win_height)
-	extern	half_horizontal_line	; draw a horizontal line of half-pixels at (win_top,win_leftx2,win_width)
+	extern	half_horizontal_line		; draw a horizontal line of half-pixels at (win_top,win_leftx2,win_width)
+	extern	TFT_CmdWrite			; send a one byte command to the screen
 
  IFDEF _screendump
 	extern	TFT_dump_screen			; send a screenshot via the serial interface immediately
--- a/src/tft_outputs.asm	Fri Aug 11 15:53:49 2023 +0200
+++ b/src/tft_outputs.asm	Thu Mar 14 16:56:46 2024 +0100
@@ -4,7 +4,7 @@
 ;
 ;   high-level Display Outputs
 ;
-;   Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved.
+;   Copyright (c) 2011, JD Gascuel, heinrichs weikamp gmbh, all right reserved.
 ;=============================================================================
 ; HISTORY
 ;  2011-08-07 : [mH] moving from OSTC code
@@ -587,6 +587,31 @@
 ;
 	global	TFT_surfmode_time
 TFT_surfmode_time:
+    	TSTOSS	opt_timeformat					; =1: Use 12h format
+	bra	TFT_surfmode_time24				; <>1: Use 24h format
+	; 12h Format
+	WIN_SMALL surf_clock_column,surf_clock_row
+	FONT_COLOR_MEMO						; set color
+	SMOVSS	rtc_year,rtc_latched_year			; ISR-safe 6 byte copy of date and time
+	movff	rtc_latched_hour,lo			; get   hours
+	call	TFT_convert_lo_into_12h_format			; converts lo (0-23h) into lo (1-12) and sets aux_flag for PM/AM
+	output_99							; print hours (0-99)
+	movlw	':'							; load a ":"
+	movff	rtc_latched_secs,lo			; get seconds
+	btfss	lo,0						; on even second?
+	movlw	' '							; NO - load a space char
+	movwf	POSTINC2					; print ":" or space char
+	movff	rtc_latched_mins,lo			; get   minutes
+	output_99x							; print minutes (00-99)
+	btfsc	aux_flag					; =1 for PM
+	bra	TFT_surfmode_time_PM
+	STRCAT_PRINT "AM"
+	return								; done
+TFT_surfmode_time_PM:	
+        STRCAT_PRINT "PM"
+	return								; done
+	
+TFT_surfmode_time24:
 	WIN_SMALL surf_clock_column+.7,surf_clock_row
 	FONT_COLOR_MEMO						; set color
 	SMOVSS	rtc_year,rtc_latched_year	; ISR-safe 6 byte copy of date and time
@@ -1067,8 +1092,32 @@
 ;
 	global	TFT_imprint_time_date_fast
 TFT_imprint_time_date_fast:
-	WIN_SMALL .20,.40					; column, row - keep clear of the cursor area on the left!
-	FONT_COLOR_MEMO						; select color
+    	WIN_SMALL .20,.35					; column, row - keep clear of the cursor area on the left!
+	FONT_COLOR_MEMO						; set color
+	TSTOSS	opt_timeformat					; =1: Use 12h format
+	bra	TFT_imprint_time_date_fast24			; <>1: Use 24h format
+	; 12h Format
+	movff	rtc_latched_hour,lo				; get   hours
+	rcall	TFT_convert_lo_into_12h_format			; converts lo (0-23h) into lo (1-12) and sets aux_flag for PM/AM
+	output_99							; print hours (0-99)
+	movlw	':'							; load a ":"
+	movff	rtc_latched_secs,lo			; get seconds
+	btfss	lo,0						; on even second?
+	movlw	' '							; NO - load a space char
+	movwf	POSTINC2					; print ":" or space char
+	movff	rtc_latched_mins,lo			; get   minutes
+	output_99x							; print minutes (00-99)
+	PUTC	':'							; print ":"
+	movff	rtc_latched_secs,lo			; get   seconds
+	output_99x							; print seconds (00-99)
+	btfsc	aux_flag					; =1 for PM
+	bra	TFT_surfmode_time_PM_fast
+	STRCAT "AM "
+	bra	TFT_imprint_time_date_fast_date				; done
+TFT_surfmode_time_PM_fast:	
+        STRCAT "PM "
+	bra	TFT_imprint_time_date_fast_date				; done
+TFT_imprint_time_date_fast24:
 	movff	rtc_latched_hour,lo			; get   hours
 	output_99							; print hours (0-99)
 	PUTC	':'							; print ":"
@@ -1078,6 +1127,7 @@
 	movff	rtc_latched_secs,lo			; get   seconds
 	output_99x							; print seconds (00-99)
 	STRCAT	"  "						; append two spaces
+TFT_imprint_time_date_fast_date:
 	movff	rtc_latched_year, lo		; get date
 	movff	rtc_latched_month,hi		; ...
 	movff	rtc_latched_day,  up		; ...
@@ -1085,7 +1135,31 @@
 	PUTC_PRINT " "						; append a space and dump to screen
 	return								; done
 
-
+	global	TFT_convert_lo_into_12h_format
+TFT_convert_lo_into_12h_format:	; converts lo (0-23h) into lo (1-12) with PM/AM flag in aux_flag
+	tstfsz	lo
+	bra	TFT_convert_lo_into_12h_format1
+	; 0 -> 12AM
+	movlw	.12
+	movwf	lo
+	bcf	aux_flag			; PM/AM Bit
+	return
+TFT_convert_lo_into_12h_format1:
+	movlw	.13
+	cpfslt	lo				; >12h?
+	bra	TFT_convert_lo_into_12h_format2	; yes
+	; lo stays the same
+	bsf	aux_flag			; PM/AM Bit
+	movlw	.12				; 12:00 is 12:00 PM...
+	cpfseq	lo
+	bcf	aux_flag
+	return
+TFT_convert_lo_into_12h_format2:
+	movlw	.12
+	subwf	lo,F
+	bsf	aux_flag			; PM/AM Bit
+	return
+    
  IFDEF _external_sensor
 
 ;-----------------------------------------------------------------------------
@@ -1415,6 +1489,8 @@
 	return								;       NO  - done
 	btfsc	safety_stop_active			;       YES - safety stop shown?
 	return								;             YES - done
+	btfsc	alt_layout_active			;   In alternative layout?
+	return						;       YES - DONE.
 	goto	TFT_show_slow_reminder		;             NO  - show "slow" reminder
 
 
@@ -2106,8 +2182,8 @@
 	return								; YES - abort
 	MOVII	int_O_NDL_norm,mpr			; NO  - get NDL time in normal plan
 	rcall	TFT_show_ndl_tts_set_color	;     - set color
-	btfsc	deco_locked					;     - was the dive in deco?
-	bra		TFT_show_ndl_norm			;       YES - use normal layout
+;	btfsc	deco_locked					;     - was the dive in deco?
+;	bra		TFT_show_ndl_norm			;       YES - use normal layout
 	btfsc	alt_layout_active			;       NO  - alternative layout active?
 	bra		TFT_show_ndl_alt			;             YES - use alternative layout
 	;bra	TFT_show_ndl_norm			;             NO  - use normal layout
@@ -2291,8 +2367,23 @@
 	global	TFT_clear_apnoe_surface
 TFT_clear_apnoe_surface:
 	WIN_BOX_BLACK dm_apnoe_last_max_depth_text_row, .239, dm_apnoe_last_max_depth_column, .159
+	WIN_BOX_BLACK dm_customview_bot, dm_apnoe_last_max_depth_text_row, dm_apnoe_surface_dive_text_col, .159
 	return								; done
 
+;-----------------------------------------------------------------------------
+; Dive Mode - show apnoe #dive counter
+;
+	global	TFT_apnoe_divecounter
+TFT_apnoe_divecounter:
+	FONT_COLOR_MASK						; select mask color
+	WIN_TINY dm_apnoe_surface_dive_text_col, dm_apnoe_surface_dive_text_row
+	STRCPY_TEXT_PRINT tTotalDives		; print label
+	FONT_COLOR_MEMO						; select memo color
+	WIN_STD dm_apnoe_surface_divecnt_col, dm_apnoe_surface_divecnt_row
+	movff	apnoe_dive_counter,lo
+	output_256							; print #dives (0-255)
+	PRINT								; dump to screen
+	return								; done
 
 ;=============================================================================
 tft_out8	CODE
@@ -2782,7 +2873,9 @@
 	WIN_BOX_BLACK dm_safetystop_row, dm_safetystop_bot, dm_safetystop_text_column, dm_safetystop_rgt ; top, bottom, left, right
 	bcf		safety_stop_active			;           - safety stop not shown any more
 	btfss	deco_region					;           - was the dive within deco stops region?
-	return								;             NO  - done
+	return			
+	btfsc	alt_layout_active			; In alternative layout?
+	return						;     YES - DONE.
 	;bra	TFT_show_slow_reminder		;             YES - show "SLOW" reminder
 
 
@@ -2862,10 +2955,16 @@
 ;
 	global	TFT_surf_mesg_desat
 TFT_surf_mesg_desat:
+	movlw	.11
+	cpfseq	active_customview			; custom view 11 (DSAT/NOFLY/CNS) shown?
+	bra	TFT_surf_mesg_desat1			; No, continue
+	return						; Yes. Skip the warning then
+TFT_surf_mesg_desat1:	
 	rcall	TFT_message_open			; set row and column for the message
 	tstfsz	WREG						; is there room for the message?
 	return								; NO - skip message in this cycle
 
+TFT_surf_mesg_desat2:	
 	FONT_COLOR_MEMO						; select color
 	STRCPY	"Desat:"					; print label
 	MOVII	int_O_desaturation_time,mpr	; get desaturation time in minutes
@@ -2877,6 +2976,11 @@
 ;
 	global	TFT_surf_mesg_nofly
 TFT_surf_mesg_nofly:
+    	movlw	.11
+	cpfseq	active_customview			; custom view 11 (DSAT/NOFLY/CNS) shown?
+	bra	TFT_surf_mesg_nofly1			; No, continue
+	return						; Yes. Skip the warning then
+TFT_surf_mesg_nofly1:	
 	rcall	TFT_message_open			; set row and column for the message
 	tstfsz	WREG						; is there room for the message?
 	return								; NO - skip message in this cycle
@@ -3517,7 +3621,20 @@
 tft_out13	CODE
 ;=============================================================================
 
-
+;-----------------------------------------------------------------------------
+; Surface Custom View - DESAT, NoFly, CNS
+;
+	
+	global	TFT_surf_desat_nofly_cns
+TFT_surf_desat_nofly_cns:
+	WIN_SMALL surf_gaslist_column+.10,surf_gaslist_row+.5
+	call	TFT_surf_mesg_desat2
+	WIN_SMALL surf_gaslist_column+.10,surf_gaslist_row+(surf_gaslist_spacing*.1)+.5
+	call	TFT_nofly_time_fly
+	WIN_SMALL surf_gaslist_column+.10,surf_gaslist_row+(surf_gaslist_spacing*.2)+.5
+	bra	TFT_surface_tissues_5		; continue
+	
+	
 ;-----------------------------------------------------------------------------
 ; Surface Custom View - Last Dive Summery
 ;
@@ -3861,6 +3978,7 @@
 
 	; draw CNS% in-between tissue bars
 	WIN_SMALL surf_tissue_He_column+.22,surf_tissue_He_row
+TFT_surface_tissues_5:	
 	MOVII	int_O_CNS_current,mpr		; get current CNS
 	call	TFT_color_code_cns			; color-code CNS value
 	STRCPY_TEXT tCNS2					; "CNS: "
@@ -5101,6 +5219,27 @@
 	WIN_SMALL dm_custom_clock_column, dm_custom_clock_row
 	FONT_COLOR_MEMO						; select color
 	SMOVSS	rtc_year,rtc_latched_year	; ISR-safe 6 byte copy of date and time
+	TSTOSS	opt_timeformat					; =1: Use 12h format
+	bra	TFT_clock_batt_surfpress24			; <>1: Use 24h format
+	; 12h Format
+	movff	rtc_latched_hour,lo				; get   hours
+	call	TFT_convert_lo_into_12h_format			; converts lo (0-23h) into lo (1-12) and sets aux_flag for PM/AM
+	output_99							; print hours (0-99)
+	movlw	':'							; load a ":"
+	movff	rtc_latched_secs,lo			; get seconds
+	btfss	lo,0						; on even second?
+	movlw	' '							; NO - load a space char
+	movwf	POSTINC2					; print ":" or space char
+	movff	rtc_latched_mins,lo			; get   minutes
+	output_99x							; print minutes (00-99)
+	btfsc	aux_flag					; =1 for PM
+	bra	TFT_clock_batt_surfpress_PM
+	STRCAT_PRINT "AM"
+	bra	TFT_clock_batt_surfpress_batt				; done
+TFT_clock_batt_surfpress_PM:	
+        STRCAT_PRINT "PM"
+	bra	TFT_clock_batt_surfpress_batt				; done
+TFT_clock_batt_surfpress24:
 	movff	rtc_latched_hour,lo			; get   hours
 	output_99							; print hours (0-99)
 	PUTC	':'							; print ":"
@@ -5110,7 +5249,7 @@
 	movff	rtc_latched_secs,lo			; get   seconds
 	output_99x							; print seconds (00-99)
 	PRINT								; dump to screen
-
+TFT_clock_batt_surfpress_batt:
 	; show battery voltage
 	WIN_SMALL dm_custom_battery_column, dm_custom_battery_volt_row
 	;FONT_COLOR_MEMO						; select color
--- a/src/tft_outputs.inc	Fri Aug 11 15:53:49 2023 +0200
+++ b/src/tft_outputs.inc	Thu Mar 14 16:56:46 2024 +0100
@@ -3,7 +3,7 @@
 ;   File tft_outputs.inc                    * combined next generation V3.09.5
 ;
 ;
-;   Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved.
+;   Copyright (c) 2011, JD Gascuel, heinrichs weikamp gmbh, all right reserved.
 ;=============================================================================
 ; HISTORY
 ;  2011-08-07 : [mH] moving from OSTC code
@@ -34,6 +34,7 @@
 	extern	TFT_surf_cv_text					; the custom text
 	extern	TFT_surf_cv_tissues					; tissue diagram (also used by logbook)
 	extern	TFT_surf_cv_settings				; all deco settings
+	extern	TFT_surf_desat_nofly_cns
 
  IFDEF _rx_functions
 	extern	TFT_surf_cv_tankdata				; show the tank pressure data in surface customview
@@ -62,6 +63,7 @@
 	extern	TFT_imprint_time_date				; imprint current     time and date
 	extern	TFT_imprint_time_date_fast			; imprint last cahced time and date
 	extern	TFT_imprint_color_schemes			; imprint color schemes (animated dive time)
+	extern	TFT_convert_lo_into_12h_format			; converts lo (0-23h) into lo (1-12) with PM/AM flag in aux_flag
 
  IFDEF _external_sensor
 	extern	TFT_imprint_menu_mV					; imprint sensor data in menu    mode - mv
@@ -95,6 +97,7 @@
 	extern	TFT_show_apnoe_times				; show  apnoe current and overall time
 	extern	TFT_show_apnoe_surface				; show  apnoe surface mode data
 	extern	TFT_clear_apnoe_surface				; clear apnoe surface data
+	extern	TFT_apnoe_divecounter				; show apnoe #dive counter
 
 	extern	TFT_clear_deco_data					; clear deco data (NDL or stop & TTS)
 	extern	TFT_clear_divemode_menu				; clear the divemode menu
--- a/src/varargs.inc	Fri Aug 11 15:53:49 2023 +0200
+++ b/src/varargs.inc	Thu Mar 14 16:56:46 2024 +0100
@@ -4,7 +4,7 @@
 ;
 ;    Utilities to pass multiple arguments in compact code stream.
 ;
-;   Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved.
+;   Copyright (c) 2011, JD Gascuel, heinrichs weikamp gmbh, all right reserved.
 ;=============================================================================
 ; HISTORY
 ;  2011-05-27 : [jDG] Creation.
--- a/src/wait.asm	Fri Aug 11 15:53:49 2023 +0200
+++ b/src/wait.asm	Thu Mar 14 16:56:46 2024 +0100
@@ -4,7 +4,7 @@
 ;
 ;   Wait routines
 ;
-;   Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved.
+;   Copyright (c) 2011, JD Gascuel, heinrichs weikamp gmbh, all right reserved.
 ;=============================================================================
 ; HISTORY
 ;   2004-01-31 : [chsw] initial version
--- a/src/wait.inc	Fri Aug 11 15:53:49 2023 +0200
+++ b/src/wait.inc	Thu Mar 14 16:56:46 2024 +0100
@@ -4,7 +4,7 @@
 ;
 ;   Wait routines
 ;
-;   Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved.
+;   Copyright (c) 2011, JD Gascuel, heinrichs weikamp gmbh, all right reserved.
 ;=============================================================================
 ; HISTORY
 ;   2004-01-31 : [chsw] Initial version