Subversion Repositories DashDisplay

Rev

Rev 72 | Rev 75 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 72 Rev 74
Line 22... Line 22...
22
namespace
22
namespace
23
{
23
{
24
        int const WIDTH = 128;
24
        int const WIDTH = 128;
25
        int const HEIGHT = 64;
25
        int const HEIGHT = 64;
26
        int const DISPLAY_RAMWIDTH = 132;
26
        int const DISPLAY_RAMWIDTH = 132;
-
 
27
 
-
 
28
        uniqueObs_t const nullObs = {PLX_MAX_OBS, PLX_MAX_INST};
27
}
29
}
28
 
30
 
29
uint8_t displayBuffer[2][dataSize(WIDTH, HEIGHT)];
31
uint8_t displayBuffer[2][dataSize(WIDTH, HEIGHT)];
30
 
32
 
31
stm32_halDisplay_t displays[MAX_DISPLAYS] =
33
stm32_halDisplay_t displays[MAX_DISPLAYS] =
Line 103... Line 105...
103
                        display.setPixelMode(WHITE);
105
                        display.setPixelMode(WHITE);
104
                        display.display();
106
                        display.display();
105
                        context_t &context = contexts[i];
107
                        context_t &context = contexts[i];
106
                        context.dial_timer = 500; // enough time to see at least one frame of PLX before NVRAM check
108
                        context.dial_timer = 500; // enough time to see at least one frame of PLX before NVRAM check
107
                        context.dial1 = -1;
109
                        context.dial1 = -1;
108
                        context.OldObservation = -1;
110
                        context.OldObservation = nullObs;
109
                        context.OldObservationIndex = -1;
-
 
110
                }
111
                }
111
        }
112
        }
112
 
113
 
113
        // Check to see if there is an observation/instance in the dynamic data array
114
        // Check to see if there is an observation/instance in the dynamic data array
114
        // that matches the current observation/instance in the NVRAM
115
        // that matches the current observation/instance in the NVRAM
Line 117... Line 118...
117
        cc_check_nvram(int dialIndex)
118
        cc_check_nvram(int dialIndex)
118
        {
119
        {
119
                if (dialIndex < 0 && dialIndex > MAX_DISPLAYS)
120
                if (dialIndex < 0 && dialIndex > MAX_DISPLAYS)
120
                        return;
121
                        return;
121
                // algorithm only works when there is a vector of observations
122
                // algorithm only works when there is a vector of observations
122
       
123
 
123
                context_t &context = contexts[dialIndex];
124
                context_t &context = contexts[dialIndex];
124
 
125
 
125
                // check for timer timeout on consistent timer
126
                // check for timer timeout on consistent timer
126
 
127
 
127
                if (context.dial_timer)
128
                if (context.dial_timer)
Line 135... Line 136...
135
                                nvram_info_t *dial_nvram = find_nvram_data(dialIndex + 1);
136
                                nvram_info_t *dial_nvram = find_nvram_data(dialIndex + 1);
136
 
137
 
137
                                if (dial_nvram && context.knobPos < 0)
138
                                if (dial_nvram && context.knobPos < 0)
138
                                {
139
                                {
139
                                        for (i = 0; i < MAXRDG; i++)
140
                                        for (i = 0; i < MAXRDG; i++)
140
                                                if (isValid(i) && (Info[i].observation == dial_nvram->data.observation) && (Info[i].instance == dial_nvram->data.instance))
141
                                                if (isValid(i) && (Info[i].observation.Obs == dial_nvram->data.observation) && (Info[i].observation.Instance == dial_nvram->data.instance))
141
                                                {
142
                                                {
142
                                                        context.knobPos = i;
143
                                                        context.knobPos = i;
143
                                                        return;
144
                                                        return;
144
                                                }
145
                                                }
145
                                }
146
                                }
Line 149... Line 150...
149
                                // dont save dial info for invalid data
150
                                // dont save dial info for invalid data
150
                                if (!isValid(context.knobPos))
151
                                if (!isValid(context.knobPos))
151
                                        return;
152
                                        return;
152
                                // is this a change since the last timeout ?
153
                                // is this a change since the last timeout ?
153
 
154
 
154
                                if (!dial_nvram || (Info[context.knobPos].observation != dial_nvram->data.observation) || (Info[context.knobPos].instance != dial_nvram->data.instance))
155
                                if (!dial_nvram || (Info[context.knobPos].observation.Obs != dial_nvram->data.observation) || (Info[context.knobPos].observation.Instance != dial_nvram->data.instance))
155
                                {
156
                                {
156
 
157
 
157
                                        // store the observation and instance in the NVRAM, not dial position.
158
                                        // store the observation and instance in the NVRAM, not dial position.
158
                                        nvram_info_t curr_val;
159
                                        nvram_info_t curr_val;
159
                                        curr_val.data.observation = Info[context.knobPos].observation;
160
                                        curr_val.data.observation = Info[context.knobPos].observation.Obs;
160
                                        curr_val.data.instance = Info[context.knobPos].instance;
161
                                        curr_val.data.instance = Info[context.knobPos].observation.Instance;
161
                                        curr_val.data.tag = dialIndex + 1;
162
                                        curr_val.data.tag = dialIndex + 1;
162
 
163
 
163
                                        write_nvram_data(curr_val);
164
                                        write_nvram_data(curr_val);
164
                                }
165
                                }
165
                        }
166
                        }
Line 168... Line 169...
168
 
169
 
169
        int
170
        int
170
        cc_display(int dialIndex, int suppressIndex)
171
        cc_display(int dialIndex, int suppressIndex)
171
 
172
 
172
        {
173
        {
173
       
174
 
174
               
-
 
175
                if (dialIndex < 0 && dialIndex > MAX_DISPLAYS)
175
                if (dialIndex < 0 && dialIndex > MAX_DISPLAYS)
176
                        return -1;
176
                        return -1;
177
                context_t &context = contexts[dialIndex];
177
                context_t &context = contexts[dialIndex];
178
                displayDial_t &dial = dials[dialIndex];
178
                displayDial_t &dial = dials[dialIndex];
179
                stm32_halDisplay_t &display = displays[dialIndex];
179
                stm32_halDisplay_t &display = displays[dialIndex];
180
                int itemIndex = context.knobPos;
180
                int itemIndex = context.knobPos;
181
                char buff[10];
181
                char buff[10];
182
                int i;
182
                int i;
183
                char *msg;
183
                char *msg;
184
                int len;
184
                int len;
185
                // check for startup phase 
185
                // check for startup phase
186
                if (itemIndex < 0)
186
                if (itemIndex < 0)
187
                {
187
                {
188
                        display.clearDisplay(BLACK);
188
                        display.clearDisplay(BLACK);
189
                        i = small_sprintf(buff, "Wait");
189
                        i = small_sprintf(buff, "Wait");
190
                        display.gotoxy(64 - i * 4, 48);
190
                        display.gotoxy(64 - i * 4, 48);
191
                        display.printString(large_font, buff, i, WHITE);
191
                        display.printString(large_font, buff, i, WHITE);
192
 
192
 
193
                        display.display();
193
                        display.display();
194
                        return -1;
194
                        return -1;
195
                }
195
                }
196
 
196
 
197
 
-
 
198
 
-
 
199
                // check for item suppression
197
                // check for item suppression
200
                if (itemIndex == suppressIndex)
198
                if (itemIndex == suppressIndex)
201
                {
199
                {
202
                        context.dial1 = -1;
200
                        context.dial1 = -1;
203
                        context.OldObservation = -1;
201
                        context.OldObservation = nullObs;
204
                        context.OldObservationIndex = -1;
-
 
205
 
-
 
206
                        display.clearDisplay(BLACK);
202
                        display.clearDisplay(BLACK);
207
                        i = small_sprintf(buff, "Supp-%02d", itemIndex);
203
                        i = small_sprintf(buff, "Supp-%02d", itemIndex);
208
                        display.gotoxy(64 - i * 4, 48);
204
                        display.gotoxy(64 - i * 4, 48);
209
                        display.printString(large_font, buff, i, WHITE);
205
                        display.printString(large_font, buff, i, WHITE);
210
 
206
 
211
                        display.display();
207
                        display.display();
212
                        return -1; // we suppressed this display
208
                        return -1; // we suppressed this display
213
                }
209
                }
214
 
210
 
215
                // check for item validity 
211
                // check for item validity
216
                if(!isValid(itemIndex))
212
                if (!isValid(itemIndex))
217
                {
213
                {
218
                        context.dial1 = -1;
214
                        context.dial1 = -1;
219
                        context.OldObservation = -1;
215
                        context.OldObservation = nullObs;
220
                        context.OldObservationIndex = -1;
-
 
221
                        display.clearDisplay(BLACK);
216
                        display.clearDisplay(BLACK);
222
                        i = small_sprintf(buff, "Inval-%02d", itemIndex);
217
                        i = small_sprintf(buff, "Inval-%02d", itemIndex);
223
                        display.gotoxy(64 - i * 4, 48);
218
                        display.gotoxy(64 - i * 4, 48);
224
                        display.printString(large_font, buff, i, WHITE);
219
                        display.printString(large_font, buff, i, WHITE);
225
 
220
 
226
                        display.display();
221
                        display.display();
227
                        return itemIndex;
222
                        return itemIndex;
228
                }
223
                }
229
 
224
 
230
                // clear startup display off the screen
225
                // clear startup display off the screen
231
                if (context.OldObservation == -1)
226
                if (context.OldObservation.Obs == -1)
232
                        display.clearDisplay(BLACK);
227
                        display.clearDisplay(BLACK);
233
 
228
 
234
                int DataVal = Info[itemIndex].data; // data reading
229
                int DataVal = Info[itemIndex].data; // data reading
235
                int Observation = Info[itemIndex].observation;
230
                PLX_Observations Observation = Info[itemIndex].observation.Obs;
236
                int ObservationIndex = Info[itemIndex].instance;
231
                uint8_t Instance = Info[itemIndex].observation.Instance;
237
                // now to convert the readings and format strings
232
                // now to convert the readings and format strings
238
                // find out limits
233
                // find out limits
239
 
-
 
240
                // if the user presses the dial then reset min/max to current value
234
                // if the user presses the dial then reset min/max to current value
241
                if (push_pos[dialIndex] == 1)
235
                if (push_pos[dialIndex] == 1)
242
                {
236
                {
243
                        Info[itemIndex].Max = DataVal;
237
                        Info[itemIndex].Max = DataVal;
244
                        Info[itemIndex].Min = DataVal; // 12 bit max value
238
                        Info[itemIndex].Min = DataVal; // 12 bit max value
245
                }
239
                }
246
 
240
 
247
                // detect change in observation being displayed, reset the dial
241
                // detect change in observation being displayed, reset the dial
248
                if (Observation < PLX_MAX_OBS)
242
                if (Observation < PLX_MAX_OBS)
249
                {
243
                {
250
                        if (Observation != context.OldObservation || ObservationIndex != context.OldObservationIndex)
244
                        if (Observation != context.OldObservation.Obs || Instance != context.OldObservation.Instance)
251
                        {
245
                        {
252
 
246
 
253
                                display.clearDisplay(BLACK);
247
                                display.clearDisplay(BLACK);
254
                                dial.draw_scale(DisplayInfo[Observation].Low,
248
                                dial.draw_scale(DisplayInfo[Observation].Low,
255
                                                                DisplayInfo[Observation].High, 12, 1,
249
                                                                DisplayInfo[Observation].High, 12, 1,
Line 257... Line 251...
257
 
251
 
258
                                dial.draw_limits();
252
                                dial.draw_limits();
259
 
253
 
260
                                msg = DisplayInfo[Observation].name;
254
                                msg = DisplayInfo[Observation].name;
261
                                len = 7;
255
                                len = 7;
262
                                int len1 = ObservationIndex > 0 ? len - 1 : len;
256
                                int len1 = Instance > 0 ? len - 1 : len;
263
                                for (i = 0; i < len1 && msg[i]; i++)
257
                                for (i = 0; i < len1 && msg[i]; i++)
264
                                {
258
                                {
265
                                        buff[i] = msg[i];
259
                                        buff[i] = msg[i];
266
                                }
260
                                }
267
                                if (ObservationIndex > 0 && i < len)
261
                                if (Instance > 0 && i < len)
268
                                {
262
                                {
269
                                        buff[i++] = ObservationIndex + '1';
263
                                        buff[i++] = Instance + '1';
270
                                }
264
                                }
271
 
265
 
272
                                display.gotoxy(64 - i * 4, 48);
266
                                display.gotoxy(64 - i * 4, 48);
273
                                display.printString(large_font, buff, i, WHITE);
267
                                display.printString(large_font, buff, i, WHITE);
274
 
268
 
275
                                context.OldObservation = Observation;
269
                                context.OldObservation.Obs = Observation;
276
                                context.OldObservationIndex = ObservationIndex;
270
                                context.OldObservation.Instance = Instance;
277
                                context.dial1 = -1; // do not display old needle, cleared screen
271
                                context.dial1 = -1; // do not display old needle, cleared screen
278
                                display.display();
272
                                display.display();
279
                        }
273
                        }
280
                }
274
                }
281
 
275
 
Line 343... Line 337...
343
                }
337
                }
344
                else
338
                else
345
                {
339
                {
346
                        if (Info[itemIndex].lastUpdated && ((HAL_GetTick() - Info[itemIndex].lastUpdated) > 1000))
340
                        if (Info[itemIndex].lastUpdated && ((HAL_GetTick() - Info[itemIndex].lastUpdated) > 1000))
347
                        {
341
                        {
348
                                context.OldObservation = -1;     // force a redraw of axes on next entry point
342
                                context.OldObservation = nullObs; // force a redraw on next update
349
                                Info[itemIndex].lastUpdated = 0; // and stop further timeouts.
343
                                Info[itemIndex].lastUpdated = 0;  // and stop further timeouts.
350
                        }
344
                        }
351
                }
345
                }
352
 
346
 
353
                display.gotoxy(0, 32);
347
                display.gotoxy(0, 32);
354
 
348