Этот? Куда его?
#define pulse_high(p,d) digitalWrite(p,HIGH);delay(d);digitalWrite(p,LOW);
#define B_CLK 50
Вот сама программа:
#include <OneWire.h>
#include <DallasTemperature.h>
#include <UTFT.h>
#include <UTouch.h>
#include <Wire.h>
#include <Time.h>
#include <DS1307RTC.h>
#include <memorysaver.h>
extern uint8_t SmallRusFont[];
extern uint8_t BigRusFont[];
extern uint8_t SevenSegNumFont[];
UTFT myGLCD(ITDB32WC, 38,39,40,41);
UTouch myTouch(6,5,4,3,2);
#define ONE_WIRE_BUS 12
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
DeviceAddress insideThermometer;
int pumpPin = 10;
int buzzerPin = 8;
int buzzerPwPin = 9;
int heatPin = 11;
char* stMash[] = {"C""\xAB\xA3\xAC"" co""\xA0""o""\x99", "\x89""ay""\x9C""a"" 1", "\x89""ay""\x9C""a"" 2", "\x89""ay""\x9C""a"" 3", "\x89""ay""\x9C""a"" 4", "\x89""ay""\x9C""a"" 5", "Me""\xA8""ay""\xA4"};
char* stHops[] = {"K""\x9D\xA3\xAF\xA7""e""\xA2\x9D""e", " ", "X""\xA1""e""\xA0""\xAC"" 1", "X""\xA1""e""\xA0""\xAC"" 2", "X""\xA1""e""\xA0""\xAC"" 3", "X""\xA1""e""\xA0""\xAC"" 4", "X""\xA1""e""\xA0""\xAC"" 5"};
char* stMessage[] = {"\x82""O""\x80""A""""B""\x92"" BO""\x82\x91", "TEM""\x89""EPAT""\x8A""PA", "'C", "\x82""O""\x80""A""B""\x86""T""\x92"" CO""\x88""O""\x82", "\x97""pe""\xA1\xAF", "\x8A\x99""a""\xA0\x9D\xA4\xAC", "\x8A\x82""A""\x88\x86""T""\x92"" ""\x82""PO""\x80\x86""H""\x8A", "\x9F\x9D\xA3""e""\xA2\x9D""e", "K""\x86\x89\x95\x8D""EH""\x86""E"};
int arLineX = 0;
int arLineY = 0;
int scr = 0;
int strPl = 0;
int brew = 0;
int mash = 0;
int heat = 0;
int timer = 0;
int addCheck = 0;
int actBoil = 0;
int aBoilPw = 100;
int boilPw = 100;
int hopsBeep = 0;
unsigned long time;
int swDel = 0;
int lineN = 0;
int chLine = 0;
int x, y, i;
int r, g, b, bgR, bgG, bgB;
float tempC = 0;
int t11, t12, t21, t22;
int s1x, s1y, s2x, s2y, s3x, s3y, s4x, s4y, s5x, s5y, s6x, s6y, s7x, s7y;
int sw, swSw, swXY;
int tempNum = 0;
int timeNum = 0;
int addMalt = 40;
int rest1Temp = 0;
int rest2Temp = 0;
int rest3Temp = 0;
int rest4Temp = 0;
int rest5Temp = 0;
int mashOutTemp = 78;
int rest1Time = 0;
int rest2Time = 0;
int rest3Time = 0;
int rest4Time = 0;
int rest5Time = 0;
int mashOutTime = 0;
int boilTime = 0;
int activeBoilTime = 0;
int hops1Time = 0;
int hops2Time = 0;
int hops3Time = 0;
int hops4Time = 0;
int hops5Time = 0;
int aMalt, r1Temp, r2Temp, r3Temp, r4Temp, r5Temp, mOTemp, r1Time, r2Time, r3Time, r4Time, r5Time, mOTime, boil, aBoil, h1, h2, h3, h4, h5;
int timerHours, timerMinutes, timerSeconds, showHours, showMinutes, showSeconds, calcTime, aBoilHours, aBoilMinutes, aBoilSeconds, hopsHours, hopsMinutes, aBt1, aBt2;
void beep (int tone, int duration)
{
digitalWrite(buzzerPwPin, HIGH);
delay(15);
for (long i = 0; i < duration * 500L; i += tone * 1)
{
digitalWrite(buzzerPin, HIGH);
delayMicroseconds(tone);
digitalWrite(buzzerPin, LOW);
delayMicroseconds(tone);
}
digitalWrite(buzzerPwPin, LOW);
}
void setup ()
{
myGLCD.InitLCD();
myGLCD.clrScr();
myTouch.InitTouch();
myTouch.setPrecision(PREC_EXTREME);
pinMode(pumpPin, OUTPUT);
pinMode(buzzerPin, OUTPUT);
pinMode(buzzerPwPin, OUTPUT);
pinMode(heatPin, OUTPUT);
myGLCD.setFont(BigRusFont);
myGLCD.setBackColor(0, 0, 255);
sensors.begin();
sensors.getAddress(insideThermometer, 0);
sensors.setResolution(insideThermometer, 10);
sensors.requestTemperatures();
tempC = sensors.getTempCByIndex(0);
r = 255;
g = 0;
b = 0;
screen (scr, 1, 0,0,0,0);
beep (1136, 1000);
}
void drawNumLine (int lx, int ly, int direc)
{
swXY = 4;
swSw = 0;
if (direc == 0)
{
for (sw=0; sw<=8; sw++)
{
myGLCD.drawLine (lx+swXY, ly, (lx+37)-swXY, ly);
ly = ly+1;
if (swSw == 0)
{
swXY = swXY-1;
}
else
{
swXY = swXY+1;
}
if (swXY == 0)
{
swSw = 1;
}
}
}
if (direc == 1)
{
for (sw=0; sw<=8; sw++)
{
myGLCD.drawLine (lx, ly+swXY, lx, (ly+41)-swXY);
lx = lx+1;
if (swSw == 0)
{
swXY = swXY-1;
}
else
{
swXY = swXY+1;
}
if (swXY == 0)
{
swSw = 1;
}
}
}
}
void drawNum (int num)
{
myGLCD.setColor (r, g, b);
if (num==0)
{
drawNumLine (s1x, s1y, 0);
drawNumLine (s2x, s2y, 1);
drawNumLine (s3x, s3y, 1);
drawNumLine (s5x, s5y, 1);
drawNumLine (s6x, s6y, 1);
drawNumLine (s7x, s7y, 0);
myGLCD.setColor (bgR, bgG, bgB);
drawNumLine (s4x, s4y, 0);
myGLCD.setColor (r, g, b);
}
if (num==1)
{
drawNumLine (s3x, s3y, 1);
drawNumLine (s6x, s6y, 1);
myGLCD.setColor (bgR, bgG, bgB);
drawNumLine (s1x, s1y, 0);
drawNumLine (s2x, s2y, 1);
drawNumLine (s4x, s4y, 0);
drawNumLine (s5x, s5y, 1);
drawNumLine (s7x, s7y, 0);
myGLCD.setColor (r, g, b);
}
if (num==2)
{
drawNumLine (s1x, s1y, 0);
drawNumLine (s3x, s3y, 1);
drawNumLine (s4x, s4y, 0);
drawNumLine (s5x, s5y, 1);
drawNumLine (s7x, s7y, 0);
myGLCD.setColor (bgR, bgG, bgB);
drawNumLine (s2x, s2y, 1);
drawNumLine (s6x, s6y, 1);
myGLCD.setColor (r, g, b);
}
if (num==3)
{
drawNumLine (s1x, s1y, 0);
drawNumLine (s3x, s3y, 1);
drawNumLine (s4x, s4y, 0);
drawNumLine (s6x, s6y, 1);
drawNumLine (s7x, s7y, 0);
myGLCD.setColor (bgR, bgG, bgB);
drawNumLine (s2x, s2y, 1);
drawNumLine (s5x, s5y, 1);
myGLCD.setColor (r, g, b);
}
if (num==4)
{
drawNumLine (s2x, s2y, 1);
drawNumLine (s3x, s3y, 1);
drawNumLine (s4x, s4y, 0);
drawNumLine (s6x, s6y, 1);
myGLCD.setColor (bgR, bgG, bgB);
drawNumLine (s1x, s1y, 0);
drawNumLine (s5x, s5y, 1);
drawNumLine (s7x, s7y, 0);
myGLCD.setColor (r, g, b);
}
if (num==5)
{
drawNumLine (s1x, s1y, 0);
drawNumLine (s2x, s2y, 1);
drawNumLine (s4x, s4y, 0);
drawNumLine (s6x, s6y, 1);
drawNumLine (s7x, s7y, 0);
myGLCD.setColor (bgR, bgG, bgB);
drawNumLine (s3x, s3y, 1);
drawNumLine (s5x, s5y, 1);
myGLCD.setColor (r, g, b);
}
if (num==6)
{
drawNumLine (s1x, s1y, 0);
drawNumLine (s2x, s2y, 1);
drawNumLine (s4x, s4y, 0);
drawNumLine (s5x, s5y, 1);
drawNumLine (s6x, s6y, 1);
drawNumLine (s7x, s7y, 0);
myGLCD.setColor (bgR, bgG, bgB);
drawNumLine (s3x, s3y, 1);
myGLCD.setColor (r, g, b);
}
if (num==7)
{
drawNumLine (s1x, s1y, 0);
drawNumLine (s3x, s3y, 1);
drawNumLine (s6x, s6y, 1);
myGLCD.setColor (bgR, bgG, bgB);
drawNumLine (s2x, s2y, 1);
drawNumLine (s4x, s4y, 0);
drawNumLine (s5x, s5y, 1);
drawNumLine (s7x, s7y, 0);
myGLCD.setColor (r, g, b);
}
if (num==8)
{
drawNumLine (s1x, s1y, 0);
drawNumLine (s2x, s2y, 1);
drawNumLine (s3x, s3y, 1);
drawNumLine (s4x, s4y, 0);
drawNumLine (s5x, s5y, 1);
drawNumLine (s6x, s6y, 1);
drawNumLine (s7x, s7y, 0);
}
if (num==9)
{
drawNumLine (s1x, s1y, 0);
drawNumLine (s2x, s2y, 1);
drawNumLine (s3x, s3y, 1);
drawNumLine (s4x, s4y, 0);
drawNumLine (s6x, s6y, 1);
drawNumLine (s7x, s7y, 0);
myGLCD.setColor (bgR, bgG, bgB);
drawNumLine (s5x, s5y, 1);
myGLCD.setColor (r, g, b);
}
if (num==10)
{
myGLCD.setColor (bgR, bgG, bgB);
drawNumLine (s1x, s1y, 0);
drawNumLine (s2x, s2y, 1);
drawNumLine (s3x, s3y, 1);
drawNumLine (s4x, s4y, 0);
drawNumLine (s5x, s5y, 1);
drawNumLine (s6x, s6y, 1);
drawNumLine (s7x, s7y, 0);
myGLCD.setColor (r, g, b);
}
}
void numCoord (int numX, int numY)
{
s1x = numX+6;
s1y = numY;
s2x = numX;
s2y = numY+6;
s3x = numX+41;
s3y = numY+6;
s4x = numX+6;
s4y = numY+45;
s5x = numX;
s5y = numY+51;
s6x = numX+41;
s6y = numY+51;
s7x = numX+6;
s7y = numY+90;
}
void printTemperature(DeviceAddress deviceAddress)
{
tempC = sensors.getTempCByIndex(0);
if (mash==17)
{
tempC = 99;
}
if (tempC < 0)
{
tempC = 0;
}
if (tempC > 99)
{
tempC = 99;
}
if (tempC >= 10)
{
t11 = tempC/10;
t21 = tempC-(t11*10);
if (t11 != t12)
{
numCoord (185, 71);
drawNum (10);
drawNum (t11);
t12 = t11;
}
if (t21 != t22)
{
numCoord (250, 71);
drawNum (10);
drawNum (t21);
t22 = t21;
}
}
if (tempC < 10)
{
if (t12 > 0)
{
numCoord (185, 71);
drawNum (10);
t11 = 0;
t12 = t11;
}
t21 = tempC;
if (t21 != t22)
{
numCoord (250, 71);
drawNum (10);
drawNum (t21);
t22 = t21;
}
}
}
void screen (int screenN, int screenFont, int screenFontX1, int screenFontY1, int screenFontX2, int screenFontY2)
{
if (screenFont == 1)
{
myGLCD.fillScr (0, 0, 0);
delay (1000);
}
if (screenFontX2 > 0)
{
myGLCD.fillRect (screenFontX1, screenFontY1, screenFontX2, screenFontY2);
}
if (screenN == 0)
{
myGLCD.setBackColor (255, 0, 0); //цвет заливки натписи красный
myGLCD.setColor (255, 0, 0); //цвет надписи пуск
myGLCD.fillRoundRect (10, 5, 309, 64);
myGLCD.setColor (255, 255, 255);
myGLCD.print ("\x89\x8A""CK", 120, 25); // кнопка пуск
myGLCD.setBackColor (0, 0, 255);
myGLCD.setColor (0, 0, 255);
myGLCD.fillRoundRect (10, 75, 309, 234);
//myGLCD.fillRoundRect (10, 125, 309, 174);
//myGLCD.fillRoundRect (10, 185, 309, 234);
myGLCD.setColor (255, 255, 255);
myGLCD.drawRoundRect (10, 5, 309, 64);
myGLCD.drawRoundRect (10, 75, 309, 234);
//myGLCD.drawRoundRect (10, 125, 309, 174);
// myGLCD.drawRoundRect (10, 185, 309, 234);
myGLCD.print ("\x81""OTOB""\x86""M ""\x89\x86""BO", 55, 130); //готовим пиво
if (brew == 0)
{
// myGLCD.print ("P""\x8A""\x8D""HO""\x87", 112, 142);
}
if (brew > 0)
{
// myGLCD.print ("TO BREW", 104, 142);
}
//myGLCD.print ("HACTPO""\x87""K""\x86", 96, 202);
}
if (screenN == 1)
{
myGLCD.setBackColor (0, 0, 255);
myGLCD.setColor (4, 12, 0);
myGLCD.fillRoundRect (10, 5, 240, 114);
myGLCD.setColor (0, 0, 255);
myGLCD.fillRoundRect (250, 5, 309, 54);
myGLCD.fillRoundRect (250, 65, 309, 114);
myGLCD.fillRoundRect (10, 125, 154, 174);
myGLCD.fillRoundRect (165, 125, 309, 174);
myGLCD.fillRoundRect (10, 185, 309, 234);
myGLCD.setColor (255, 255, 255);
myGLCD.drawRoundRect (10, 5, 240, 114);
myGLCD.drawRoundRect (250, 5, 309, 54);
myGLCD.drawRoundRect (250, 65, 309, 114);
myGLCD.drawRoundRect (10, 125, 154, 174);
myGLCD.drawRoundRect (165, 125, 309, 174);
myGLCD.drawRoundRect (10, 185, 309, 234);
myGLCD.drawLine (109, 191, 109, 224);
myGLCD.drawLine (110, 190, 110, 225);
myGLCD.drawLine (111, 191, 111, 224);
myGLCD.drawLine (209, 191, 209, 224);
myGLCD.drawLine (210, 190, 210, 225);
myGLCD.drawLine (211, 191, 211, 224);
drawArrow (0, 280, 30);
drawArrow (1, 280, 90);
drawArrow (2, 33, 150);
drawArrow (3, 131, 150);
drawArrow (2, 188, 150);
drawArrow (3, 286, 150);
myGLCD.print ("HA""\x85""A""\x82", 22, 202);
myGLCD.print ("\x82""A""\x88""EE", 220, 202);
myGLCD.setFont(SmallRusFont);
myGLCD.print ("TEM""\x89""EPAT""\x8A""PA", 40, 128);
myGLCD.print ("BPEM""\x95", 220, 128);
myGLCD.setFont(BigRusFont);
myGLCD.setBackColor (4, 12, 0);
myGLCD.setColor (252, 252, 124);
myGLCD.print ("\x8A""c""\xA4""a""\xA2""o""\x97""k""\x9D", 55, 8);
myGLCD.setBackColor (0, 0, 255);
lineN = 0;
chLine = 0;
lines ();
showNumbers ();
}
if (screenN == 2)
{
myGLCD.setBackColor (0, 0, 255);
myGLCD.setColor (4, 12, 0);
myGLCD.fillRoundRect (10, 5, 240, 114);
myGLCD.setColor (0, 0, 255);
myGLCD.fillRoundRect (250, 5, 309, 54);
myGLCD.fillRoundRect (250, 65, 309, 114);
myGLCD.fillRoundRect (10, 125, 154, 174);
myGLCD.fillRoundRect (165, 125, 309, 174);
myGLCD.fillRoundRect (10, 185, 309, 234);
myGLCD.setColor (255, 255, 255);
myGLCD.drawRoundRect (10, 5, 240, 114);
myGLCD.drawRoundRect (250, 5, 309, 54);
myGLCD.drawRoundRect (250, 65, 309, 114);
myGLCD.drawRoundRect (10, 125, 154, 174);
myGLCD.drawRoundRect (165, 125, 309, 174);
myGLCD.drawRoundRect (10, 185, 309, 234);
myGLCD.drawLine (109, 191, 109, 224);
myGLCD.drawLine (110, 190, 110, 225);
myGLCD.drawLine (111, 191, 111, 224);
myGLCD.drawLine (209, 191, 209, 224);
myGLCD.drawLine (210, 190, 210, 225);
myGLCD.drawLine (211, 191, 211, 224);
drawArrow (0, 280, 30);
drawArrow (1, 280, 90);
drawArrow (2, 33, 150);
drawArrow (3, 131, 150);
drawArrow (2, 188, 150);
drawArrow (3, 286, 150);
myGLCD.print ("HA""\x85""A""\x82", 22, 202);
myGLCD.print ("\x82""A""\x88""EE", 220, 202);
myGLCD.setFont(SmallRusFont);
myGLCD.setColor (140, 140, 255);
myGLCD.print ("TEM""\x89""EPAT""\x8A""PA", 40, 128);
myGLCD.setColor (255, 255, 255);
myGLCD.print ("BPEM""\x95", 220, 128);
myGLCD.setFont(BigRusFont);
myGLCD.setBackColor (4, 12, 0);
myGLCD.setColor (252, 252, 124);
myGLCD.print ("\x85""ak""\xA0""a""\x99""ka"" X""\xA1""e""\xA0""\xAF", 13, 8);
myGLCD.setBackColor (0, 0, 255);
lineN = 0;
chLine = 0;
lines ();
showNumbers ();
}
if (screenN == 3)
{
myGLCD.setBackColor (0, 0, 255);
myGLCD.setColor (4, 12, 0);
myGLCD.fillRoundRect (10, 5, 309, 174);
myGLCD.setColor (0, 0, 255);
myGLCD.fillRoundRect (10, 185, 309, 234);
myGLCD.setColor (255, 255, 255);
myGLCD.drawRoundRect (10, 5, 309, 174);
myGLCD.drawRoundRect (10, 185, 309, 234);
myGLCD.drawLine (109, 196, 109, 224);
myGLCD.drawLine (110, 195, 110, 225);
myGLCD.drawLine (111, 196, 111, 224);
myGLCD.drawLine (209, 196, 209, 224);
myGLCD.drawLine (210, 195, 210, 225);
myGLCD.drawLine (211, 196, 211, 224);
myGLCD.print ("HA""\x85""A""\x82", 22, 202);
// myGLCD.print ("Coxpa", 122, 190);
// myGLCD.print ("\xA2""\x9D""\xA4""\xAC",128,210);
if (brew == 0)
{
myGLCD.print ("CTAPT", 220, 202);
}
myGLCD.drawLine (159, 15, 159, 164);
myGLCD.setBackColor (4, 12, 0);
myGLCD.setColor (252, 252, 124);
myGLCD.print ("\x85""a""\xA4""\x9D""pa""\xA2""\x9D""e", 14, 8);
myGLCD.print ("X""\xA1""e""\xA0""\xAC",196, 8);
myGLCD.setBackColor (0, 0, 255);
lines ();
showNumbers ();
}
if (screenN == 4)
{
myGLCD.setBackColor (0, 0, 255);
myGLCD.setColor (4, 12, 0);
myGLCD.fillRoundRect (10, 60, 169, 179);
myGLCD.setColor (0, 0, 255);
myGLCD.fillRoundRect (10, 185, 309, 234);
myGLCD.fillRoundRect (10, 5, 309, 54);
myGLCD.setColor (255, 255, 255);
myGLCD.drawRoundRect (10, 60, 169, 179);
myGLCD.drawRoundRect (10, 185, 309, 234);
myGLCD.drawRoundRect (10, 5, 309, 54);
myGLCD.drawLine (109, 196, 109, 224);
myGLCD.drawLine (110, 195, 110, 225);
myGLCD.drawLine (111, 196, 111, 224);
myGLCD.drawLine (209, 196, 209, 224);
myGLCD.drawLine (210, 195, 210, 225);
myGLCD.drawLine (211, 196, 211, 224);
myGLCD.drawRoundRect (175, 60, 309, 179);
//myGLCD.print ("MEH""\x94", 28, 202);
// myGLCD.print ("CTO""\x89", 228, 202);
}
}
void drawArrow (int der, int arX, int arY)
{
if (der == 0)
{
myGLCD.drawLine (arX-2, arY-13, arX-2, arY+15);
myGLCD.drawLine (arX-1, arY-14, arX-1, arY+15);
myGLCD.drawLine (arX, arY-15, arX, arY+15);
myGLCD.drawLine (arX+1, arY-14, arX+1, arY+15);
myGLCD.drawLine (arX+2, arY-13, arX+2, arY+15);
arLineX = arX-3;
arLineY = arY-12;
while (arLineY < arY)
{
myGLCD.drawLine (arLineX, arLineY, arLineX, arY-1);
arLineX = arLineX--;
arLineY = arLineY++;
}
arLineX = arX+3;
arLineY = arY-12;
while (arLineY < arY)
{
myGLCD.drawLine (arLineX, arLineY, arLineX, arY-1);
arLineX = arLineX++;
arLineY = arLineY++;
}
}
if (der == 1)
{
myGLCD.drawLine (arX-2, arY+13, arX-2, arY-15);
myGLCD.drawLine (arX-1, arY+14, arX-1, arY-15);
myGLCD.drawLine (arX, arY+15, arX, arY-15);
myGLCD.drawLine (arX+1, arY+14, arX+1, arY-15);
myGLCD.drawLine (arX+2, arY+13, arX+2, arY-15);
arLineX = arX-3;
arLineY = arY+12;
while (arLineY > arY)
{
myGLCD.drawLine (arLineX, arLineY, arLineX, arY+1);
arLineX = arLineX--;
arLineY = arLineY--;
}
arLineX = arX+3;
arLineY = arY+12;
while (arLineY > arY)
{
myGLCD.drawLine (arLineX, arLineY, arLineX, arY+1);
arLineX = arLineX++;
arLineY = arLineY--;
}
}
if (der == 2)
{
myGLCD.drawLine (arX-13, arY-2, arX+15, arY-2);
myGLCD.drawLine (arX-14, arY-1, arX+15, arY-1);
myGLCD.drawLine (arX-15, arY, arX+15, arY);
myGLCD.drawLine (arX-14, arY+1, arX+15, arY+1);
myGLCD.drawLine (arX-13, arY+2, arX+15, arY+2);
arLineX = arX-12;
arLineY = arY+3;
while (arLineX < arX)
{
myGLCD.drawLine (arLineX, arLineY, arX, arLineY);
arLineX = arLineX++;
arLineY = arLineY++;
}
arLineX = arX-12;
arLineY = arY-3;
while (arLineX < arX)
{
myGLCD.drawLine (arLineX, arLineY, arX, arLineY);
arLineX = arLineX++;
arLineY = arLineY--;
}
}
if (der == 3)
{
myGLCD.drawLine (arX-15, arY-2, arX+13, arY-2);
myGLCD.drawLine (arX-15, arY-1, arX+14, arY-1);
myGLCD.drawLine (arX-15, arY, arX+15, arY);
myGLCD.drawLine (arX-15, arY+1, arX+14, arY+1);
myGLCD.drawLine (arX-15, arY+2, arX+13, arY+2);
arLineX = arX+12;
arLineY = arY+3;
while (arLineX > arX)
{
myGLCD.drawLine (arLineX, arLineY, arX, arLineY);
arLineX = arLineX--;
arLineY = arLineY++;
}
arLineX = arX+12;
arLineY = arY-3;
while (arLineX > arX)
{
myGLCD.drawLine (arLineX, arLineY, arX, arLineY);
arLineX = arLineX--;
arLineY = arLineY--;
}
}
}
void lines ()
{
int lineY = 26;
if (scr == 1)
{
myGLCD.setColor (55, 72, 54);
myGLCD.setBackColor (4, 12, 0);
for (int i = 0; i < 5; i++)
{
myGLCD.print (stMash[lineN], 13, lineY);
lineN++;
lineY = lineY + 17;
}
myGLCD.setColor (63, 254, 0);
lineN = (lineN-5) + chLine;
lineY = 26 + (chLine * 17);
myGLCD.print (stMash[lineN], 13, lineY);
lineN = lineN - chLine;
}
if (scr == 2)
{
myGLCD.setColor (55, 72, 54);
myGLCD.setBackColor (4, 12, 0);
for (int i = 0; i < 5; i++)
{
myGLCD.print (stHops[lineN], 13, lineY);
lineN++;
lineY = lineY + 17;
}
myGLCD.setColor (63, 254, 0);
lineN = (lineN-5) + chLine;
lineY = 26 + (chLine * 17);
myGLCD.print (stHops[lineN], 13, lineY);
lineN = lineN - chLine;
}
if (scr == 3)
{
myGLCD.setFont (SmallRusFont);
myGLCD.setColor (63, 254, 0);
myGLCD.setBackColor (4, 12, 0);
myGLCD.print ("C""\x7F", 90, 26);
myGLCD.print ("Bpe""\xA1""\xAF", 118, 26);
myGLCD.print ("Bpe""\xA1""\xAF", 265, 26);
lineY = 39;
for (int i = 0; i < 7; i++)
{
myGLCD.print (stMash[i], 15, lineY);
lineY = lineY + 13;
}
lineY = 39;
for (int i = 0; i < 7; i++)
{
myGLCD.print (stHops[i], 164, lineY);
lineY = lineY + 13;
}
myGLCD.setFont (BigRusFont);
}
}
void showNumbers ()
{
if (scr==1)
{
myGLCD.setColor (255, 255, 255);
myGLCD.setBackColor (0, 0, 255);
if (lineN==0)
{
if (chLine==0)
{
tempNum = addMalt;
timeNum = 0;
}
if (chLine==1)
{
tempNum = rest1Temp;
timeNum = rest1Time;
}
if (chLine==2)
{
tempNum = rest2Temp;
timeNum = rest2Time;
}
}
if ((lineN==1) && (chLine==2))
{
tempNum = rest3Temp;
timeNum = rest3Time;
}
if ((lineN==2) && (chLine==2))
{
tempNum = rest4Temp;
timeNum = rest4Time;
}
if ((lineN==2) && (chLine==3))
{
tempNum = rest5Temp;
timeNum = rest5Time;
}
if ((lineN==2) && (chLine==4))
{
tempNum = mashOutTemp;
timeNum = mashOutTime;
}
if (tempNum<10)
{
strPl = 16;
}
if ((tempNum>=10) && (tempNum<100))
{
strPl = 8;
}
if (tempNum>=100)
{
strPl = 0;
}
myGLCD.print (" ", 58, 143);
myGLCD.printNumI (tempNum, 58+strPl, 143);
if (timeNum<10)
{
strPl = 16;
}
if ((timeNum>=10) && (timeNum<100))
{
strPl = 8;
}
if (timeNum>=100)
{
strPl = 0;
}
myGLCD.print (" ", 213, 143);
myGLCD.printNumI (timeNum, 213+strPl, 143);
}
if (scr==2)
{
myGLCD.setColor (255, 255, 255);
myGLCD.setBackColor (0, 0, 255);
if (lineN==0)
{
if (chLine==0)
{
tempNum = 0;
timeNum = boilTime;
}
if (chLine==1)
{
tempNum = 0;
timeNum = activeBoilTime;
}
if (chLine==2)
{
tempNum = 0;
timeNum = hops1Time;
}
}
if ((lineN==1) && (chLine==2))
{
tempNum = 0;
timeNum = hops2Time;
}
if ((lineN==2) && (chLine==2))
{
tempNum = 0;
timeNum = hops3Time;
}
if ((lineN==2) && (chLine==3))
{
tempNum = 0;
timeNum = hops4Time;
}
if ((lineN==2) && (chLine==4))
{
tempNum = 0;
timeNum = hops5Time;
}
if (tempNum<10)
{
strPl = 16;
}
if ((tempNum>=10) && (tempNum<100))
{
strPl = 8;
}
if (tempNum>=100)
{
strPl = 0;
}
myGLCD.print (" ", 58, 143);
myGLCD.printNumI (tempNum, 58+strPl, 143);
if (timeNum<10)
{
strPl = 16;
}
if ((timeNum>=10) && (timeNum<100))
{
strPl = 8;
}
if (timeNum>=100)
{
strPl = 0;
}
myGLCD.print (" ", 213, 143);
myGLCD.printNumI (timeNum, 213+strPl, 143);
}
if (scr==3)
{
myGLCD.setFont(SmallRusFont);
myGLCD.setColor (252, 252, 124);
myGLCD.setBackColor (4, 12, 0);
if (addMalt>=10)
{
myGLCD.printNumI (addMalt, 95, 39);
}
else
{
myGLCD.printNumI (addMalt, 103, 39);
}
if (rest1Temp>=10)
{
myGLCD.printNumI (rest1Temp, 95, 52);
}
else
{
myGLCD.printNumI (rest1Temp, 103, 52);
}
if (rest2Temp>=10)
{
myGLCD.printNumI (rest2Temp, 95, 65);
}
else
{
myGLCD.printNumI (rest2Temp, 103, 65);
}
if (rest3Temp>=10)
{
myGLCD.printNumI (rest3Temp, 95, 78);
}
else
{
myGLCD.printNumI (rest3Temp, 103, 78);
}
if (rest4Temp>=10)
{
myGLCD.printNumI (rest4Temp, 95, 91);
}
else
{
myGLCD.printNumI (rest4Temp, 103, 91);
}
if (rest5Temp>=10)
{
myGLCD.printNumI (rest5Temp, 95, 104);
}
else
{
myGLCD.printNumI (rest5Temp, 103, 104);
}
if (mashOutTemp>=10)
{
myGLCD.printNumI (mashOutTemp, 95, 117);
}
else
{
myGLCD.printNumI (mashOutTemp, 103, 117);
}
myGLCD.printNumI (0, 147, 39);
if (rest1Time<10)
{
myGLCD.printNumI (rest1Time, 147, 52);
}
if ((rest1Time>=10) && (rest1Time<100))
{
myGLCD.printNumI (rest1Time, 139, 52);
}
if (rest1Time>=100)
{
myGLCD.printNumI (rest1Time, 131, 52);
}
if (rest2Time<10)
{
myGLCD.printNumI (rest2Time, 147, 65);
}
if ((rest2Time>=10) && (rest2Time<100))
{
myGLCD.printNumI (rest2Time, 139, 65);
}
if (rest2Time>=100)
{
myGLCD.printNumI (rest2Time, 131, 65);
}
if (rest3Time<10)
{
myGLCD.printNumI (rest3Time, 147, 78);
}
if ((rest3Time>=10) && (rest3Time<100))
{
myGLCD.printNumI (rest3Time, 139, 78);
}
if (rest3Time>=100)
{
myGLCD.printNumI (rest3Time, 131, 78);
}
if (rest4Time<10)
{
myGLCD.printNumI (rest4Time, 147, 91);
}
if ((rest4Time>=10) && (rest4Time<100))
{
myGLCD.printNumI (rest4Time, 139, 91);
}
if (rest4Time>=100)
{
myGLCD.printNumI (rest4Time, 131, 91);
}
if (rest5Time<10)
{
myGLCD.printNumI (rest5Time, 147, 104);
}
if ((rest5Time>=10) && (rest5Time<100))
{
myGLCD.printNumI (rest5Time, 139, 104);
}
if (rest5Time>=100)
{
myGLCD.printNumI (rest5Time, 131, 104);
}
if (mashOutTime<10)
{
myGLCD.printNumI (mashOutTime, 147, 117);
}
if ((mashOutTime>=10) && (mashOutTime<100))
{
myGLCD.printNumI (mashOutTime, 139, 117);
}
if (mashOutTime>=100)
{
myGLCD.printNumI (mashOutTime, 131, 117);
}
if (boilTime<10)
{
myGLCD.printNumI (boilTime, 297, 39);
}
if ((boilTime>=10) && (boilTime<100))
{
myGLCD.printNumI (boilTime, 289, 39);
}
if (boilTime>=100)
{
myGLCD.printNumI (boilTime, 281, 39);
}
if (activeBoilTime<10)
{
myGLCD.printNumI (activeBoilTime, 297, 52);
}
if ((activeBoilTime>=10) && (activeBoilTime<100))
{
myGLCD.printNumI (activeBoilTime, 289, 52);
}
if (activeBoilTime>=100)
{
myGLCD.printNumI (activeBoilTime, 281, 52);
}
if (hops1Time<10)
{
myGLCD.printNumI (hops1Time, 297, 65);
}
if ((hops1Time>=10) && (hops1Time<100))
{
myGLCD.printNumI (hops1Time, 289, 65);
}
if (hops1Time>=100)
{
myGLCD.printNumI (hops1Time, 281, 65);
}
if (hops2Time<10)
{
myGLCD.printNumI (hops2Time, 297, 78);
}
if ((hops2Time>=10) && (hops2Time<100))
{
myGLCD.printNumI (hops2Time, 289, 78);
}
if (hops2Time>=100)
{
myGLCD.printNumI (hops2Time, 281, 78);
}
if (hops3Time<10)
{
myGLCD.printNumI (hops3Time, 297, 91);
}
if ((hops3Time>=10) && (hops3Time<100))
{
myGLCD.printNumI (hops3Time, 289, 91);
}
if (hops3Time>=100)
{
myGLCD.printNumI (hops3Time, 281, 91);
}
if (hops4Time<10)
{
myGLCD.printNumI (hops4Time, 297, 104);
}
if ((hops4Time>=10) && (hops4Time<100))
{
myGLCD.printNumI (hops4Time, 289, 104);
}
if (hops4Time>=100)
{
myGLCD.printNumI (rest5Time, 281, 104);
}
if (hops5Time<10)
{
myGLCD.printNumI (hops5Time, 297, 117);
}
if ((hops5Time>=10) && (hops5Time<100))
{
myGLCD.printNumI (hops5Time, 289, 117);
}
if (hops5Time>=100)
{
myGLCD.printNumI (hops5Time, 281, 117);
}
}
myGLCD.setFont(BigRusFont);
}
void pushButton (int butt, int tt)
{
if (butt==0)
{
while (myTouch.dataAvailable())
myTouch.read();
x = 0;
y = 0;
}
if (butt==1)
{
if ((lineN==0) && (chLine>0))
{
chLine--;
}
if ((lineN>0) && (chLine==2))
{
lineN--;
}
if ((lineN==2) && (chLine>2))
{
chLine--;
}
myGLCD.setColor (4, 12, 0);
myGLCD.fillRoundRect (11, 25, 238, 113);
lines ();
showNumbers ();
}
if (butt==2)
{
if ((lineN==2) && (chLine<4))
{
chLine++;
}
if ((lineN<2) && (chLine==2))
{
lineN++;
}
if ((lineN==0) && (chLine<2))
{
chLine++;
}
myGLCD.setColor (4, 12, 0);
myGLCD.fillRoundRect (11, 25, 238, 113);
lines ();
showNumbers ();
}
if (tt==1)
{
myGLCD.setColor (255, 255, 255);
myGLCD.setBackColor (0, 0, 255);
if (butt==3)
{
if (tempNum>0)
{
tempNum--;
if (tempNum<10)
{
tempNum = 0;
}
}
}
if (butt==4)
{
if (tempNum<99)
{
tempNum++;
if (tempNum<10)
{
tempNum = 10;
}
}
}
if (lineN==0)
{
if (chLine==0)
{
addMalt = tempNum;
}
if (chLine==1)
{
rest1Temp= tempNum;
}
if (chLine==2)
{
rest2Temp = tempNum;
}
}
if ((lineN==1) && (chLine==2))
{
rest3Temp = tempNum;
}
if ((lineN==2) && (chLine==2))
{
rest4Temp = tempNum;
}
if ((lineN==2) && (chLine==3))
{
rest5Temp = tempNum;
}
if ((lineN==2) && (chLine==4))
{
mashOutTemp = tempNum;
}
showNumbers ();
}
if (tt==2)
{
if (butt==3)
{
if (timeNum>0)
{
timeNum--;
}
}
if (butt==4)
{
if (timeNum<300)
{
timeNum++;
}
}
if (scr==1)
{
if (lineN==0)
{
if (chLine==1)
{
rest1Time= timeNum;
}
if (chLine==2)
{
rest2Time = timeNum;
}
}
if ((lineN==1) && (chLine==2))
{
rest3Time = timeNum;
}
if ((lineN==2) && (chLine==2))
{
rest4Time = timeNum;
}
if ((lineN==2) && (chLine==3))
{
rest5Time = timeNum;
}
if ((lineN==2) && (chLine==4))
{
mashOutTime = timeNum;
}
}
if (scr==2)
{
if (lineN==0)
{
if (chLine==0)
{
boilTime = timeNum;
}
if (chLine==1)
{
activeBoilTime= timeNum;
}
if (chLine==2)
{
hops1Time = timeNum;
}
}
if ((lineN==1) && (chLine==2))
{
hops2Time = timeNum;
}
if ((lineN==2) && (chLine==2))
{
hops3Time = timeNum;
}
if ((lineN==2) && (chLine==3))
{
hops4Time = timeNum;
}
if ((lineN==2) && (chLine==4))
{
hops5Time = timeNum;
}
}
showNumbers ();
}
}
void mashing ()
{
if (mash != 17)
{
sensors.requestTemperatures();
tempC = sensors.getTempCByIndex(0);
}
if (mash == 1)
{
if (tempC < aMalt)
{
if (heat == 0)
{
digitalWrite(heatPin, HIGH);
heat = 1;
}
}
if (tempC >= aMalt)
{
if (heat == 1)
{
digitalWrite(heatPin, LOW);
heat = 0;
mash = 2;
digitalWrite(pumpPin, LOW);
mashMessages();
}
}
}
if (mash == 3)
{
if (tempC < r1Temp)
{
if (heat == 0)
{
digitalWrite(heatPin, HIGH);
heat = 1;
}
}
if (tempC >= r1Temp)
{
if (heat == 1)
{
digitalWrite(heatPin, LOW);
heat = 0;
mash = 4;
setTimer(r1Time);
mashMessages();
}
}
}
if (mash == 4)
{
if (timer == 1)
{
if (tempC < r1Temp)
{
if (heat == 0)
{
digitalWrite(heatPin, HIGH);
heat = 1;
}
}
if (tempC >= r1Temp)
{
if (heat == 1)
{
digitalWrite(heatPin, LOW);
heat = 0;
}
}
}
if (timer == 0)
{
mash = 5;
mashMessages();
}
}
if (mash == 5)
{
if (tempC < r2Temp)
{
if (heat == 0)
{
digitalWrite(heatPin, HIGH);
heat = 1;
}
}
if (tempC >= r2Temp)
{
if (heat == 1)
{
digitalWrite(heatPin, LOW);
heat = 0;
mash = 6;
setTimer(r2Time);
mashMessages();
}
}
}
if (mash == 6)
{
if (timer == 1)
{
if (tempC < r2Temp)
{
if (heat == 0)
{
digitalWrite(heatPin, HIGH);
heat = 1;
}
}
if (tempC >= r2Temp)
{
if (heat == 1)
{
digitalWrite(heatPin, LOW);
heat = 0;
}
}
}
if (timer == 0)
{
mash = 7;
mashMessages();
}
}
if (mash == 7)
{
if (tempC < r3Temp)
{
if (heat == 0)
{
digitalWrite(heatPin, HIGH);
heat = 1;
}
}
if (tempC >= r3Temp)
{
if (heat == 1)
{
digitalWrite(heatPin, LOW);
heat = 0;
mash = 8;
setTimer(r3Time);
mashMessages();
}
}
}
if (mash == 8)
{
if (timer == 1)
{
if (tempC < r3Temp)
{
if (heat == 0)
{
digitalWrite(heatPin, HIGH);
heat = 1;
}
}
if (tempC >= r3Temp)
{
if (heat == 1)
{
digitalWrite(heatPin, LOW);
heat = 0;
}
}
}
if (timer == 0)
{
mash = 9;
mashMessages();
}
}
if (mash == 9)
{
if (tempC < r4Temp)
{
if (heat == 0)
{
digitalWrite(heatPin, HIGH);
heat = 1;
}
}
if (tempC >= r4Temp)
{
if (heat == 1)
{
digitalWrite(heatPin, LOW);
heat = 0;
mash = 10;
setTimer(r4Time);
mashMessages();
}
}
}
if (mash == 10)
{
if (timer == 1)
{
if (tempC < r4Temp)
{
if (heat == 0)
{
digitalWrite(heatPin, HIGH);
heat = 1;
}
}
if (tempC >= r4Temp)
{
if (heat == 1)
{
digitalWrite(heatPin, LOW);
heat = 0;
}
}
}
if (timer == 0)
{
mash = 11;
mashMessages();
}
}
if (mash == 11)
{
if (tempC < r5Temp)
{
if (heat == 0)
{
digitalWrite(heatPin, HIGH);
heat = 1;
}
}
if (tempC >= r5Temp)
{
if (heat == 1)
{
digitalWrite(heatPin, LOW);
heat = 0;
mash = 12;
setTimer(r5Time);
mashMessages();
}
}
}
if (mash == 12)
{
if (timer == 1)
{
if (tempC < r5Temp)
{
if (heat == 0)
{
digitalWrite(heatPin, HIGH);
heat = 1;
}
}
if (tempC >= r5Temp)
{
if (heat == 1)
{
digitalWrite(heatPin, LOW);
heat = 0;
}
}
}
if (timer == 0)
{
mash = 13;
mashMessages();
}
}
if (mash == 13)
{
if (tempC < mOTemp)
{
if (heat == 0)
{
digitalWrite(heatPin, HIGH);
heat = 1;
}
}
if (tempC >= mOTemp)
{
if (heat == 1)
{
digitalWrite(heatPin, LOW);
heat = 0;
mash = 14;
setTimer(mOTime);
mashMessages();
}
}
}
if (mash == 14)
{
if (timer == 1)
{
if (tempC < mOTemp)
{
if (heat == 0)
{
digitalWrite(heatPin, HIGH);
heat = 1;
}
}
if (tempC >= mOTemp)
{
if (heat == 1)
{
digitalWrite(heatPin, LOW);
heat = 0;
}
}
}
if (timer == 0)
{
mash = 15;
mashMessages();
}
}
if (mash == 16)
{
if (tempC < 97)
{
if (heat == 0)
{
digitalWrite(heatPin, HIGH);
heat = 1;
}
}
if (tempC >= 97)
{
if (heat == 1)
{
mash = 17;
setTimer(boil);
mashMessages();
}
}
}
if (mash==17)
{
if (actBoil == 1)
{
if (aBoilPw < 100)
{
{
if (swDel==0)
{
digitalWrite(heatPin, HIGH);
heat = 1;
time = millis();
swDel = 1;
}
if (swDel==1)
{
if (millis()>=time+aBoilPw*20)
{
swDel = 2;
}
}
if (swDel==2)
{
digitalWrite(heatPin, LOW);
heat = 0;
time = millis();
swDel = 3;
}
if (swDel==3)
{
if (millis()>=time+(2000-aBoilPw*20))
{
swDel = 0;
}
}
}
}
else
{
if (heat == 0)
{
digitalWrite(heatPin, HIGH);
heat = 1;
}
}
}
else
{
if (boilPw < 100)
{
if (swDel==0)
{
digitalWrite(heatPin, HIGH);
heat = 1;
time = millis();
swDel = 1;
}
if (swDel==1)
{
if (millis()>=time+boilPw*20)
{
swDel = 2;
}
}
if (swDel==2)
{
digitalWrite(heatPin, LOW);
heat = 0;
time = millis();
swDel = 3;
}
if (swDel==3)
{
if (millis()>=time+(2000-boilPw*20))
{
swDel = 0;
}
}
}
else
{
if (heat == 0)
{
digitalWrite(heatPin, HIGH);
heat = 1;
}
}
}
if (timer == 0)
{
mash = 18;
digitalWrite(heatPin, LOW);
heat = 0;
mashMessages();
}
}
if (mash==19)
{
sensors.requestTemperatures();
tempC = sensors.getTempCByIndex(0);
printTemperature(insideThermometer);
}
}
void setTimer(int mashTime)
{
tmElements_t tm;
if (timer == 0)
{
if (RTC.read(tm))
{
timerSeconds = tm.Second;
timerMinutes = tm.Minute+mashTime;
timerHours = tm.Hour;
while (timerMinutes > 59)
{
timerMinutes = timerMinutes-60;
timerHours = timerHours + 1;
}
if (timerHours > 23)
{
timerHours = timerHours - 24;
}
if (mash == 17)
{
if ((h1 > 0) && (h1 != boil))
{
hopsBeep = 1;
hopsMinutes = timerMinutes-h1;
hopsHours = timerHours;
while (hopsMinutes < 0)
{
hopsMinutes = hopsMinutes+60;
hopsHours = hopsHours - 1;
}
}
if (h1 == boil)
{
beep (1136, 1000);
hopsMinutes = timerMinutes-h2;
hopsHours = timerHours;
while (hopsMinutes < 0)
{
hopsMinutes = hopsMinutes+60;
hopsHours = hopsHours - 1;
}
hopsBeep = 2;
}
if (aBoil > 0)
{
actBoil = 1;
aBoilSeconds = tm.Second;
aBoilMinutes = tm.Minute+aBoil;
aBoilHours = tm.Hour;
while (aBoilMinutes > 59)
{
aBoilMinutes = aBoilMinutes-60;
aBoilHours = aBoilHours + 1;
}
}
}
}
timer = 1;
}
}
void checkTimer()
{
tmElements_t tm;
if (timer == 1)
{
if (RTC.read(tm))
{
if ((timerHours == tm.Hour) && (timerMinutes <= tm.Minute) && (timerSeconds <= tm.Second))
{
timer = 0;
}
if (actBoil == 1)
{
if ((aBoilHours == tm.Hour) && (aBoilMinutes <= tm.Minute) && (aBoilSeconds <= tm.Second))
{
actBoil = 0;
myGLCD.setColor (63, 254, 0);
myGLCD.setBackColor (4, 12, 0);
if (boilPw < 100)
{
myGLCD.printNumI(boilPw, 119, 112);
}
else
{
myGLCD.printNumI(boilPw, 103, 112);
}
myGLCD.setBackColor (0, 0, 255);
}
}
if (hopsBeep == 1)
{
if ((hopsHours == tm.Hour) && (hopsMinutes <= tm.Minute) && (timerSeconds <= tm.Second))
{
beep (1136, 1000);
if ((h2 > 0) && (h2 != h1))
{
hopsMinutes = timerMinutes-h2;
hopsHours = timerHours;
while (hopsMinutes < 0)
{
hopsMinutes = hopsMinutes+60;
hopsHours = hopsHours - 1;
}
hopsBeep = 2;
}
else
{
hopsBeep = 0;
}
}
}
if (hopsBeep == 2)
{
if ((hopsHours == tm.Hour) && (hopsMinutes <= tm.Minute) && (timerSeconds <= tm.Second))
{
beep (1136, 1000);
if ((h3 > 0) && (h3 != h2))
{
hopsMinutes = timerMinutes-h3;
hopsHours = timerHours;
while (hopsMinutes < 0)
{
hopsMinutes = hopsMinutes+60;
hopsHours = hopsHours - 1;
}
hopsBeep = 3;
}
else
{
hopsBeep = 0;
}
}
}
if (hopsBeep == 3)
{
if ((hopsHours == tm.Hour) && (hopsMinutes <= tm.Minute) && (timerSeconds <= tm.Second))
{
beep (1136, 1000);
if ((h4 > 0) && (h4 != h3))
{
hopsMinutes = timerMinutes-h4;
hopsHours = timerHours;
while (hopsMinutes < 0)
{
hopsMinutes = hopsMinutes+60;
hopsHours = hopsHours - 1;
}
hopsBeep = 4;
}
else
{
hopsBeep = 0;
}
}
}
if (hopsBeep == 4)
{
if ((hopsHours == tm.Hour) && (hopsMinutes <= tm.Minute) && (timerSeconds <= tm.Second))
{
beep (1136, 1000);
if ((h5 > 0) && (h5 != h4))
{
hopsMinutes = timerMinutes-h5;
hopsHours = timerHours;
while (hopsMinutes < 0)
{
hopsMinutes = hopsMinutes+60;
hopsHours = hopsHours - 1;
}
hopsBeep = 5;
}
else
{
hopsBeep = 0;
}
}
}
if (hopsBeep == 5)
{
if ((hopsHours == tm.Hour) && (hopsMinutes <= tm.Minute) && (timerSeconds <= tm.Second))
{
beep (1136, 1000);
hopsBeep = 0;
}
}
}
}
}
void mashMessages()
{
tmElements_t tm;
if (mash==0)
{
myGLCD.setColor(252, 252, 124);
myGLCD.print(stMessage[0], 65, 22);
myGLCD.setColor(63, 254, 0);
myGLCD.print("CTAPT", 120, 202);
addCheck = 1;
while (addCheck==1)
{
if (myTouch.dataAvailable())
{
myTouch.read();
x=myTouch.getX();
y=myTouch.getY();
if ((y>=185) && (y<=234) && (x>=112) && (x<=208))
{
addCheck = 0;
mash = 1;
myGLCD.setColor (0, 0, 255);
myGLCD.fillRect (114, 187, 206, 232);
}
}
}
}
if (mash==1)
{
myGLCD.setColor (0, 0, 255);
myGLCD.fillRoundRect (12, 7, 307, 52);
myGLCD.setColor(252, 252, 124);
myGLCD.print(stMessage[1], 80, 12);
myGLCD.print(stMash[0], 48, 32);
myGLCD.printNumI(aMalt, 208, 32);
myGLCD.print(stMessage[2], 240, 32);
pumpAir();
}
if (mash==2)
{
if (scr != 4)
{
scr=4;
screen (scr, 1, 0,0,0,0);
numCoord (185, 71);
drawNum (0);
numCoord (250, 71);
drawNum (0);
t12 = 0;
t22 = 0;
}
myGLCD.setColor (0, 0, 255);
myGLCD.fillRoundRect (12, 7, 307, 52);
myGLCD.setColor(252, 252, 124);
myGLCD.print(stMash[0], 96, 12);
myGLCD.setColor(63, 254, 0);
myGLCD.print("CTAPT", 120, 202);
addCheck = 1;
sensors.requestTemperatures();
tempC = sensors.getTempCByIndex(0);
printTemperature(insideThermometer);
beep (1136, 1000);
delay(1000);
beep (1136, 1000);
while (addCheck==1)
{
if (myTouch.dataAvailable())
{
myTouch.read();
x=myTouch.getX();
y=myTouch.getY();
if ((y>=185) && (y<=234) && (x>=112) && (x<=208))
{
addCheck = 0;
mash = 3;
myGLCD.setColor (0, 0, 255);
myGLCD.fillRect (114, 187, 206, 232);
}
}
}
}
if (mash==3)
{
myGLCD.setColor (0, 0, 255);
myGLCD.fillRoundRect (12, 7, 307, 52);
myGLCD.setColor(252, 252, 124);
myGLCD.print(stMessage[1], 80, 12);
myGLCD.print(stMash[1], 64, 32);
myGLCD.printNumI(r1Temp, 192, 32);
myGLCD.print(stMessage[2], 224, 32);
digitalWrite(pumpPin, HIGH);
}
if (mash == 4)
{
if (scr == 4)
{
myGLCD.setColor (0, 0, 255);
myGLCD.fillRoundRect (12, 7, 307, 52);
myGLCD.setColor(252, 252, 124);
myGLCD.print(stMash[1], 96, 12);
myGLCD.print(":", 80, 32);
myGLCD.print(":", 128, 32);
myGLCD.print(stMessage[4], 184, 32);
}
}
if (mash==5)
{
if (r2Time > 0)
{
if (scr == 4)
{
myGLCD.setColor (0, 0, 255);
myGLCD.fillRoundRect (12, 7, 307, 52);
myGLCD.setColor(252, 252, 124);
myGLCD.print(stMessage[1], 80, 12);
myGLCD.print(stMash[2], 64, 32);
myGLCD.printNumI(r2Temp, 192, 32);
myGLCD.print(stMessage[2], 224, 32);
}
}
else
{
mash = 7;
}
}
if (mash == 6)
{
if (scr == 4)
{
myGLCD.setColor (0, 0, 255);
myGLCD.fillRoundRect (12, 7, 307, 52);
myGLCD.setColor(252, 252, 124);
myGLCD.print(stMash[2], 96, 12);
myGLCD.print(":", 80, 32);
myGLCD.print(":", 128, 32);
myGLCD.print(stMessage[4], 184, 32);
}
}
if (mash==7)
{
if (r3Time > 0)
{
if (scr == 4)
{
myGLCD.setColor (0, 0, 255);
myGLCD.fillRoundRect (12, 7, 307, 52);
myGLCD.setColor(252, 252, 124);
myGLCD.print(stMessage[1], 80, 12);
myGLCD.print(stMash[3], 64, 32);
myGLCD.printNumI(r3Temp, 192, 32);
myGLCD.print(stMessage[2], 224, 32);
}
}
else
{
mash = 9;
}
}
if (mash == 8)
{
if (scr == 4)
{
myGLCD.setColor (0, 0, 255);
myGLCD.fillRoundRect (12, 7, 307, 52);
myGLCD.setColor(252, 252, 124);
myGLCD.print(stMash[3], 96, 12);
myGLCD.print(":", 80, 32);
myGLCD.print(":", 128, 32);
myGLCD.print(stMessage[4], 184, 32);
}
}
if (mash==9)
{
if (r4Time > 0)
{
if (scr == 4)
{
myGLCD.setColor (0, 0, 255);
myGLCD.fillRoundRect (12, 7, 307, 52);
myGLCD.setColor(252, 252, 124);
myGLCD.print(stMessage[1], 80, 12);
myGLCD.print(stMash[4], 64, 32);
myGLCD.printNumI(r4Temp, 192, 32);
myGLCD.print(stMessage[2], 224, 32);
}
}
else
{
mash = 11;
}
}
if (mash == 10)
{
if (scr == 4)
{
myGLCD.setColor (0, 0, 255);
myGLCD.fillRoundRect (12, 7, 307, 52);
myGLCD.setColor(252, 252, 124);
myGLCD.print(stMash[4], 96, 12);
myGLCD.print(":", 80, 32);
myGLCD.print(":", 128, 32);
myGLCD.print(stMessage[4], 184, 32);
}
}
if (mash==11)
{
if (r5Time > 0)
{
if (scr == 4)
{
myGLCD.setColor (0, 0, 255);
myGLCD.fillRoundRect (12, 7, 307, 52);
myGLCD.setColor(252, 252, 124);
myGLCD.print(stMessage[1], 80, 12);
myGLCD.print(stMash[5], 64, 32);
myGLCD.printNumI(r5Temp, 192, 32);
myGLCD.print(stMessage[2], 224, 32);
}
}
else
{
mash = 13;
}
}
if (mash == 12)
{
if (scr == 4)
{
myGLCD.setColor (0, 0, 255);
myGLCD.fillRoundRect (12, 7, 307, 52);
myGLCD.setColor(252, 252, 124);
myGLCD.print(stMash[5], 96, 12);
myGLCD.print(":", 80, 32);
myGLCD.print(":", 128, 32);
myGLCD.print(stMessage[4], 184, 32);
}
}
if (mash==13)
{
if (mOTime > 0)
{
if (scr == 4)
{
myGLCD.setColor (0, 0, 255);
myGLCD.fillRoundRect (12, 7, 307, 52);
myGLCD.setColor(252, 252, 124);
myGLCD.print(stMessage[1], 80, 12);
myGLCD.print(stMash[6], 64, 32);
myGLCD.printNumI(mOTemp, 192, 32);
myGLCD.print(stMessage[2], 224, 32);
}
}
else
{
mash = 15;
}
}
if (mash == 14)
{
if (scr == 4)
{
myGLCD.setColor (0, 0, 255);
myGLCD.fillRoundRect (12, 7, 307, 52);
myGLCD.setColor(252, 252, 124);
myGLCD.print(stMash[6], 96, 12);
myGLCD.print(":", 80, 32);
myGLCD.print(":", 128, 32);
myGLCD.print(stMessage[4], 184, 32);
}
}
if (mash==15)
{
if (scr != 4)
{
scr=4;
screen (scr, 1, 0,0,0,0);
numCoord (185, 71);
drawNum (0);
numCoord (250, 71);
drawNum (0);
t12 = 0;
t22 = 0;
}
myGLCD.setColor (0, 0, 255);
myGLCD.fillRoundRect (12, 7, 307, 52);
myGLCD.setColor(252, 252, 124);
//myGLCD.print(stMessage[5], 64, 12);
myGLCD.print(stMessage[6], 36, 22);
myGLCD.print("CTAPT", 120, 202);
addCheck = 1;
digitalWrite(pumpPin, LOW);
digitalWrite(heatPin, LOW);
heat = 0;
sensors.requestTemperatures();
tempC = sensors.getTempCByIndex(0);
printTemperature(insideThermometer);
beep (1136, 1000);
delay(1000);
beep (1136, 1000);
while (addCheck==1)
{
if (myTouch.dataAvailable())
{
myTouch.read();
x=myTouch.getX();
y=myTouch.getY();
if ((y>=185) && (y<=234) && (x>=112) && (x<=208))
{
addCheck = 0;
if (boil > 0)
{
mash = 16;
}
else
{
mash = 18;
}
myGLCD.setColor (0, 0, 255);
myGLCD.fillRect (114, 187, 206, 232);
}
}
}
}
if (mash==16)
{
if (scr == 4)
{
myGLCD.setColor (0, 0, 255);
myGLCD.fillRoundRect (12, 7, 307, 52);
myGLCD.setColor(252, 252, 124);
myGLCD.print(stMessage[1], 80, 12);
myGLCD.print(stMessage[7], 64, 32);
myGLCD.printNumI(97, 192, 32);
myGLCD.print(stMessage[2], 224, 32);
}
else
{
mash = 19;
}
}
if (mash == 17)
{
printTemperature(insideThermometer);
myGLCD.setColor (0, 0, 255);
myGLCD.fillRoundRect (12, 7, 307, 52);
myGLCD.setColor(252, 252, 124);
myGLCD.print(stMessage[7], 128, 12);
myGLCD.print(":", 80, 32);
myGLCD.print(":", 128, 32);
myGLCD.print(stMessage[4], 184, 32);
myGLCD.setColor(255, 255, 255);
drawArrow (0, 135, 85);
drawArrow (1, 135, 155);
myGLCD.setColor (63, 254, 0);
myGLCD.setBackColor (4, 12, 0);
myGLCD.print("%", 151, 112);
if (aBoil > 0)
{
if (aBoilPw < 100)
{
myGLCD.printNumI(aBoilPw, 119, 112);
}
else
{
myGLCD.printNumI(aBoilPw, 103, 112);
}
}
else
{
if (boilPw < 100)
{
myGLCD.printNumI(boilPw, 119, 112);
}
else
{
myGLCD.printNumI(boilPw, 103, 112);
}
}
myGLCD.setBackColor (0, 0, 255);
}
if (mash==18)
{
myGLCD.setColor (0, 0, 255);
myGLCD.fillRoundRect (12, 7, 307, 52);
myGLCD.setColor(252, 252, 124);
myGLCD.print(stMessage[8], 88, 12);
myGLCD.print("CTAPT", 120, 202);
addCheck = 1;
sensors.requestTemperatures();
tempC = sensors.getTempCByIndex(0);
printTemperature(insideThermometer);
beep (1136, 1000);
delay(1000);
beep (1136, 1000);
while (addCheck==1)
{
if (myTouch.dataAvailable())
{
myTouch.read();
x=myTouch.getX();
y=myTouch.getY();
if ((y>=185) && (y<=234) && (x>=112) && (x<=208))
{
addCheck = 0;
mash = 19;
myGLCD.setColor (0, 0, 255);
myGLCD.fillRect (114, 187, 206, 232);
}
}
}
}
}
void pumpAir ()
{
for (i=0; i<3; i++)
{
sensors.requestTemperatures();
tempC = sensors.getTempCByIndex(0);
printTemperature(insideThermometer);
digitalWrite(pumpPin, HIGH);
delay(3000);
digitalWrite(pumpPin, LOW);
delay(3000);
}
digitalWrite(pumpPin, HIGH);
}
void loop ()
{
tmElements_t tm;
if (myTouch.dataAvailable())
{
myTouch.read();
x=myTouch.getX();
y=myTouch.getY();
if (scr==0)
{
if ((y>=5) && (y<=54))
{
pushButton (0,0);
scr = 1;
screen (scr, 1, 0,0,0,0);
}
if ((y>=125) && (y<=174))
{
if (brew > 0)
{
pushButton (0,0);
scr=4;
screen (scr, 1, 0,0,0,0);
mashMessages();
numCoord (185, 71);
drawNum (0);
numCoord (250, 71);
drawNum (0);
t12 = 0;
t22 = 0;
}
}
}
if (scr==1)
{
if ((x>=250) && (x<=309))
{
if ((y>=5) && (y<=54))
{
pushButton (1,0);
}
if ((y>=65) && (y<=114))
{
pushButton (2,0);
}
}
if ((y>=125) && (y<=174))
{
if ((x>=10) && (x<=57))
{
pushButton (3,1);
delay (100);
}
if ((x>=106) && (x<=154))
{
pushButton (4,1);
delay (100);
}
if ((x>=165) && (x<=212))
{
pushButton (3,2);
delay (100);
}
if ((x>=261) && (x<=309))
{
pushButton (4,2);
delay (100);
}
}
if ((y>=185) && (y<=234))
{
if ((x>=10) && (x<=100))
{
pushButton (0,0);
scr=0;
screen (scr, 1, 0,0,0,0);
}
if ((x>=220) && (x<=319))
{
pushButton (0,0);
scr=2;
screen (scr, 1, 0,0,0,0);
}
}
}
if (scr==2)
{
if ((x>=250) && (x<=309))
{
if ((y>=5) && (y<=54))
{
pushButton (1,0);
}
if ((y>=65) && (y<=114))
{
pushButton (2,0);
}
}
if ((y>=125) && (y<=174))
{
if ((x>=165) && (x<=212))
{
pushButton (3,2);
delay (100);
}
if ((x>=261) && (x<=309))
{
pushButton (4,2);
delay (100);
}
}
if ((y>=185) && (y<=234))
{
if ((x>=10) && (x<=100))
{
pushButton (0,0);
scr=1;
screen (scr, 1, 0,0,0,0);
}
if ((x>=220) && (x<=319))
{
pushButton (0,0);
scr=3;
screen (scr, 1, 0,0,0,0);
}
}
}
if (scr==3)
{
if ((y>=185) && (y<=234))
{
if ((x>=10) && (x<=100))
{
pushButton (0,0);
scr=2;
screen (scr, 1, 0,0,0,0);
}
if ((x>=220) && (x<=319))
{
if (brew == 0)
{
pushButton (0,0);
scr=4;
screen (scr, 1, 0,0,0,0);
numCoord (185, 71);
drawNum (0);
numCoord (250, 71);
drawNum (0);
t12 = 0;
t22 = 0;
sensors.requestTemperatures();
tempC = sensors.getTempCByIndex(0);
printTemperature(insideThermometer);
aMalt = addMalt;
r1Temp = rest1Temp;
r2Temp = rest2Temp;
r3Temp = rest3Temp;
r4Temp = rest4Temp;
r5Temp = rest5Temp;
mOTemp = mashOutTemp;
r1Time = rest1Time;
r2Time = rest2Time;
r3Time = rest3Time;
r4Time = rest4Time;
r5Time = rest5Time;
mOTime = mashOutTime;
boil = boilTime;
aBoil = activeBoilTime;
h1 = hops1Time;
h2 = hops2Time;
h3 = hops3Time;
h4 = hops4Time;
h5 = hops5Time;
brew = 1;
mashMessages();
}
}
}
}
if (scr==4)
{
if ((x>=10) && (x<=100))
{
pushButton (0,0);
scr=0;
screen (scr, 1, 0,0,0,0);
}
if (actBoil==1)
{
if ((x>=110) && (x<=160) && (y>=60) && (y<=110))
{
myGLCD.setColor (63, 254, 0);
myGLCD.setBackColor (4, 12, 0);
i=0;
digitalWrite(heatPin, HIGH);
heat = 1;
while (myTouch.dataAvailable())
{
if (aBoilPw < 97)
{
aBoilPw = aBoilPw+1;
i++;
if (i<=5)
{
delay (250);
}
else
{
delay (100);
}
myGLCD.print(" ", 103, 112);
if (aBoilPw < 97)
{
myGLCD.printNumI(aBoilPw, 119, 112);
}
else
{
myGLCD.printNumI(aBoilPw, 103, 112);
}
}
myTouch.read();
x=0;
y=0;
}
myGLCD.setBackColor (0, 0, 255);
}
if ((x>=110) && (x<=160) && (y>=130) && (y<=180))
{
myGLCD.setColor (63, 254, 0);
myGLCD.setBackColor (4, 12, 0);
i=0;
digitalWrite(heatPin, LOW);
heat = 0;
while (myTouch.dataAvailable())
{
if (aBoilPw > 10)
{
aBoilPw = aBoilPw-1;
i--;
if (i<=5)
{
delay (250);
}
else
{
delay (100);
}
myGLCD.print(" ", 103, 112);
myGLCD.printNumI(aBoilPw, 119, 112);
}
myTouch.read();
x=0;
y=0;
}
myGLCD.setBackColor (0, 0, 255);
}
}
if (actBoil==0)
{
if ((x>=110) && (x<=160) && (y>=60) && (y<=110))
{
myGLCD.setColor (63, 254, 0);
myGLCD.setBackColor (4, 12, 0);
i=0;
digitalWrite(heatPin, HIGH);
heat = 1;
while (myTouch.dataAvailable())
{
if (boilPw < 100)
{
boilPw = boilPw+1;
i++;
if (i<=5)
{
delay (250);
}
else
{
delay (100);
}
myGLCD.print(" ", 103, 112);
if (boilPw < 100)
{
myGLCD.printNumI(boilPw, 119, 112);
}
else
{
myGLCD.printNumI(boilPw, 103, 112);
}
}
myTouch.read();
x=0;
y=0;
}
myGLCD.setBackColor (0, 0, 255);
}
if ((x>=110) && (x<=160) && (y>=130) && (y<=180))
{
myGLCD.setColor (63, 254, 0);
myGLCD.setBackColor (4, 12, 0);
i=0;
digitalWrite(heatPin, LOW);
heat = 0;
while (myTouch.dataAvailable())
{
if (boilPw > 10)
{
boilPw = boilPw-1;
i--;
if (i<=5)
{
delay (250);
}
else
{
delay (100);
}
myGLCD.print(" ", 103, 112);
myGLCD.printNumI(boilPw, 119, 112);
}
myTouch.read();
x=0;
y=0;
}
myGLCD.setBackColor (0, 0, 255);
}
}
}
}
if (scr==4)
{
if (mash != 17)
{
printTemperature(insideThermometer);
}
if ((mash==4) || (mash==6) || (mash==8) || (mash==10) || (mash==12) || (mash==14) || (mash==17))
{
checkTimer();
if (RTC.read(tm))
{
calcTime = 0;
if (timerSeconds >= tm.Second)
{
showSeconds = timerSeconds-tm.Second;
}
if (timerSeconds < tm.Second)
{
showSeconds = (timerSeconds+60)-tm.Second;
calcTime = 1;
}
if (calcTime == 1)
{
if (timerMinutes >= tm.Minute)
{
showMinutes = timerMinutes-tm.Minute-1;
calcTime = 0;
if (showMinutes < 0)
{
showMinutes = showMinutes + 60;
calcTime = 1;
}
}
if (timerMinutes < tm.Minute)
{
showMinutes = (timerMinutes+60)-tm.Minute-1;
calcTime = 1;
}
}
else
{
if (timerMinutes >= tm.Minute)
{
showMinutes = timerMinutes-tm.Minute;
}
if (timerMinutes < tm.Minute)
{
showMinutes = (timerMinutes+60)-tm.Minute;
calcTime = 1;
}
}
if (calcTime == 0)
{
if (timerHours >= tm.Hour)
{
showHours = timerHours-tm.Hour;
}
if (timerHours < tm.Hour)
{
showHours = (timerHours+24)-tm.Hour;
}
}
else
{
if (timerHours >= tm.Hour)
{
showHours = timerHours-tm.Hour-1;
}
if (timerHours < tm.Hour)
{
showHours = (timerHours+24)-tm.Hour-1;
}
}
}
myGLCD.setColor(252, 252, 124);
myGLCD.printNumI(showHours, 64, 32);
if (showMinutes > 9)
{
myGLCD.printNumI(showMinutes, 96, 32);
}
if (showMinutes <= 9)
{
myGLCD.printNumI(0, 96, 32);
myGLCD.printNumI(showMinutes, 112, 32);
}
if (showSeconds > 9)
{
myGLCD.printNumI(showSeconds, 144, 32);
}
if (showSeconds <= 9)
{
myGLCD.printNumI(0, 144, 32);
myGLCD.printNumI(showSeconds, 160, 32);
}
}
}
if (brew == 1)
{
checkTimer();
mashing();
}
}