Skip to content

Commit 379551c

Browse files
committed
Add displayBatteryVsEthernet code saver
1 parent 47cb150 commit 379551c

File tree

1 file changed

+25
-100
lines changed

1 file changed

+25
-100
lines changed

Firmware/RTK_Surveyor/Display.ino

Lines changed: 25 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,21 @@ void beginDisplay()
126126
systemPrintln("Display not detected");
127127
}
128128

129+
//Avoid code repetition
130+
void displayBatteryVsEthernet()
131+
{
132+
if (HAS_BATTERY)
133+
icons |= ICON_BATTERY; //Top right
134+
else //if (HAS_ETHERNET)
135+
{
136+
if (online.ethernetStatus == ETH_CONNECTED)
137+
blinking_icons |= ICON_ETHERNET; //Don't blink if link is up
138+
else
139+
blinking_icons ^= ICON_ETHERNET;
140+
icons |= (blinking_icons & ICON_ETHERNET); //Top Right
141+
}
142+
}
143+
129144
//Given the system state, display the appropriate information
130145
void updateDisplay()
131146
{
@@ -205,50 +220,23 @@ void updateDisplay()
205220
| ICON_HORIZONTAL_ACCURACY //Center right
206221
| paintSIV() //Bottom left
207222
| ICON_LOGGING; //Bottom right
208-
if (productVariant != REFERENCE_STATION)
209-
icons |= ICON_BATTERY; //Top right
210-
else
211-
{
212-
if (online.ethernetStatus == ETH_CONNECTED)
213-
blinking_icons |= ICON_ETHERNET; //Don't blink if link is up
214-
else
215-
blinking_icons ^= ICON_ETHERNET;
216-
icons |= (blinking_icons & ICON_ETHERNET); //Top Right
217-
}
223+
displayBatteryVsEthernet(); //Top right
218224
iconsRadio = setRadioIcons(); //Top left
219225
break;
220226
case (STATE_ROVER_NO_FIX):
221227
icons = ICON_CROSS_HAIR //Center left
222228
| ICON_HORIZONTAL_ACCURACY //Center right
223229
| paintSIV() //Bottom left
224230
| ICON_LOGGING; //Bottom right
225-
if (productVariant != REFERENCE_STATION)
226-
icons |= ICON_BATTERY; //Top right
227-
else
228-
{
229-
if (online.ethernetStatus == ETH_CONNECTED)
230-
blinking_icons |= ICON_ETHERNET; //Don't blink if link is up
231-
else
232-
blinking_icons ^= ICON_ETHERNET;
233-
icons |= (blinking_icons & ICON_ETHERNET); //Top Right
234-
}
231+
displayBatteryVsEthernet(); //Top right
235232
iconsRadio = setRadioIcons(); //Top left
236233
break;
237234
case (STATE_ROVER_FIX):
238235
icons = ICON_CROSS_HAIR //Center left
239236
| ICON_HORIZONTAL_ACCURACY //Center right
240237
| paintSIV() //Bottom left
241238
| ICON_LOGGING; //Bottom right
242-
if (productVariant != REFERENCE_STATION)
243-
icons |= ICON_BATTERY; //Top right
244-
else
245-
{
246-
if (online.ethernetStatus == ETH_CONNECTED)
247-
blinking_icons |= ICON_ETHERNET; //Don't blink if link is up
248-
else
249-
blinking_icons ^= ICON_ETHERNET;
250-
icons |= (blinking_icons & ICON_ETHERNET); //Top Right
251-
}
239+
displayBatteryVsEthernet(); //Top right
252240
iconsRadio = setRadioIcons(); //Top left
253241
break;
254242
case (STATE_ROVER_RTK_FLOAT):
@@ -257,33 +245,15 @@ void updateDisplay()
257245
| ICON_HORIZONTAL_ACCURACY //Center right
258246
| paintSIV() //Bottom left
259247
| ICON_LOGGING; //Bottom right
260-
if (productVariant != REFERENCE_STATION)
261-
icons |= ICON_BATTERY; //Top right
262-
else
263-
{
264-
if (online.ethernetStatus == ETH_CONNECTED)
265-
blinking_icons |= ICON_ETHERNET; //Don't blink if link is up
266-
else
267-
blinking_icons ^= ICON_ETHERNET;
268-
icons |= (blinking_icons & ICON_ETHERNET); //Top Right
269-
}
248+
displayBatteryVsEthernet(); //Top right
270249
iconsRadio = setRadioIcons(); //Top left
271250
break;
272251
case (STATE_ROVER_RTK_FIX):
273252
icons = ICON_CROSS_HAIR_DUAL//Center left
274253
| ICON_HORIZONTAL_ACCURACY //Center right
275254
| paintSIV() //Bottom left
276255
| ICON_LOGGING; //Bottom right
277-
if (productVariant != REFERENCE_STATION)
278-
icons |= ICON_BATTERY; //Top right
279-
else
280-
{
281-
if (online.ethernetStatus == ETH_CONNECTED)
282-
blinking_icons |= ICON_ETHERNET; //Don't blink if link is up
283-
else
284-
blinking_icons ^= ICON_ETHERNET;
285-
icons |= (blinking_icons & ICON_ETHERNET); //Top Right
286-
}
256+
displayBatteryVsEthernet(); //Top right
287257
iconsRadio = setRadioIcons(); //Top left
288258
break;
289259

@@ -300,74 +270,29 @@ void updateDisplay()
300270
| ICON_HORIZONTAL_ACCURACY //Center right
301271
| paintSIV() //Bottom left
302272
| ICON_LOGGING; //Bottom right
303-
if (productVariant != REFERENCE_STATION)
304-
icons |= ICON_BATTERY; //Top right
305-
else
306-
{
307-
if (online.ethernetStatus == ETH_CONNECTED)
308-
blinking_icons |= ICON_ETHERNET; //Don't blink if link is up
309-
else
310-
blinking_icons ^= ICON_ETHERNET;
311-
icons |= (blinking_icons & ICON_ETHERNET); //Top Right
312-
}
273+
displayBatteryVsEthernet(); //Top right
313274
iconsRadio = setRadioIcons(); //Top left
314275
break;
315276
case (STATE_BASE_TEMP_SURVEY_STARTED):
316277
icons = ICON_LOGGING; //Bottom right
317-
if (productVariant != REFERENCE_STATION)
318-
icons |= ICON_BATTERY; //Top right
319-
else
320-
{
321-
if (online.ethernetStatus == ETH_CONNECTED)
322-
blinking_icons |= ICON_ETHERNET; //Don't blink if link is up
323-
else
324-
blinking_icons ^= ICON_ETHERNET;
325-
icons |= (blinking_icons & ICON_ETHERNET); //Top Right
326-
}
278+
displayBatteryVsEthernet(); //Top right
327279
iconsRadio = setRadioIcons(); //Top left
328280
paintBaseTempSurveyStarted();
329281
break;
330282
case (STATE_BASE_TEMP_TRANSMITTING):
331283
icons = ICON_LOGGING; //Bottom right
332-
if (productVariant != REFERENCE_STATION)
333-
icons |= ICON_BATTERY; //Top right
334-
else
335-
{
336-
if (online.ethernetStatus == ETH_CONNECTED)
337-
blinking_icons |= ICON_ETHERNET; //Don't blink if link is up
338-
else
339-
blinking_icons ^= ICON_ETHERNET;
340-
icons |= (blinking_icons & ICON_ETHERNET); //Top Right
341-
}
284+
displayBatteryVsEthernet(); //Top right
342285
iconsRadio = setRadioIcons(); //Top left
343286
paintRTCM();
344287
break;
345288
case (STATE_BASE_FIXED_NOT_STARTED):
346289
icons = 0; //Top right
347-
if (productVariant != REFERENCE_STATION)
348-
icons |= ICON_BATTERY; //Top right
349-
else
350-
{
351-
if (online.ethernetStatus == ETH_CONNECTED)
352-
blinking_icons |= ICON_ETHERNET; //Don't blink if link is up
353-
else
354-
blinking_icons ^= ICON_ETHERNET;
355-
icons |= (blinking_icons & ICON_ETHERNET); //Top Right
356-
}
290+
displayBatteryVsEthernet(); //Top right
357291
iconsRadio = setRadioIcons(); //Top left
358292
break;
359293
case (STATE_BASE_FIXED_TRANSMITTING):
360294
icons = ICON_LOGGING; //Bottom right
361-
if (productVariant != REFERENCE_STATION)
362-
icons |= ICON_BATTERY; //Top right
363-
else
364-
{
365-
if (online.ethernetStatus == ETH_CONNECTED)
366-
blinking_icons |= ICON_ETHERNET; //Don't blink if link is up
367-
else
368-
blinking_icons ^= ICON_ETHERNET;
369-
icons |= (blinking_icons & ICON_ETHERNET); //Top Right
370-
}
295+
displayBatteryVsEthernet(); //Top right
371296
iconsRadio = setRadioIcons(); //Top left
372297
paintRTCM();
373298
break;

0 commit comments

Comments
 (0)