Rev 77 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 77 | Rev 79 | ||
|---|---|---|---|
| Line 106... | Line 106... | ||
| 106 | display.display(); |
106 | display.display(); |
| 107 | context_t &context = contexts[i]; |
107 | context_t &context = contexts[i]; |
| 108 | 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 |
| 109 | context.dial1 = -1; |
109 | context.dial1 = -1; |
| 110 | context.OldObservation = nullObs; |
110 | context.OldObservation = nullObs; |
| - | 111 | ||
| - | 112 | context.knobPos = -1; // indicate it is initialised |
|
| 111 | } |
113 | } |
| 112 | } |
114 | } |
| 113 | 115 | ||
| 114 | // Check to see if there is an observation/instance in the dynamic data array |
116 | // Check to see if there is an observation/instance in the dynamic data array |
| 115 | // that matches the current observation/instance in the NVRAM |
117 | // that matches the current observation/instance in the NVRAM |
| Line 134... | Line 136... | ||
| 134 | context.dial_timer = DialTimeout; |
136 | context.dial_timer = DialTimeout; |
| 135 | int i; |
137 | int i; |
| 136 | // use dialIndex+1 as tag for data : always non-zero. |
138 | // use dialIndex+1 as tag for data : always non-zero. |
| 137 | nvram_info_t *dial_nvram = find_nvram_data(dialIndex + 1); |
139 | nvram_info_t *dial_nvram = find_nvram_data(dialIndex + 1); |
| 138 | 140 | ||
| - | 141 | // initial read operation if knobPos < 0 |
|
| 139 | if (dial_nvram && context.knobPos < 0) |
142 | if (dial_nvram && context.knobPos < 0) |
| 140 | { |
143 | { |
| 141 | for (i = 0; i < INFO_SIZE; i++) |
- | |
| 142 | if (isValid(i) && (Info[i].observation.Obs == dial_nvram->data.observation) && (Info[i].observation.Instance == dial_nvram->data.instance)) |
- | |
| 143 | { |
- | |
| 144 | context.knobPos = i; |
144 | context.knobPos = dial_nvram->data.pos; |
| 145 | return; |
145 | return; |
| 146 | } |
- | |
| 147 | } |
146 | } |
| 148 | if (context.knobPos == -1) |
147 | if (context.knobPos < 0) |
| 149 | context.knobPos = dialIndex; // timed out , not in NVRAM, use a default |
148 | context.knobPos = dialIndex; // timed out , not in NVRAM, use a default |
| 150 | 149 | ||
| 151 | // dont save dial info for invalid data |
150 | // dont save dial info for invalid data |
| 152 | if (!isValid(context.knobPos)) |
151 | if (!isValid(context.knobPos)) |
| 153 | return; |
152 | return; |
| 154 | // is this a change since the last timeout ? |
153 | // is this a change since the last timeout ? |
| 155 | 154 | ||
| 156 | if (!dial_nvram || (Info[context.knobPos].observation.Obs != dial_nvram->data.observation) || (Info[context.knobPos].observation.Instance != dial_nvram->data.instance)) |
155 | if (!dial_nvram || context.knobPos != dial_nvram->data.pos) |
| 157 | { |
156 | { |
| 158 | 157 | ||
| 159 | // store the observation and instance in the NVRAM, not dial position. |
158 | // store the observation and instance in the NVRAM, not dial position. |
| 160 | nvram_info_t curr_val; |
159 | nvram_info_t curr_val; |
| 161 | curr_val.data.observation = Info[context.knobPos].observation.Obs; |
160 | curr_val.data.pos = context.knobPos; |
| 162 | curr_val.data.instance = Info[context.knobPos].observation.Instance; |
- | |
| 163 | curr_val.data.tag = dialIndex + 1; |
161 | curr_val.data.tag = dialIndex + 1; |
| 164 | 162 | ||
| 165 | write_nvram_data(curr_val); |
163 | write_nvram_data(curr_val); |
| 166 | } |
164 | } |
| 167 | } |
165 | } |