Subversion Repositories DashDisplay

Rev

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

Rev 67 Rev 70
Line 13... Line 13...
13
#include "libOLED/stm32_halDisplay.H"
13
#include "libOLED/stm32_halDisplay.H"
14
#include "libOLED/fontclass.H"
14
#include "libOLED/fontclass.H"
15
#include "libOLED/displayDial.H"
15
#include "libOLED/displayDial.H"
16
#include "libPlx/displayInfo.H"
16
#include "libPlx/displayInfo.H"
17
#include "libOLED/ap_math.h"
17
#include "libOLED/ap_math.h"
-
 
18
#include "libSmallPrintf/small_printf.h"
18
 
19
 
19
#include "splash.H"
20
#include "splash.H"
20
 
21
 
21
namespace
22
namespace
22
{
23
{
Line 115... Line 116...
115
        void
116
        void
116
        cc_check_nvram(int dialIndex)
117
        cc_check_nvram(int dialIndex)
117
        {
118
        {
118
                if (dialIndex < 0 && dialIndex > MAX_DISPLAYS)
119
                if (dialIndex < 0 && dialIndex > MAX_DISPLAYS)
119
                        return;
120
                        return;
120
                // algorithm only works when there is a vector of observations  
121
                // algorithm only works when there is a vector of observations
121
                if(PLXItems == 0)
-
 
122
                        return;
122
       
123
                context_t &context = contexts[dialIndex];
123
                context_t &context = contexts[dialIndex];
124
 
124
 
125
                // check for timer timeout on consistent timer
125
                // check for timer timeout on consistent timer
126
 
126
 
127
                if (context.dial_timer)
127
                if (context.dial_timer)
Line 134... Line 134...
134
                                // use dialIndex+1 as tag for data : always non-zero.
134
                                // use dialIndex+1 as tag for data : always non-zero.
135
                                nvram_info_t *dial_nvram = find_nvram_data(dialIndex + 1);
135
                                nvram_info_t *dial_nvram = find_nvram_data(dialIndex + 1);
136
 
136
 
137
                                if (dial_nvram && context.knobPos < 0)
137
                                if (dial_nvram && context.knobPos < 0)
138
                                {
138
                                {
139
                                        for (i = 0; i < PLXItems; i++)
139
                                        for (i = 0; i < MAXRDG; i++)
140
                                                if ((Info[i].observation == dial_nvram->data.observation) && (Info[i].instance == dial_nvram->data.instance))
140
                                                if (isValid(i) && (Info[i].observation == dial_nvram->data.observation) && (Info[i].instance == dial_nvram->data.instance))
141
                                                {
141
                                                {
142
                                                        context.knobPos = i;
142
                                                        context.knobPos = i;
143
                                                        return;
143
                                                        return;
144
                                                }
144
                                                }
145
                                }
145
                                }
146
                                if (context.knobPos == -1)
146
                                if (context.knobPos == -1)
147
                                        context.knobPos = dialIndex; // timed out , not in NVRAM, use a default
147
                                        context.knobPos = dialIndex; // timed out , not in NVRAM, use a default
148
 
148
 
-
 
149
                                // dont save dial info for invalid data
-
 
150
                                if (!isValid(context.knobPos))
-
 
151
                                        return;
149
                                // is this a change since the last timeout ?
152
                                // is this a change since the last timeout ?
-
 
153
 
150
                                if (!dial_nvram || (Info[context.knobPos].observation != dial_nvram->data.observation) || (Info[context.knobPos].instance != dial_nvram->data.instance))
154
                                if (!dial_nvram || (Info[context.knobPos].observation != dial_nvram->data.observation) || (Info[context.knobPos].instance != dial_nvram->data.instance))
151
                                {
155
                                {
152
 
156
 
153
                                        // store the observation and instance in the NVRAM, not dial position.
157
                                        // store the observation and instance in the NVRAM, not dial position.
154
                                        nvram_info_t curr_val;
158
                                        nvram_info_t curr_val;
Line 172... Line 176...
172
                displayDial_t &dial = dials[dialIndex];
176
                displayDial_t &dial = dials[dialIndex];
173
                stm32_halDisplay_t &display = displays[dialIndex];
177
                stm32_halDisplay_t &display = displays[dialIndex];
174
                int itemIndex = context.knobPos;
178
                int itemIndex = context.knobPos;
175
                char buff[10];
179
                char buff[10];
176
                int i;
180
                int i;
-
 
181
                char *msg;
-
 
182
                int len;
177
 
183
 
178
                // check for item suppression
184
                // check for item suppression
179
                if (itemIndex == suppressIndex)
185
                if (itemIndex == suppressIndex)
180
                {
186
                {
181
                        context.dial1 = -1;
187
                        context.dial1 = -1;
182
                        context.OldObservation = -1;
188
                        context.OldObservation = -1;
183
                        context.OldObservationIndex = -1;
189
                        context.OldObservationIndex = -1;
184
 
190
 
185
                        display.clearDisplay();
191
                        display.clearDisplay(BLACK);
-
 
192
                        i = small_sprintf(buff, "Supp-%02d", itemIndex);
-
 
193
                        display.gotoxy(64 - i * 4, 48);
-
 
194
                        display.printString(large_font, buff, i, WHITE);
-
 
195
 
186
                        display.display();
196
                        display.display();
187
                        return -1; // we suppressed this display
197
                        return -1; // we suppressed this display
188
                }
198
                }
189
 
199
 
-
 
200
                // check for item validity 
-
 
201
                if(!isValid(itemIndex))
-
 
202
                {
-
 
203
                        context.dial1 = -1;
-
 
204
                        context.OldObservation = -1;
-
 
205
                        context.OldObservationIndex = -1;
-
 
206
                        display.clearDisplay(BLACK);
-
 
207
                        i = small_sprintf(buff, "Inval-%02d", itemIndex);
-
 
208
                        display.gotoxy(64 - i * 4, 48);
-
 
209
                        display.printString(large_font, buff, i, WHITE);
-
 
210
 
-
 
211
                        display.display();
-
 
212
                        return itemIndex;
-
 
213
                }
-
 
214
 
190
                // clear startup display off the screen
215
                // clear startup display off the screen
191
                if (context.OldObservation == -1)
216
                if (context.OldObservation == -1)
192
                        display.clearDisplay(BLACK);
217
                        display.clearDisplay(BLACK);
193
 
218
 
194
                int DataVal = Info[itemIndex].data; // data reading
219
                int DataVal = Info[itemIndex].data; // data reading
195
                int Observation = Info[itemIndex].observation;
220
                int Observation = Info[itemIndex].observation;
196
                int ObservationIndex = Info[itemIndex].instance;
221
                int ObservationIndex = Info[itemIndex].instance;
197
                // now to convert the readings and format strings
222
                // now to convert the readings and format strings
198
                // find out limits
223
                // find out limits
199
                char *msg;
-
 
200
                int len;
-
 
201
 
224
 
202
                // if the user presses the dial then reset min/max to current value
225
                // if the user presses the dial then reset min/max to current value
203
                if (push_pos[dialIndex] == 1)
226
                if (push_pos[dialIndex] == 1)
204
                {
227
                {
205
                        Info[itemIndex].Max = DataVal;
228
                        Info[itemIndex].Max = DataVal;
Line 210... Line 233...
210
                if (Observation < PLX_MAX_OBS)
233
                if (Observation < PLX_MAX_OBS)
211
                {
234
                {
212
                        if (Observation != context.OldObservation || ObservationIndex != context.OldObservationIndex)
235
                        if (Observation != context.OldObservation || ObservationIndex != context.OldObservationIndex)
213
                        {
236
                        {
214
 
237
 
215
                                display.clearDisplay();
238
                                display.clearDisplay(BLACK);
216
                                dial.draw_scale(DisplayInfo[Observation].Low,
239
                                dial.draw_scale(DisplayInfo[Observation].Low,
217
                                                                DisplayInfo[Observation].High, 12, 1,
240
                                                                DisplayInfo[Observation].High, 12, 1,
218
                                                                DisplayInfo[Observation].TickScale);
241
                                                                DisplayInfo[Observation].TickScale);
219
 
242
 
220
                                dial.draw_limits();
243
                                dial.draw_limits();