Mercurial > public > ostc4
annotate Discovery/Src/tMenuSetpoint.c @ 813:1e688b630a6e
Used real sensor state in simulation:
In previous version the status information of the digital O2 sensors were not forwarded to the simulator. As result the simulator did not show the failure reaction in case of error injection using the RTE.
In the new version the status information provided by RTE is used within the simulator.
author | Ideenmodellierer |
---|---|
date | Sun, 03 Sep 2023 17:53:07 +0200 |
parents | 4c41d9a18c7f |
children | c4ee952b9425 |
rev | line source |
---|---|
38 | 1 /////////////////////////////////////////////////////////////////////////////// |
2 /// -*- coding: UTF-8 -*- | |
3 /// | |
4 /// \file Discovery/Src/tMenuSetpoint.c | |
5 /// \brief | |
6 /// \author heinrichs weikamp gmbh | |
7 /// \date 19-Dec-2014 | |
8 /// | |
9 /// \details | |
10 /// | |
11 /// $Id$ | |
12 /////////////////////////////////////////////////////////////////////////////// | |
13 /// \par Copyright (c) 2014-2018 Heinrichs Weikamp gmbh | |
14 /// | |
15 /// This program is free software: you can redistribute it and/or modify | |
16 /// it under the terms of the GNU General Public License as published by | |
17 /// the Free Software Foundation, either version 3 of the License, or | |
18 /// (at your option) any later version. | |
19 /// | |
20 /// This program is distributed in the hope that it will be useful, | |
21 /// but WITHOUT ANY WARRANTY; without even the implied warranty of | |
22 /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
23 /// GNU General Public License for more details. | |
24 /// | |
25 /// You should have received a copy of the GNU General Public License | |
26 /// along with this program. If not, see <http://www.gnu.org/licenses/>. | |
27 ////////////////////////////////////////////////////////////////////////////// | |
28 | |
29 /* Includes ------------------------------------------------------------------*/ | |
30 #include "tMenu.h" | |
788
4abfb8a2a435
Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents:
662
diff
changeset
|
31 #include "tMenuEditSetpoint.h" |
38 | 32 #include "tMenuSetpoint.h" |
33 #include "unit.h" | |
34 | |
35 /* Private function prototypes -----------------------------------------------*/ | |
36 | |
37 /* Exported functions --------------------------------------------------------*/ | |
38 | |
788
4abfb8a2a435
Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents:
662
diff
changeset
|
39 uint32_t tMSP_refresh(char *text, uint16_t *tab, char *subtext) |
38 | 40 { |
788
4abfb8a2a435
Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents:
662
diff
changeset
|
41 SSettings *settings = settingsGetPointer(); |
4abfb8a2a435
Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents:
662
diff
changeset
|
42 |
38 | 43 const SSetpointLine * pSetpointLine; |
44 | |
788
4abfb8a2a435
Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents:
662
diff
changeset
|
45 uint8_t textPointer, setpoint_cbar, depthUp, first; |
38 | 46 |
47 if(actual_menu_content == MENU_SURFACE) | |
788
4abfb8a2a435
Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents:
662
diff
changeset
|
48 pSetpointLine = settings->setpoint; |
38 | 49 else |
50 pSetpointLine = stateUsed->diveSettings.setpoint; | |
51 | |
52 textPointer = 0; | |
53 *tab = 130; | |
54 *subtext = 0; | |
55 | |
662 | 56 if((actual_menu_content == MENU_SURFACE) || (stateUsed->diveSettings.diveMode != DIVEMODE_PSCR)) /* do not show setpoints in PSCR mode */ |
38 | 57 { |
811
4c41d9a18c7f
Added function to skip lines which are not needed for operation:
Ideenmodellierer
parents:
792
diff
changeset
|
58 if (settings->autoSetpoint) { |
4c41d9a18c7f
Added function to skip lines which are not needed for operation:
Ideenmodellierer
parents:
792
diff
changeset
|
59 disableLine(StMSP_Blank); |
4c41d9a18c7f
Added function to skip lines which are not needed for operation:
Ideenmodellierer
parents:
792
diff
changeset
|
60 } |
4c41d9a18c7f
Added function to skip lines which are not needed for operation:
Ideenmodellierer
parents:
792
diff
changeset
|
61 else { |
4c41d9a18c7f
Added function to skip lines which are not needed for operation:
Ideenmodellierer
parents:
792
diff
changeset
|
62 enableLine(StMSP_Blank); |
4c41d9a18c7f
Added function to skip lines which are not needed for operation:
Ideenmodellierer
parents:
792
diff
changeset
|
63 } |
662 | 64 for(int spId=1;spId<=NUM_GASES;spId++) |
65 { | |
788
4abfb8a2a435
Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents:
662
diff
changeset
|
66 if (settings->autoSetpoint) { |
811
4c41d9a18c7f
Added function to skip lines which are not needed for operation:
Ideenmodellierer
parents:
792
diff
changeset
|
67 disableLine(StMSP_Blank); |
789
b7cd0c5c8e43
When using automatic setpoint switching, allow the user to set an arbitrary ppO2 as a custom setpoint during the dive.
heinrichsweikamp
parents:
788
diff
changeset
|
68 if (spId == 5) { |
b7cd0c5c8e43
When using automatic setpoint switching, allow the user to set an arbitrary ppO2 as a custom setpoint during the dive.
heinrichsweikamp
parents:
788
diff
changeset
|
69 if (actual_menu_content == MENU_SURFACE) { |
b7cd0c5c8e43
When using automatic setpoint switching, allow the user to set an arbitrary ppO2 as a custom setpoint during the dive.
heinrichsweikamp
parents:
788
diff
changeset
|
70 textPointer += snprintf(&text[textPointer], 40, "\020%c%c\016\016%c%c\017 %c%c\002%c\n\r", TXT_2BYTE, TXT2BYTE_SetpointShort, TXT_2BYTE, TXT2BYTE_SetpointLow, TXT_2BYTE, TXT2BYTE_SetpointDelayed, settings->delaySetpointLow ? '\005' : '\006'); |
b7cd0c5c8e43
When using automatic setpoint switching, allow the user to set an arbitrary ppO2 as a custom setpoint during the dive.
heinrichsweikamp
parents:
788
diff
changeset
|
71 } else { |
b7cd0c5c8e43
When using automatic setpoint switching, allow the user to set an arbitrary ppO2 as a custom setpoint during the dive.
heinrichsweikamp
parents:
788
diff
changeset
|
72 textPointer += snprintf(&text[textPointer], 40, "\020%c%c %c%c\n\r", TXT_2BYTE, TXT2BYTE_Custom, TXT_2BYTE, TXT2BYTE_Setpoint); |
b7cd0c5c8e43
When using automatic setpoint switching, allow the user to set an arbitrary ppO2 as a custom setpoint during the dive.
heinrichsweikamp
parents:
788
diff
changeset
|
73 } |
b7cd0c5c8e43
When using automatic setpoint switching, allow the user to set an arbitrary ppO2 as a custom setpoint during the dive.
heinrichsweikamp
parents:
788
diff
changeset
|
74 |
788
4abfb8a2a435
Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents:
662
diff
changeset
|
75 continue; |
4abfb8a2a435
Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents:
662
diff
changeset
|
76 } else if (spId > SETPOINT_INDEX_AUTO_DECO) { |
4abfb8a2a435
Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents:
662
diff
changeset
|
77 textPointer += snprintf(&text[textPointer], 3, "\n\r"); |
38 | 78 |
788
4abfb8a2a435
Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents:
662
diff
changeset
|
79 continue; |
4abfb8a2a435
Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents:
662
diff
changeset
|
80 } |
4abfb8a2a435
Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents:
662
diff
changeset
|
81 } |
38 | 82 |
788
4abfb8a2a435
Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents:
662
diff
changeset
|
83 setpoint_cbar = pSetpointLine[spId].setpoint_cbar; |
4abfb8a2a435
Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents:
662
diff
changeset
|
84 depthUp = pSetpointLine[spId].depth_meter; |
4abfb8a2a435
Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents:
662
diff
changeset
|
85 first = pSetpointLine[spId].note.ub.first; |
4abfb8a2a435
Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents:
662
diff
changeset
|
86 |
792
25103f5c7e29
Avoid a configuration warning after the firmware upgrade by disabling automatic setpoint switching. This makes sure the user's automatic setpoint configuration is not overwritten by the validity checks if the settings are not in the correct spots for the new configuration. Users will have to manually re-create the automatic setpoint switching configuration in the new format;
heinrichsweikamp
parents:
789
diff
changeset
|
87 char colour; |
788
4abfb8a2a435
Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents:
662
diff
changeset
|
88 if (settings->autoSetpoint && spId == SETPOINT_INDEX_AUTO_DECO && !pSetpointLine[spId].note.ub.active) { |
792
25103f5c7e29
Avoid a configuration warning after the firmware upgrade by disabling automatic setpoint switching. This makes sure the user's automatic setpoint configuration is not overwritten by the validity checks if the settings are not in the correct spots for the new configuration. Users will have to manually re-create the automatic setpoint switching configuration in the new format;
heinrichsweikamp
parents:
789
diff
changeset
|
89 colour = '\031'; |
788
4abfb8a2a435
Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents:
662
diff
changeset
|
90 } else { |
792
25103f5c7e29
Avoid a configuration warning after the firmware upgrade by disabling automatic setpoint switching. This makes sure the user's automatic setpoint configuration is not overwritten by the validity checks if the settings are not in the correct spots for the new configuration. Users will have to manually re-create the automatic setpoint switching configuration in the new format;
heinrichsweikamp
parents:
789
diff
changeset
|
91 colour = '\020'; |
788
4abfb8a2a435
Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents:
662
diff
changeset
|
92 } |
38 | 93 |
788
4abfb8a2a435
Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents:
662
diff
changeset
|
94 uint8_t setpointBar = setpoint_cbar / 100; |
38 | 95 |
792
25103f5c7e29
Avoid a configuration warning after the firmware upgrade by disabling automatic setpoint switching. This makes sure the user's automatic setpoint configuration is not overwritten by the validity checks if the settings are not in the correct spots for the new configuration. Users will have to manually re-create the automatic setpoint switching configuration in the new format;
heinrichsweikamp
parents:
789
diff
changeset
|
96 textPointer += snprintf(&text[textPointer], 4, "%c%c%c", colour, TXT_2BYTE, TXT2BYTE_SetpointShort); |
788
4abfb8a2a435
Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents:
662
diff
changeset
|
97 textPointer += printSetpointName(&text[textPointer], spId, settings, true); |
792
25103f5c7e29
Avoid a configuration warning after the firmware upgrade by disabling automatic setpoint switching. This makes sure the user's automatic setpoint configuration is not overwritten by the validity checks if the settings are not in the correct spots for the new configuration. Users will have to manually re-create the automatic setpoint switching configuration in the new format;
heinrichsweikamp
parents:
789
diff
changeset
|
98 |
25103f5c7e29
Avoid a configuration warning after the firmware upgrade by disabling automatic setpoint switching. This makes sure the user's automatic setpoint configuration is not overwritten by the validity checks if the settings are not in the correct spots for the new configuration. Users will have to manually re-create the automatic setpoint switching configuration in the new format;
heinrichsweikamp
parents:
789
diff
changeset
|
99 text[textPointer++] = '\t'; |
38 | 100 |
788
4abfb8a2a435
Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents:
662
diff
changeset
|
101 if (first == 0 || actual_menu_content != MENU_SURFACE) { |
4abfb8a2a435
Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents:
662
diff
changeset
|
102 strcpy(&text[textPointer++],"\177"); |
4abfb8a2a435
Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents:
662
diff
changeset
|
103 } |
38 | 104 |
788
4abfb8a2a435
Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents:
662
diff
changeset
|
105 textPointer += snprintf(&text[textPointer], 40, "* %u.%02u\016\016 bar\017\034 \016\016 \017", setpointBar, setpoint_cbar - (100 * setpointBar)); |
4abfb8a2a435
Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents:
662
diff
changeset
|
106 if (!settings->autoSetpoint || spId < SETPOINT_INDEX_AUTO_DECO) { |
792
25103f5c7e29
Avoid a configuration warning after the firmware upgrade by disabling automatic setpoint switching. This makes sure the user's automatic setpoint configuration is not overwritten by the validity checks if the settings are not in the correct spots for the new configuration. Users will have to manually re-create the automatic setpoint switching configuration in the new format;
heinrichsweikamp
parents:
789
diff
changeset
|
107 if (depthUp) { |
25103f5c7e29
Avoid a configuration warning after the firmware upgrade by disabling automatic setpoint switching. This makes sure the user's automatic setpoint configuration is not overwritten by the validity checks if the settings are not in the correct spots for the new configuration. Users will have to manually re-create the automatic setpoint switching configuration in the new format;
heinrichsweikamp
parents:
789
diff
changeset
|
108 colour = '\020'; |
25103f5c7e29
Avoid a configuration warning after the firmware upgrade by disabling automatic setpoint switching. This makes sure the user's automatic setpoint configuration is not overwritten by the validity checks if the settings are not in the correct spots for the new configuration. Users will have to manually re-create the automatic setpoint switching configuration in the new format;
heinrichsweikamp
parents:
789
diff
changeset
|
109 } else { |
25103f5c7e29
Avoid a configuration warning after the firmware upgrade by disabling automatic setpoint switching. This makes sure the user's automatic setpoint configuration is not overwritten by the validity checks if the settings are not in the correct spots for the new configuration. Users will have to manually re-create the automatic setpoint switching configuration in the new format;
heinrichsweikamp
parents:
789
diff
changeset
|
110 colour = '\031'; |
25103f5c7e29
Avoid a configuration warning after the firmware upgrade by disabling automatic setpoint switching. This makes sure the user's automatic setpoint configuration is not overwritten by the validity checks if the settings are not in the correct spots for the new configuration. Users will have to manually re-create the automatic setpoint switching configuration in the new format;
heinrichsweikamp
parents:
789
diff
changeset
|
111 } |
788
4abfb8a2a435
Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents:
662
diff
changeset
|
112 |
792
25103f5c7e29
Avoid a configuration warning after the firmware upgrade by disabling automatic setpoint switching. This makes sure the user's automatic setpoint configuration is not overwritten by the validity checks if the settings are not in the correct spots for the new configuration. Users will have to manually re-create the automatic setpoint switching configuration in the new format;
heinrichsweikamp
parents:
789
diff
changeset
|
113 textPointer += snprintf(&text[textPointer], 40, "%c%3u\016\016 \035%c%c\017\n\r", colour, unit_depth_integer(depthUp), unit_depth_char1(), unit_depth_char2()); |
788
4abfb8a2a435
Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents:
662
diff
changeset
|
114 } else { |
792
25103f5c7e29
Avoid a configuration warning after the firmware upgrade by disabling automatic setpoint switching. This makes sure the user's automatic setpoint configuration is not overwritten by the validity checks if the settings are not in the correct spots for the new configuration. Users will have to manually re-create the automatic setpoint switching configuration in the new format;
heinrichsweikamp
parents:
789
diff
changeset
|
115 textPointer += snprintf(&text[textPointer], 14, " %c\016\016 \035%c%c\017\n\r", pSetpointLine[spId].note.ub.active ? '\005' : '\006', TXT_2BYTE, TXT2BYTE_Enabled); |
788
4abfb8a2a435
Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents:
662
diff
changeset
|
116 } |
662 | 117 } |
38 | 118 } |
788
4abfb8a2a435
Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents:
662
diff
changeset
|
119 if (actual_menu_content != MENU_SURFACE) { |
38 | 120 text[textPointer++] = '\020'; |
121 text[textPointer++] = TXT_2BYTE; | |
122 text[textPointer++] = TXT2BYTE_UseSensor; | |
123 text[textPointer++] = '\n'; | |
124 text[textPointer++] = '\r'; | |
662 | 125 |
126 | |
127 if(stateUsed->diveSettings.diveMode == DIVEMODE_PSCR) | |
128 { | |
788
4abfb8a2a435
Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents:
662
diff
changeset
|
129 textPointer += snprintf(&text[textPointer], 20,"\020%c", TXT_SimPpo2); |
662 | 130 } |
38 | 131 text[textPointer++] = 0; |
132 } | |
650 | 133 else |
134 { | |
135 text[textPointer++] = '\020'; | |
136 text[textPointer++] = TXT_2BYTE; | |
137 text[textPointer++] = TXT2BYTE_AutomaticSP; | |
138 text[textPointer++] = '\002'; | |
788
4abfb8a2a435
Define explicit setpoints for low / high / deco. Add an option to delay the switch to SPlow until all decompression has been cleared. (mikeller)
heinrichsweikamp
parents:
662
diff
changeset
|
139 if (settings->autoSetpoint) |
650 | 140 text[textPointer++] = '\005'; |
141 else | |
142 text[textPointer++] = '\006'; | |
143 text[textPointer++] = 0; | |
144 } | |
38 | 145 return StMSP; |
146 } |