Rev 55 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 55 | Rev 56 | ||
|---|---|---|---|
| Line 87... | Line 87... | ||
| 87 | 87 | ||
| 88 | for (auto i = 0; i < MAX_DISPLAYS; i++) |
88 | for (auto i = 0; i < MAX_DISPLAYS; i++) |
| 89 | { |
89 | { |
| 90 | display_t &display = displays[i]; |
90 | display_t &display = displays[i]; |
| 91 | displayDial_t &dial = dials[i]; |
91 | displayDial_t &dial = dials[i]; |
| 92 | display.clearDisplay (); |
92 | display.clearDisplay (BLACK); |
| 93 | display.setPixelMode (WHITE); |
93 | display.setPixelMode (WHITE); |
| 94 | dial.draw_scale (0, 10, 12, 1, 1); |
94 | dial.draw_scale (0, 10, 12, 1, 1); |
| 95 | dial.draw_limits (); |
95 | dial.draw_limits (); |
| 96 | display.gotoxy (8, 32); |
96 | display.gotoxy (8, 32); |
| 97 | display.printString (large_font, "Display ", 8, WHITE); |
97 | display.printString (large_font, "Display ", 8, WHITE); |
| 98 | display.printString (large_font, i == 0 ? "1" : "2", 1, BLACK); |
98 | display.printString (large_font, i == 0 ? "1" : "2", 1, BLACK); |
| 99 | showMinMax (display, 2, 123, 456); |
99 | showMinMax (display, 2, 123, 456); |
| 100 | 100 | ||
| 101 | display.display (); |
101 | display.display (); |
| - | 102 | context_t &context = contexts[i]; |
|
| - | 103 | context.dial_timer = DialTimeout * 2; // extra long delay before writeback dial setting |
|
| - | 104 | context.dial1 = -1; |
|
| - | 105 | } |
|
| - | 106 | ||
| - | 107 | } |
|
| - | 108 | ||
| - | 109 | // Check to see if there is an observation/instance in the dynamic data array |
|
| - | 110 | // that matches the current observation/instance in the NVRAM |
|
| - | 111 | int |
|
| - | 112 | cc_check_nvram (int dialIndex, int itemIndex) |
|
| - | 113 | { |
|
| - | 114 | if (dialIndex < 0 && dialIndex > MAX_DISPLAYS) |
|
| - | 115 | return -1; |
|
| - | 116 | context_t &context = contexts[dialIndex]; |
|
| - | 117 | // check for timer timeout on consistent timer |
|
| - | 118 | ||
| - | 119 | if (context.dial_timer) |
|
| - | 120 | { |
|
| - | 121 | context.dial_timer--; |
|
| - | 122 | if (context.dial_timer == 0) |
|
| - | 123 | { |
|
| - | 124 | context.dial_timer = DialTimeout; |
|
| - | 125 | int i; |
|
| - | 126 | if (itemIndex < 0) |
|
| - | 127 | { |
|
| - | 128 | for (i = 0; i < PLXItems; i++) |
|
| - | 129 | if (Info[i].observation |
|
| - | 130 | == dial_nvram[dialIndex].data.observation |
|
| - | 131 | && Info[i].instance |
|
| - | 132 | == dial_nvram[dialIndex].data.instance) |
|
| - | 133 | { |
|
| - | 134 | itemIndex = i; |
|
| - | 135 | return itemIndex; |
|
| - | 136 | } |
|
| - | 137 | } |
|
| - | 138 | if (itemIndex == -1) |
|
| - | 139 | itemIndex = dialIndex; // timed out , not in NVRAM, use a default |
|
| - | 140 | ||
| - | 141 | // is this a change since the last timeout ? |
|
| - | 142 | if (Info[itemIndex].observation |
|
| - | 143 | != dial_nvram[dialIndex].data.observation |
|
| - | 144 | || Info[itemIndex].instance |
|
| - | 145 | != dial_nvram[dialIndex].data.instance) |
|
| - | 146 | { |
|
| - | 147 | ||
| - | 148 | // store the observation and instance in the NVRAM, not dial position. |
|
| - | 149 | nvram_info_t curr_val; |
|
| - | 150 | curr_val.data.observation = Info[itemIndex].observation; |
|
| - | 151 | curr_val.data.instance = Info[itemIndex].instance; |
|
| - | 152 | uint32_t addr = (uint32_t) (&dial_nvram[dialIndex]); |
|
| - | 153 | WriteUint32NVRAM (addr, curr_val.u32); |
|
| - | 154 | } |
|
| - | 155 | } |
|
| 102 | } |
156 | } |
| - | 157 | return itemIndex; |
|
| 103 | } |
158 | } |
| 104 | 159 | ||
| 105 | int |
160 | int |
| 106 | cc_display (int dialIndex, int itemIndex, int suppressIndex) |
161 | cc_display (int dialIndex, int itemIndex, int suppressIndex) |
| 107 | 162 | ||
| Line 112... | Line 167... | ||
| 112 | displayDial_t &dial = dials[dialIndex]; |
167 | displayDial_t &dial = dials[dialIndex]; |
| 113 | stm32_halDisplay_t &display = displays[dialIndex]; |
168 | stm32_halDisplay_t &display = displays[dialIndex]; |
| 114 | char buff[10]; |
169 | char buff[10]; |
| 115 | int i; |
170 | int i; |
| 116 | 171 | ||
| 117 | - | ||
| 118 | // check for item suppression |
172 | // check for item suppression |
| 119 | if (itemIndex == suppressIndex) |
173 | if (itemIndex == suppressIndex) |
| 120 | { |
174 | { |
| 121 | context.dial1 = -1; |
175 | context.dial1 = -1; |
| 122 | context.OldObservation = -1; |
176 | context.OldObservation = -1; |
| Line 127... | Line 181... | ||
| 127 | return -1; // we suppressed this display |
181 | return -1; // we suppressed this display |
| 128 | } |
182 | } |
| 129 | 183 | ||
| 130 | // clear startup display off the screen |
184 | // clear startup display off the screen |
| 131 | if (context.OldObservation == -1) |
185 | if (context.OldObservation == -1) |
| 132 | display.clearDisplay (); |
186 | display.clearDisplay (BLACK); |
| 133 | 187 | ||
| 134 | int DataVal = ConvPLX (Data.Sensor[itemIndex].ReadingH, |
- | |
| 135 | Data.Sensor[itemIndex].ReadingL); // data reading |
188 | int DataVal = Info[itemIndex].data; // data reading |
| 136 | int Observation = ConvPLX (Data.Sensor[itemIndex].AddrH, |
189 | int Observation = Info[itemIndex].observation; |
| 137 | Data.Sensor[itemIndex].AddrL); |
- | |
| 138 | int ObservationIndex = ConvPLX (0, Data.Sensor[itemIndex].Instance); |
190 | int ObservationIndex = Info[itemIndex].instance; |
| 139 | // now to convert the readings and format strings |
191 | // now to convert the readings and format strings |
| 140 | // find out limits |
192 | // find out limits |
| 141 | char *msg; |
193 | char *msg; |
| 142 | int len; |
194 | int len; |
| 143 | 195 | ||
| 144 | // if the user presses the dial then reset min/max to current value |
196 | // if the user presses the dial then reset min/max to current value |
| 145 | if (push_pos[dialIndex] == 1) |
197 | if (push_pos[dialIndex] == 1) |
| 146 | { |
198 | { |
| 147 | Max[itemIndex] = DataVal; |
199 | Info[itemIndex].Max = DataVal; |
| 148 | Min[itemIndex] = DataVal; // 12 bit max value |
200 | Info[itemIndex].Min = DataVal; // 12 bit max value |
| 149 | } |
201 | } |
| 150 | 202 | ||
| 151 | if (Observation < PLX_MAX_OBS) |
203 | if (Observation < PLX_MAX_OBS) |
| 152 | { |
204 | { |
| 153 | if (Observation != context.OldObservation |
205 | if (Observation != context.OldObservation |
| 154 | || ObservationIndex != context.OldObservationIndex) |
206 | || ObservationIndex != context.OldObservationIndex) |
| 155 | { |
207 | { |
| 156 | 208 | ||
| 157 | context.dial_timer = DialTimeout; |
- | |
| 158 | - | ||
| 159 | context.dial1 = -1; |
- | |
| 160 | display.clearDisplay (); |
209 | display.clearDisplay (); |
| 161 | dial.draw_scale (DisplayInfo[Observation].Low, |
210 | dial.draw_scale (DisplayInfo[Observation].Low, |
| 162 | DisplayInfo[Observation].High, 12, 1, |
211 | DisplayInfo[Observation].High, 12, 1, |
| 163 | DisplayInfo[Observation].TickScale); |
212 | DisplayInfo[Observation].TickScale); |
| 164 | 213 | ||
| Line 183... | Line 232... | ||
| 183 | context.OldObservationIndex = ObservationIndex; |
232 | context.OldObservationIndex = ObservationIndex; |
| 184 | 233 | ||
| 185 | display.display (); |
234 | display.display (); |
| 186 | 235 | ||
| 187 | } |
236 | } |
| 188 | else |
- | |
| 189 | { |
- | |
| 190 | // check for timer timeout on consistent timer |
- | |
| 191 | if (context.dial_timer) |
- | |
| 192 | { |
- | |
| 193 | context.dial_timer--; |
- | |
| 194 | - | ||
| 195 | if (context.dial_timer == 0) |
- | |
| 196 | { |
- | |
| 197 | uint16_t curr_val = dial_pos[dialIndex]; |
- | |
| 198 | if (curr_val >= 0) // do not write -1 as a setting. |
- | |
| 199 | { |
- | |
| 200 | uint32_t addr = (uint32_t) (&dial_nvram[dialIndex]); |
- | |
| 201 | WriteUint16NVRAM (addr, curr_val); |
- | |
| 202 | } |
- | |
| 203 | } |
- | |
| 204 | } |
- | |
| 205 | } |
- | |
| 206 | 237 | ||
| 207 | } |
238 | } |
| 208 | 239 | ||
| 209 | double max_rdg; |
240 | double max_rdg; |
| 210 | double min_rdg; |
241 | double min_rdg; |
| Line 212... | Line 243... | ||
| 212 | int int_rdg; |
243 | int int_rdg; |
| 213 | int int_max; |
244 | int int_max; |
| 214 | int int_min; |
245 | int int_min; |
| 215 | 246 | ||
| 216 | max_rdg = ConveriMFDRaw2Data (Observation, DisplayInfo[Observation].Units, |
247 | max_rdg = ConveriMFDRaw2Data (Observation, DisplayInfo[Observation].Units, |
| 217 | Max[itemIndex]); |
248 | Info[itemIndex].Max); |
| 218 | min_rdg = ConveriMFDRaw2Data (Observation, DisplayInfo[Observation].Units, |
249 | min_rdg = ConveriMFDRaw2Data (Observation, DisplayInfo[Observation].Units, |
| 219 | Min[itemIndex]); |
250 | Info[itemIndex].Min); |
| 220 | cur_rdg = ConveriMFDRaw2Data (Observation, DisplayInfo[Observation].Units, |
251 | cur_rdg = ConveriMFDRaw2Data (Observation, DisplayInfo[Observation].Units, |
| 221 | DataVal); |
252 | Info[itemIndex].data); |
| 222 | 253 | ||
| 223 | int dp_pos; // where to print the decimal place |
254 | int dp_pos; // where to print the decimal place |
| 224 | float scale = 1.0; |
255 | float scale = 1.0; |
| 225 | switch (DisplayInfo[Observation].DP) |
256 | switch (DisplayInfo[Observation].DP) |
| 226 | { |
257 | { |