#include <Wire.h>
#include <OneWire.h>
#include <LiquidCrystal_I2C.h>
#include <EEPROM.h>
LiquidCrystal_I2C _lcd1(0x27, 20, 4);
int _dispTempLength1=0;
boolean _isNeedClearDisp1;
struct UB_24760541
{
String ubo_98898145 = "";
int _gtv6 = 0;
String _gtv1 = "";
String _swi1 = "";
}
;
UB_24760541 UB_24760541_Instance7;
UB_24760541 UB_24760541_Instance8;
UB_24760541 UB_24760541_Instance5;
UB_24760541 UB_24760541_Instance3;
UB_24760541 UB_24760541_Instance1;
UB_24760541 UB_24760541_Instance2;
UB_24760541 UB_24760541_Instance4;
int UB_24760541_ubi_200586030 = 0;
OneWire _ow17(17);
byte _FLPArray2967877[9];
const int _menuParametrsArray[] PROGMEM = {1, 3, 1, 0, 0, 0, 0, 0, 1, 1, 7, 0, 2, 4, 7, 0, 0, 0, 5, 7, 1, 4, 8, 0, 3, 4, 8, 0, 0, 0, 6, 7, 1, 4, 9, 0, 4, 4, 1, 0, 0, 0, 2, 7, 1, 4, 1, 0, 5, 4, 2, 0, 0, 0, 2, 7, 1, 4, 2, 0, 6, 4, 3, 0, 0, 0, 3, 7, 1, 4, 3, 0, 7, 4, 4, 0, 0, 0, 2, 7, 1, 4, 4, 0, 8, 4, 5, 0, 0, 0, 4, 7, 1, 4, 5, 0, 9, 4, 6, 0, 0, 0, 4, 7, 1, 4, 6, 0};
bool _menuValueArray_bool[1];
const bool _menuConstantValuesArray_bool[] PROGMEM = {1, 0};
int _menuValueArray_int[8];
const int _menuConstantValuesArray_int[] PROGMEM = {1, 360, 100, 90, 25, 99, 0};
const char _flprogMenuNameString1[] PROGMEM = "Timer 1 H";
const char _flprogMenuNameString2[] PROGMEM = "Timer 2 vent min";
const char _flprogMenuNameString3[] PROGMEM = "Timer 3 lamp min";
const char _flprogMenuNameString4[] PROGMEM = "Servo";
const char _flprogMenuNameString5[] PROGMEM = "Timer 4";
const char _flprogMenuNameString6[] PROGMEM = "Timer 5";
const char _flprogMenuNameString7[] PROGMEM = "display";
const char _flprogMenuNameString8[] PROGMEM = "Holodil";
const char _flprogMenuNameString9[] PROGMEM = "Vlagnost";
const char* const _flprogMenuStringsArray[] PROGMEM = { _flprogMenuNameString1, _flprogMenuNameString2, _flprogMenuNameString3, _flprogMenuNameString4, _flprogMenuNameString5, _flprogMenuNameString6, _flprogMenuNameString7, _flprogMenuNameString8, _flprogMenuNameString9};
struct _menuItemStricture
{
int startInArrayIndex;
}
;
struct _menuMainStricture
{
int startIndex;
int stopIndex;
bool isSwitchMenuAroundRing;
_menuItemStricture currentItem;
}
;
_menuItemStricture _MenuItems[9];
_menuMainStricture _MainMenus[1];
bool _gtv1;
bool _gtv2;
bool _gtv3;
bool _gtv4;
bool _gtv5;
bool _gtv6;
bool _gtv7;
bool _gtv8;
bool _gtv9;
bool _gtv11;
int _gtv10;
int _gtv12;
bool _gtv17;
bool _trgrt3 = 0;
bool _trgrt3I = 0;
bool _trgrt2 = 0;
bool _trgrt2I = 0;
int _disp5oldLength = 0;
bool _gen3I = 0;
bool _gen3O = 0;
unsigned long _gen3P = 0UL;
String _swi3;
bool _bounseInputD4S = 0;
bool _bounseInputD4O = 0;
unsigned long _bounseInputD4P = 0UL;
int _disp2oldLength = 0;
bool _bounseInputD2S = 0;
bool _bounseInputD2O = 0;
unsigned long _bounseInputD2P = 0UL;
bool _sowb2_needScan = 0;
bool _sowb2_ost = 0;
bool _sowb2_Out_1 = 0;
bool _tim1I = 0;
bool _tim1O = 0;
unsigned long _tim1P = 0UL;
String _swi8;
bool _gen1I = 0;
bool _gen1O = 0;
unsigned long _gen1P = 0UL;
bool _tim3I = 0;
bool _tim3O = 0;
unsigned long _tim3P = 0UL;
String _swi2;
String _swi5;
int _disp1oldLength = 0;
unsigned long _d18x2x1Tti = 0UL;
float _d18x2x1O = 0.00;
String _swi7;
int _disp3oldLength = 0;
bool _gen4I = 0;
bool _gen4O = 0;
unsigned long _gen4P = 0UL;
bool _MenuBlock_172447835_AMO_38465833 = 0;
bool _MenuBlock_172447835_AMO_95290837 = 0;
bool _MenuBlock_172447835_AMO_118084506 = 0;
bool _MenuBlock_172447835_AMO_96119032 = 0;
bool _MenuBlock_172447835_AMO_60308158 = 0;
bool _MenuBlock_172447835_AMO_155881297 = 0;
bool _MenuBlock_172447835_AMO_261554241 = 0;
bool _MenuBlock_172447835_AMO_122112339 = 0;
bool _MenuBlock_172447835_AMO_3502575 = 0;
String _MenuBlock_172447835_MNO;
String _MenuBlock_172447835_VNO;
bool _MenuBlock_172447835_OEIS = 0;
bool _MenuBlock_172447835_OMUIS = 0;
bool _MenuBlock_172447835_OMDIS = 0;
bool _MenuBlock_172447835_OVUIS = 0;
bool _MenuBlock_172447835_OVDIS = 0;
bool _bounseInputD3S = 0;
bool _bounseInputD3O = 0;
unsigned long _bounseInputD3P = 0UL;
int _disp6oldLength = 0;
bool _D1B2 = 0;
String _swi4;
String _swi1;
bool _tempVariable_bool;
int _tempVariable_int;
float _tempVariable_float;
void setup()
{
pinMode(4, INPUT_PULLUP);
pinMode(2, INPUT_PULLUP);
pinMode(3, INPUT_PULLUP);
Wire.begin();
delay(10);
if(((readByteFromEEPROM(0, 0, 0x0))) != 88)
{
(updateByteToEEPROM(0, 0, 0x0, (88)));
(updateIntegerToEEPROM(1, 0, 0x0, (0)));
(updateIntegerToEEPROM(3, 0, 0x0, (0)));
(updateIntegerToEEPROM(5, 0, 0x0, (0)));
(updateIntegerToEEPROM(7, 0, 0x0, (90)));
(updateIntegerToEEPROM(9, 0, 0x0, (30)));
(updateIntegerToEEPROM(11, 0, 0x0, (40)));
(updateIntegerToEEPROM(13, 0, 0x0, (15)));
(updateIntegerToEEPROM(15, 0, 0x0, (20)));
}
_lcd1.init();
_lcd1.noBacklight();
_bounseInputD2O = digitalRead(2);
_bounseInputD3O = digitalRead(3);
_bounseInputD4O = digitalRead(4);
_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;
_MenuItems[7].startInArrayIndex = 84;
_MenuItems[8].startInArrayIndex = 96;
_MainMenus[0].startIndex = 1;
_MainMenus[0].isSwitchMenuAroundRing = 1;
_MainMenus[0].stopIndex = 9;
_MainMenus[0].currentItem = _MenuItems[0];
_menuValueArray_int[0] = (readIntegerFromEEPROM(1, 0, 0x0));
_menuValueArray_int[1] = (readIntegerFromEEPROM(3, 0, 0x0));
_menuValueArray_int[2] = (readIntegerFromEEPROM(5, 0, 0x0));
_menuValueArray_int[3] = (readIntegerFromEEPROM(7, 0, 0x0));
_menuValueArray_int[4] = (readIntegerFromEEPROM(9, 0, 0x0));
_menuValueArray_int[5] = (readIntegerFromEEPROM(11, 0, 0x0));
_menuValueArray_int[6] = (readIntegerFromEEPROM(13, 0, 0x0));
_menuValueArray_int[7] = (readIntegerFromEEPROM(15, 0, 0x0));
}
void loop()
{
if (_isNeedClearDisp1)
{
_lcd1.clear();
_isNeedClearDisp1= 0;
}
bool _bounceInputTmpD2 = (digitalRead (2));
if (_bounseInputD2S)
{
if (millis() >= (_bounseInputD2P + 40))
{
_bounseInputD2O= _bounceInputTmpD2;
_bounseInputD2S=0;
}
}
else
{
if (_bounceInputTmpD2 != _bounseInputD2O)
{
_bounseInputD2S=1;
_bounseInputD2P = millis();
}
}
bool _bounceInputTmpD3 = (digitalRead (3));
if (_bounseInputD3S)
{
if (millis() >= (_bounseInputD3P + 40))
{
_bounseInputD3O= _bounceInputTmpD3;
_bounseInputD3S=0;
}
}
else
{
if (_bounceInputTmpD3 != _bounseInputD3O)
{
_bounseInputD3S=1;
_bounseInputD3P = millis();
}
}
bool _bounceInputTmpD4 = (digitalRead (4));
if (_bounseInputD4S)
{
if (millis() >= (_bounseInputD4P + 40))
{
_bounseInputD4O= _bounceInputTmpD4;
_bounseInputD4S=0;
}
}
else
{
if (_bounceInputTmpD4 != _bounseInputD4O)
{
_bounseInputD4S=1;
_bounseInputD4P = millis();
}
}
//Плата:1
if (!(_bounseInputD2O))
{
if (! _gen4I)
{
_gen4I = 1;
_gen4O = 1;
_gen4P = millis();
}
}
else
{
_gen4I = 0 ;
_gen4O= 0;
}
if (_gen4I)
{
if (_isTimer (_gen4P , 100))
{
_gen4P = millis();
_gen4O = ! _gen4O;
}
}
_gtv7 = _gen4O;
if (!(_bounseInputD3O))
{
if (! _gen3I)
{
_gen3I = 1;
_gen3O = 1;
_gen3P = millis();
}
}
else
{
_gen3I = 0 ;
_gen3O= 0;
}
if (_gen3I)
{
if (_isTimer (_gen3P , 100))
{
_gen3P = millis();
_gen3O = ! _gen3O;
}
}
_gtv6 = _gen3O;
if(((_gtv7) || (_gtv6) || (!(_bounseInputD4O))))
{
_tim1O = 1;
_tim1I = 1;
}
else
{
if(_tim1I)
{
_tim1I = 0;
_tim1P = millis();
}
else
{
if (_tim1O)
{
if (_isTimer(_tim1P, 60000)) _tim1O = 0;
}
}
}
if(_tim1O)
{
if(! _D1B2)
{
_lcd1.backlight();
_D1B2=1;
}
}
else
{
if(_D1B2)
{
_lcd1.noBacklight();
_D1B2=0;
}
}
if (!(((_gtv7) || (_gtv6) || (!(_bounseInputD4O)))))
{
if (_tim3I)
{
if (_isTimer(_tim3P, 10000))
{
_tim3O = 1;
}
}
else
{
_tim3I =1;
_tim3P = millis();
}
}
else
{
_tim3O = 0;
_tim3I = 0;
}
if (_tim3O)
{
if (_trgrt2I)
{
_trgrt2 = 0;
}
else
{
_trgrt2 = 1;
_trgrt2I = 1;
}
}
else
{
_trgrt2 = 0;
_trgrt2I = 0;
}
;
if (!(0))
{
_tempVariable_bool = 1;
if (! _MenuBlock_172447835_OEIS)
{
_MenuBlock_172447835_OEIS = 1;
}
_tempVariable_int = pgm_read_byte(&_menuParametrsArray[((_MainMenus[0].currentItem).startInArrayIndex)+10]);
_MenuBlock_172447835_MNO = _readStringFromProgmem ((char*)pgm_read_word(&(_flprogMenuStringsArray[_tempVariable_int - 1])));
_MenuBlock_172447835_VNO = _menuOutputValueString (0);
_MenuBlock_172447835_AMO_38465833 = pgm_read_byte(&_menuParametrsArray[(_MainMenus[0].currentItem).startInArrayIndex]) == 1;
_MenuBlock_172447835_AMO_95290837 = pgm_read_byte(&_menuParametrsArray[(_MainMenus[0].currentItem).startInArrayIndex]) == 2;
_MenuBlock_172447835_AMO_118084506 = pgm_read_byte(&_menuParametrsArray[(_MainMenus[0].currentItem).startInArrayIndex]) == 3;
_MenuBlock_172447835_AMO_96119032 = pgm_read_byte(&_menuParametrsArray[(_MainMenus[0].currentItem).startInArrayIndex]) == 4;
_MenuBlock_172447835_AMO_60308158 = pgm_read_byte(&_menuParametrsArray[(_MainMenus[0].currentItem).startInArrayIndex]) == 5;
_MenuBlock_172447835_AMO_155881297 = pgm_read_byte(&_menuParametrsArray[(_MainMenus[0].currentItem).startInArrayIndex]) == 6;
_MenuBlock_172447835_AMO_261554241 = pgm_read_byte(&_menuParametrsArray[(_MainMenus[0].currentItem).startInArrayIndex]) == 7;
_MenuBlock_172447835_AMO_122112339 = pgm_read_byte(&_menuParametrsArray[(_MainMenus[0].currentItem).startInArrayIndex]) == 8;
_MenuBlock_172447835_AMO_3502575 = pgm_read_byte(&_menuParametrsArray[(_MainMenus[0].currentItem).startInArrayIndex]) == 9;
}
else
{
_tempVariable_bool = 0;
if (_MenuBlock_172447835_OEIS)
{
_MenuBlock_172447835_OEIS = 0;
_menuUpdateToEEpromItems();
}
_MenuBlock_172447835_AMO_38465833 = 0;
_MenuBlock_172447835_AMO_95290837 = 0;
_MenuBlock_172447835_AMO_118084506 = 0;
_MenuBlock_172447835_AMO_96119032 = 0;
_MenuBlock_172447835_AMO_60308158 = 0;
_MenuBlock_172447835_AMO_155881297 = 0;
_MenuBlock_172447835_AMO_261554241 = 0;
_MenuBlock_172447835_AMO_122112339 = 0;
_MenuBlock_172447835_AMO_3502575 = 0;
_MenuBlock_172447835_MNO = "";
_MenuBlock_172447835_VNO = "";
}
if(0)
{
if (! _MenuBlock_172447835_OMUIS)
{
_MenuBlock_172447835_OMUIS = 1;
if(_tempVariable_bool)
{
_menuUpEvents(0);
_menuUpdateToEEpromItems();
}
}
}
else
{
_MenuBlock_172447835_OMUIS = 0;
}
if(!(_bounseInputD4O))
{
if (! _MenuBlock_172447835_OMDIS)
{
_MenuBlock_172447835_OMDIS = 1;
if(_tempVariable_bool)
{
_menuDownEvents(0);
_menuUpdateToEEpromItems();
}
}
}
else
{
_MenuBlock_172447835_OMDIS = 0;
}
if(_gtv7)
{
if (! _MenuBlock_172447835_OVUIS)
{
_MenuBlock_172447835_OVUIS = 1;
if(_tempVariable_bool)
{
_valueUpEvents(0);
}
}
}
else
{
_MenuBlock_172447835_OVUIS = 0;
}
if(_gtv6)
{
if (! _MenuBlock_172447835_OVDIS)
{
_MenuBlock_172447835_OVDIS = 1;
if(_tempVariable_bool)
{
_valueDownEvents(0);
}
}
}
else
{
_MenuBlock_172447835_OVDIS = 0;
}
if(_trgrt2)
{
if (_tempVariable_bool)
{
(_MainMenus[0]).currentItem = _MenuItems[0];
_menuUpdateToEEpromItems();
}
}
_gtv17 = _MenuBlock_172447835_AMO_3502575;
_gtv11 = _MenuBlock_172447835_AMO_122112339;
_gtv8 = _MenuBlock_172447835_AMO_261554241;
_gtv5 = _MenuBlock_172447835_AMO_155881297;
_gtv4 = _MenuBlock_172447835_AMO_60308158;
_gtv3 = _MenuBlock_172447835_AMO_96119032;
_gtv2 = _MenuBlock_172447835_AMO_118084506;
_gtv1 = _MenuBlock_172447835_AMO_95290837;
if (((_gtv1) || (_gtv2) || (_gtv3) || (_gtv4) || (_gtv5) || (_gtv8) || (_gtv11) || (_gtv17)))
{
if (! _gen1I)
{
_gen1I = 1;
_gen1O = 1;
_gen1P = millis();
}
}
else
{
_gen1I = 0 ;
_gen1O= 0;
}
if (_gen1I)
{
if (_isTimer (_gen1P , 500))
{
_gen1P = millis();
_gen1O = ! _gen1O;
}
}
_gtv9 = _gen1O;
//Плата:2
if(_isTimer(_d18x2x1Tti, 1000))
{
_d18x2x1Tti = millis();
_tempVariable_float = _readDS18_ow17(_FLPArray2967877, _FLPArray2967877[8]);
if (_tempVariable_float < 500)
{
_d18x2x1O = _tempVariable_float;
}
}
_gtv10 = (int((_d18x2x1O)));
if (1)
{
if (_trgrt3I)
{
_trgrt3 = 0;
}
else
{
_trgrt3 = 1;
_trgrt3I = 1;
}
}
else
{
_trgrt3 = 0;
_trgrt3I = 0;
}
;
if(_sowb2_needScan)
{
if(_oneWireSeach (_FLPArray2967877, _ow17))
{
_sowb2_Out_1=1;
}
_ow17.reset_search();
_sowb2_needScan=0;
}
if(_trgrt3)
{
if(! _sowb2_ost)
{
_sowb2_ost=1;
_sowb2_needScan=1;
_sowb2_Out_1=0;
}
}
else
{
_sowb2_ost=0;
}
_gtv12 = (map(((analogRead (0))), (0), (1023), (-20), (99)));
//Плата:3
UB_24760541_ubi_200586030 = (_menuValueArray_int[6]);
_func_UB_24760541(&UB_24760541_Instance8, UB_24760541_ubi_200586030);
if(_gtv9)
{
_swi8=String(" ");
}
else
{
_swi8=UB_24760541_Instance8.ubo_98898145;
}
UB_24760541_ubi_200586030 = _gtv10;
_func_UB_24760541(&UB_24760541_Instance7, UB_24760541_ubi_200586030);
if(_gtv1)
{
_swi7=_swi8;
}
else
{
_swi7=UB_24760541_Instance7.ubo_98898145;
}
if (!(0))
{
_dispTempLength1 = ((((String("T kam ")) + (_swi7) + (String("C"))))).length();
if (_disp5oldLength > _dispTempLength1)
{
_isNeedClearDisp1 = 1;
}
_disp5oldLength = _dispTempLength1;
_lcd1.setCursor(0, 0);
_lcd1.print((((String("T kam ")) + (_swi7) + (String("C")))));
}
else
{
if (_disp5oldLength > 0)
{
_isNeedClearDisp1 = 1;
_disp5oldLength = 0;
}
}
UB_24760541_ubi_200586030 = (_menuValueArray_int[7]);
_func_UB_24760541(&UB_24760541_Instance3, UB_24760541_ubi_200586030);
if(_gtv9)
{
_swi3=String(" ");
}
else
{
_swi3=UB_24760541_Instance3.ubo_98898145;
}
UB_24760541_ubi_200586030 = _gtv12;
_func_UB_24760541(&UB_24760541_Instance5, UB_24760541_ubi_200586030);
if(_gtv2)
{
_swi5=_swi3;
}
else
{
_swi5=UB_24760541_Instance5.ubo_98898145;
}
if (!(0))
{
_dispTempLength1 = ((((String("T izd ")) + (_swi5) + (String("C"))))).length();
if (_disp6oldLength > _dispTempLength1)
{
_isNeedClearDisp1 = 1;
}
_disp6oldLength = _dispTempLength1;
_lcd1.setCursor(11, 0);
_lcd1.print((((String("T izd ")) + (_swi5) + (String("C")))));
}
else
{
if (_disp6oldLength > 0)
{
_isNeedClearDisp1 = 1;
_disp6oldLength = 0;
}
}
UB_24760541_ubi_200586030 = (_menuValueArray_int[0]);
_func_UB_24760541(&UB_24760541_Instance1, UB_24760541_ubi_200586030);
if(((_gtv3) && (_gtv9)))
{
_swi1=String(" ");
}
else
{
_swi1=UB_24760541_Instance1.ubo_98898145;
}
if (!(0))
{
_dispTempLength1 = ((((String("Time sushki ")) + (_swi1) + (String(" min"))))).length();
if (_disp3oldLength > _dispTempLength1)
{
_isNeedClearDisp1 = 1;
}
_disp3oldLength = _dispTempLength1;
_lcd1.setCursor(0, 1);
_lcd1.print((((String("Time sushki ")) + (_swi1) + (String(" min")))));
}
else
{
if (_disp3oldLength > 0)
{
_isNeedClearDisp1 = 1;
_disp3oldLength = 0;
}
}
UB_24760541_ubi_200586030 = (_menuValueArray_int[1]);
_func_UB_24760541(&UB_24760541_Instance2, UB_24760541_ubi_200586030);
if(((_gtv4) && (_gtv9)))
{
_swi2=String(" ");
}
else
{
_swi2=UB_24760541_Instance2.ubo_98898145;
}
if (!(0))
{
_dispTempLength1 = ((((String("Time varki ")) + (_swi2) + (String(" min"))))).length();
if (_disp2oldLength > _dispTempLength1)
{
_isNeedClearDisp1 = 1;
}
_disp2oldLength = _dispTempLength1;
_lcd1.setCursor(0, 2);
_lcd1.print((((String("Time varki ")) + (_swi2) + (String(" min")))));
}
else
{
if (_disp2oldLength > 0)
{
_isNeedClearDisp1 = 1;
_disp2oldLength = 0;
}
}
UB_24760541_ubi_200586030 = (_menuValueArray_int[2]);
_func_UB_24760541(&UB_24760541_Instance4, UB_24760541_ubi_200586030);
if(((_gtv5) && (_gtv9)))
{
_swi4=String(" ");
}
else
{
_swi4=UB_24760541_Instance4.ubo_98898145;
}
if (!(0))
{
_dispTempLength1 = ((((String("Time kopchen ")) + (_swi4) + (String(" min"))))).length();
if (_disp1oldLength > _dispTempLength1)
{
_isNeedClearDisp1 = 1;
}
_disp1oldLength = _dispTempLength1;
_lcd1.setCursor(0, 3);
_lcd1.print((((String("Time kopchen ")) + (_swi4) + (String(" min")))));
}
else
{
if (_disp1oldLength > 0)
{
_isNeedClearDisp1 = 1;
_disp1oldLength = 0;
}
}
}
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()
{
(updateIntegerToEEPROM(1, 0, 0x0, ((_menuValueArray_int[0]))));
(updateIntegerToEEPROM(3, 0, 0x0, ((_menuValueArray_int[1]))));
(updateIntegerToEEPROM(5, 0, 0x0, ((_menuValueArray_int[2]))));
(updateIntegerToEEPROM(7, 0, 0x0, ((_menuValueArray_int[3]))));
(updateIntegerToEEPROM(9, 0, 0x0, ((_menuValueArray_int[4]))));
(updateIntegerToEEPROM(11, 0, 0x0, ((_menuValueArray_int[5]))));
(updateIntegerToEEPROM(13, 0, 0x0, ((_menuValueArray_int[6]))));
(updateIntegerToEEPROM(15, 0, 0x0, ((_menuValueArray_int[7]))));
}
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])));
}
}
float _convertDS18x2xData(byte type_s, byte data[12])
{
int16_t raw = (data[1] << 8) | data[0];
if (type_s)
{
raw = raw << 3;
if (data[7] == 0x10)
{
raw = (raw & 0xFFF0) + 12 - data[6];
}
}
else
{
byte cfg = (data[4] & 0x60);
if (cfg == 0x00)raw = raw & ~7;
else if(cfg == 0x20)raw = raw & ~3;
else if(cfg == 0x40) raw = raw & ~1;
}
return (float)raw / 16.0;
}
float _readDS18_ow17(byte addr[8], byte type_s)
{
byte data[12];
byte i;
_ow17.reset();
_ow17.select(addr);
_ow17.write(0xBE);
for (i = 0; i < 9; i++)
{
data[i] = _ow17.read();
}
_ow17.reset();
_ow17.select(addr);
_ow17.write(0x44);
if (_ow17.crc8(data, 8) != data[8])
{
return 501;
}
return _convertDS18x2xData(type_s, data);
}
bool _oneWireSeach (byte array[], OneWire ow)
{
byte temp[8];
byte i;
if (!ow.search(temp))
{
return false;
}
if (OneWire::crc8(temp, 7) != temp[7])
{
return false;
}
switch (temp[0])
{
case 0x10:
array[8] = 1;
break;
case 0x28:
array[8] = 0;
break;
case 0x22:
array[8] = 0;
break;
default:
return false;
}
for (i = 0; i < 8; i++)
{
array[i] = temp[i];
}
return true;
}
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);
}
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_24760541(struct UB_24760541 *_ubInstans, int ubi_200586030)
{
String ubo_98898145 = _ubInstans->ubo_98898145;
int _gtv6 = _ubInstans->_gtv6;
String _gtv1 = _ubInstans->_gtv1;
String _swi1 = _ubInstans->_swi1;
_gtv1 = (String(_gtv6));
if((_gtv6) > (9))
{
_swi1=_gtv1;
}
else
{
_swi1=((String("0")) + (_gtv1));
}
ubo_98898145 = _swi1;
_gtv6 = ubi_200586030;
_ubInstans->ubo_98898145 = ubo_98898145;
_ubInstans->_gtv6 = _gtv6;
_ubInstans->_gtv1 = _gtv1;
_ubInstans->_swi1 = _swi1;
}Loading
ds18b20
ds18b20