Rev 63 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 63 | Rev 65 | ||
|---|---|---|---|
| Line 56... | Line 56... | ||
| 56 | #endif |
56 | #endif |
| 57 | static void |
57 | static void |
| 58 | showMinMax(display_t &display, uint8_t dp_pos, int16_t int_min, |
58 | showMinMax(display_t &display, uint8_t dp_pos, int16_t int_min, |
| 59 | uint16_t int_max) |
59 | uint16_t int_max) |
| 60 | { |
60 | { |
| 61 | const char padding[]=" "; |
61 | const char padding[] = " "; |
| 62 | // left justified display of minimum |
62 | // left justified display of minimum |
| 63 | int8_t width=display.fontSigDigits(small_font, 0, 0, 0, dp_pos, int_min, WHITE); |
63 | int8_t width = display.fontSigDigits(small_font, 0, 0, 0, dp_pos, int_min, WHITE); |
| 64 | // pad with spaces if fewer than 6 characters are used. |
64 | // pad with spaces if fewer than 6 characters are used. |
| 65 | if(width !=6) |
65 | if (width != 6) |
| 66 | display.printString(small_font,padding,6-width,WHITE); |
66 | display.printString(small_font, padding, 6 - width, WHITE); |
| 67 | 67 | ||
| 68 | display.gotoxy(0, 8); |
68 | display.gotoxy(0, 8); |
| 69 | display.printString(small_font, "Min", 3, WHITE); |
69 | display.printString(small_font, "Min", 3, WHITE); |
| 70 | 70 | ||
| 71 | // right justified display of maximum |
71 | // right justified display of maximum |
| 72 | width = display.fontSigDigits(small_font, 120, 0, 1, dp_pos, int_max, WHITE); |
72 | width = display.fontSigDigits(small_font, 120, 0, 1, dp_pos, int_max, WHITE); |
| 73 | // right justified display of maximum : pad spaces to left |
73 | // right justified display of maximum : pad spaces to left |
| 74 | if(width !=6) |
74 | if (width != 6) |
| 75 | display.printString(small_font,padding,6-width,WHITE); |
75 | display.printString(small_font, padding, 6 - width, WHITE); |
| 76 | 76 | ||
| 77 | display.gotoxy(110, 8); |
77 | display.gotoxy(110, 8); |
| 78 | display.printString(small_font, "Max", 3, WHITE); |
78 | display.printString(small_font, "Max", 3, WHITE); |
| 79 | } |
79 | } |
| 80 | 80 | ||
| 81 | void |
81 | void |
| Line 127... | Line 127... | ||
| 127 | context.dial_timer--; |
127 | context.dial_timer--; |
| 128 | if (context.dial_timer == 0) |
128 | if (context.dial_timer == 0) |
| 129 | { |
129 | { |
| 130 | context.dial_timer = DialTimeout; |
130 | context.dial_timer = DialTimeout; |
| 131 | int i; |
131 | int i; |
| - | 132 | // use dialIndex+1 as tag for data : always non-zero. |
|
| - | 133 | nvram_info_t *dial_nvram = find_nvram_data(dialIndex + 1); |
|
| - | 134 | ||
| 132 | if (context.knobPos < 0) |
135 | if (dial_nvram && context.knobPos < 0) |
| 133 | { |
136 | { |
| 134 | for (i = 0; i < PLXItems; i++) |
137 | for (i = 0; i < PLXItems; i++) |
| 135 | if (Info[i].observation == dial_nvram[dialIndex].data.observation && Info[i].instance == dial_nvram[dialIndex].data.instance) |
138 | if ((Info[i].observation == dial_nvram->data.observation) && (Info[i].instance == dial_nvram->data.instance)) |
| 136 | { |
139 | { |
| 137 | context.knobPos = i; |
140 | context.knobPos = i; |
| 138 | return; |
141 | return; |
| 139 | } |
142 | } |
| 140 | } |
143 | } |
| 141 | if (context.knobPos == -1) |
144 | if (context.knobPos == -1) |
| 142 | context.knobPos = dialIndex; // timed out , not in NVRAM, use a default |
145 | context.knobPos = dialIndex; // timed out , not in NVRAM, use a default |
| 143 | 146 | ||
| 144 | // is this a change since the last timeout ? |
147 | // is this a change since the last timeout ? |
| 145 | if (Info[context.knobPos].observation != dial_nvram[dialIndex].data.observation || Info[context.knobPos].instance != dial_nvram[dialIndex].data.instance) |
148 | if (!dial_nvram || (Info[context.knobPos].observation != dial_nvram->data.observation) || (Info[context.knobPos].instance != dial_nvram->data.instance)) |
| 146 | { |
149 | { |
| 147 | 150 | ||
| 148 | // store the observation and instance in the NVRAM, not dial position. |
151 | // store the observation and instance in the NVRAM, not dial position. |
| 149 | nvram_info_t curr_val; |
152 | nvram_info_t curr_val; |
| 150 | curr_val.data.observation = Info[context.knobPos].observation; |
153 | curr_val.data.observation = Info[context.knobPos].observation; |
| 151 | curr_val.data.instance = Info[context.knobPos].instance; |
154 | curr_val.data.instance = Info[context.knobPos].instance; |
| 152 | uint32_t addr = (uint32_t)(&dial_nvram[dialIndex]); |
155 | curr_val.data.tag = dialIndex + 1; |
| - | 156 | ||
| 153 | WriteUint32NVRAM(addr, curr_val.u32); |
157 | write_nvram_data(curr_val); |
| 154 | } |
158 | } |
| 155 | } |
159 | } |
| 156 | } |
160 | } |
| 157 | } |
161 | } |
| 158 | 162 | ||
| Line 291... | Line 295... | ||
| 291 | } |
295 | } |
| 292 | dial.draw_needle(context.dial0); |
296 | dial.draw_needle(context.dial0); |
| 293 | context.dial1 = context.dial0; |
297 | context.dial1 = context.dial0; |
| 294 | showMinMax(display, dp_pos, int_min, int_max); |
298 | showMinMax(display, dp_pos, int_min, int_max); |
| 295 | 299 | ||
| 296 | display.gotoxy(0,32); |
300 | display.gotoxy(0, 32); |
| 297 | 301 | ||
| 298 | // display BT connection status |
302 | // display BT connection status |
| 299 | display.printString(small_font,btConnected() ? "\x81": " ",1); |
303 | display.printString(small_font, btConnected() ? "\x81" : " ", 1); |
| 300 | 304 | ||
| 301 | display.display(); |
305 | display.display(); |
| 302 | 306 | ||
| 303 | return itemIndex; |
307 | return itemIndex; |
| 304 | } |
308 | } |