Rev 56 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 56 | Rev 57 | ||
---|---|---|---|
Line 86... | Line 86... | ||
86 | HAL_Delay (1000); |
86 | HAL_Delay (1000); |
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]; |
- | |
92 | display.clearDisplay (BLACK); |
91 | display.clearDisplay (BLACK); |
93 | display.setPixelMode (WHITE); |
92 | display.setPixelMode (WHITE); |
94 | dial.draw_scale (0, 10, 12, 1, 1); |
- | |
95 | dial.draw_limits (); |
- | |
96 | display.gotoxy (8, 32); |
- | |
97 | display.printString (large_font, "Display ", 8, WHITE); |
- | |
98 | display.printString (large_font, i == 0 ? "1" : "2", 1, BLACK); |
- | |
99 | showMinMax (display, 2, 123, 456); |
- | |
100 | - | ||
101 | display.display (); |
93 | display.display (); |
102 | context_t &context = contexts[i]; |
94 | context_t &context = contexts[i]; |
103 | context.dial_timer = DialTimeout * 2; // extra long delay before writeback dial setting |
95 | context.dial_timer = 200; // enough time to see at least one frame of PLX before NVRAM check |
104 | context.dial1 = -1; |
96 | context.dial1 = -1; |
- | 97 | context.OldObservation = -1; |
|
- | 98 | context.OldObservationIndex = -1; |
|
105 | } |
99 | } |
106 | 100 | ||
107 | } |
101 | } |
108 | 102 | ||
109 | // Check to see if there is an observation/instance in the dynamic data array |
103 | // Check to see if there is an observation/instance in the dynamic data array |
110 | // that matches the current observation/instance in the NVRAM |
104 | // that matches the current observation/instance in the NVRAM |
- | 105 | ||
111 | int |
106 | void |
112 | cc_check_nvram (int dialIndex, int itemIndex) |
107 | cc_check_nvram (int dialIndex) |
113 | { |
108 | { |
114 | if (dialIndex < 0 && dialIndex > MAX_DISPLAYS) |
109 | if (dialIndex < 0 && dialIndex > MAX_DISPLAYS) |
115 | return -1; |
110 | return; |
116 | context_t &context = contexts[dialIndex]; |
111 | context_t &context = contexts[dialIndex]; |
- | 112 | ||
117 | // check for timer timeout on consistent timer |
113 | // check for timer timeout on consistent timer |
118 | 114 | ||
119 | if (context.dial_timer) |
115 | if (context.dial_timer) |
120 | { |
116 | { |
121 | context.dial_timer--; |
117 | context.dial_timer--; |
122 | if (context.dial_timer == 0) |
118 | if (context.dial_timer == 0) |
123 | { |
119 | { |
124 | context.dial_timer = DialTimeout; |
120 | context.dial_timer = DialTimeout; |
125 | int i; |
121 | int i; |
126 | if (itemIndex < 0) |
122 | if (context.knobPos < 0) |
127 | { |
123 | { |
128 | for (i = 0; i < PLXItems; i++) |
124 | for (i = 0; i < PLXItems; i++) |
129 | if (Info[i].observation |
125 | if (Info[i].observation |
130 | == dial_nvram[dialIndex].data.observation |
126 | == dial_nvram[dialIndex].data.observation |
131 | && Info[i].instance |
127 | && Info[i].instance |
132 | == dial_nvram[dialIndex].data.instance) |
128 | == dial_nvram[dialIndex].data.instance) |
133 | { |
129 | { |
134 | itemIndex = i; |
130 | context.knobPos = i; |
135 | return itemIndex; |
131 | return; |
136 | } |
132 | } |
137 | } |
133 | } |
138 | if (itemIndex == -1) |
134 | if (context.knobPos == -1) |
139 | itemIndex = dialIndex; // timed out , not in NVRAM, use a default |
135 | context.knobPos = dialIndex; // timed out , not in NVRAM, use a default |
140 | 136 | ||
141 | // is this a change since the last timeout ? |
137 | // is this a change since the last timeout ? |
142 | if (Info[itemIndex].observation |
138 | if (Info[context.knobPos].observation |
143 | != dial_nvram[dialIndex].data.observation |
139 | != dial_nvram[dialIndex].data.observation |
144 | || Info[itemIndex].instance |
140 | || Info[context.knobPos].instance |
145 | != dial_nvram[dialIndex].data.instance) |
141 | != dial_nvram[dialIndex].data.instance) |
146 | { |
142 | { |
147 | 143 | ||
148 | // store the observation and instance in the NVRAM, not dial position. |
144 | // store the observation and instance in the NVRAM, not dial position. |
149 | nvram_info_t curr_val; |
145 | nvram_info_t curr_val; |
150 | curr_val.data.observation = Info[itemIndex].observation; |
146 | curr_val.data.observation = Info[context.knobPos].observation; |
151 | curr_val.data.instance = Info[itemIndex].instance; |
147 | curr_val.data.instance = Info[context.knobPos].instance; |
152 | uint32_t addr = (uint32_t) (&dial_nvram[dialIndex]); |
148 | uint32_t addr = (uint32_t) (&dial_nvram[dialIndex]); |
153 | WriteUint32NVRAM (addr, curr_val.u32); |
149 | WriteUint32NVRAM (addr, curr_val.u32); |
154 | } |
150 | } |
155 | } |
151 | } |
156 | } |
152 | } |
157 | return itemIndex; |
- | |
158 | } |
153 | } |
159 | 154 | ||
160 | int |
155 | int |
161 | cc_display (int dialIndex, int itemIndex, int suppressIndex) |
156 | cc_display (int dialIndex, int suppressIndex) |
162 | 157 | ||
163 | { |
158 | { |
164 | if (dialIndex < 0 && dialIndex > MAX_DISPLAYS) |
159 | if (dialIndex < 0 && dialIndex > MAX_DISPLAYS) |
165 | return -1; |
160 | return -1; |
166 | context_t &context = contexts[dialIndex]; |
161 | context_t &context = contexts[dialIndex]; |
167 | displayDial_t &dial = dials[dialIndex]; |
162 | displayDial_t &dial = dials[dialIndex]; |
168 | stm32_halDisplay_t &display = displays[dialIndex]; |
163 | stm32_halDisplay_t &display = displays[dialIndex]; |
- | 164 | int itemIndex = context.knobPos; |
|
169 | char buff[10]; |
165 | char buff[10]; |
170 | int i; |
166 | int i; |
171 | 167 | ||
172 | // check for item suppression |
168 | // check for item suppression |
173 | if (itemIndex == suppressIndex) |
169 | if (itemIndex == suppressIndex) |
Line 228... | Line 224... | ||
228 | display.gotoxy (64 - i * 4, 48); |
224 | display.gotoxy (64 - i * 4, 48); |
229 | display.printString (large_font, buff, i, WHITE); |
225 | display.printString (large_font, buff, i, WHITE); |
230 | 226 | ||
231 | context.OldObservation = Observation; |
227 | context.OldObservation = Observation; |
232 | context.OldObservationIndex = ObservationIndex; |
228 | context.OldObservationIndex = ObservationIndex; |
233 | - | ||
- | 229 | context.dial1 = -1; // do not display old needl, cleared screen |
|
234 | display.display (); |
230 | display.display (); |
235 | 231 | ||
236 | } |
232 | } |
237 | 233 | ||
238 | } |
234 | } |