#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <Encoder.h>
#include <EEPROM.h>
LiquidCrystal_I2C _lcd1(0x27, 16, 2);
int _dispTempLength1=0;
boolean _isNeedClearDisp1;
struct UB_15422045
{
bool ubo_94105530 = 0;
String ubo_208450993 = "";
String ubo_264315812 = "";
bool ubo_195431352 = 0;
bool ubo_248478582 = 0;
int _gtv1 = 0;
bool _trgs1 = 0;
}
;
UB_15422045 UB_15422045_Instance1;
int UB_15422045_ubi_262053609 = 0;
int UB_15422045_ubi_106682247 = 0;
int UB_15422045_ubi_235905620 = 0;
bool UB_15422045_ubi_253484413 = 0;
struct UB_49870140
{
String ubo_136218795 = "";
bool ubo_240660080 = 0;
bool _gtv1 = 0;
bool _gtv2 = 0;
bool _count1I = 0;
unsigned long _count1_Value = 0UL;
bool _gen1I = 0;
bool _gen1O = 0;
unsigned long _gen1P = 0UL;
bool _trgs1 = 0;
bool _trgs2 = 0;
}
;
UB_49870140 UB_49870140_Instance1;
long UB_49870140_ubi_108673896 = 0L;
long UB_49870140_ubi_91013910 = 0L;
bool UB_49870140_ubi_197128335 = 0;
bool UB_49870140_ubi_79516391 = 0;
bool Zero;
bool Key;
bool Menu;
bool Short;
bool Long;
int PIN;
bool Plus;
bool Minus;
Encoder myEnc(2 , 3);
long newPosition;
long oldPosition= -999;
bool oldkey;
bool K_FL;
unsigned long oldtime;
unsigned long deltatime;
unsigned long keytime;
unsigned long detect;
struct _poligonInexes
{
int minIndex;
int maxIndex;
}
;
int _Poligon_InArray_2[158] = {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, 48, 49, 50, 51, 53, 54, 56, 57, 58, 60, 62, 63, 65, 67, 68, 70, 72, 74, 76, 78, 80, 83, 85, 87, 90, 92, 95, 98, 100, 103, 106, 109, 112, 115, 119, 122, 125, 129, 133, 137, 141, 145, 149, 153, 158, 162, 167, 172, 177, 182, 187, 192, 198, 204, 210, 216, 222, 228, 235, 241, 248, 255, 263, 270, 278, 286, 294, 302, 310, 319, 327, 336, 345, 354, 364, 373, 383, 393, 403, 413, 424, 434, 445, 456, 467, 478, 489, 500, 512, 523, 534, 546, 557, 569, 581, 592, 604, 615, 627, 639, 650, 661, 673, 684, 695, 706, 728, 738, 749, 759, 769, 779, 788};
int _Poligon_OutArray_2[158] = {273, 249, 232, 219, 209, 201, 194, 188, 182, 178, 173, 169, 166, 163, 160, 157, 154, 152, 149, 147, 145, 143, 141, 140, 138, 136, 135, 133, 132, 130, 129, 128, 127, 125, 124, 123, 122, 121, 120, 119, 118, 117, 116, 115, 114, 113, 112, 111, 110, 109, 108, 107, 106, 105, 104, 103, 102, 101, 100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70, 69, 68, 67, 66, 65, 64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 6, 5, 4, 3, 2, 1, 0};
const int _menuParametrsArray[] PROGMEM = {1, 3, 2, 0, 0, 0, 8, 8, 1, 8, 2, 0, 2, 4, 1, 0, 0, 0, 2, 6, 1, 4, 3, 0, 3, 4, 2, 0, 0, 0, 3, 6, 1, 4, 5, 0, 4, 4, 3, 0, 0, 0, 4, 6, 1, 4, 6, 0, 5, 4, 4, 0, 0, 0, 5, 6, 1, 4, 7, 0, 6, 3, 1, 0, 0, 0, 0, 0, 1, 2, 1, 0, 7, 3, 3, 0, 0, 0, 0, 0, 1, 2, 4, 0};
bool _menuValueArray_bool[3];
const bool _menuConstantValuesArray_bool[] PROGMEM = {1};
int _menuValueArray_int[4];
const int _menuConstantValuesArray_int[] PROGMEM = {1, 100, 23, 10, 59, 0};
const char _flprogMenuNameString1[] PROGMEM = "PUSK";
const char _flprogMenuNameString2[] PROGMEM = "Output";
const char _flprogMenuNameString3[] PROGMEM = "Temperatura";
const char _flprogMenuNameString4[] PROGMEM = "STOP";
const char _flprogMenuNameString5[] PROGMEM = "hour";
const char _flprogMenuNameString6[] PROGMEM = "Gisteresis t";
const char _flprogMenuNameString7[] PROGMEM = "minuty";
const char _flprogMenuNameString8[] PROGMEM = "";
const char* const _flprogMenuStringsArray[] PROGMEM = { _flprogMenuNameString1, _flprogMenuNameString2, _flprogMenuNameString3, _flprogMenuNameString4, _flprogMenuNameString5, _flprogMenuNameString6, _flprogMenuNameString7, _flprogMenuNameString8};
struct _menuItemStricture
{
int startInArrayIndex;
}
;
struct _menuMainStricture
{
int startIndex;
int stopIndex;
bool isSwitchMenuAroundRing;
_menuItemStricture currentItem;
}
;
_menuItemStricture _MenuItems[7];
_menuMainStricture _MainMenus[1];
bool _gtv1 = 0;
bool _gtv2 = 0;
long _gtv3;
bool _gtv4 = 0;
bool _gtv5 = 0;
bool _gtv6 = 0;
int _gtv7;
bool _gtv9 = 0;
bool _gtv10 = 0;
bool _gtv18;
bool _gtv19;
bool _gtv20;
bool _gtv21;
bool _gtv22 = 0;
bool _gtv23 = 0;
int _disp5oldLength = 0;
bool _bounseInputD4S = 0;
bool _bounseInputD4O = 0;
unsigned long _bounseInputD4P = 0UL;
bool _trgrt1 = 0;
bool _trgrt1I = 0;
bool _trgrt6 = 0;
bool _trgrt6I = 0;
int _disp4oldLength = 0;
bool _tim6I = 0;
bool _tim6O = 0;
unsigned long _tim6P = 0UL;
int _disp2oldLength = 0;
bool _trgrt2 = 0;
bool _trgrt2I = 0;
int _disp8oldLength = 0;
bool _trgrt3 = 0;
bool _trgrt3I = 0;
int _disp3oldLength = 0;
int _disp9oldLength = 0;
bool _trgs4 = 0;
bool _tim4I = 0;
bool _tim4O = 0;
unsigned long _tim4P = 0UL;
int _disp1oldLength = 0;
int _disp10oldLength = 0;
bool _trgrt4 = 0;
bool _trgrt4I = 0;
bool _MenuBlock_351052363_AMO_7251826 = 0;
bool _MenuBlock_351052363_AMO_512291394 = 0;
bool _MenuBlock_351052363_AMO_481475938 = 0;
bool _MenuBlock_351052363_AMO_22207341 = 0;
bool _MenuBlock_351052363_AMO_417519080 = 0;
bool _MenuBlock_351052363_AMO_93720452 = 0;
bool _MenuBlock_351052363_AMO_47861012 = 0;
String _MenuBlock_351052363_MNO;
String _MenuBlock_351052363_VNO;
bool _MenuBlock_351052363_OEIS = 0;
bool _MenuBlock_351052363_OMUIS = 0;
bool _MenuBlock_351052363_OMDIS = 0;
bool _MenuBlock_351052363_OVUIS = 0;
bool _MenuBlock_351052363_OVDIS = 0;
bool _bounseInputD9S = 0;
bool _bounseInputD9O = 0;
unsigned long _bounseInputD9P = 0UL;
int _disp6oldLength = 0;
bool _tim1I = 0;
bool _tim1O = 0;
unsigned long _tim1P = 0UL;
int _disp7oldLength = 0;
bool _tim3I = 0;
bool _tim3O = 0;
unsigned long _tim3P = 0UL;
bool _trgt2 = 0;
bool _trgt2I = 0;
bool _bounseInputD10S = 0;
bool _bounseInputD10O = 0;
unsigned long _bounseInputD10P = 0UL;
bool _tim2I = 0;
bool _tim2O = 0;
unsigned long _tim2P = 0UL;
bool _tempVariable_bool;
int _tempVariable_int;
void setup()
{
pinMode(4, INPUT_PULLUP);
pinMode(9, INPUT_PULLUP);
pinMode(10, INPUT_PULLUP);
pinMode(11, OUTPUT);
digitalWrite(11, 0);
pinMode(8, OUTPUT);
digitalWrite(8, 0);
Wire.begin();
delay(10);
if(((readByteFromEEPROM(0, 0, 0x0))) != 249)
{
(updateByteToEEPROM(0, 0, 0x0, (249)));
(updateBooleanToEEPROM(1, 0, 0x0, (0)));
(updateBooleanToEEPROM(1, 1, 0x0, (0)));
(updateIntegerToEEPROM(2, 0, 0x0, (40)));
(updateIntegerToEEPROM(4, 0, 0x0, (0)));
(updateIntegerToEEPROM(6, 0, 0x0, (10)));
(updateIntegerToEEPROM(8, 0, 0x0, (2)));
}
_lcd1.init();
_lcd1.backlight();
_bounseInputD10O = digitalRead(10);
_bounseInputD4O = digitalRead(4);
_bounseInputD9O = digitalRead(9);
oldkey=false;
oldtime=0;
_MenuItems[0].startInArrayIndex = 0;
_MenuItems[1].startInArrayIndex = 12;
_MenuItems[2].startInArrayIndex = 24;
_MenuItems[3].startInArrayIndex = 36;
_MenuItems[4].startInArrayIndex = 48;
_MenuItems[5].startInArrayIndex = 60;
_MenuItems[6].startInArrayIndex = 72;
_MainMenus[0].startIndex = 1;
_MainMenus[0].isSwitchMenuAroundRing = 1;
_MainMenus[0].stopIndex = 7;
_MainMenus[0].currentItem = _MenuItems[0];
_menuValueArray_bool[0] = (readBooleanFromEEPROM(1, 0, 0x0));
_menuValueArray_int[0] = (readIntegerFromEEPROM(2, 0, 0x0));
_menuValueArray_bool[2] = (readBooleanFromEEPROM(1, 1, 0x0));
_menuValueArray_int[1] = (readIntegerFromEEPROM(4, 0, 0x0));
_menuValueArray_int[2] = (readIntegerFromEEPROM(6, 0, 0x0));
_menuValueArray_int[3] = (readIntegerFromEEPROM(8, 0, 0x0));
}
void loop()
{
if (_isNeedClearDisp1)
{
_lcd1.clear();
_isNeedClearDisp1= 0;
}
bool _bounceInputTmpD9 = (digitalRead (9));
if (_bounseInputD9S)
{
if (millis() >= (_bounseInputD9P + 40))
{
_bounseInputD9O= _bounceInputTmpD9;
_bounseInputD9S=0;
}
}
else
{
if (_bounceInputTmpD9 != _bounseInputD9O)
{
_bounseInputD9S=1;
_bounseInputD9P = millis();
}
}
bool _bounceInputTmpD10 = (digitalRead (10));
if (_bounseInputD10S)
{
if (millis() >= (_bounseInputD10P + 40))
{
_bounseInputD10O= _bounceInputTmpD10;
_bounseInputD10S=0;
}
}
else
{
if (_bounceInputTmpD10 != _bounseInputD10O)
{
_bounseInputD10S=1;
_bounseInputD10P = millis();
}
}
bool _bounceInputTmpD4 = (digitalRead (4));
if (_bounseInputD4S)
{
if (millis() >= (_bounseInputD4P + 40))
{
_bounseInputD4O= _bounceInputTmpD4;
_bounseInputD4S=0;
}
}
else
{
if (_bounceInputTmpD4 != _bounseInputD4O)
{
_bounseInputD4S=1;
_bounseInputD4P = millis();
}
}
//Плата:1
//Наименование:датчик
_gtv7 = (_poligon(((analogRead (0))), _Poligon_InArray_2, _Poligon_OutArray_2, 158));
//Плата:2
//Наименование:энкодер
Zero = _gtv1;
Key = 0;
Menu = 0;
newPosition = myEnc.read();
if (newPosition != oldPosition)
{
oldPosition = newPosition;
}
if (Zero == 1)
{
myEnc.write(0);
}
PIN= newPosition/4;
if (Key !=oldkey)
{
oldkey = Key;
if (Key)
{
Short = 0;
Long = 0;
K_FL=1;
oldtime=millis();
}
else
{
if (K_FL)
{
Short=1;
keytime=millis();
K_FL=0;
}
}
}
if ((Key)and (!Long) and (K_FL))
{
if ((millis()-oldtime)>= 600)
{
Long = 1;
keytime=millis();
K_FL=0;
}
}
if ((Short)or(Long))
{
deltatime=millis()-keytime;
if (deltatime> 100)
{
Short =0;
Long =0;
K_FL=0;
}
}
//Вычисление плюса и минуса
if(Menu)
{
if(newPosition>=4)
{
Plus=1;
myEnc.write(0);
}
if(newPosition<=-4)
{
Minus=1;
myEnc.write(0);
}
if(newPosition>-3&&newPosition<3)
{
Plus=0;
Minus=0;
}
}
_gtv3 = PIN;
if (((((!(_bounseInputD4O)) && (!(_gtv2)))) || (((!(_bounseInputD4O)) && (_gtv4)))))
{
if (_tim6I)
{
if (_isTimer(_tim6P, 3000))
{
_tim6O = 1;
}
}
else
{
_tim6I =1;
_tim6P = millis();
}
}
else
{
_tim6O = 0;
_tim6I = 0;
}
bool _tmp2 = _tim6O;
if (_tmp2)
{
if (! _trgt2I) _trgt2 = ! _trgt2;
}
_trgt2I = _tmp2;
_gtv2 = _trgt2;
//Плата:3
//Наименование:Меню
if (!(_bounseInputD4O))
{
if (_tim1I)
{
if (_isTimer(_tim1P, 3000))
{
_tim1O = 1;
}
}
else
{
_tim1I =1;
_tim1P = millis();
}
}
else
{
_tim1O = 0;
_tim1I = 0;
}
if (_tim1O)
{
if (_trgrt1I)
{
_trgrt1 = 0;
}
else
{
_trgrt1 = 1;
_trgrt1I = 1;
}
}
else
{
_trgrt1 = 0;
_trgrt1I = 0;
}
;
if(((_trgrt1) && (_gtv5)))
{
_menuValueArray_int[0] = _gtv3;
(updateIntegerToEEPROM(2, 0, 0x0, ((_menuValueArray_int[0]))));
}
if (_gtv5)
{
_dispTempLength1 = ((((String("ust ")) + ((String((_menuValueArray_int[0]), DEC)))))).length();
if (_disp4oldLength > _dispTempLength1)
{
_isNeedClearDisp1 = 1;
}
_disp4oldLength = _dispTempLength1;
_lcd1.setCursor(7, 1);
_lcd1.print((((String("ust ")) + ((String((_menuValueArray_int[0]), DEC))))));
}
else
{
if (_disp4oldLength > 0)
{
_isNeedClearDisp1 = 1;
_disp4oldLength = 0;
}
}
if (((_gtv5) || (_gtv6) || (_gtv9) || (_gtv10) || (_gtv22) || (_gtv23)))
{
_dispTempLength1 = ((((String("E ")) + ((String(_gtv3, DEC)))))).length();
if (_disp2oldLength > _dispTempLength1)
{
_isNeedClearDisp1 = 1;
}
_disp2oldLength = _dispTempLength1;
_lcd1.setCursor(0, 1);
_lcd1.print((((String("E ")) + ((String(_gtv3, DEC))))));
}
else
{
if (_disp2oldLength > 0)
{
_isNeedClearDisp1 = 1;
_disp2oldLength = 0;
}
}
if (!(!(_bounseInputD4O)))
{
if (_trgrt6I)
{
_trgrt6 = 0;
}
else
{
_trgrt6 = 1;
_trgrt6I = 1;
}
}
else
{
_trgrt6 = 0;
_trgrt6I = 0;
}
;
if (_gtv2)
{
_tempVariable_bool = 1;
if (! _MenuBlock_351052363_OEIS)
{
_MenuBlock_351052363_OEIS = 1;
}
_tempVariable_int = pgm_read_byte(&_menuParametrsArray[((_MainMenus[0].currentItem).startInArrayIndex)+10]);
_MenuBlock_351052363_MNO = _readStringFromProgmem ((char*)pgm_read_word(&(_flprogMenuStringsArray[_tempVariable_int - 1])));
_MenuBlock_351052363_VNO = _menuOutputValueString (0);
_MenuBlock_351052363_AMO_7251826 = pgm_read_byte(&_menuParametrsArray[(_MainMenus[0].currentItem).startInArrayIndex]) == 1;
_MenuBlock_351052363_AMO_512291394 = pgm_read_byte(&_menuParametrsArray[(_MainMenus[0].currentItem).startInArrayIndex]) == 2;
_MenuBlock_351052363_AMO_481475938 = pgm_read_byte(&_menuParametrsArray[(_MainMenus[0].currentItem).startInArrayIndex]) == 3;
_MenuBlock_351052363_AMO_22207341 = pgm_read_byte(&_menuParametrsArray[(_MainMenus[0].currentItem).startInArrayIndex]) == 4;
_MenuBlock_351052363_AMO_417519080 = pgm_read_byte(&_menuParametrsArray[(_MainMenus[0].currentItem).startInArrayIndex]) == 5;
_MenuBlock_351052363_AMO_93720452 = pgm_read_byte(&_menuParametrsArray[(_MainMenus[0].currentItem).startInArrayIndex]) == 6;
_MenuBlock_351052363_AMO_47861012 = pgm_read_byte(&_menuParametrsArray[(_MainMenus[0].currentItem).startInArrayIndex]) == 7;
}
else
{
_tempVariable_bool = 0;
if (_MenuBlock_351052363_OEIS)
{
_MenuBlock_351052363_OEIS = 0;
_menuUpdateToEEpromItems();
}
_MenuBlock_351052363_AMO_7251826 = 0;
_MenuBlock_351052363_AMO_512291394 = 0;
_MenuBlock_351052363_AMO_481475938 = 0;
_MenuBlock_351052363_AMO_22207341 = 0;
_MenuBlock_351052363_AMO_417519080 = 0;
_MenuBlock_351052363_AMO_93720452 = 0;
_MenuBlock_351052363_AMO_47861012 = 0;
_MenuBlock_351052363_MNO = "";
_MenuBlock_351052363_VNO = "";
}
if(_trgrt6)
{
if (! _MenuBlock_351052363_OMUIS)
{
_MenuBlock_351052363_OMUIS = 1;
if(_tempVariable_bool)
{
_menuUpEvents(0);
_menuUpdateToEEpromItems();
}
}
}
else
{
_MenuBlock_351052363_OMUIS = 0;
}
if(0)
{
if (! _MenuBlock_351052363_OMDIS)
{
_MenuBlock_351052363_OMDIS = 1;
if(_tempVariable_bool)
{
_menuDownEvents(0);
_menuUpdateToEEpromItems();
}
}
}
else
{
_MenuBlock_351052363_OMDIS = 0;
}
if(0)
{
if (! _MenuBlock_351052363_OVUIS)
{
_MenuBlock_351052363_OVUIS = 1;
if(_tempVariable_bool)
{
_valueUpEvents(0);
}
}
}
else
{
_MenuBlock_351052363_OVUIS = 0;
}
if(0)
{
if (! _MenuBlock_351052363_OVDIS)
{
_MenuBlock_351052363_OVDIS = 1;
if(_tempVariable_bool)
{
_valueDownEvents(0);
}
}
}
else
{
_MenuBlock_351052363_OVDIS = 0;
}
_gtv23 = _MenuBlock_351052363_AMO_47861012;
_gtv22 = _MenuBlock_351052363_AMO_93720452;
_gtv10 = _MenuBlock_351052363_AMO_417519080;
_gtv9 = _MenuBlock_351052363_AMO_22207341;
_gtv6 = _MenuBlock_351052363_AMO_481475938;
_gtv5 = _MenuBlock_351052363_AMO_512291394;
_gtv4 = _MenuBlock_351052363_AMO_7251826;
if (_gtv2)
{
_dispTempLength1 = ((_MenuBlock_351052363_MNO)).length();
if (_disp8oldLength > _dispTempLength1)
{
_isNeedClearDisp1 = 1;
}
_disp8oldLength = _dispTempLength1;
_lcd1.setCursor(int((16 - _dispTempLength1)/2), 0);
_lcd1.print((_MenuBlock_351052363_MNO));
}
else
{
if (_disp8oldLength > 0)
{
_isNeedClearDisp1 = 1;
_disp8oldLength = 0;
}
}
if (!(_bounseInputD4O))
{
if (_tim2I)
{
if (_isTimer(_tim2P, 3000))
{
_tim2O = 1;
}
}
else
{
_tim2I =1;
_tim2P = millis();
}
}
else
{
_tim2O = 0;
_tim2I = 0;
}
if (_tim2O)
{
if (_trgrt2I)
{
_trgrt2 = 0;
}
else
{
_trgrt2 = 1;
_trgrt2I = 1;
}
}
else
{
_trgrt2 = 0;
_trgrt2I = 0;
}
;
if(((_trgrt2) && (_gtv6)))
{
_menuValueArray_int[1] = _gtv3;
(updateIntegerToEEPROM(4, 0, 0x0, ((_menuValueArray_int[1]))));
}
if (_gtv6)
{
_dispTempLength1 = ((((String("uct ")) + ((String((_menuValueArray_int[1]), DEC)))))).length();
if (_disp3oldLength > _dispTempLength1)
{
_isNeedClearDisp1 = 1;
}
_disp3oldLength = _dispTempLength1;
_lcd1.setCursor(7, 1);
_lcd1.print((((String("uct ")) + ((String((_menuValueArray_int[1]), DEC))))));
}
else
{
if (_disp3oldLength > 0)
{
_isNeedClearDisp1 = 1;
_disp3oldLength = 0;
}
}
if (!(_bounseInputD4O))
{
if (_tim3I)
{
if (_isTimer(_tim3P, 3000))
{
_tim3O = 1;
}
}
else
{
_tim3I =1;
_tim3P = millis();
}
}
else
{
_tim3O = 0;
_tim3I = 0;
}
if (_tim3O)
{
if (_trgrt3I)
{
_trgrt3 = 0;
}
else
{
_trgrt3 = 1;
_trgrt3I = 1;
}
}
else
{
_trgrt3 = 0;
_trgrt3I = 0;
}
;
if(((_trgrt3) && (_gtv9)))
{
_menuValueArray_int[2] = _gtv3;
(updateIntegerToEEPROM(6, 0, 0x0, ((_menuValueArray_int[2]))));
}
if (_gtv9)
{
_dispTempLength1 = ((((String("uct ")) + ((String((_menuValueArray_int[2]), DEC)))))).length();
if (_disp5oldLength > _dispTempLength1)
{
_isNeedClearDisp1 = 1;
}
_disp5oldLength = _dispTempLength1;
_lcd1.setCursor(7, 1);
_lcd1.print((((String("uct ")) + ((String((_menuValueArray_int[2]), DEC))))));
}
else
{
if (_disp5oldLength > 0)
{
_isNeedClearDisp1 = 1;
_disp5oldLength = 0;
}
}
if (!(_bounseInputD4O))
{
if (_tim4I)
{
if (_isTimer(_tim4P, 3000))
{
_tim4O = 1;
}
}
else
{
_tim4I =1;
_tim4P = millis();
}
}
else
{
_tim4O = 0;
_tim4I = 0;
}
if (_tim4O)
{
if (_trgrt4I)
{
_trgrt4 = 0;
}
else
{
_trgrt4 = 1;
_trgrt4I = 1;
}
}
else
{
_trgrt4 = 0;
_trgrt4I = 0;
}
;
if(((_trgrt4) && (_gtv10)))
{
_menuValueArray_int[3] = _gtv3;
(updateIntegerToEEPROM(8, 0, 0x0, ((_menuValueArray_int[3]))));
}
if (_gtv10)
{
_dispTempLength1 = ((((String("uct ")) + ((String((_menuValueArray_int[3]), DEC)))))).length();
if (_disp6oldLength > _dispTempLength1)
{
_isNeedClearDisp1 = 1;
}
_disp6oldLength = _dispTempLength1;
_lcd1.setCursor(7, 1);
_lcd1.print((((String("uct ")) + ((String((_menuValueArray_int[3]), DEC))))));
}
else
{
if (_disp6oldLength > 0)
{
_isNeedClearDisp1 = 1;
_disp6oldLength = 0;
}
}
//Плата:4
//Наименование:Терморегулятор
UB_15422045_ubi_262053609 = (_menuValueArray_int[0]);
UB_15422045_ubi_106682247 = (_menuValueArray_int[2]);
UB_15422045_ubi_235905620 = _gtv7;
UB_15422045_ubi_253484413 = !(_gtv2);
_func_UB_15422045(&UB_15422045_Instance1, UB_15422045_ubi_262053609, UB_15422045_ubi_106682247, UB_15422045_ubi_235905620, UB_15422045_ubi_253484413);
if (UB_15422045_Instance1.ubo_248478582)
{
_dispTempLength1 = ((UB_15422045_Instance1.ubo_264315812)).length();
if (_disp1oldLength > _dispTempLength1)
{
_isNeedClearDisp1 = 1;
}
_disp1oldLength = _dispTempLength1;
_lcd1.setCursor(10, 0);
_lcd1.print((UB_15422045_Instance1.ubo_264315812));
}
else
{
if (_disp1oldLength > 0)
{
_isNeedClearDisp1 = 1;
_disp1oldLength = 0;
}
}
if (UB_15422045_Instance1.ubo_195431352)
{
_dispTempLength1 = ((UB_15422045_Instance1.ubo_208450993)).length();
if (_disp7oldLength > _dispTempLength1)
{
_isNeedClearDisp1 = 1;
}
_disp7oldLength = _dispTempLength1;
_lcd1.setCursor(0, 0);
_lcd1.print((UB_15422045_Instance1.ubo_208450993));
}
else
{
if (_disp7oldLength > 0)
{
_isNeedClearDisp1 = 1;
_disp7oldLength = 0;
}
}
_gtv21 = UB_15422045_Instance1.ubo_94105530;
//Плата:5
//Наименование:плата выходов
_gtv18 = ((!(_bounseInputD9O)) || ((_menuValueArray_bool[0])));
UB_49870140_ubi_108673896 = (_menuValueArray_int[1]);
UB_49870140_ubi_91013910 = (_menuValueArray_int[3]);
UB_49870140_ubi_197128335 = _gtv18;
UB_49870140_ubi_79516391 = _gtv19;
_func_UB_49870140(&UB_49870140_Instance1, UB_49870140_ubi_108673896, UB_49870140_ubi_91013910, UB_49870140_ubi_197128335, UB_49870140_ubi_79516391);
_gtv20 = UB_49870140_Instance1.ubo_240660080;
if (!(_gtv2))
{
_dispTempLength1 = ((UB_49870140_Instance1.ubo_136218795)).length();
if (_disp10oldLength > _dispTempLength1)
{
_isNeedClearDisp1 = 1;
}
_disp10oldLength = _dispTempLength1;
_lcd1.setCursor(10, 1);
_lcd1.print((UB_49870140_Instance1.ubo_136218795));
}
else
{
if (_disp10oldLength > 0)
{
_isNeedClearDisp1 = 1;
_disp10oldLength = 0;
}
}
_gtv19 = (((_menuValueArray_bool[2])) || (!(_bounseInputD10O)));
if (!(_gtv2))
{
_dispTempLength1 = (String("Taymer")).length();
if (_disp9oldLength > _dispTempLength1)
{
_isNeedClearDisp1 = 1;
}
_disp9oldLength = _dispTempLength1;
_lcd1.setCursor(0, 1);
_lcd1.print(String("Taymer"));
}
else
{
if (_disp9oldLength > 0)
{
_isNeedClearDisp1 = 1;
_disp9oldLength = 0;
}
}
digitalWrite(11, ((_gtv20) && (_gtv21)));
//Плата:6
//Наименование:плата уровня
if(((analogRead (1))) == (850)) _trgs4 = 1;
if(!(((analogRead (2))) == (850))) _trgs4 = 0;
digitalWrite(8, _trgs4);
}
bool _isTimer(unsigned long startTime, unsigned long period)
{
unsigned long currentTime;
currentTime = millis();
if (currentTime>= startTime)
{
return (currentTime>=(startTime + period));
}
else
{
return (currentTime >=(4294967295-startTime+period));
}
}
String _readStringFromProgmem (char *string)
{
String result = String("");
while (pgm_read_byte(string)!='\0')
{
result=result+ char(pgm_read_byte(string));
string++;
}
return result;
}
void _menuUpEvents (int menuIndex)
{
int tempIndex = pgm_read_byte(&_menuParametrsArray[((_MainMenus[menuIndex]).currentItem).startInArrayIndex]);
int parIndex = pgm_read_byte(&_menuParametrsArray[ (((_MainMenus[menuIndex]).currentItem).startInArrayIndex)+5]);
int parentStartIndex;
int parentStopIndex;
if (parIndex == 0)
{
parentStartIndex = (_MainMenus[menuIndex]).startIndex;
parentStopIndex =(_MainMenus[menuIndex]).stopIndex;
}
else
{
parentStartIndex = pgm_read_byte(&_menuParametrsArray[((_MenuItems[parIndex - 1]).startInArrayIndex)+3]);
parentStopIndex = pgm_read_byte(&_menuParametrsArray[((_MenuItems[parIndex-1]).startInArrayIndex)+4]);
}
if (tempIndex == parentStartIndex)
{
if((_MainMenus[menuIndex]).isSwitchMenuAroundRing)
{
(_MainMenus[menuIndex]).currentItem = _MenuItems[parentStopIndex -1];
return;
}
else
{
return;
}
}
(_MainMenus[menuIndex]).currentItem = _MenuItems[tempIndex - 2];
return;
}
void _menuDownEvents (int menuIndex)
{
int tempIndex = pgm_read_byte(&_menuParametrsArray[((_MainMenus[menuIndex]).currentItem).startInArrayIndex]);
int parIndex = pgm_read_byte(&_menuParametrsArray[(((_MainMenus[menuIndex]).currentItem).startInArrayIndex)+5]);
int parentStartIndex;
int parentStopIndex;
if (parIndex == 0)
{
parentStartIndex = (_MainMenus[menuIndex]).startIndex;
parentStopIndex =(_MainMenus[menuIndex]).stopIndex;
}
else
{
parentStartIndex = pgm_read_byte(&_menuParametrsArray[((_MenuItems[parIndex-1]).startInArrayIndex)+3]);
parentStopIndex = pgm_read_byte(&_menuParametrsArray[((_MenuItems[parIndex-1]).startInArrayIndex)+4]);
}
if (tempIndex == parentStopIndex)
{
if((_MainMenus[menuIndex]).isSwitchMenuAroundRing)
{
(_MainMenus[menuIndex]).currentItem = _MenuItems[parentStartIndex -1];
return;
}
else
{
return;
}
}
(_MainMenus[menuIndex]).currentItem = _MenuItems[tempIndex];
return;
}
void _valueUpEvents (int menuIndex)
{
int valIndex = pgm_read_byte(&_menuParametrsArray[(((_MainMenus[menuIndex]).currentItem).startInArrayIndex)+2]);
int itemType = pgm_read_byte(&_menuParametrsArray[(((_MainMenus[menuIndex]).currentItem).startInArrayIndex)+1]);
int indexMax = pgm_read_byte(&_menuParametrsArray[(((_MainMenus[menuIndex]).currentItem).startInArrayIndex)+6]);
int indexStep = pgm_read_byte(&_menuParametrsArray[(((_MainMenus[menuIndex]).currentItem).startInArrayIndex)+8]);
if(itemType ==3)
{
_menuValueArray_bool[valIndex - 1 ] = 1;
return;
}
if (itemType == 4)
{
if (! indexMax == 0)
{
if (! (int(pgm_read_word(&_menuConstantValuesArray_int[indexMax -1])) > int(_menuValueArray_int[valIndex -1])))
{
return;
}
}
_menuValueArray_int[valIndex -1] = _menuValueArray_int[valIndex -1] + (pgm_read_word(&_menuConstantValuesArray_int[indexStep -1]));
}
}
void _valueDownEvents (int menuIndex)
{
int valIndex = pgm_read_byte(&_menuParametrsArray[(((_MainMenus[menuIndex]).currentItem).startInArrayIndex)+2]);
int itemType = pgm_read_byte(&_menuParametrsArray[(((_MainMenus[menuIndex]).currentItem).startInArrayIndex)+1]);
int indexMin = pgm_read_byte(&_menuParametrsArray[(((_MainMenus[menuIndex]).currentItem).startInArrayIndex)+7]);
int indexStep = pgm_read_byte(&_menuParametrsArray[(((_MainMenus[menuIndex]).currentItem).startInArrayIndex)+8]);
if(itemType ==3)
{
_menuValueArray_bool[valIndex -1] = 0;
return;
}
if (itemType == 4)
{
if (! indexMin == 0)
{
if (! ((int(pgm_read_word(&_menuConstantValuesArray_int[indexMin - 1]))) < int(_menuValueArray_int[valIndex - 1])))
{
return;
}
}
_menuValueArray_int[valIndex - 1] = _menuValueArray_int[valIndex - 1] - (pgm_read_word(&_menuConstantValuesArray_int[indexStep - 1]));
}
}
String _menuOutputValueString (int menuIndex)
{
int itemType = pgm_read_byte(&_menuParametrsArray[ (((_MainMenus[menuIndex]).currentItem).startInArrayIndex)+1]);
int valIndex = pgm_read_byte(&_menuParametrsArray[(((_MainMenus[menuIndex]).currentItem).startInArrayIndex)+2]);
int indexMin = pgm_read_byte(&_menuParametrsArray[(((_MainMenus[menuIndex]).currentItem).startInArrayIndex)+7]);
int indexMax = pgm_read_byte(&_menuParametrsArray[(((_MainMenus[menuIndex]).currentItem).startInArrayIndex)+6]);
if(valIndex == 0)
{
return "";
}
int convFormat = pgm_read_byte(&_menuParametrsArray[(((_MainMenus[menuIndex]).currentItem).startInArrayIndex)+9]);
if(itemType == 3)
{
return _convertBoolean(itemType, convFormat, valIndex, indexMax, indexMin);
}
if(itemType == 4)
{
return _convertNamber(itemType, convFormat, valIndex, indexMax, indexMin);
}
return "";
}
void _menuUpdateToEEpromItems()
{
(updateBooleanToEEPROM(1, 0, 0x0, ((_menuValueArray_bool[0]))));
(updateIntegerToEEPROM(2, 0, 0x0, ((_menuValueArray_int[0]))));
(updateBooleanToEEPROM(1, 1, 0x0, ((_menuValueArray_bool[2]))));
(updateIntegerToEEPROM(4, 0, 0x0, ((_menuValueArray_int[1]))));
(updateIntegerToEEPROM(6, 0, 0x0, ((_menuValueArray_int[2]))));
(updateIntegerToEEPROM(8, 0, 0x0, ((_menuValueArray_int[3]))));
}
String _convertNamber(int itemType, int convFormat, int valIndex, int indexMax, int indexMin)
{
if (itemType== 4)
{
if (convFormat == 4)
{
return String((_menuValueArray_int[valIndex - 1 ]),DEC);
}
if (convFormat == 5)
{
return String((_menuValueArray_int[valIndex - 1]),HEX);
}
if (convFormat == 6)
{
return String((_menuValueArray_int[valIndex -1]),BIN);
}
}
}
String _convertBoolean(int itemType, int convFormat, int valIndex, int indexMax, int indexMin)
{
if (convFormat == 1)
{
if(_menuValueArray_bool[valIndex -1])
{
return "1";
}
else
{
return "0";
}
}
if (convFormat == 2)
{
if(_menuValueArray_bool[valIndex -1])
{
return "True";
}
else
{
return "False";
}
}
if (convFormat == 3)
{
if(_menuValueArray_bool[valIndex -1 ])
{
return "Да";
}
else
{
return "Нет";
}
}
if(_menuValueArray_bool[valIndex -1])
{
return _readStringFromProgmem ((char*)pgm_read_word(&(_flprogMenuStringsArray[indexMax - 1])));
}
else
{
return _readStringFromProgmem ((char*)pgm_read_word(&(_flprogMenuStringsArray[indexMin - 1])));
}
}
int _poligon(int value, int intArray[], int outArray[], int arraySize)
{
struct _poligonInexes indexes;
indexes = _getPoligonIndexes(value, intArray, arraySize);
return map(value, intArray[indexes.minIndex], intArray[indexes.maxIndex], outArray[indexes.minIndex], outArray[indexes.maxIndex]);
}
struct _poligonInexes _getPoligonIndexes(int value, int array[], int arraySize)
{
struct _poligonInexes result;
int i;
result.minIndex = 0;
result.maxIndex = 0;
for (i = 0; i < arraySize; i++)
{
if (array [result.minIndex] > array[i])
{
result.minIndex = i;
}
if (array [result.maxIndex] < array[i])
{
result.maxIndex = i;
}
}
for (i = 0; i < arraySize; i++)
{
if ((array [i] >= value) && (array [result.maxIndex] > array[i]))
{
result.maxIndex = i;
}
}
if (result.maxIndex==0)
{
result.minIndex = 0;
result.maxIndex=1;
}
else
{
result.minIndex = result.maxIndex -1;
}
return result;
return result;
}
byte readByteFromEEPROM(int addres, byte bitAddres, byte chipAddres)
{
return EEPROM.read(addres);
}
void updateByteToEEPROM(int addres, byte bitAddres, byte chipAddres, byte value)
{
return EEPROM.update(addres, value);
}
bool readBooleanFromEEPROM(int addres, byte bitAddres, byte chipAddres)
{
byte temp = readByteFromEEPROM(addres, bitAddres, chipAddres);
return bitRead(temp, bitAddres);
}
void updateBooleanToEEPROM(int addres, byte bitAddres, byte chipAddres, bool value)
{
byte temp = readByteFromEEPROM(addres, bitAddres, chipAddres);
bitWrite(temp, bitAddres, value);
updateByteToEEPROM(addres, bitAddres, chipAddres, temp);
}
int readIntegerFromEEPROM(int addres, byte bitAddres, byte chipAddres)
{
byte hight = readByteFromEEPROM(addres, bitAddres, chipAddres);
byte low = readByteFromEEPROM((addres+1), bitAddres, chipAddres);
return word(hight, low);
}
void updateIntegerToEEPROM(int addres, byte bitAddres, byte chipAddres, int value)
{
updateByteToEEPROM(addres, bitAddres, chipAddres, highByte(value));
updateByteToEEPROM((addres+1), bitAddres, chipAddres, lowByte(value));
}
void _func_UB_15422045(struct UB_15422045 *_ubInstans, int ubi_262053609, int ubi_106682247, int ubi_235905620, bool ubi_253484413)
{
bool ubo_94105530 = _ubInstans->ubo_94105530;
String ubo_208450993 = _ubInstans->ubo_208450993;
String ubo_264315812 = _ubInstans->ubo_264315812;
bool ubo_195431352 = _ubInstans->ubo_195431352;
bool ubo_248478582 = _ubInstans->ubo_248478582;
int _gtv1 = _ubInstans->_gtv1;
bool _trgs1 = _ubInstans->_trgs1;
ubo_195431352 = ubi_253484413;
ubo_248478582 = ubi_253484413;
ubo_264315812 = ((String("t")) + ((String(ubi_262053609, DEC))) + (String("\xdf\C")));
ubo_208450993 = ((String("t")) + ((String(_gtv1, DEC))) + (String("\xdf\C")));
if((_gtv1) <= ((ubi_262053609)-(ubi_106682247))) _trgs1 = 1;
if((_gtv1) >= (ubi_262053609)) _trgs1 = 0;
ubo_94105530 = ((ubi_253484413) && (_trgs1));
_gtv1 = ubi_235905620;
_ubInstans->ubo_94105530 = ubo_94105530;
_ubInstans->ubo_208450993 = ubo_208450993;
_ubInstans->ubo_264315812 = ubo_264315812;
_ubInstans->ubo_195431352 = ubo_195431352;
_ubInstans->ubo_248478582 = ubo_248478582;
_ubInstans->_gtv1 = _gtv1;
_ubInstans->_trgs1 = _trgs1;
}
void _func_UB_49870140(struct UB_49870140 *_ubInstans, long ubi_108673896, long ubi_91013910, bool ubi_197128335, bool ubi_79516391)
{
String ubo_136218795 = _ubInstans->ubo_136218795;
bool ubo_240660080 = _ubInstans->ubo_240660080;
bool _gtv1 = _ubInstans->_gtv1;
bool _gtv2 = _ubInstans->_gtv2;
bool _count1I = _ubInstans->_count1I;
unsigned long _count1_Value = _ubInstans->_count1_Value;
bool _gen1I = _ubInstans->_gen1I;
bool _gen1O = _ubInstans->_gen1O;
unsigned long _gen1P = _ubInstans->_gen1P;
bool _trgs1 = _ubInstans->_trgs1;
bool _trgs2 = _ubInstans->_trgs2;
if(ubi_197128335) _trgs1 = 1;
if(((_gtv1) || (ubi_79516391))) _trgs1 = 0;
if(_trgs1) _trgs2 = 1;
if(((_gtv1) || (((_gtv1) || (ubi_79516391))))) _trgs2 = 0;
ubo_240660080 = _trgs2;
if (_trgs1)
{
if (! _gen1I)
{
_gen1I = 1;
_gen1O = 1;
_gen1P = millis();
}
}
else
{
_gen1I = 0 ;
_gen1O= 0;
}
if (_gen1I)
{
if (_isTimer (_gen1P , 500))
{
_gen1P = millis();
_gen1O = ! _gen1O;
}
}
if (ubi_79516391)
{
_count1_Value = 0;
}
else
{
if (_gen1O)
{
if (! _count1I)
{
_count1I = 1;
_count1_Value = _count1_Value + 1;
}
}
else
{
_count1I = 0;
}
}
ubo_136218795 = (((String(((((ubi_108673896)*(3600))+((ubi_91013910)*(60)))-(_count1_Value))/(3600), DEC))) + (String(":")) + ((String(((((((ubi_108673896)*(3600))+((ubi_91013910)*(60)))-(_count1_Value)) % (3600)))/(60), DEC))) + (String(":")) + ((String((((((((ubi_108673896)*(3600))+((ubi_91013910)*(60)))-(_count1_Value)) % (3600))) % (60)), DEC))));
_gtv1 = ((((ubi_108673896)*(3600))+((ubi_91013910)*(60)))-(_count1_Value)) == (0);
_ubInstans->ubo_136218795 = ubo_136218795;
_ubInstans->ubo_240660080 = ubo_240660080;
_ubInstans->_gtv1 = _gtv1;
_ubInstans->_gtv2 = _gtv2;
_ubInstans->_count1I = _count1I;
_ubInstans->_count1_Value = _count1_Value;
_ubInstans->_gen1I = _gen1I;
_ubInstans->_gen1O = _gen1O;
_ubInstans->_gen1P = _gen1P;
_ubInstans->_trgs1 = _trgs1;
_ubInstans->_trgs2 = _trgs2;
}