1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
|
/*
* Modes.c
*
* Created on: 17 Sep 2016
* Author: Ralim <ralim@ralimtek.com>
*/
#include "Modes.h"
uint8_t StatusFlags = 0;
uint32_t temporaryTempStorage = 0;
operatingModeEnum operatingMode;
settingsPageEnum settingsPage;
//This does the required processing and state changes
void ProcessUI() {
uint8_t Buttons = getButtons(); //read the buttons status
static uint32_t lastModeChange = 0;
switch (operatingMode) {
case STARTUP:
if (Buttons == (BUT_A | BUT_B)) {
operatingMode = THERMOMETER;
} else if (Buttons == BUT_A) {
//A key pressed so we are moving to soldering mode
operatingMode = SOLDERING;
Oled_DisplayOn();
} else if (Buttons == BUT_B) {
//B Button was pressed so we are moving to the Settings menu
operatingMode = SETTINGS;
Oled_DisplayOn();
}
break;
case SOLDERING:
//^ This is to make the button more delayed in timing for people to find A+B easier
//We need to check the buttons if we need to jump out
if ((Buttons == BUT_A && !systemSettings.boostModeEnabled)
|| Buttons == BUT_B) {
//A or B key pressed so we are moving to temp set
operatingMode = TEMP_ADJ;
if (StatusFlags == 8) {
//Boost mode was enabled before
//We need to cancel the temp
systemSettings.SolderingTemp = temporaryTempStorage;
StatusFlags = 0;
}
} else if (Buttons == (BUT_A | BUT_B)) {
//Both buttons were pressed, exit back to the cooling screen
operatingMode = COOLING;
if (StatusFlags == 8) {
//Boost mode was enabled before
//We need to cancel the temp
systemSettings.SolderingTemp = temporaryTempStorage;
StatusFlags = 0;
}
} else if ((getRawButtons() == BUT_A && systemSettings.boostModeEnabled)) {
if (StatusFlags != 8) {
StatusFlags = 8;
temporaryTempStorage = systemSettings.SolderingTemp;
systemSettings.SolderingTemp = systemSettings.BoostTemp;
}
//Update the PID Loop
int32_t newOutput = computePID(systemSettings.SolderingTemp);
setIronTimer(newOutput);
} else {
if (StatusFlags == 8) {
//Boost mode was enabled before
//We need to cancel the temp
systemSettings.SolderingTemp = temporaryTempStorage;
StatusFlags = 0;
}
//We need to check the timer for movement in case we need to goto idle
if (systemSettings.sensitivity) {
uint32_t timeout = 0;
if (systemSettings.SleepTime < 6)
timeout = 1000 * 10 * systemSettings.SleepTime;
else
timeout = 60 * 1000 * (systemSettings.SleepTime - 5);
if (millis() - getLastMovement() > (timeout)) {
if (millis() - getLastButtonPress() > (timeout)) {
operatingMode = SLEEP;
return;
}
}
}
uint16_t voltage = readDCVoltage(systemSettings.voltageDiv); //get X10 voltage
if ((voltage) < lookupVoltageLevel(systemSettings.cutoutSetting)) {
operatingMode = UVLOWARN;
lastModeChange = millis();
}
//Update the PID Loop
int32_t newOutput = computePID(systemSettings.SolderingTemp);
setIronTimer(newOutput);
}
break;
case TEMP_ADJ:
if (OLED_GetOrientation() == 1) {
if (Buttons == BUT_B) {
//A key pressed so we are moving down in temp
if (systemSettings.SolderingTemp > 1000)
systemSettings.SolderingTemp -= 100;
} else if (Buttons == BUT_A) {
//B key pressed so we are moving up in temp
if (systemSettings.SolderingTemp < 4500)
systemSettings.SolderingTemp += 100;
} else {
//we check the timeout for how long the buttons have not been pushed
//if idle for > 3 seconds then we return to soldering
//Or if both buttons pressed
if (Buttons == (BUT_A | BUT_B)) {
operatingMode = STARTUP;
saveSettings();
} else if ((millis() - getLastButtonPress() > 2000)) {
operatingMode = SOLDERING;
}
}
} else {
if (Buttons == BUT_A) {
//A key pressed so we are moving down in temp
if (systemSettings.SolderingTemp > 1000)
systemSettings.SolderingTemp -= 100;
} else if (Buttons == BUT_B) {
//B key pressed so we are moving up in temp
if (systemSettings.SolderingTemp < 4500)
systemSettings.SolderingTemp += 100;
} else {
//we check the timeout for how long the buttons have not been pushed
//if idle for > 3 seconds then we return to soldering
//Or if both buttons pressed
if ((millis() - getLastButtonPress() > 2000)
|| Buttons == (BUT_A | BUT_B)) {
operatingMode = SOLDERING;
saveSettings();
}
}
}
break;
case SETTINGS:
//Settings is the mode with the most logic
//Here we are in the menu so we need to increment through the sub menus / increase the value
if (StatusFlags == 4 && Buttons != 0) {
//The user pressed the button to breakout of the settings help prompt
StatusFlags = 0;
} else {
if (Buttons == (BUT_A | BUT_B)) {
//Both buttons were pressed, exit back to the startup screen
settingsPage = 0; //reset
operatingMode = STARTUP; //reset back to the startup
saveSettings(); //Save the settings
StartUp_Accelerometer(systemSettings.sensitivity); //Start the accelerometer
} else if (Buttons & BUT_B) {
//A key iterates through the menu
if (settingsPage == SETTINGSOPTIONSCOUNT) {
//Roll off the end
settingsPage = 0; //reset
operatingMode = STARTUP; //reset back to the startup
saveSettings(); //Save the settings
StartUp_Accelerometer(systemSettings.sensitivity); //Start the accelerometer
} else {
++settingsPage; //move to the next option
}
} else if (Buttons & BUT_A) {
//B changes the value selected
switch (settingsPage) {
case UVCO:
//we are incrementing the cutout voltage
systemSettings.cutoutSetting += 1; //Go up 1V at a jump
systemSettings.cutoutSetting %= 5; //wrap 0->4
break;
case SLEEP_TEMP:
systemSettings.SleepTemp += 100; //Go up 10C at a time
if (systemSettings.SleepTemp > 3000)
systemSettings.SleepTemp = 500; //cant sleep higher than 300 or less than 50
break;
case SLEEP_TIME:
++systemSettings.SleepTime; //Go up 1 minute at a time
if (systemSettings.SleepTime > 16)
systemSettings.SleepTime = 1;//can't set time over 30 mins
//Remember that ^ is the time of no movement
break;
case SHUTDOWN_TIME:
++systemSettings.ShutdownTime;
if (systemSettings.ShutdownTime > 60)
systemSettings.ShutdownTime = 0; //wrap to off
break;
case TEMPDISPLAY:
systemSettings.displayTempInF =
!systemSettings.displayTempInF;
break;
case SCREENROTATION:
systemSettings.OrientationMode++;
systemSettings.OrientationMode =
systemSettings.OrientationMode % 3;
break;
case MOTIONSENSITIVITY:
systemSettings.sensitivity++;
systemSettings.sensitivity = systemSettings.sensitivity
% 10;
break;
case TEMPROUNDING:
systemSettings.temperatureRounding++;
systemSettings.temperatureRounding =
systemSettings.temperatureRounding % 3;
break;
case DISPUPDATERATE:
systemSettings.displayUpdateSpeed++;
systemSettings.displayUpdateSpeed =
systemSettings.displayUpdateSpeed % 3;
break;
case BOOSTMODE:
systemSettings.boostModeEnabled =
!systemSettings.boostModeEnabled;
break;
case BOOSTTEMP:
systemSettings.BoostTemp += 100; //Go up 10C at a time
if (systemSettings.BoostTemp > 4500)
systemSettings.BoostTemp = 2500; //loop back at 250
break;
case POWERDISPLAY:
systemSettings.powerDisplay = !systemSettings.powerDisplay;
break;
case AUTOSTART:
systemSettings.autoStart++;
systemSettings.autoStart %= 3;
break;
case COOLINGBLINK:
systemSettings.coolingTempBlink =
!systemSettings.coolingTempBlink;
break;
#ifdef PIDTUNING
case PIDP:
pidSettings.kp++;
pidSettings.kp %= 20;
break;
case PIDI:
pidSettings.ki++;
pidSettings.ki %= 10;
break;
case PIDD:
pidSettings.kd++;
pidSettings.kd %= 30;
break;
#endif
default:
break;
}
}
}
break;
case SLEEP:
//The iron is sleeping at a lower temperature due to lack of movement
if (Buttons & BUT_A) {
//A Button was pressed so we are moving back to soldering
operatingMode = SOLDERING;
Oled_DisplayOn();
return;
} else if (Buttons & BUT_B) {
//B Button was pressed so we are moving back to soldering
operatingMode = SOLDERING;
Oled_DisplayOn();
return;
} else if (systemSettings.sensitivity && !InterruptMask) {
if (millis() - getLastMovement() < 1000) {//moved in the last second
operatingMode = SOLDERING; //Goto active mode again
Oled_DisplayOn();
return;
}
}
if (systemSettings.sensitivity) {
//Check if we should shutdown
if ((millis() - getLastMovement()
> (systemSettings.ShutdownTime * 60000))
|| (millis() - getLastButtonPress()
> systemSettings.ShutdownTime * 60000)) {
operatingMode = COOLING; //shutdown the tip
Oled_DisplayOn();
}
}
//else if nothing has been pushed we need to compute the PID to keep the iron at the sleep temp
int32_t newOutput = computePID(systemSettings.SleepTemp);
setIronTimer(newOutput);
break;
case COOLING: {
setIronTimer(0); //turn off heating
//This mode warns the user the iron is still cooling down
if (Buttons & (BUT_A | BUT_B)) { //we check if the user has pushed a button to exit
//Either button was pushed
operatingMode = STARTUP;
}
}
break;
case UVLOWARN:
//We are here if the DC voltage went too low
//We want to jump back to IDLE after a bit
if (millis() - lastModeChange > 3000) { //its been 3 seconds
operatingMode = STARTUP; //jump back to idle mode
}
break;
case THERMOMETER: {
//This lets the user check the tip temp without heating the iron.. And eventually calibration will be added here
if (Buttons == BUT_A) {
//Single button press, cycle over to the DC display
StatusFlags = 0;
operatingMode = DCINDISP;
} else if (Buttons == BUT_B) {
StatusFlags = 0;
operatingMode = TEMPCAL;
} else if (Buttons == (BUT_A | BUT_B)) {
//If the user is holding both button, exit the screen
operatingMode = STARTUP;
}
}
break;
case DCINDISP: {
//This lets the user check the input voltage
if (StatusFlags == 0) {
if (Buttons == BUT_A) {
//Single button press, cycle over to the temp display
operatingMode = THERMOMETER;
} else if (Buttons == BUT_B) {
//dc cal mode
StatusFlags = 1;
} else if (Buttons == (BUT_A | BUT_B)) {
//If the user is holding both button, exit the screen
operatingMode = STARTUP;
}
} else {
//User is calibrating the dc input
if (Buttons == BUT_A) {
if (!systemSettings.OrientationMode)
systemSettings.voltageDiv++;
else
systemSettings.voltageDiv--;
} else if (Buttons == BUT_B) {
if (!systemSettings.OrientationMode)
systemSettings.voltageDiv--;
else
systemSettings.voltageDiv++;
} else if (Buttons == (BUT_A | BUT_B)) {
StatusFlags = 0;
saveSettings();
}
if (systemSettings.voltageDiv < 120)
systemSettings.voltageDiv = 160;
else if (systemSettings.voltageDiv > 160)
systemSettings.voltageDiv = 120;
}
}
break;
case TEMPCAL: {
if (Buttons == BUT_B) {
//Single button press, cycle over to the DC IN
operatingMode = THERMOMETER;
} else if (Buttons == BUT_A) {
//Try and calibrate
if (StatusFlags == 0) {
if ((readTipTemp() < 300) && (readSensorTemp() < 300)) {
StatusFlags = 1;
systemSettings.tempCalibration = readTipTemp();
saveSettings();
} else {
StatusFlags = 2;
}
}
} else if (Buttons == (BUT_A | BUT_B)) {
//If the user is holding both button, exit the screen
operatingMode = STARTUP;
}
}
break;
default:
break;
}
}
/*
* Draws the temp with temp conversion if needed
*/
void drawTemp(uint16_t temp, uint8_t x, uint8_t roundingMode) {
if (systemSettings.displayTempInF)
temp = (temp * 9 + 1600) / 5;/*Convert to F -> T*(9/5)+32*/
if (temp % 10 > 5)
temp += 10; //round up
temp /= 10;
//handle rounding modes
if (roundingMode == ROUNDING_FIVE) {
if (temp % 10 < 5)
temp = (temp / 10) * 10;
else
temp = ((temp / 10) * 10) + 5;
} else if (roundingMode == ROUNDING_TEN) {
temp = (temp / 10) * 10;
}
OLED_DrawThreeNumber(temp, x);
}
/*
* Performs all the OLED drawing for the current operating mode
*/
void DrawUI() {
static uint32_t lastOLEDDrawTime = 0;
static uint16_t lastSolderingDrawnTemp1 = 0;
static uint16_t lastSolderingDrawnTemp2 = 0;
static uint8_t settingsLongTestScrollPos = 0;
uint16_t temp = readIronTemp(0, 0, 0xFFFF);
if (systemSettings.sensitivity) {
if (millis() - getLastMovement() > (5 * 60 * 1000)
&& (millis() - getLastButtonPress() > (5 * 60 * 1000))
&& (temp < 400)) {
//OLED off
Oled_DisplayOff();
} else {
Oled_DisplayOn();
}
}
switch (operatingMode) {
case STARTUP:
//We are chilling in the idle mode
//Check if movement in the last 5 minutes , if not sleep OLED
OLED_DrawIDLELogo(); //Draw the icons for prompting the user
temp = readIronTemp(0, 1, 0xFFFF);//to update the internal filter buffer
break;
case SOLDERING:
//The user is soldering
{
if (systemSettings.displayUpdateSpeed == DISPLAYMODE_SLOW
&& (millis() - lastOLEDDrawTime < 200))
return;
else if (systemSettings.displayUpdateSpeed == DISPLAYMODE_MEDIUM
&& (millis() - lastOLEDDrawTime < 100))
return;
Clear_Screen();
Oled_DisplayOn();
uint32_t tempavg = (temp + lastSolderingDrawnTemp1
+ lastSolderingDrawnTemp2);
tempavg /= 3;
drawTemp(tempavg, 0, systemSettings.temperatureRounding);
lastSolderingDrawnTemp1 = temp;
lastSolderingDrawnTemp2 = lastSolderingDrawnTemp1;
lastOLEDDrawTime = millis();
//Now draw symbols
if (StatusFlags == 8)
OLED_DrawExtraFontChars(2, 4);
else {
OLED_DrawChar(' ', 4);
}
//Draw in battery symbol if desired
if (systemSettings.cutoutSetting) {
//User is on a lithium battery
//we need to calculate which of the 10 levels they are on
uint8_t cellCount = systemSettings.cutoutSetting + 2;
uint16_t cellV = readDCVoltage(systemSettings.voltageDiv)
/ cellCount;
//Should give us approx cell voltage X10
//Range is 42 -> 33 = 9 steps therefore we will use battery 1-10
if (cellV < 33)
cellV = 33;
cellV -= 33; //Should leave us a number of 0-9
if (cellV > 9)
cellV = 9;
OLED_DrawSymbolChar(cellV + 1, 5);
}
if (systemSettings.displayTempInF) {
//OLED_DrawChar(SettingTempFChar, 3);
OLED_DrawExtraFontChars(0, 3);
} else {
//OLED_DrawChar(SettingTempCChar, 3);
OLED_DrawExtraFontChars(1, 3);
}
//Optionally draw the arrows, or draw the power instead
if (systemSettings.powerDisplay) {
//We want to draw in a neat little bar graph of power being pushed to the tip
//ofset 11
uint16_t count = getIronTimer() / (1000 / 28);
if (count > 28)
count = 28;
OLED_DrawWideChar((count), 6);
} else {
//Draw in the arrows if the user has the power display turned off
if (getIronTimer() == 0
&& (temp / 10) > (systemSettings.SolderingTemp / 10)) {
//Cooling
OLED_DrawSymbol(6, 5);
} else {
if (getIronTimer() < 1500) {
//Maintaining
OLED_DrawSymbol(6, 7);
} else { //we are heating
OLED_DrawSymbol(6, 6);
}
}
}
}
break;
case TEMP_ADJ:
//We are prompting the user to change the temp so we draw the current setpoint temp
//With the nifty arrows
OLED_DrawChar(' ', 0);
OLED_DrawChar('<', 1);
drawTemp(systemSettings.SolderingTemp, 2, 0);
OLED_DrawChar(' ', 5);
OLED_DrawChar(' ', 7);
OLED_DrawChar('>', 6);
break;
case SETTINGS:
//We are prompting the user the setting name
if (millis() - getLastButtonPress() > 3000) {
StatusFlags = 4;
//If the user has idled for > 3 seconds, show the long name for the selected setting instead
//draw from settingsLongTestScrollPos through to end of screen
uint8_t lengthLeft = strlen(SettingsLongNames[settingsPage])
- settingsLongTestScrollPos;
if (lengthLeft < 1)
settingsLongTestScrollPos = 0;
//^ Reset once not much left
if (lengthLeft > 8)
lengthLeft = 8;
OLED_DrawString(
SettingsLongNames[(uint8_t) settingsPage]
+ settingsLongTestScrollPos, lengthLeft);
if (lengthLeft < 8)
for (uint8_t i = lengthLeft; i < 8; i++)
OLED_DrawChar(' ', i);
if (millis() - lastOLEDDrawTime > 120) {
settingsLongTestScrollPos++;
lastOLEDDrawTime = millis();
}
} else {
settingsLongTestScrollPos = 0;
switch (settingsPage) {
case UVCO:
OLED_DrawString(SettingsShortNames[UVCO], 6);
if (systemSettings.cutoutSetting == 0) {
//DC
OLED_DrawChar('D', 6);
OLED_DrawChar('C', 7);
} else {
//S count
OLED_DrawChar('2' + systemSettings.cutoutSetting, 6);
OLED_DrawChar('S', 7);
}
break;
case SLEEP_TEMP:
OLED_DrawString(SettingsShortNames[SLEEP_TEMP], 5);
OLED_DrawThreeNumber(systemSettings.SleepTemp / 10, 5);
break;
case SLEEP_TIME:
Clear_Screen();
OLED_DrawString(SettingsShortNames[SLEEP_TIME], 5);
//Draw in the timescale
if (systemSettings.SleepTime < 6) {
OLED_DrawChar('S', 7);
OLED_DrawTwoNumber(systemSettings.SleepTime * 10, 5);
} else {
OLED_DrawChar('M', 7);
OLED_DrawTwoNumber(systemSettings.SleepTime - 5, 5);
}
break;
case SHUTDOWN_TIME:
OLED_DrawString(SettingsShortNames[SHUTDOWN_TIME], 6);
OLED_DrawTwoNumber(systemSettings.ShutdownTime, 6);
break;
case TEMPDISPLAY:/*Are we showing in C or F ?*/
OLED_DrawString(SettingsShortNames[TEMPDISPLAY], 7);
if (systemSettings.displayTempInF)
OLED_DrawChar(SettingTempFChar, 7);
else
OLED_DrawChar(SettingTempCChar, 7);
break;
case SCREENROTATION:
OLED_DrawString(SettingsShortNames[SCREENROTATION], 7);
switch (systemSettings.OrientationMode) {
case 0:
OLED_DrawChar(SettingRightChar, 7);
break;
case 1:
OLED_DrawChar(SettingLeftChar, 7);
break;
case 2:
OLED_DrawChar(SettingAutoChar, 7);
break;
}
break;
case MOTIONSENSITIVITY:
OLED_DrawString(SettingsShortNames[MOTIONSENSITIVITY], 7);
OLED_DrawChar('0' + systemSettings.sensitivity, 7);
break;
case TEMPROUNDING:
//We are prompting the user about their display mode preferences
{
OLED_DrawString(SettingsShortNames[TEMPROUNDING], 7);
switch (systemSettings.temperatureRounding) {
case ROUNDING_NONE:
OLED_DrawChar('1', 7);
break;
case ROUNDING_FIVE:
OLED_DrawChar('5', 7);
break;
case ROUNDING_TEN:
OLED_DrawChar('X', 7);
break;
}
}
break;
case DISPUPDATERATE:
//We are prompting the user about their display mode preferences
{
OLED_DrawString(SettingsShortNames[DISPUPDATERATE], 7);
switch (systemSettings.displayUpdateSpeed) {
case DISPLAYMODE_FAST:
OLED_DrawChar(SettingFastChar, 7);
break;
case DISPLAYMODE_SLOW:
OLED_DrawChar(SettingSlowChar, 7);
break;
case DISPLAYMODE_MEDIUM:
OLED_DrawChar(SettingMediumChar, 7);
break;
}
}
break;
case BOOSTMODE:
OLED_DrawString(SettingsShortNames[BOOSTMODE], 7);
switch (systemSettings.boostModeEnabled) {
case 1:
OLED_DrawChar(SettingTrueChar, 7);
break;
case 0:
OLED_DrawChar(SettingFalseChar, 7);
break;
}
break;
case BOOSTTEMP:
OLED_DrawString(SettingsShortNames[BOOSTTEMP], 5);
OLED_DrawThreeNumber(systemSettings.BoostTemp / 10, 5);
break;
case POWERDISPLAY:
OLED_DrawString(SettingsShortNames[POWERDISPLAY], 7);
switch (systemSettings.powerDisplay) {
case 1:
OLED_DrawChar(SettingTrueChar, 7);
break;
case 0:
OLED_DrawChar(SettingFalseChar, 7);
break;
}
break;
case AUTOSTART:
OLED_DrawString(SettingsShortNames[AUTOSTART], 7);
switch (systemSettings.autoStart) {
case 1:
OLED_DrawChar(SettingTrueChar, 7);
break;
case 0:
OLED_DrawChar(SettingFalseChar, 7);
break;
case 2:
OLED_DrawChar(SettingSleepChar, 7);
break;
}
break;
case COOLINGBLINK:
OLED_DrawString(SettingsShortNames[COOLINGBLINK], 7);
switch (systemSettings.coolingTempBlink) {
case 1:
OLED_DrawChar(SettingTrueChar, 7);
break;
case 0:
OLED_DrawChar(SettingFalseChar, 7);
break;
}
break;
#ifdef PIDTUNING
case PIDP:
OLED_DrawString("PIDP ", 5);
OLED_DrawThreeNumber(pidSettings.kp, 5);
break;
case PIDI:
OLED_DrawString("PIDI ", 5);
OLED_DrawThreeNumber(pidSettings.ki, 5);
break;
case PIDD:
OLED_DrawString("PIDD ", 5);
OLED_DrawThreeNumber(pidSettings.kd, 5);
break;
#endif
default:
break;
}
}
break;
case SLEEP:
//The iron is in sleep temp mode
//Draw in temp and sleep
Clear_Screen();
OLED_DrawString("SLP ", 4);
drawTemp(temp, 4, systemSettings.temperatureRounding);
Oled_DisplayOn();
break;
case COOLING:
//We are warning the user the tip is cooling
Clear_Screen();
OLED_DrawString(CoolingPromptString, 5);
temp = readIronTemp(0, 1, 0xFFFF); //force temp re-reading
if (temp > 500 && systemSettings.coolingTempBlink
&& (millis() % 1000) > 500) {
} else {
drawTemp(temp, 5, systemSettings.temperatureRounding);
}
break;
case UVLOWARN:
OLED_DrawString(UVLOWarningString, 8);
break;
case THERMOMETER:
temp = readIronTemp(0, 1, 0xFFFF); //Force a reading as heater is off
OLED_DrawString("Temp ", 5);//extra one to it clears the leftover 'L' from IDLE
drawTemp(temp, 5, 0);
break;
case DCINDISP: {
uint16_t voltage = readDCVoltage(systemSettings.voltageDiv); //get X10 voltage
if (StatusFlags == 0 || ((millis() % 1000) > 500)) {
OLED_DrawString("IN", 2);
OLED_DrawChar(48 + ((voltage / 100) % 10), 2);
voltage -= (voltage / 100) * 100;
OLED_DrawChar(48 + ((voltage / 10) % 10), 3);
voltage -= (voltage / 10) * 10;
OLED_DrawChar('.', 4);
OLED_DrawChar(48 + (voltage % 10), 5);
OLED_DrawChar('V', 6);
OLED_DrawChar(' ', 7);
} else {
OLED_DrawString("IN ", 8);
}
}
break;
case TEMPCAL: {
OLED_DrawString(TempCalStatus[StatusFlags], 8);
}
break;
default:
break;
}
}
|