-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathGrinder_Timer_1_1.ino
More file actions
848 lines (628 loc) · 23 KB
/
Grinder_Timer_1_1.ino
File metadata and controls
848 lines (628 loc) · 23 KB
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
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
/******************************************************/
// Setup how many ticks the encoder gives per click
int encoderScaler=1;
// uncomment "#define _Load_std_Values_" to Load standard Values
//#define _Load_std_Values_
// Specify Communication between I2C or UART
// I think I2C is more stable than UART - the code is only tested with I2C
#define _Digole_Serial_I2C_ //To tell compiler compile the special communication only, OLED DATA => ARDUINO ANALOG IN A4 ---- OLED CLK => ARDUINO ANALOG IN A5
//#define _Digole_Serial_UART_ //To tell compiler compile the special communication only, OLED DATA => ARDUINO DIGITAL IN 1
/*******************************************************/
#include <Encoder.h>
#include <EEPROM.h>
// Setup interface with OLED Display
//all available are:_Digole_Serial_UART_, _Digole_Serial_I2C_
#include <DigoleSerial.h>
//--------UART setup, if you don't use UART, use // to comment following line
#if defined(_Digole_Serial_UART_)
DigoleSerialDisp mydisp(&Serial, 9600); //UART:Arduino UNO: Pin 1(TX)on arduino to RX on module
#endif
//--------I2C setup, if you don't use I2C, use // to comment following 2 lines
#if defined(_Digole_Serial_I2C_)
#include <Wire.h>
DigoleSerialDisp mydisp(&Wire,'\x27'); //I2C:Arduino UNO: SDA (data line) is on analog input pin 4, and SCL (clock line) is on analog input pin 5 on UNO and Duemilanove
#endif
//-------------------------
const int buttonPin = 10; // Number of the push button pin
const int ButtonLedPin = 11; // Number of the Solid State pin
const int SsrPin = 12; // Number of the Solid State Relay pin
const int light_1 = 3; // Number of the Grinder Light 1 pin
const int light_2 = 5; // Number of the Grinder Light 2 pin
Encoder myEnc(9, 8); // Pins for encoder
int Button_Switch = 0;
double button_Seen = 0;
double Grinding_Started = 0;
double Save_Time;
double timeLeft;
double Total_Runtime;
double Total_kg_Grinded;
double Gram_of_coffee_per_sec = 2.5;
double Grinder_Run_Time_ms;
double Screen_Saver;
double Sleep_Time_min = 10;
int Grinder_State = 0;
boolean Grinder_State_Just_Changed = true;
int timerMode=0;
int ResumeResetTime=5;
int sleepLightLevel=1;
int minLightLevel=5;
int maxLightLevel=100;
int screenSaverTime=10;
int resetTotalTimer=0;
// Resume Time Variables
double ReStartResetTimer;
double WaitToStartAgain;
boolean DisplayState;
// Declare Fonts
const unsigned char fonts[] = {6, 10, 18, 51, 120, 123};
const char *fontdir[] = {"0\xb0", "90\xb0", "180\xb0", "270\xb0"};
void setup() {
// Setup PIns to In/Outputs
pinMode(ButtonLedPin, OUTPUT);
pinMode(buttonPin, INPUT);
pinMode(SsrPin, OUTPUT);
pinMode(light_1, OUTPUT);
pinMode(light_2, OUTPUT);
digitalWrite(buttonPin, HIGH); // Turn on Pull Up resistor
Serial.begin(9600); //Start Serial Communication
Init();
}
// Update values for Encoder function
//long oldPosition = EEPROM.read(100);
//int Saved_Value_to_EEPROM = oldPosition;
void loop() {
switch (Grinder_State){
case 0:{ // Idle waiting for things to be done
if (Grinder_State_Just_Changed){
Grinder_State_Just_Changed=false;
}
// Light in push button is pulsing
Button_Led(false);
// Grinder light is turned off
Grinder_Light(1);
// Check if grinder time is changed by encoder
Grinder_Run_Time_ms = Encoder_Counter_Grinder_Time();
// Check Button State
int TempButton = Button();
// Short Activation of Button
if ( 1 == TempButton ){
Grinder_State = 1;
Grinder_State_Just_Changed = true;
Screen_Saver=millis();
Save_Grinder_Run_Time_To_EEPROM(myEnc.read());
}
if ( 2 == TempButton ){
Grinder_State = 100;
Grinder_State_Just_Changed = true;
Screen_Saver=millis();
ClearOLED();
}
// Nothing happens - fall a sleep
if (millis() >= Screen_Saver + screenSaverTime*60000){
Grinder_State = 10;
Grinder_State_Just_Changed = true;
}
break;}
/*********************************************
Grinding
*********************************************/
case 1:
if (Grinder_State_Just_Changed){
Grinder_State_Just_Changed=false;
digitalWrite(SsrPin, HIGH); //Turn on motor
Grinding_Started = millis(); // Log grinder start time
}
// Steady light in Push Button
Button_Led(true);
// Turn on Grinder Light
Grinder_Light(2);
// Update grinder timer bar
CountDownBar(Grinder_Run_Time_ms, true);
//Grinder_Run_Time_ms = Encoder_Counter_Grinder_Time();
// Update lower display
//if (millis() + 50 <= Grinder_Run_Time_ms + Grinding_Started){
UpdateLowerDisplay((Grinding_Started + (Grinder_Run_Time_ms)-millis())/1000);
//}
// Check for grinder finished
if (millis() >= Grinder_Run_Time_ms + Grinding_Started){
// Update total run time
Total_Runtime = Total_Runtime + ((millis()-Grinding_Started)/1000);
// goto grinder switch state 0
Grinder_State = 0;
// Grinder switch state just changed
Grinder_State_Just_Changed = true;
// Turn OFF Grinder Solid State Relay
digitalWrite(SsrPin, LOW);
//Update lower part of display
UpdateLowerDisplayNOW(Grinder_Run_Time_ms/1000);
// Update top part of display - clear counter bar
CountDownBar(Grinder_Run_Time_ms, false);
ClearTopOLED();
// Save total runtime to EEprom
Save_Total_Run_Time_To_EEPROM(Total_Runtime);
// Update top part of display
UpdateTotalRunTimeDisplay (Total_Runtime);
}
// if button is pushed stop grinding
if ( 1 == Button()){
if (timerMode==0){
Serial.println("Grinder Stopped goto State 0");
// Update total run time
Total_Runtime = Total_Runtime + ((millis()-Grinding_Started)/1000);
// goto grinder switch state 0
Grinder_State = 0;
// Grinder switch state just changed
Grinder_State_Just_Changed = true;
digitalWrite(SsrPin, LOW);
//UpdateLowerDisplayNOW(Grinder_Run_Time_ms/1000);
CountDownBar(Grinder_Run_Time_ms, false);
ClearTopOLED();
// Save total runtime to EEprom
Save_Total_Run_Time_To_EEPROM(Total_Runtime);
// Update top part of display
UpdateTotalRunTimeDisplay (Total_Runtime);
}
else{
// Save Time Left
timeLeft=(Grinding_Started + (Grinder_Run_Time_ms)-millis());
UpdateLowerDisplayNOW(timeLeft/1000);
// Update total run time
Total_Runtime = Total_Runtime + ((millis()-Grinding_Started)/1000);
// goto grinder switch state 0
Grinder_State = 3;
Serial.println("Grinder Stopped goto State 3");
Serial.print("Time Left: ");
Serial.println(timeLeft);
// Grinder switch state just changed
Grinder_State_Just_Changed = true;
digitalWrite(SsrPin, LOW);
//UpdateLowerDisplayNOW(Grinder_Run_Time_ms/1000);
CountDownBar(Grinder_Run_Time_ms, true);
//ClearTopOLED();
// Save total runtime to EEprom
Save_Total_Run_Time_To_EEPROM(Total_Runtime);
// Update top part of display
//UpdateTotalRunTimeDisplay (Total_Runtime);
}
}
break;
/*********************************************
Resume mode paused grinder
*********************************************/
case 3:{
if (Grinder_State_Just_Changed){
Grinder_State_Just_Changed=false;
WaitToStartAgain=millis();
ReStartResetTimer=millis();
DisplayState=1;
}
// Flash resuming time on display
if (millis()>=WaitToStartAgain+400){
WaitToStartAgain=millis();
if (DisplayState==1){
DisplayState=0;
mydisp.setColor(0);
mydisp.drawBox(0,28,110,36);
mydisp.setColor(1);
}
else{
DisplayState=1;
UpdateLowerDisplayNOW(timeLeft/1000);
}
}
// Reset resume timer fired go back to Idle state
if (millis()>=ReStartResetTimer+ResumeResetTime*1000){
// goto grinder switch state 0
Grinder_State = 0;
// Grinder switch state just changed
Grinder_State_Just_Changed = true;
//Update lower part of display
UpdateLowerDisplayNOW(Grinder_Run_Time_ms/1000);
// Update top part of display - clear counter bar
CountDownBar(Grinder_Run_Time_ms, false);
// Clear entire OLED
ClearTopOLED();
// Save total runtime to EEprom
Save_Total_Run_Time_To_EEPROM(Total_Runtime);
// Update top part of display
UpdateTotalRunTimeDisplay (Total_Runtime);
}
// Check Button State
int TempButton = Button();
// Short Activation of Button
if ( 1 == TempButton ){
Grinder_State = 4;
Grinder_State_Just_Changed = true;
Screen_Saver=millis();
//Save_Grinder_Run_Time_To_EEPROM(myEnc.read());
}
if ( 2 == TempButton ){
Grinder_State = 100;
Grinder_State_Just_Changed = true;
Screen_Saver=millis();
ClearOLED();
}
break;}
/*********************************************
Resume mode grinding after pause
*********************************************/
case 4:
if (Grinder_State_Just_Changed){
Grinder_State_Just_Changed=false;
digitalWrite(SsrPin, HIGH); //Turn on motor
Grinding_Started = millis(); // Log grinder start time
}
// Steady light in Push Button
Button_Led(true);
// Turn on Grinder Light
Grinder_Light(2);
// Update grinder timer bar
CountDownBar(Grinder_Run_Time_ms, true);
//Grinder_Run_Time_ms = Encoder_Counter_Grinder_Time();
// Update lower display
if (millis() + 100 <= timeLeft + Grinding_Started){
UpdateLowerDisplay((Grinding_Started + (timeLeft)-millis())/1000);
}
// Check for grinder finished
if (millis() >= timeLeft + Grinding_Started){
// Update total run time
Total_Runtime = Total_Runtime + ((millis()-Grinding_Started)/1000);
// goto grinder switch state 0
Grinder_State = 0;
// Grinder switch state just changed
Grinder_State_Just_Changed = true;
// Turn OFF Grinder Solid State Relay
digitalWrite(SsrPin, LOW);
//Update lower part of display
UpdateLowerDisplayNOW(Grinder_Run_Time_ms/1000);
// Update top part of display - clear counter bar
CountDownBar(Grinder_Run_Time_ms, false);
// Clear entire OLED
ClearTopOLED();
// Save total runtime to EEprom
Save_Total_Run_Time_To_EEPROM(Total_Runtime);
// Update top part of display
UpdateTotalRunTimeDisplay (Total_Runtime);
}
// if button is pushed stop grinding
if ( 1 == Button()){
// Save Time Left
timeLeft=(Grinding_Started + (timeLeft)-millis());
// Update total run time
Total_Runtime = Total_Runtime + ((millis()-Grinding_Started)/1000);
// goto grinder switch state 0
Grinder_State = 3;
// Grinder switch state just changed
Grinder_State_Just_Changed = true;
digitalWrite(SsrPin, LOW);
//UpdateLowerDisplayNOW(Grinder_Run_Time_ms/1000);
CountDownBar(Grinder_Run_Time_ms, true);
// Save total runtime to EEprom
Save_Total_Run_Time_To_EEPROM(Total_Runtime);
}
break;
/*********************************************
Sleep Mode
*********************************************/
case 10:
if (Grinder_State_Just_Changed){
Grinder_State_Just_Changed=false;
ClearOLED();
}
// Check for button push
Button();
// Puls Push button light
//Button_Led(false);
Button_HeartBeat();
// Check for update of encoder values
Grinder_Run_Time_ms = Encoder_Counter_Grinder_Time();
// Grinder Light
Grinder_Light(0);
// shoul screen saver be interruptet
if (millis() <= Screen_Saver + 100){
Grinder_State = 0;
Grinder_State_Just_Changed = true;
Screen_Saver=millis();
Start_Screen();
}
break;
/*********************************************
Selection of Grinder Mode (Re-Start or Resume)
*********************************************/
case 100:{
if (Grinder_State_Just_Changed){
Grinder_State_Just_Changed=false;
mydisp.setFont(fonts[2]);
mydisp.setTextPosAbs(18,10);
mydisp.print("Timer mode");
myEnc.write(timerMode*encoderScaler);
//UpdateLowerDisplayInt(maxLightLevel);
mydisp.setFont(120); //font 123 only have chars of space and 1 to 9
//mydisp.setTextPosAbs(45,37);
if (timerMode==0){mydisp.setTextPosAbs(0,50);mydisp.print("0-ReStart");}
if (timerMode==1){mydisp.setTextPosAbs(0,50);mydisp.print("1-Resume");}
}
timerMode=Encoder_Mode(0,1);
Grinder_Light(1);
// Check Button State
int TempButton = Button();
if ( 1 == TempButton ){
Grinder_State_Just_Changed = true;
Grinder_State = 101;
ClearOLED();
Screen_Saver=millis();
}
if ( 2 == TempButton ){
Grinder_State = 0;
ClearOLED();
Save_Menu_To_EEPROM();
myEnc.write(EEPROM.read(100)*255+EEPROM.read(101));
Start_Screen();
//Grinder_State_Just_Changed = true;
Screen_Saver=millis();
}
break;}
/*********************************************
Set Reset time for Re-Start Mode
*********************************************/
case 101:{
if (Grinder_State_Just_Changed){
Grinder_State_Just_Changed=false;
mydisp.setFont(fonts[2]);
mydisp.setTextPosAbs(0,10);
mydisp.println("Set Reset Time");
mydisp.print("Resume Mode[s]");
myEnc.write(ResumeResetTime*encoderScaler);
UpdateLowerDisplayInt(ResumeResetTime);
}
ResumeResetTime=Encoder_Menu(0,100);
Grinder_Light(0);
// Check Button State
int TempButton = Button();
if ( 1 == TempButton ){
Grinder_State_Just_Changed = true;
Grinder_State = 109;
ClearOLED();
Screen_Saver=millis();
}
if ( 2 == TempButton ){
Grinder_State = 0;
ClearOLED();
Save_Menu_To_EEPROM();
myEnc.write(EEPROM.read(100)*255+EEPROM.read(101));
Start_Screen();
//Grinder_State_Just_Changed = true;
Screen_Saver=millis();
}
break;}
/*********************************************
Selection of Sleep Light Level
*********************************************/
case 109:{
if (Grinder_State_Just_Changed){
Grinder_State_Just_Changed=false;
mydisp.setFont(fonts[2]);
mydisp.setTextPosAbs(0,10);
mydisp.println("Sleep Light");
mydisp.print("Level [pct]");
myEnc.write(sleepLightLevel*encoderScaler);
UpdateLowerDisplayInt(sleepLightLevel);
}
sleepLightLevel=Encoder_Menu(0,100);
Grinder_Light(0);
// Check Button State
int TempButton = Button();
if ( 1 == TempButton ){
Grinder_State_Just_Changed = true;
Grinder_State = 110;
ClearOLED();
Screen_Saver=millis();
}
if ( 2 == TempButton ){
Grinder_State = 0;
ClearOLED();
Save_Menu_To_EEPROM();
myEnc.write(EEPROM.read(100)*255+EEPROM.read(101));
Start_Screen();
//Grinder_State_Just_Changed = true;
Screen_Saver=millis();
}
break;}
/*********************************************
Selection of Min Light Level
*********************************************/
case 110:{
if (Grinder_State_Just_Changed){
Grinder_State_Just_Changed=false;
mydisp.setFont(fonts[2]);
mydisp.setTextPosAbs(0,10);
mydisp.println("Idle Light");
mydisp.print("Level [pct]");
myEnc.write(minLightLevel*encoderScaler);
UpdateLowerDisplayInt(minLightLevel);
}
minLightLevel=Encoder_Menu(0,100);
Grinder_Light(1 );
// Check Button State
int TempButton = Button();
if ( 1 == TempButton ){
Grinder_State_Just_Changed = true;
Grinder_State = 120;
ClearOLED();
Screen_Saver=millis();
}
if ( 2 == TempButton ){
Grinder_State = 0;
ClearOLED();
Save_Menu_To_EEPROM();
myEnc.write(EEPROM.read(100)*255+EEPROM.read(101));
Start_Screen();
//Grinder_State_Just_Changed = true;
Screen_Saver=millis();
}
break;}
/*********************************************
Selection of Max Light Level
*********************************************/
case 120:{
if (Grinder_State_Just_Changed){
Grinder_State_Just_Changed=false;
mydisp.setFont(fonts[2]);
mydisp.setTextPosAbs(0,10);
mydisp.println("Grind Light");
mydisp.print("Level [pct]");
myEnc.write(maxLightLevel*encoderScaler);
UpdateLowerDisplayInt(maxLightLevel);
}
maxLightLevel=Encoder_Menu(0,100);
Grinder_Light(2);
// Check Button State
int TempButton = Button();
if ( 1 == TempButton ){
Grinder_State_Just_Changed = true;
Grinder_State = 130;
ClearOLED();
Screen_Saver=millis();
}
if ( 2 == TempButton ){
Grinder_State = 0;
ClearOLED();
Save_Menu_To_EEPROM();
myEnc.write(EEPROM.read(100)*255+EEPROM.read(101));
Start_Screen();
//Grinder_State_Just_Changed = true;
Screen_Saver=millis();
}
break;}
/*********************************************
Set Sleep Time
*********************************************/
case 130:{
if (Grinder_State_Just_Changed){
Grinder_State_Just_Changed=false;
mydisp.setFont(fonts[2]);
mydisp.setTextPosAbs(0,10);
mydisp.println("Sleep time");
mydisp.print("[min]");
myEnc.write(screenSaverTime*encoderScaler);
UpdateLowerDisplayInt(screenSaverTime);
}
screenSaverTime=Encoder_Menu(0,240);
Grinder_Light(1);
// Check Button State
int TempButton = Button();
if ( 1 == TempButton ){
Grinder_State_Just_Changed = true;
Grinder_State = 140;
ClearOLED();
Screen_Saver=millis();
}
if ( 2 == TempButton ){
Grinder_State = 0;
ClearOLED();
Save_Menu_To_EEPROM();
myEnc.write(EEPROM.read(100)*255+EEPROM.read(101));
Start_Screen();
//Grinder_State_Just_Changed = true;
Screen_Saver=millis();
}
break;}
/*********************************************
Reset Total Counter
*********************************************/
case 140:{
if (Grinder_State_Just_Changed){
Grinder_State_Just_Changed=false;
mydisp.setFont(fonts[2]);
mydisp.setTextPosAbs(0,10);
mydisp.println("Reset Total");
mydisp.print("Counter");
myEnc.write(resetTotalTimer*encoderScaler);
//UpdateLowerDisplayInt(maxLightLevel);
mydisp.setFont(120); //font 123 only have chars of space and 1 to 9
//mydisp.setTextPosAbs(45,37);
if (resetTotalTimer==0){mydisp.setTextPosAbs(20,55);mydisp.print("0-NO");}
if (resetTotalTimer==1){mydisp.setTextPosAbs(15,55);mydisp.print("1-YES");}
}
resetTotalTimer=Encoder_Reset(0,1);
Grinder_Light(1);
// Check Button State
int TempButton = Button();
if ( 1 == TempButton ){
if (resetTotalTimer==1){
Grinder_State_Just_Changed = true;
Grinder_State = 141;
ClearOLED();
Screen_Saver=millis();
resetTotalTimer=0;
}
else if (resetTotalTimer==0){
Grinder_State = 100;
Grinder_State_Just_Changed = true;
Screen_Saver=millis();
ClearOLED();
}
}
if ( 2 == TempButton ){
Grinder_State = 0;
ClearOLED();
Save_Menu_To_EEPROM();
myEnc.write(EEPROM.read(100)*255+EEPROM.read(101));
Start_Screen();
//Grinder_State_Just_Changed = true;
Screen_Saver=millis();
}
break;}
/*********************************************
Are Yor sure you want to Reset
*********************************************/
case 141:
if (Grinder_State_Just_Changed){
Grinder_State_Just_Changed=false;
mydisp.setFont(fonts[2]);
mydisp.setTextPosAbs(0,10);
mydisp.println("ARE YOU SURE?");
//mydisp.print("Counter");
myEnc.write(resetTotalTimer*encoderScaler);
//UpdateLowerDisplayInt(maxLightLevel);
mydisp.setFont(120); //font 123 only have chars of space and 1 to 9
//mydisp.setTextPosAbs(45,37);
if (resetTotalTimer==0){mydisp.setTextPosAbs(20,55);mydisp.print("0-NO");}
if (resetTotalTimer==1){mydisp.setTextPosAbs(15,55);mydisp.print("1-YES");}
}
resetTotalTimer=Encoder_Reset(0,1);
Grinder_Light(1);
// Check Button State
int TempButton = Button();
if ( 1 == TempButton ){
if (resetTotalTimer==1){
resetTotalTimer=0;
Grinder_State = 0;
ClearOLED();
Save_Menu_To_EEPROM();
Total_Runtime=0;
Save_Total_Run_Time_To_EEPROM(Total_Runtime);
myEnc.write(EEPROM.read(100)*255+EEPROM.read(101));
Start_Screen();
//Grinder_State_Just_Changed = true;
Screen_Saver=millis();
}
else if (resetTotalTimer==0){
Grinder_State = 100;
Grinder_State_Just_Changed = true;
Screen_Saver=millis();
ClearOLED();
}
}
if ( 2 == TempButton ){
Grinder_State = 0;
ClearOLED();
Save_Menu_To_EEPROM();
myEnc.write(EEPROM.read(100)*255+EEPROM.read(101));
Start_Screen();
//Grinder_State_Just_Changed = true;
Screen_Saver=millis();
}
break;
}
}