annotate BootLoader/Src/tInfoBootloader.c @ 471:73da921869d9 fix-bat-2

bugfix: implement battery charge percentage in dive header This commit is (much) less trivial than the related 919e5cb51c92. First, rename the CCRmode attribute (corresponding to byte Ox59) of the SLogbookHeaderOSTC3. This byte (according to the hwOS interface document) does not contain any CCR related value, but it contains "battery information". Already since 2017, this byte is used from libdivecomputer to interface the charge percentage. So, its renamed from CCRmode to batteryCharge, to reflect its true purpose. Now, simply add a batteryCharge attribute to the SLogbookHeader (and see below why that is possible, without breaking things). The remaining changes are trivial to implement battery charge percentage in dive header. Caveat: do not get confused by the exact role of the individual logbook header types. SLogbookHeaderOSTC3 is the formal type of the logbook format that the OSTC4 produces. This format is supposed to identical to the format, as is used in hwOS for the series of small OSTCs. Only some values of attributes are different. For example, the OSTC4 supports VPM, so byte 0x79 (deco model used for this dive) also has a value for VPM. But the SLogbookHeader type, despite its name and structure, is *not* a true logbook header, as it includes attributes that are not available in the SLogbookHeaderOSTC3 formal header type. Signed-off-by: Jan Mulder <jan@jlmulder.nl>
author Jan Mulder <jlmulder@xs4all.nl>
date Wed, 22 Apr 2020 13:08:57 +0200
parents 7801c5d8a562
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
30
ea1003f63e44 ADD GPL License ...
jDG
parents: 25
diff changeset
1 ///////////////////////////////////////////////////////////////////////////////
ea1003f63e44 ADD GPL License ...
jDG
parents: 25
diff changeset
2 /// -*- coding: UTF-8 -*-
ea1003f63e44 ADD GPL License ...
jDG
parents: 25
diff changeset
3 ///
ea1003f63e44 ADD GPL License ...
jDG
parents: 25
diff changeset
4 /// \file BootLoader/Src/tInfoBootloader.c
ea1003f63e44 ADD GPL License ...
jDG
parents: 25
diff changeset
5 /// \brief Write something on the screen in between steps
36
7801c5d8a562 Update author name for release
heinrichsweikamp
parents: 30
diff changeset
6 /// \author heinrichs weikamp gmbh
30
ea1003f63e44 ADD GPL License ...
jDG
parents: 25
diff changeset
7 /// \date 08-May-2015
ea1003f63e44 ADD GPL License ...
jDG
parents: 25
diff changeset
8 ///
ea1003f63e44 ADD GPL License ...
jDG
parents: 25
diff changeset
9 /// $Id$
ea1003f63e44 ADD GPL License ...
jDG
parents: 25
diff changeset
10 ///////////////////////////////////////////////////////////////////////////////
ea1003f63e44 ADD GPL License ...
jDG
parents: 25
diff changeset
11 /// \par Copyright (c) 2014-2018 Heinrichs Weikamp gmbh
ea1003f63e44 ADD GPL License ...
jDG
parents: 25
diff changeset
12 ///
ea1003f63e44 ADD GPL License ...
jDG
parents: 25
diff changeset
13 /// This program is free software: you can redistribute it and/or modify
ea1003f63e44 ADD GPL License ...
jDG
parents: 25
diff changeset
14 /// it under the terms of the GNU General Public License as published by
ea1003f63e44 ADD GPL License ...
jDG
parents: 25
diff changeset
15 /// the Free Software Foundation, either version 3 of the License, or
ea1003f63e44 ADD GPL License ...
jDG
parents: 25
diff changeset
16 /// (at your option) any later version.
ea1003f63e44 ADD GPL License ...
jDG
parents: 25
diff changeset
17 ///
ea1003f63e44 ADD GPL License ...
jDG
parents: 25
diff changeset
18 /// This program is distributed in the hope that it will be useful,
ea1003f63e44 ADD GPL License ...
jDG
parents: 25
diff changeset
19 /// but WITHOUT ANY WARRANTY; without even the implied warranty of
ea1003f63e44 ADD GPL License ...
jDG
parents: 25
diff changeset
20 /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
ea1003f63e44 ADD GPL License ...
jDG
parents: 25
diff changeset
21 /// GNU General Public License for more details.
ea1003f63e44 ADD GPL License ...
jDG
parents: 25
diff changeset
22 ///
ea1003f63e44 ADD GPL License ...
jDG
parents: 25
diff changeset
23 /// You should have received a copy of the GNU General Public License
ea1003f63e44 ADD GPL License ...
jDG
parents: 25
diff changeset
24 /// along with this program. If not, see <http://www.gnu.org/licenses/>.
ea1003f63e44 ADD GPL License ...
jDG
parents: 25
diff changeset
25 //////////////////////////////////////////////////////////////////////////////
ea1003f63e44 ADD GPL License ...
jDG
parents: 25
diff changeset
26
ea1003f63e44 ADD GPL License ...
jDG
parents: 25
diff changeset
27 /* Includes ------------------------------------------------------------------*/
ea1003f63e44 ADD GPL License ...
jDG
parents: 25
diff changeset
28 #include "tInfoBootloader.h"
ea1003f63e44 ADD GPL License ...
jDG
parents: 25
diff changeset
29
ea1003f63e44 ADD GPL License ...
jDG
parents: 25
diff changeset
30 #include "base_bootloader.h"
ea1003f63e44 ADD GPL License ...
jDG
parents: 25
diff changeset
31 #include "gfx_colors.h"
ea1003f63e44 ADD GPL License ...
jDG
parents: 25
diff changeset
32 #include "gfx_engine.h"
ea1003f63e44 ADD GPL License ...
jDG
parents: 25
diff changeset
33 #include "gfx_fonts.h"
ea1003f63e44 ADD GPL License ...
jDG
parents: 25
diff changeset
34 #include "ostc.h"
ea1003f63e44 ADD GPL License ...
jDG
parents: 25
diff changeset
35
ea1003f63e44 ADD GPL License ...
jDG
parents: 25
diff changeset
36 #include <string.h>
ea1003f63e44 ADD GPL License ...
jDG
parents: 25
diff changeset
37 /* Exported variables --------------------------------------------------------*/
ea1003f63e44 ADD GPL License ...
jDG
parents: 25
diff changeset
38
ea1003f63e44 ADD GPL License ...
jDG
parents: 25
diff changeset
39 /* Private variables ---------------------------------------------------------*/
ea1003f63e44 ADD GPL License ...
jDG
parents: 25
diff changeset
40
ea1003f63e44 ADD GPL License ...
jDG
parents: 25
diff changeset
41 GFX_DrawCfgScreen tIBscreen;
ea1003f63e44 ADD GPL License ...
jDG
parents: 25
diff changeset
42 GFX_DrawCfgWindow tIBwindow;
ea1003f63e44 ADD GPL License ...
jDG
parents: 25
diff changeset
43 uint8_t line = 1;
ea1003f63e44 ADD GPL License ...
jDG
parents: 25
diff changeset
44
ea1003f63e44 ADD GPL License ...
jDG
parents: 25
diff changeset
45 char textButtonLeft[30] = { 0 };
ea1003f63e44 ADD GPL License ...
jDG
parents: 25
diff changeset
46 char textButtonMid[31] = { 0 };
ea1003f63e44 ADD GPL License ...
jDG
parents: 25
diff changeset
47 char textButtonRight[31] = { 0 };
ea1003f63e44 ADD GPL License ...
jDG
parents: 25
diff changeset
48
ea1003f63e44 ADD GPL License ...
jDG
parents: 25
diff changeset
49 /* Private types -------------------------------------------------------------*/
ea1003f63e44 ADD GPL License ...
jDG
parents: 25
diff changeset
50
ea1003f63e44 ADD GPL License ...
jDG
parents: 25
diff changeset
51 /* Private function prototypes -----------------------------------------------*/
ea1003f63e44 ADD GPL License ...
jDG
parents: 25
diff changeset
52
ea1003f63e44 ADD GPL License ...
jDG
parents: 25
diff changeset
53 /* Exported functions --------------------------------------------------------*/
ea1003f63e44 ADD GPL License ...
jDG
parents: 25
diff changeset
54
ea1003f63e44 ADD GPL License ...
jDG
parents: 25
diff changeset
55 void tInfoBootloader_init(void)
ea1003f63e44 ADD GPL License ...
jDG
parents: 25
diff changeset
56 {
ea1003f63e44 ADD GPL License ...
jDG
parents: 25
diff changeset
57 tIBscreen.FBStartAdress = 0;
ea1003f63e44 ADD GPL License ...
jDG
parents: 25
diff changeset
58 tIBscreen.ImageHeight = 480;
ea1003f63e44 ADD GPL License ...
jDG
parents: 25
diff changeset
59 tIBscreen.ImageWidth = 800;
ea1003f63e44 ADD GPL License ...
jDG
parents: 25
diff changeset
60 tIBscreen.LayerIndex = 1;
ea1003f63e44 ADD GPL License ...
jDG
parents: 25
diff changeset
61
ea1003f63e44 ADD GPL License ...
jDG
parents: 25
diff changeset
62 tIBwindow.Image = &tIBscreen;
ea1003f63e44 ADD GPL License ...
jDG
parents: 25
diff changeset
63 tIBwindow.WindowNumberOfTextLines = 6;
ea1003f63e44 ADD GPL License ...
jDG
parents: 25
diff changeset
64 tIBwindow.WindowLineSpacing = 65;
ea1003f63e44 ADD GPL License ...
jDG
parents: 25
diff changeset
65 tIBwindow.WindowTab = 400;
ea1003f63e44 ADD GPL License ...
jDG
parents: 25
diff changeset
66 tIBwindow.WindowX0 = 20;
ea1003f63e44 ADD GPL License ...
jDG
parents: 25
diff changeset
67 tIBwindow.WindowX1 = 779;
ea1003f63e44 ADD GPL License ...
jDG
parents: 25
diff changeset
68 tIBwindow.WindowY0 = 0;
ea1003f63e44 ADD GPL License ...
jDG
parents: 25
diff changeset
69 tIBwindow.WindowY1 = 799;
ea1003f63e44 ADD GPL License ...
jDG
parents: 25
diff changeset
70
ea1003f63e44 ADD GPL License ...
jDG
parents: 25
diff changeset
71 line = 1;
ea1003f63e44 ADD GPL License ...
jDG
parents: 25
diff changeset
72 }
ea1003f63e44 ADD GPL License ...
jDG
parents: 25
diff changeset
73
ea1003f63e44 ADD GPL License ...
jDG
parents: 25
diff changeset
74
ea1003f63e44 ADD GPL License ...
jDG
parents: 25
diff changeset
75 void tInfo_button_text(const char *text_left, const char *text_mid, const char *text_right)
ea1003f63e44 ADD GPL License ...
jDG
parents: 25
diff changeset
76 {
ea1003f63e44 ADD GPL License ...
jDG
parents: 25
diff changeset
77 if(text_left)
ea1003f63e44 ADD GPL License ...
jDG
parents: 25
diff changeset
78 strncpy(textButtonLeft,text_left,30);
ea1003f63e44 ADD GPL License ...
jDG
parents: 25
diff changeset
79 if(text_mid)
ea1003f63e44 ADD GPL License ...
jDG
parents: 25
diff changeset
80 {
ea1003f63e44 ADD GPL License ...
jDG
parents: 25
diff changeset
81 textButtonMid[0] = '\001';
ea1003f63e44 ADD GPL License ...
jDG
parents: 25
diff changeset
82 strncpy(&textButtonMid[1],text_mid,30);
ea1003f63e44 ADD GPL License ...
jDG
parents: 25
diff changeset
83 }
ea1003f63e44 ADD GPL License ...
jDG
parents: 25
diff changeset
84 if(text_right)
ea1003f63e44 ADD GPL License ...
jDG
parents: 25
diff changeset
85 {
ea1003f63e44 ADD GPL License ...
jDG
parents: 25
diff changeset
86 textButtonRight[0] = '\002';
ea1003f63e44 ADD GPL License ...
jDG
parents: 25
diff changeset
87 strncpy(&textButtonRight[1],text_right,30);
ea1003f63e44 ADD GPL License ...
jDG
parents: 25
diff changeset
88 }
ea1003f63e44 ADD GPL License ...
jDG
parents: 25
diff changeset
89 }
ea1003f63e44 ADD GPL License ...
jDG
parents: 25
diff changeset
90
ea1003f63e44 ADD GPL License ...
jDG
parents: 25
diff changeset
91
ea1003f63e44 ADD GPL License ...
jDG
parents: 25
diff changeset
92 void tInfo_newpage(const char *text)
ea1003f63e44 ADD GPL License ...
jDG
parents: 25
diff changeset
93 {
ea1003f63e44 ADD GPL License ...
jDG
parents: 25
diff changeset
94 uint32_t backup = tIBscreen.FBStartAdress;
ea1003f63e44 ADD GPL License ...
jDG
parents: 25
diff changeset
95
ea1003f63e44 ADD GPL License ...
jDG
parents: 25
diff changeset
96 tIBscreen.FBStartAdress = getFrame(18);
ea1003f63e44 ADD GPL License ...
jDG
parents: 25
diff changeset
97 line = 1;
ea1003f63e44 ADD GPL License ...
jDG
parents: 25
diff changeset
98 if(text)
ea1003f63e44 ADD GPL License ...
jDG
parents: 25
diff changeset
99 GFX_write_string(&FontT48, &tIBwindow, text,line);
ea1003f63e44 ADD GPL License ...
jDG
parents: 25
diff changeset
100 line++;
ea1003f63e44 ADD GPL License ...
jDG
parents: 25
diff changeset
101
ea1003f63e44 ADD GPL License ...
jDG
parents: 25
diff changeset
102 if(*textButtonLeft)
ea1003f63e44 ADD GPL License ...
jDG
parents: 25
diff changeset
103 write_content_simple(&tIBscreen, 0, 800, 480-24, &FontT24,textButtonLeft,CLUT_ButtonSurfaceScreen);
ea1003f63e44 ADD GPL License ...
jDG
parents: 25
diff changeset
104 if(*textButtonMid)
ea1003f63e44 ADD GPL License ...
jDG
parents: 25
diff changeset
105 write_content_simple(&tIBscreen, 0, 800, 480-24, &FontT24,textButtonMid,CLUT_ButtonSurfaceScreen);
ea1003f63e44 ADD GPL License ...
jDG
parents: 25
diff changeset
106 if(*textButtonRight)
ea1003f63e44 ADD GPL License ...
jDG
parents: 25
diff changeset
107 write_content_simple(&tIBscreen, 0, 800, 480-24, &FontT24,textButtonRight,CLUT_ButtonSurfaceScreen);
ea1003f63e44 ADD GPL License ...
jDG
parents: 25
diff changeset
108
ea1003f63e44 ADD GPL License ...
jDG
parents: 25
diff changeset
109 GFX_SetFrameTop(tIBscreen.FBStartAdress);
ea1003f63e44 ADD GPL License ...
jDG
parents: 25
diff changeset
110 GFX_change_LTDC();
ea1003f63e44 ADD GPL License ...
jDG
parents: 25
diff changeset
111
ea1003f63e44 ADD GPL License ...
jDG
parents: 25
diff changeset
112 if(backup != 0)
ea1003f63e44 ADD GPL License ...
jDG
parents: 25
diff changeset
113 releaseFrame(18,backup);
ea1003f63e44 ADD GPL License ...
jDG
parents: 25
diff changeset
114 }
ea1003f63e44 ADD GPL License ...
jDG
parents: 25
diff changeset
115
ea1003f63e44 ADD GPL License ...
jDG
parents: 25
diff changeset
116
ea1003f63e44 ADD GPL License ...
jDG
parents: 25
diff changeset
117 void tInfo_write(const char *text)
ea1003f63e44 ADD GPL License ...
jDG
parents: 25
diff changeset
118 {
ea1003f63e44 ADD GPL License ...
jDG
parents: 25
diff changeset
119 if((line > 6) || (tIBscreen.FBStartAdress == 0))
ea1003f63e44 ADD GPL License ...
jDG
parents: 25
diff changeset
120 tInfo_newpage(text);
ea1003f63e44 ADD GPL License ...
jDG
parents: 25
diff changeset
121 else
ea1003f63e44 ADD GPL License ...
jDG
parents: 25
diff changeset
122 {
ea1003f63e44 ADD GPL License ...
jDG
parents: 25
diff changeset
123 if(text)
ea1003f63e44 ADD GPL License ...
jDG
parents: 25
diff changeset
124 GFX_write_string(&FontT48, &tIBwindow, text,line);
ea1003f63e44 ADD GPL License ...
jDG
parents: 25
diff changeset
125 line++;
ea1003f63e44 ADD GPL License ...
jDG
parents: 25
diff changeset
126
ea1003f63e44 ADD GPL License ...
jDG
parents: 25
diff changeset
127 }
ea1003f63e44 ADD GPL License ...
jDG
parents: 25
diff changeset
128 }
ea1003f63e44 ADD GPL License ...
jDG
parents: 25
diff changeset
129
ea1003f63e44 ADD GPL License ...
jDG
parents: 25
diff changeset
130 /* Private functions ---------------------------------------------------------*/