Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed TFT_fonts SPI_TFT_ILI9341 beep _24LCXXX
main.cpp@7:8410439dee73, 2018-02-13 (annotated)
- Committer:
 - sinrab
 - Date:
 - Tue Feb 13 13:11:04 2018 +0000
 - Revision:
 - 7:8410439dee73
 - Parent:
 - 5:0b3c71d7e475
 - Child:
 - 8:d3f0787970a8
 - Child:
 - 9:84a59e981307
 
??? ??????????? ?????, ??????? ?????????? ???? ? ???? ????
Who changed what in which revision?
| User | Revision | Line number | New contents of line | 
|---|---|---|---|
| sinrab | 0:ed1ba99f7b14 | 1 | #include "mbed.h" | 
| sinrab | 0:ed1ba99f7b14 | 2 | #include "SPI_TFT_ILI9341.h" | 
| sinrab | 4:776f59129c24 | 3 | #include "_24LCXXX.h" | 
| sinrab | 4:776f59129c24 | 4 | #include "beep.h" | 
| sinrab | 3:791cf9a867d1 | 5 | //---------------------------------- | 
| sinrab | 0:ed1ba99f7b14 | 6 | #include "digi36x44.h" | 
| sinrab | 3:791cf9a867d1 | 7 | #include "Consolas26x49.h" | 
| sinrab | 3:791cf9a867d1 | 8 | #include "Consolas19x35.h" | 
| sinrab | 0:ed1ba99f7b14 | 9 | #include "Courier8x13.h" | 
| sinrab | 0:ed1ba99f7b14 | 10 | #include "CourierNew13x23.h" | 
| sinrab | 0:ed1ba99f7b14 | 11 | #include "Lucida13x21.h" | 
| sinrab | 0:ed1ba99f7b14 | 12 | //---------------------------------- | 
| sinrab | 0:ed1ba99f7b14 | 13 | #define text5 0xFFFF | 
| sinrab | 0:ed1ba99f7b14 | 14 | #define back5 0x018C | 
| sinrab | 0:ed1ba99f7b14 | 15 | |
| sinrab | 0:ed1ba99f7b14 | 16 | #define text5_i 0x0000 | 
| sinrab | 0:ed1ba99f7b14 | 17 | #define back5_i 0x0660 | 
| sinrab | 0:ed1ba99f7b14 | 18 | #define back5_iset 0xF986 | 
| sinrab | 0:ed1ba99f7b14 | 19 | //---------------------------------- | 
| sinrab | 0:ed1ba99f7b14 | 20 | #define text4 0xFFFF | 
| sinrab | 0:ed1ba99f7b14 | 21 | #define back4 0x3320 | 
| sinrab | 0:ed1ba99f7b14 | 22 | |
| sinrab | 0:ed1ba99f7b14 | 23 | #define text4_i 0x0000 | 
| sinrab | 0:ed1ba99f7b14 | 24 | #define back4_i 0xFCD9 | 
| sinrab | 0:ed1ba99f7b14 | 25 | //---------------------------------- | 
| sinrab | 0:ed1ba99f7b14 | 26 | #define text2 0x0000 | 
| sinrab | 0:ed1ba99f7b14 | 27 | #define back2 0x9E7F | 
| sinrab | 0:ed1ba99f7b14 | 28 | //---------------------------------- | 
| sinrab | 3:791cf9a867d1 | 29 | #define colorline 0xECA7 // цвет рамок 0xECA7 - песочный 0x018C - темносиний 0xFFE0 - желтый | 
| sinrab | 3:791cf9a867d1 | 30 | #define color_text_on Green // ON текст | 
| sinrab | 3:791cf9a867d1 | 31 | #define color_back_on 0x0339 // ON фон | 
| sinrab | 3:791cf9a867d1 | 32 | #define color_scale1 0x3320 // шкала U | 
| sinrab | 3:791cf9a867d1 | 33 | #define color_scale2 0x9A60 // шкала I | 
| sinrab | 3:791cf9a867d1 | 34 | //---------------------------------- | 
| sinrab | 5:0b3c71d7e475 | 35 | SPI_TFT_ILI9341 TFT(PB_15, PB_14, PB_13, PB_12, PC_7, PC_6,"TFT"); // mosi, miso, sclk, cs, reset, dc | 
| sinrab | 0:ed1ba99f7b14 | 36 | void grid(void); | 
| sinrab | 2:d20b1ef35d3f | 37 | Timer fps;// FPS | 
| sinrab | 4:776f59129c24 | 38 | Timeout timerforfanstart; //таймер для запуска мотора | 
| sinrab | 4:776f59129c24 | 39 | Timeout timerforpoweriddle; //таймер для паузы срабатывания кнопки | 
| sinrab | 4:776f59129c24 | 40 | Timeout iddletimesaver; // таймер времени до включения заставки | 
| sinrab | 4:776f59129c24 | 41 | int fst=0; | 
| sinrab | 4:776f59129c24 | 42 | int fst2=0; | 
| sinrab | 7:8410439dee73 | 43 | //------для смены мощности и переданной ёмкости | 
| sinrab | 7:8410439dee73 | 44 | void Pcap(void); | 
| sinrab | 7:8410439dee73 | 45 | Ticker Power_Capacity; | 
| sinrab | 7:8410439dee73 | 46 | bool Pcapbool = true; | 
| sinrab | 7:8410439dee73 | 47 | int Pcapbool2 = 1; | 
| sinrab | 7:8410439dee73 | 48 | double mah = 0; | 
| sinrab | 7:8410439dee73 | 49 | double wh = 0; | 
| sinrab | 7:8410439dee73 | 50 | //----------- | 
| sinrab | 0:ed1ba99f7b14 | 51 | //Ticker valueUI; | 
| sinrab | 5:0b3c71d7e475 | 52 | InterruptIn button(PB_9); // кнопка питания вкл\выкл | 
| sinrab | 5:0b3c71d7e475 | 53 | Beep buzzer(PB_3); // звук | 
| sinrab | 5:0b3c71d7e475 | 54 | //I2C i2c(PC_9, PA_8); // sda, scl для флэш памяти для f401 | 
| sinrab | 5:0b3c71d7e475 | 55 | I2C i2c(PB_11, PB_10); // sda, scl для флэш памяти для f103 | 
| sinrab | 4:776f59129c24 | 56 | _24LCXXX eeprom(&i2c, 0x50); | 
| sinrab | 0:ed1ba99f7b14 | 57 | //----------------------------------------------------------------------------------------------------------- Ввести в меню опцию коррекции падения напряжения на токоизмерительном шунте. | 
| sinrab | 0:ed1ba99f7b14 | 58 | int t; // секунд с момента включения | 
| sinrab | 0:ed1ba99f7b14 | 59 | int tstart; // при включении нагрузки равна реальному времени | 
| sinrab | 1:7bc0f280c259 | 60 | time_t treal; // секунды реального времени для таймера нагрузки | 
| sinrab | 0:ed1ba99f7b14 | 61 | int h=0; //вывод часов | 
| sinrab | 0:ed1ba99f7b14 | 62 | int m=0; // минут | 
| sinrab | 0:ed1ba99f7b14 | 63 | int s=0; // секунд | 
| sinrab | 0:ed1ba99f7b14 | 64 | void timeConvert(void); | 
| sinrab | 0:ed1ba99f7b14 | 65 | //----------- my functions ---------// | 
| sinrab | 0:ed1ba99f7b14 | 66 | void drawScreen1(void); // экран 1 Главный экран | 
| sinrab | 0:ed1ba99f7b14 | 67 | void drawScreen2(void); // экран 2 dats analog in and Noise | 
| sinrab | 0:ed1ba99f7b14 | 68 | void drawScreen3(void); // экран 3 | 
| sinrab | 0:ed1ba99f7b14 | 69 | void drawScreen4(void); // экран 4 Калибровка | 
| sinrab | 0:ed1ba99f7b14 | 70 | void drawScreen5(void); // экран 5 Настройки главный | 
| sinrab | 0:ed1ba99f7b14 | 71 | void drawScreen6(void); // экран 6 | 
| sinrab | 0:ed1ba99f7b14 | 72 | void drawScreen7(void); // экран 7 | 
| sinrab | 0:ed1ba99f7b14 | 73 | void drawScreen8(void); // экран 8 | 
| sinrab | 0:ed1ba99f7b14 | 74 | void bootCold(void); // холодный старт | 
| sinrab | 4:776f59129c24 | 75 | void loaddefaultsettings(void); // загрузка настроек по умолчанию | 
| sinrab | 4:776f59129c24 | 76 | void loadsettings(void); // загрузка настроек при старте | 
| sinrab | 4:776f59129c24 | 77 | void savedefaulttoflash(void); // сохранить в флэш настройки по умолчанию (для активации работы флэш) | 
| sinrab | 4:776f59129c24 | 78 | void fans(void); // управление вентиляторами | 
| sinrab | 4:776f59129c24 | 79 | void fanstart(void); // первичный старт вентилятора | 
| sinrab | 4:776f59129c24 | 80 | void keypoweriddle(void); // для задержка опроса кнопки питания | 
| sinrab | 4:776f59129c24 | 81 | void ScreenSaver(void); // ScreenSaver | 
| sinrab | 4:776f59129c24 | 82 | void screensaverstart(void); // старт заставки | 
| sinrab | 4:776f59129c24 | 83 | void bootscreen(void); // экран при старте | 
| sinrab | 4:776f59129c24 | 84 | int saveractive=0; | 
| sinrab | 4:776f59129c24 | 85 | int onesaver=0; | 
| sinrab | 4:776f59129c24 | 86 | int onepower=0; // для задержка опроса кнопки питания | 
| sinrab | 4:776f59129c24 | 87 | //----------------- | 
| sinrab | 4:776f59129c24 | 88 | void Protect(void); // функция обработки защиты | 
| sinrab | 4:776f59129c24 | 89 | int shl=0; | 
| sinrab | 4:776f59129c24 | 90 | int shm=0; | 
| sinrab | 4:776f59129c24 | 91 | int shortline=0; | 
| sinrab | 4:776f59129c24 | 92 | //----------------- | 
| sinrab | 2:d20b1ef35d3f | 93 | float map(float, float, float, float, float); // масштабирование | 
| sinrab | 1:7bc0f280c259 | 94 | void SetDateTime(void); // установка даты и времени | 
| sinrab | 1:7bc0f280c259 | 95 | int year=2014; | 
| sinrab | 1:7bc0f280c259 | 96 | int mon=11; | 
| sinrab | 1:7bc0f280c259 | 97 | int day=1; | 
| sinrab | 1:7bc0f280c259 | 98 | int hour=16; | 
| sinrab | 1:7bc0f280c259 | 99 | int min=42; | 
| sinrab | 1:7bc0f280c259 | 100 | int sec=0; | 
| sinrab | 1:7bc0f280c259 | 101 | time_t seconds; //для часов реального времени | 
| sinrab | 4:776f59129c24 | 102 | int tempstart=42; // температура старта вентилятора | 
| sinrab | 4:776f59129c24 | 103 | int tempfull=60; // полной мощности вентилятора tempstart tempfull tempcutoff | 
| sinrab | 4:776f59129c24 | 104 | int tempcutoff=80; // отключения нагрузки | 
| sinrab | 4:776f59129c24 | 105 | int umax=31; // U max, Volt | 
| sinrab | 4:776f59129c24 | 106 | float imax=2.6; // I max, Amper | 
| sinrab | 4:776f59129c24 | 107 | float rdown=0.05; // R сопротивление шунта для расчета падения напряжения выхода от зависимости от тока нагрузки | 
| sinrab | 4:776f59129c24 | 108 | int rdown_on=1; // по умолчанию без падения напряжения на резисторе шунта | 
| sinrab | 3:791cf9a867d1 | 109 | char *ron = "On "; // для вывода в меню главных настроек On | 
| sinrab | 3:791cf9a867d1 | 110 | char *roff = "Off"; // для вывода в меню главных настроек Off | 
| sinrab | 0:ed1ba99f7b14 | 111 | //--------------------------- | 
| sinrab | 0:ed1ba99f7b14 | 112 | float avgAin0(); // среднее значение с входа A0 | 
| sinrab | 0:ed1ba99f7b14 | 113 | float avgAin1(); // среднее значение с входа A1 | 
| sinrab | 0:ed1ba99f7b14 | 114 | float avgAin2(); // среднее значение с входа A2 | 
| sinrab | 0:ed1ba99f7b14 | 115 | float avgAin3(); // среднее значение с входа A3 | 
| sinrab | 0:ed1ba99f7b14 | 116 | //---- | 
| sinrab | 0:ed1ba99f7b14 | 117 | float in0 = 0; | 
| sinrab | 0:ed1ba99f7b14 | 118 | float in1 = 0; | 
| sinrab | 0:ed1ba99f7b14 | 119 | float in2 = 0; | 
| sinrab | 0:ed1ba99f7b14 | 120 | float in3 = 0; | 
| sinrab | 0:ed1ba99f7b14 | 121 | //---- | 
| sinrab | 3:791cf9a867d1 | 122 | float U5 = 0; | 
| sinrab | 0:ed1ba99f7b14 | 123 | float Ireal = 0; | 
| sinrab | 3:791cf9a867d1 | 124 | float U30 = 0; | 
| sinrab | 0:ed1ba99f7b14 | 125 | //--------------------------- | 
| sinrab | 0:ed1ba99f7b14 | 126 | void dataProcessing(void); // обработка и подготовка данных с аналоговых входов | 
| sinrab | 0:ed1ba99f7b14 | 127 | void powerButton(void); // при нажатии кнопки питания | 
| sinrab | 0:ed1ba99f7b14 | 128 | void buttonUse(void); // обработка нажатий кнопок | 
| sinrab | 0:ed1ba99f7b14 | 129 | //----------------------------------------------------------------------------------------------------------- | 
| sinrab | 4:776f59129c24 | 130 | float a0a = 0.000679; // A0 - U 5 - avg при 0 - нижняя точка U 5 вольт | 
| sinrab | 4:776f59129c24 | 131 | float a0k = 5.006402; // A0 - U 5 - коэффициент - верхняя точка | 
| sinrab | 0:ed1ba99f7b14 | 132 | //--------------------------------------------------------------- | 
| sinrab | 4:776f59129c24 | 133 | float a1a = 0.143353; // A1 - I бп - avg при 0 - нижняя точка a1a = avgAin1() - 0.00004 | 
| sinrab | 4:776f59129c24 | 134 | float a1k = 3.224676; // A1 - I бп - коэффициент - верхняя точка a1k = 2000/(avgAin1() - a1a) при 2амперах | 
| sinrab | 0:ed1ba99f7b14 | 135 | //--------------------------------------------------------------- | 
| sinrab | 4:776f59129c24 | 136 | float a2a = 0.000015; // A2 - U 30 - avg при 0 - нижняя точка U 33 вольта | 
| sinrab | 4:776f59129c24 | 137 | float a2k = 33.627953; // A2 - U 30 - коэффициент - верхняя точка | 
| sinrab | 0:ed1ba99f7b14 | 138 | //--------------------------------------------------------------- | 
| sinrab | 0:ed1ba99f7b14 | 139 | float noisea0; //типа уровень шума (разница между минимум и максимум за 100 измерений) для А0 | 
| sinrab | 0:ed1ba99f7b14 | 140 | float noisea1; // - - для A1 | 
| sinrab | 0:ed1ba99f7b14 | 141 | float noisea2; // - - для A2 | 
| sinrab | 0:ed1ba99f7b14 | 142 | float noisea3; // - - для A3 | 
| sinrab | 0:ed1ba99f7b14 | 143 | //----------------------------------------------------------------------------------------------------------- | 
| sinrab | 5:0b3c71d7e475 | 144 | DigitalIn buttonUp(PB_8); // Up | 
| sinrab | 5:0b3c71d7e475 | 145 | DigitalIn buttonDown(PB_6); // Down | 
| sinrab | 5:0b3c71d7e475 | 146 | DigitalIn buttonEnter(PB_7); // Enter | 
| sinrab | 0:ed1ba99f7b14 | 147 | int Screen=1; // по умолчанию грузим первое меню | 
| sinrab | 0:ed1ba99f7b14 | 148 | int complit=0; // в начале меню не прорисовано | 
| sinrab | 0:ed1ba99f7b14 | 149 | int pb=0; // для прорисовки кнопки | 
| sinrab | 0:ed1ba99f7b14 | 150 | int kline=15; // номер начальной строки в меню калибровки экран 4 | 
| sinrab | 1:7bc0f280c259 | 151 | int mline=15; // номер начальной строки в меню Настройки главная экран 5 | 
| sinrab | 0:ed1ba99f7b14 | 152 | int mline2=0; //в главном меню строка 2 не выбрана | 
| sinrab | 3:791cf9a867d1 | 153 | int mline4=0; // 4 | 
| sinrab | 3:791cf9a867d1 | 154 | int mline5=0; // 5 | 
| sinrab | 3:791cf9a867d1 | 155 | int mline6=0; // 6 | 
| sinrab | 3:791cf9a867d1 | 156 | int mline7=0; // 7 | 
| sinrab | 3:791cf9a867d1 | 157 | int mline8=0; // 8 | 
| sinrab | 3:791cf9a867d1 | 158 | int mline11=0; // 11 | 
| sinrab | 4:776f59129c24 | 159 | int mline12=0; // 12 | 
| sinrab | 4:776f59129c24 | 160 | int mline13=0; // 13 | 
| sinrab | 4:776f59129c24 | 161 | int mline14=0; // 14 | 
| sinrab | 1:7bc0f280c259 | 162 | int nline=8; // номер начальной строки в меню установки времени экран 3 | 
| sinrab | 0:ed1ba99f7b14 | 163 | int pmenu=0; //в главном меню изменение выбраной строки не действительно | 
| sinrab | 0:ed1ba99f7b14 | 164 | int powerProtect=1; //защита от кз | 
| sinrab | 0:ed1ba99f7b14 | 165 | int pp=0; //защита от кз для прорисовки меню | 
| sinrab | 3:791cf9a867d1 | 166 | //int cc=0; // значит идет C.V | 
| sinrab | 2:d20b1ef35d3f | 167 | int pm=0; // для одной прорисовки сс и сv | 
| sinrab | 3:791cf9a867d1 | 168 | int cs=0; // короткое замыкание | 
| sinrab | 3:791cf9a867d1 | 169 | int csp=0; // для одной прорисовки короткого замыкания | 
| sinrab | 3:791cf9a867d1 | 170 | float brightness = 1.0f; //яркость экрана | 
| sinrab | 5:0b3c71d7e475 | 171 | PwmOut pinbrightness(PB_5); // выход на ключ регулировки яркости экрана | 
| sinrab | 3:791cf9a867d1 | 172 | float fanspeed = 0.0f; | 
| sinrab | 5:0b3c71d7e475 | 173 | PwmOut fan(PB_4); // выход вентилятора | 
| sinrab | 5:0b3c71d7e475 | 174 | //PwmOut fan2(PA_15); | 
| sinrab | 5:0b3c71d7e475 | 175 | //float fanspeed2 = 0.8f; | 
| sinrab | 3:791cf9a867d1 | 176 | int temperature = 25; // текущая температура | 
| sinrab | 5:0b3c71d7e475 | 177 | int screensaver=0; // заставка 0 - нет, 1 - часы, 2- ... | 
| sinrab | 5:0b3c71d7e475 | 178 | int beeper=0; //бипер выключен | 
| sinrab | 0:ed1ba99f7b14 | 179 | //----------------------------------------------------------------------------------------------------------- | 
| sinrab | 5:0b3c71d7e475 | 180 | DigitalOut powerMosfet(PC_11); // выход управления нагрузкой | 
| sinrab | 5:0b3c71d7e475 | 181 | DigitalIn cc(PC_10); //вход СС 0 - СС, 1 - CV | 
| sinrab | 3:791cf9a867d1 | 182 | int ccc=0; | 
| sinrab | 5:0b3c71d7e475 | 183 | DigitalOut ledcc(PD_2); // светодиод C.C | 
| sinrab | 5:0b3c71d7e475 | 184 | DigitalOut ledshort(PC_12); // светодиод КЗ | 
| sinrab | 5:0b3c71d7e475 | 185 | AnalogIn ainA0(PA_2); | 
| sinrab | 5:0b3c71d7e475 | 186 | AnalogIn ainA1(PA_3); | 
| sinrab | 5:0b3c71d7e475 | 187 | AnalogIn ainA2(PA_1); | 
| sinrab | 5:0b3c71d7e475 | 188 | AnalogIn ainA3(PA_0); | 
| sinrab | 3:791cf9a867d1 | 189 | //AnalogIn ainA4(A4); | 
| sinrab | 3:791cf9a867d1 | 190 | //AnalogIn ainA5(A5); | 
| sinrab | 4:776f59129c24 | 191 | //BusOut unused(A4,A5); | 
| sinrab | 4:776f59129c24 | 192 | //-------------для screen7-- | 
| sinrab | 4:776f59129c24 | 193 | int iiii=0; | 
| sinrab | 4:776f59129c24 | 194 | //-------------------------- | 
| sinrab | 0:ed1ba99f7b14 | 195 | //------------------------------------------------------------------------------------------------------------ | 
| sinrab | 0:ed1ba99f7b14 | 196 | //-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | 
| sinrab | 4:776f59129c24 | 197 | void loaddefaultsettings(void) | 
| sinrab | 4:776f59129c24 | 198 | { | 
| sinrab | 4:776f59129c24 | 199 | a0a = 0.000679; | 
| sinrab | 4:776f59129c24 | 200 | a0k = 5.006402; | 
| sinrab | 4:776f59129c24 | 201 | a1a = 0.143353; | 
| sinrab | 4:776f59129c24 | 202 | a1k = 3.224676; | 
| sinrab | 4:776f59129c24 | 203 | a2a = 0.000015; | 
| sinrab | 4:776f59129c24 | 204 | a2k = 33.627953; | 
| sinrab | 4:776f59129c24 | 205 | imax=2.6; | 
| sinrab | 4:776f59129c24 | 206 | rdown=0.05; | 
| sinrab | 4:776f59129c24 | 207 | brightness = 1.0f; | 
| sinrab | 4:776f59129c24 | 208 | beeper = 0; | 
| sinrab | 4:776f59129c24 | 209 | rdown_on=1; | 
| sinrab | 4:776f59129c24 | 210 | umax=31; | 
| sinrab | 4:776f59129c24 | 211 | tempstart=42; | 
| sinrab | 4:776f59129c24 | 212 | tempfull=60; | 
| sinrab | 4:776f59129c24 | 213 | tempcutoff=80; | 
| sinrab | 4:776f59129c24 | 214 | screensaver=0; | 
| sinrab | 4:776f59129c24 | 215 | ledcc=1; | 
| sinrab | 4:776f59129c24 | 216 | wait(0.5); | 
| sinrab | 4:776f59129c24 | 217 | ledcc=0; | 
| sinrab | 4:776f59129c24 | 218 | wait(0.5); | 
| sinrab | 4:776f59129c24 | 219 | } | 
| sinrab | 4:776f59129c24 | 220 | //------------------------------------------------------------------------------------------------------------ | 
| sinrab | 4:776f59129c24 | 221 | void loadsettings(void) | 
| sinrab | 4:776f59129c24 | 222 | { | 
| sinrab | 4:776f59129c24 | 223 | int s; | 
| sinrab | 4:776f59129c24 | 224 | int s1; | 
| sinrab | 4:776f59129c24 | 225 | eeprom.nbyte_read(0, (char*)&s, sizeof(s)); | 
| sinrab | 4:776f59129c24 | 226 | eeprom.nbyte_read(4, (char*)&s1, sizeof(s1)); | 
| sinrab | 4:776f59129c24 | 227 | if (s==0 && s1==1) { //если флэш активирована то грузим с неё | 
| sinrab | 4:776f59129c24 | 228 | ledshort=1; // 1 раз моргнуло - начало загрузки | 
| sinrab | 4:776f59129c24 | 229 | wait(0.02); | 
| sinrab | 4:776f59129c24 | 230 | ledshort=0; | 
| sinrab | 4:776f59129c24 | 231 | |
| sinrab | 4:776f59129c24 | 232 | eeprom.nbyte_read(8, (char*)&a0a, sizeof(a0a)); // a0a float - 4 байта | 
| sinrab | 4:776f59129c24 | 233 | eeprom.nbyte_read(12, (char*)&a0k, sizeof(a0k)); // a0k float - 4 байта | 
| sinrab | 4:776f59129c24 | 234 | eeprom.nbyte_read(16, (char*)&a1a, sizeof(a1a)); // a1a float - 4 байта | 
| sinrab | 4:776f59129c24 | 235 | eeprom.nbyte_read(20, (char*)&a1k, sizeof(a1k)); // a1k float - 4 байта | 
| sinrab | 4:776f59129c24 | 236 | eeprom.nbyte_read(24, (char*)&a2a, sizeof(a2a)); // a2a float - 4 байта | 
| sinrab | 4:776f59129c24 | 237 | eeprom.nbyte_read(28, (char*)&a2k, sizeof(a2k)); // a2k float - 4 байта | 
| sinrab | 4:776f59129c24 | 238 | |
| sinrab | 4:776f59129c24 | 239 | eeprom.nbyte_read(32, (char*)&imax, sizeof(imax)); // imax float - 4 байта | 
| sinrab | 4:776f59129c24 | 240 | eeprom.nbyte_read(36, (char*)&rdown, sizeof(rdown)); // rdown float - 4 байта | 
| sinrab | 4:776f59129c24 | 241 | eeprom.nbyte_read(40, (char*)&brightness, sizeof(brightness)); // brightness float - 4 байта | 
| sinrab | 4:776f59129c24 | 242 | eeprom.nbyte_read(44, (char*)&beeper, sizeof(beeper)); // beeper float - 4 байта | 
| sinrab | 4:776f59129c24 | 243 | |
| sinrab | 4:776f59129c24 | 244 | eeprom.nbyte_read(48, (char*)&rdown_on, sizeof(rdown_on)); // rdown_on float - 4 байт | 
| sinrab | 4:776f59129c24 | 245 | eeprom.nbyte_read(52, (char*)&umax, sizeof(umax)); // umax float - 4 байт | 
| sinrab | 4:776f59129c24 | 246 | eeprom.nbyte_read(56, (char*)&tempstart, sizeof(tempstart)); // tempstart float - 4 байт | 
| sinrab | 4:776f59129c24 | 247 | eeprom.nbyte_read(60, (char*)&tempfull, sizeof(tempfull)); // tempfull float - 4 байт | 
| sinrab | 4:776f59129c24 | 248 | eeprom.nbyte_read(64, (char*)&tempcutoff, sizeof(tempcutoff)); // tempcutoff float - 4 байт | 
| sinrab | 4:776f59129c24 | 249 | eeprom.nbyte_read(68, (char*)&screensaver, sizeof(screensaver)); // screensaver float - 4 байт | 
| sinrab | 4:776f59129c24 | 250 | |
| sinrab | 4:776f59129c24 | 251 | wait(0.05); // 2 раза моргнуло удачно загрузили | 
| sinrab | 4:776f59129c24 | 252 | ledshort=1; | 
| sinrab | 4:776f59129c24 | 253 | wait(0.02); | 
| sinrab | 4:776f59129c24 | 254 | ledshort=0; | 
| sinrab | 5:0b3c71d7e475 | 255 | }else{ | 
| sinrab | 5:0b3c71d7e475 | 256 | TFT.foreground(Red); | 
| sinrab | 5:0b3c71d7e475 | 257 | TFT.printf("ERROR - flash memory is not activated\n"); | 
| sinrab | 5:0b3c71d7e475 | 258 | TFT.foreground(White); | 
| sinrab | 5:0b3c71d7e475 | 259 | wait(5); | 
| sinrab | 5:0b3c71d7e475 | 260 | TFT.printf("Load default settings."); | 
| sinrab | 5:0b3c71d7e475 | 261 | for (int i=0; i<10; i++) | 
| sinrab | 5:0b3c71d7e475 | 262 | { | 
| sinrab | 5:0b3c71d7e475 | 263 | wait(0.1); | 
| sinrab | 5:0b3c71d7e475 | 264 | TFT.printf("."); | 
| sinrab | 5:0b3c71d7e475 | 265 | } | 
| sinrab | 5:0b3c71d7e475 | 266 | TFT.printf("\n"); | 
| sinrab | 5:0b3c71d7e475 | 267 | loaddefaultsettings(); | 
| sinrab | 4:776f59129c24 | 268 | } | 
| sinrab | 4:776f59129c24 | 269 | } | 
| sinrab | 4:776f59129c24 | 270 | //------------------------------------------------------------------------------------------------------------ | 
| sinrab | 4:776f59129c24 | 271 | void savedefaulttoflash(void) | 
| sinrab | 4:776f59129c24 | 272 | { | 
| sinrab | 4:776f59129c24 | 273 | |
| sinrab | 4:776f59129c24 | 274 | a0a = 0.000679; | 
| sinrab | 4:776f59129c24 | 275 | a0k = 5.006402; | 
| sinrab | 4:776f59129c24 | 276 | a1a = 0.143353; | 
| sinrab | 4:776f59129c24 | 277 | a1k = 3.224676; | 
| sinrab | 4:776f59129c24 | 278 | a2a = 0.000015; | 
| sinrab | 4:776f59129c24 | 279 | a2k = 33.627953; | 
| sinrab | 4:776f59129c24 | 280 | imax=2.6; | 
| sinrab | 4:776f59129c24 | 281 | rdown=0.05; | 
| sinrab | 4:776f59129c24 | 282 | brightness = 1.0f; | 
| sinrab | 4:776f59129c24 | 283 | beeper = 0; | 
| sinrab | 4:776f59129c24 | 284 | rdown_on=1; | 
| sinrab | 4:776f59129c24 | 285 | umax=31; | 
| sinrab | 4:776f59129c24 | 286 | tempstart=42; | 
| sinrab | 4:776f59129c24 | 287 | tempfull=60; | 
| sinrab | 4:776f59129c24 | 288 | tempcutoff=80; | 
| sinrab | 4:776f59129c24 | 289 | screensaver=0; | 
| sinrab | 4:776f59129c24 | 290 | |
| sinrab | 4:776f59129c24 | 291 | |
| sinrab | 4:776f59129c24 | 292 | ledshort=1; // 1 раз моргнуло - начало записи | 
| sinrab | 4:776f59129c24 | 293 | wait(0.02); | 
| sinrab | 4:776f59129c24 | 294 | ledshort=0; | 
| sinrab | 4:776f59129c24 | 295 | wait(0.05); | 
| sinrab | 4:776f59129c24 | 296 | |
| sinrab | 4:776f59129c24 | 297 | int s=0; | 
| sinrab | 4:776f59129c24 | 298 | int s1=1; | 
| sinrab | 4:776f59129c24 | 299 | eeprom.nbyte_write(0, (char*)&s, sizeof(s)); | 
| sinrab | 4:776f59129c24 | 300 | eeprom.nbyte_write(4, (char*)&s1, sizeof(s1)); | 
| sinrab | 4:776f59129c24 | 301 | |
| sinrab | 4:776f59129c24 | 302 | eeprom.nbyte_write(8, (char*)&a0a, sizeof(a0a)); // a0a float - 4 байта | 
| sinrab | 4:776f59129c24 | 303 | eeprom.nbyte_write(12, (char*)&a0k, sizeof(a0k)); // a0k float - 4 байта | 
| sinrab | 4:776f59129c24 | 304 | eeprom.nbyte_write(16, (char*)&a1a, sizeof(a1a)); // a1a float - 4 байта | 
| sinrab | 4:776f59129c24 | 305 | eeprom.nbyte_write(20, (char*)&a1k, sizeof(a1k)); // a1k float - 4 байта | 
| sinrab | 4:776f59129c24 | 306 | eeprom.nbyte_write(24, (char*)&a2a, sizeof(a2a)); // a2a float - 4 байта | 
| sinrab | 4:776f59129c24 | 307 | eeprom.nbyte_write(28, (char*)&a2k, sizeof(a2k)); // a2k float - 4 байта | 
| sinrab | 4:776f59129c24 | 308 | |
| sinrab | 4:776f59129c24 | 309 | eeprom.nbyte_write(32, (char*)&imax, sizeof(imax)); // imax float - 4 байта | 
| sinrab | 4:776f59129c24 | 310 | eeprom.nbyte_write(36, (char*)&rdown, sizeof(rdown)); // rdown float - 4 байта | 
| sinrab | 4:776f59129c24 | 311 | eeprom.nbyte_write(40, (char*)&brightness, sizeof(brightness)); // brightness float - 4 байта | 
| sinrab | 4:776f59129c24 | 312 | eeprom.nbyte_write(44, (char*)&beeper, sizeof(beeper)); // beeper float - 4 байта | 
| sinrab | 4:776f59129c24 | 313 | |
| sinrab | 4:776f59129c24 | 314 | eeprom.nbyte_write(48, (char*)&rdown_on, sizeof(rdown_on)); // rdown_on float - 4 байта | 
| sinrab | 4:776f59129c24 | 315 | eeprom.nbyte_write(52, (char*)&umax, sizeof(umax)); // umax float - 4 байта | 
| sinrab | 4:776f59129c24 | 316 | eeprom.nbyte_write(56, (char*)&tempstart, sizeof(tempstart)); // tempstart float - 4 байта | 
| sinrab | 4:776f59129c24 | 317 | eeprom.nbyte_write(60, (char*)&tempfull, sizeof(tempfull)); // tempfull float - 4 байта | 
| sinrab | 4:776f59129c24 | 318 | eeprom.nbyte_write(64, (char*)&tempcutoff, sizeof(tempcutoff)); // tempcutoff float - 4 байта | 
| sinrab | 4:776f59129c24 | 319 | eeprom.nbyte_write(68, (char*)&screensaver, sizeof(screensaver)); // screensaver float - 4 байта | 
| sinrab | 4:776f59129c24 | 320 | |
| sinrab | 4:776f59129c24 | 321 | int l; | 
| sinrab | 4:776f59129c24 | 322 | int l1; | 
| sinrab | 4:776f59129c24 | 323 | eeprom.nbyte_read(0, (char*)&l, sizeof(l)); | 
| sinrab | 4:776f59129c24 | 324 | eeprom.nbyte_read(4, (char*)&l1, sizeof(l1)); | 
| sinrab | 4:776f59129c24 | 325 | |
| sinrab | 4:776f59129c24 | 326 | if (l==s && l1==s1) { //удачно сохранилось - 2 раза моргнуло | 
| sinrab | 4:776f59129c24 | 327 | ledshort=1; | 
| sinrab | 4:776f59129c24 | 328 | wait(0.02); | 
| sinrab | 4:776f59129c24 | 329 | ledshort=0; | 
| sinrab | 4:776f59129c24 | 330 | } else { | 
| sinrab | 4:776f59129c24 | 331 | ledshort=1; | 
| sinrab | 4:776f59129c24 | 332 | TFT.background(Black); | 
| sinrab | 4:776f59129c24 | 333 | TFT.foreground(Red); | 
| sinrab | 4:776f59129c24 | 334 | TFT.set_font((unsigned char*) Consolas19x35); | 
| sinrab | 4:776f59129c24 | 335 | TFT.locate(10, 100); | 
| sinrab | 4:776f59129c24 | 336 | TFT.printf("SAVE ERROR"); | 
| sinrab | 4:776f59129c24 | 337 | wait(5); | 
| sinrab | 4:776f59129c24 | 338 | ledshort=0; | 
| sinrab | 4:776f59129c24 | 339 | } | 
| sinrab | 4:776f59129c24 | 340 | } | 
| sinrab | 0:ed1ba99f7b14 | 341 | //------------------------------------------------------------------------------------------------------------ | 
| sinrab | 0:ed1ba99f7b14 | 342 | void bootCold(void) | 
| sinrab | 0:ed1ba99f7b14 | 343 | { | 
| sinrab | 4:776f59129c24 | 344 | i2c.frequency(100000); | 
| sinrab | 0:ed1ba99f7b14 | 345 | powerMosfet = 0; // при включении выход выключен | 
| sinrab | 3:791cf9a867d1 | 346 | ledcc=0; | 
| sinrab | 3:791cf9a867d1 | 347 | ledshort=0; | 
| sinrab | 4:776f59129c24 | 348 | TFT.claim(stdout); | 
| sinrab | 5:0b3c71d7e475 | 349 | //set_time(1414838392); // Set RTC time to Wed, 28 Oct 2009 11:35:37 | 
| sinrab | 0:ed1ba99f7b14 | 350 | tstart = treal = time(NULL); | 
| sinrab | 5:0b3c71d7e475 | 351 | pinbrightness.period(0.01); // задаём частоту Шим подсветки 0.001 - 1000 герц | 
| sinrab | 3:791cf9a867d1 | 352 | fan.period(0.01); | 
| sinrab | 5:0b3c71d7e475 | 353 | //fan2.period(0.01); | 
| sinrab | 0:ed1ba99f7b14 | 354 | TFT.set_orientation(3); | 
| sinrab | 0:ed1ba99f7b14 | 355 | TFT.background(Black); | 
| sinrab | 0:ed1ba99f7b14 | 356 | TFT.cls(); | 
| sinrab | 0:ed1ba99f7b14 | 357 | wait(0.2); | 
| sinrab | 3:791cf9a867d1 | 358 | fan = fanspeed; // устанавливаем скорость | 
| sinrab | 5:0b3c71d7e475 | 359 | //fan2=fanspeed2; | 
| sinrab | 0:ed1ba99f7b14 | 360 | } | 
| sinrab | 0:ed1ba99f7b14 | 361 | //------------------------------------------------------------------------------------------------------------ | 
| sinrab | 4:776f59129c24 | 362 | void bootscreen(void) | 
| sinrab | 4:776f59129c24 | 363 | { | 
| sinrab | 4:776f59129c24 | 364 | TFT.background(Black); | 
| sinrab | 5:0b3c71d7e475 | 365 | TFT.foreground(Green); | 
| sinrab | 5:0b3c71d7e475 | 366 | TFT.locate(100, 10); | 
| sinrab | 5:0b3c71d7e475 | 367 | TFT.set_font((unsigned char*) Consolas26x49); | 
| sinrab | 5:0b3c71d7e475 | 368 | TFT.printf("PSTFT\n"); | 
| sinrab | 4:776f59129c24 | 369 | TFT.foreground(White); | 
| sinrab | 4:776f59129c24 | 370 | TFT.set_font((unsigned char*) CourierNew13x23); | 
| sinrab | 5:0b3c71d7e475 | 371 | TFT.printf(" Firmware v. 1.0.0\n"); | 
| sinrab | 5:0b3c71d7e475 | 372 | TFT.set_font((unsigned char*) Courier8x13); | 
| sinrab | 5:0b3c71d7e475 | 373 | TFT.printf(" Laboratory power supply based on STM32\n"); | 
| sinrab | 5:0b3c71d7e475 | 374 | TFT.printf(" Copyright (c) 2015 Pimenov V\n"); | 
| sinrab | 5:0b3c71d7e475 | 375 | TFT.printf(" Mail: sinrab@gmail.com \n"); | 
| sinrab | 4:776f59129c24 | 376 | pinbrightness = brightness; // включаем подсветку | 
| sinrab | 5:0b3c71d7e475 | 377 | wait(3); | 
| sinrab | 5:0b3c71d7e475 | 378 | TFT.locate(0, 150); | 
| sinrab | 5:0b3c71d7e475 | 379 | TFT.set_font((unsigned char*) Courier8x13); | 
| sinrab | 5:0b3c71d7e475 | 380 | TFT.printf("Press button ENTER\n"); | 
| sinrab | 5:0b3c71d7e475 | 381 | TFT.printf("for load default settings\n"); | 
| sinrab | 5:0b3c71d7e475 | 382 | TFT.printf("\n"); | 
| sinrab | 5:0b3c71d7e475 | 383 | wait(1); | 
| sinrab | 4:776f59129c24 | 384 | if (buttonEnter==0) { | 
| sinrab | 5:0b3c71d7e475 | 385 | TFT.printf("Load default settings."); | 
| sinrab | 5:0b3c71d7e475 | 386 | for (int i=0; i<10; i++) | 
| sinrab | 5:0b3c71d7e475 | 387 | { | 
| sinrab | 5:0b3c71d7e475 | 388 | wait(0.1); | 
| sinrab | 5:0b3c71d7e475 | 389 | TFT.printf("."); | 
| sinrab | 5:0b3c71d7e475 | 390 | } | 
| sinrab | 5:0b3c71d7e475 | 391 | TFT.printf("\n"); | 
| sinrab | 4:776f59129c24 | 392 | loaddefaultsettings(); | 
| sinrab | 4:776f59129c24 | 393 | }else{ | 
| sinrab | 5:0b3c71d7e475 | 394 | TFT.printf("Load settings from flash memory."); | 
| sinrab | 5:0b3c71d7e475 | 395 | for (int i=0; i<9; i++) | 
| sinrab | 5:0b3c71d7e475 | 396 | { | 
| sinrab | 5:0b3c71d7e475 | 397 | wait(0.1); | 
| sinrab | 5:0b3c71d7e475 | 398 | TFT.printf("."); | 
| sinrab | 5:0b3c71d7e475 | 399 | } | 
| sinrab | 5:0b3c71d7e475 | 400 | TFT.printf("\n"); | 
| sinrab | 4:776f59129c24 | 401 | loadsettings(); | 
| sinrab | 4:776f59129c24 | 402 | } | 
| sinrab | 5:0b3c71d7e475 | 403 | //wait(100); | 
| sinrab | 4:776f59129c24 | 404 | } | 
| sinrab | 4:776f59129c24 | 405 | //-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | 
| sinrab | 0:ed1ba99f7b14 | 406 | int main() //--------- Главная функция ---------// | 
| sinrab | 0:ed1ba99f7b14 | 407 | { | 
| sinrab | 0:ed1ba99f7b14 | 408 | bootCold(); // холодный старт | 
| sinrab | 4:776f59129c24 | 409 | bootscreen(); | 
| sinrab | 0:ed1ba99f7b14 | 410 | button.fall(&powerButton); // прерывание кнопки включения нагрузки запускает функцию | 
| sinrab | 7:8410439dee73 | 411 | Power_Capacity.attach(&Pcap, 1.0); // таймер для смены вывода на экран мощности и ёмкости | 
| sinrab | 0:ed1ba99f7b14 | 412 | |
| sinrab | 0:ed1ba99f7b14 | 413 | while(1) { | 
| sinrab | 0:ed1ba99f7b14 | 414 | |
| sinrab | 0:ed1ba99f7b14 | 415 | dataProcessing(); // обработка и подготовка данных с аналоговых входов | 
| sinrab | 4:776f59129c24 | 416 | fans(); | 
| sinrab | 4:776f59129c24 | 417 | Protect(); | 
| sinrab | 4:776f59129c24 | 418 | if (saveractive==0) { | 
| sinrab | 4:776f59129c24 | 419 | buttonUse(); // обработка нажатий кнопок | 
| sinrab | 4:776f59129c24 | 420 | } | 
| sinrab | 4:776f59129c24 | 421 | ScreenSaver(); // заставка | 
| sinrab | 0:ed1ba99f7b14 | 422 | if (Screen == 1) drawScreen1(); | 
| sinrab | 0:ed1ba99f7b14 | 423 | if (Screen == 2) drawScreen2(); | 
| sinrab | 0:ed1ba99f7b14 | 424 | if (Screen == 3) drawScreen3(); | 
| sinrab | 0:ed1ba99f7b14 | 425 | if (Screen == 4) drawScreen4(); | 
| sinrab | 0:ed1ba99f7b14 | 426 | if (Screen == 5) drawScreen5(); | 
| sinrab | 0:ed1ba99f7b14 | 427 | if (Screen == 6) drawScreen6(); | 
| sinrab | 0:ed1ba99f7b14 | 428 | if (Screen == 7) drawScreen7(); | 
| sinrab | 0:ed1ba99f7b14 | 429 | if (Screen == 8) drawScreen8(); | 
| sinrab | 0:ed1ba99f7b14 | 430 | |
| sinrab | 0:ed1ba99f7b14 | 431 | } | 
| sinrab | 0:ed1ba99f7b14 | 432 | } //--------- Главная функция ---------// | 
| sinrab | 4:776f59129c24 | 433 | //-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | 
| sinrab | 0:ed1ba99f7b14 | 434 | //------------------------------------------------------------------------------------------------------------ | 
| sinrab | 0:ed1ba99f7b14 | 435 | //------------------------------------------------------------------------------------------------------------ | 
| sinrab | 0:ed1ba99f7b14 | 436 | void drawScreen1(void) // экран 1 | 
| sinrab | 0:ed1ba99f7b14 | 437 | { | 
| sinrab | 0:ed1ba99f7b14 | 438 | if (complit==0) { | 
| sinrab | 3:791cf9a867d1 | 439 | pm=0; | 
| sinrab | 3:791cf9a867d1 | 440 | ccc=0; | 
| sinrab | 0:ed1ba99f7b14 | 441 | pb=0; | 
| sinrab | 0:ed1ba99f7b14 | 442 | pp=0; | 
| sinrab | 5:0b3c71d7e475 | 443 | csp=0; | 
| sinrab | 0:ed1ba99f7b14 | 444 | TFT.set_orientation(3); | 
| sinrab | 0:ed1ba99f7b14 | 445 | TFT.background(Black); | 
| sinrab | 0:ed1ba99f7b14 | 446 | TFT.cls(); | 
| sinrab | 3:791cf9a867d1 | 447 | TFT.rect(0,0,319,239,colorline); //рамка | 
| sinrab | 3:791cf9a867d1 | 448 | TFT.rect(10,62,309,76,colorline); //аналоговая рамка 1 | 
| sinrab | 3:791cf9a867d1 | 449 | TFT.rect(10,137,309,151,colorline); //авалоговая рамка 2 | 
| sinrab | 0:ed1ba99f7b14 | 450 | //grid(); | 
| sinrab | 0:ed1ba99f7b14 | 451 | //int y = 51; | 
| sinrab | 0:ed1ba99f7b14 | 452 | //TFT.line(5,y,310,y, White); | 
| sinrab | 0:ed1ba99f7b14 | 453 | TFT.background(Black); | 
| sinrab | 3:791cf9a867d1 | 454 | TFT.foreground(colorline); // цвет слов | 
| sinrab | 4:776f59129c24 | 455 | TFT.set_font((unsigned char*) Consolas26x49); | 
| sinrab | 2:d20b1ef35d3f | 456 | TFT.locate(193, 13); | 
| sinrab | 3:791cf9a867d1 | 457 | TFT.printf("v"); // V | 
| sinrab | 4:776f59129c24 | 458 | TFT.locate(165, 88); | 
| sinrab | 3:791cf9a867d1 | 459 | TFT.printf("ma"); // mA | 
| sinrab | 0:ed1ba99f7b14 | 460 | complit = 1; // прорисовали! | 
| sinrab | 0:ed1ba99f7b14 | 461 | |
| sinrab | 3:791cf9a867d1 | 462 | TFT.fillrect(7,161,104,183,0x2104); // подвал левый квадрат верхний заливка | 
| sinrab | 3:791cf9a867d1 | 463 | TFT.fillrect(7,185,104,207,0x2104); // средний | 
| sinrab | 3:791cf9a867d1 | 464 | TFT.fillrect(7,207,104,231,0x2104); // нижний | 
| sinrab | 0:ed1ba99f7b14 | 465 | |
| sinrab | 3:791cf9a867d1 | 466 | TFT.rect(6,160,105,232,colorline); // левый квадрат | 
| sinrab | 3:791cf9a867d1 | 467 | TFT.line(7,184,104,184,colorline); // левый разделительная линия вверхняя | 
| sinrab | 3:791cf9a867d1 | 468 | TFT.line(7,208,104,208,colorline); // нижняя | 
| sinrab | 3:791cf9a867d1 | 469 | TFT.rect(112,160,207,192,colorline); //средний квадрат верх | 
| sinrab | 3:791cf9a867d1 | 470 | TFT.rect(112,198,207,232,colorline); // низ | 
| sinrab | 3:791cf9a867d1 | 471 | TFT.rect(214,160,313,232,colorline); //правый квадрат | 
| sinrab | 0:ed1ba99f7b14 | 472 | |
| sinrab | 0:ed1ba99f7b14 | 473 | } | 
| sinrab | 0:ed1ba99f7b14 | 474 | //----------------------------------------------------------------------------- | 
| sinrab | 3:791cf9a867d1 | 475 | if (powerProtect==0 & pp==0) { // защита от кз | 
| sinrab | 4:776f59129c24 | 476 | TFT.fillrect(113,161,206,191,Black); //0 | 
| sinrab | 3:791cf9a867d1 | 477 | TFT.background(Black); | 
| sinrab | 3:791cf9a867d1 | 478 | TFT.foreground(0x4208); | 
| sinrab | 0:ed1ba99f7b14 | 479 | TFT.set_font((unsigned char*) Lucida13x21); | 
| sinrab | 3:791cf9a867d1 | 480 | TFT.locate(115, 165); | 
| sinrab | 3:791cf9a867d1 | 481 | TFT.printf("Protect"); | 
| sinrab | 3:791cf9a867d1 | 482 | pp=1; | 
| sinrab | 3:791cf9a867d1 | 483 | } | 
| sinrab | 3:791cf9a867d1 | 484 | if (powerProtect==1 & pp==0) { //1 | 
| sinrab | 3:791cf9a867d1 | 485 | TFT.fillrect(113,161,206,191,0x0180); | 
| sinrab | 3:791cf9a867d1 | 486 | TFT.background(0x0180); | 
| sinrab | 3:791cf9a867d1 | 487 | TFT.foreground(Green); | 
| sinrab | 3:791cf9a867d1 | 488 | TFT.set_font((unsigned char*) Lucida13x21); | 
| sinrab | 3:791cf9a867d1 | 489 | TFT.locate(115, 165); | 
| sinrab | 0:ed1ba99f7b14 | 490 | TFT.printf("Protect"); | 
| sinrab | 0:ed1ba99f7b14 | 491 | pp=1; | 
| sinrab | 0:ed1ba99f7b14 | 492 | } | 
| sinrab | 4:776f59129c24 | 493 | |
| sinrab | 4:776f59129c24 | 494 | if (cs==0 & csp==0) { // прорисовка короткого замыкания TFT.rect(112,198,207,232,colorline); | 
| sinrab | 3:791cf9a867d1 | 495 | TFT.fillrect(113,199,206,231,Black); //0 | 
| sinrab | 3:791cf9a867d1 | 496 | TFT.background(Black); | 
| sinrab | 3:791cf9a867d1 | 497 | TFT.foreground(0x4208); | 
| sinrab | 0:ed1ba99f7b14 | 498 | TFT.set_font((unsigned char*) Lucida13x21); | 
| sinrab | 3:791cf9a867d1 | 499 | TFT.locate(130, 205); | 
| sinrab | 3:791cf9a867d1 | 500 | TFT.printf("SHORT"); | 
| sinrab | 3:791cf9a867d1 | 501 | csp=1; | 
| sinrab | 4:776f59129c24 | 502 | } | 
| sinrab | 4:776f59129c24 | 503 | if (cs==1 & csp==0) { //1 | 
| sinrab | 3:791cf9a867d1 | 504 | TFT.fillrect(113,199,206,231,0x6000); | 
| sinrab | 3:791cf9a867d1 | 505 | TFT.background(0x6000); | 
| sinrab | 3:791cf9a867d1 | 506 | TFT.foreground(Red); | 
| sinrab | 3:791cf9a867d1 | 507 | TFT.set_font((unsigned char*) Lucida13x21); | 
| sinrab | 3:791cf9a867d1 | 508 | TFT.locate(130, 205); | 
| sinrab | 3:791cf9a867d1 | 509 | TFT.printf("SHORT"); | 
| sinrab | 3:791cf9a867d1 | 510 | csp=1; | 
| sinrab | 4:776f59129c24 | 511 | } | 
| sinrab | 4:776f59129c24 | 512 | |
| sinrab | 0:ed1ba99f7b14 | 513 | |
| sinrab | 0:ed1ba99f7b14 | 514 | |
| sinrab | 5:0b3c71d7e475 | 515 | //fps.reset(); //мерить фпс | 
| sinrab | 5:0b3c71d7e475 | 516 | //fps.start(); | 
| sinrab | 4:776f59129c24 | 517 | |
| sinrab | 0:ed1ba99f7b14 | 518 | TFT.background(Black); | 
| sinrab | 4:776f59129c24 | 519 | |
| sinrab | 4:776f59129c24 | 520 | if (cc==0) { //если C.C то меняем цвет значения напряжения | 
| sinrab | 2:d20b1ef35d3f | 521 | TFT.foreground(Red); | 
| sinrab | 4:776f59129c24 | 522 | } else { | 
| sinrab | 2:d20b1ef35d3f | 523 | TFT.foreground(Green); | 
| sinrab | 2:d20b1ef35d3f | 524 | } | 
| sinrab | 4:776f59129c24 | 525 | |
| sinrab | 0:ed1ba99f7b14 | 526 | TFT.set_font((unsigned char*) digi36x44); | 
| sinrab | 0:ed1ba99f7b14 | 527 | TFT.locate(10, 10); | 
| sinrab | 3:791cf9a867d1 | 528 | if(U5<0) U5=0; | 
| sinrab | 4:776f59129c24 | 529 | if (U5<4.5f) { | 
| sinrab | 3:791cf9a867d1 | 530 | //TFT.fillrect(10,10,46,54,Black); | 
| sinrab | 3:791cf9a867d1 | 531 | TFT.locate(10, 10); | 
| sinrab | 3:791cf9a867d1 | 532 | TFT.printf("%5.3f", U5); // выводим значение с A0 (напряжение) | 
| sinrab | 4:776f59129c24 | 533 | } else { | 
| sinrab | 4:776f59129c24 | 534 | TFT.locate(10, 10); | 
| sinrab | 4:776f59129c24 | 535 | TFT.printf("%05.2f", U30); // выводим значение с A0 (напряжение) | 
| sinrab | 2:d20b1ef35d3f | 536 | } | 
| sinrab | 4:776f59129c24 | 537 | |
| sinrab | 2:d20b1ef35d3f | 538 | TFT.pixel(82, 53, Black); | 
| sinrab | 2:d20b1ef35d3f | 539 | TFT.pixel(117, 53, Black); | 
| sinrab | 4:776f59129c24 | 540 | |
| sinrab | 0:ed1ba99f7b14 | 541 | TFT.locate(10, 85); | 
| sinrab | 2:d20b1ef35d3f | 542 | TFT.foreground(Green); | 
| sinrab | 3:791cf9a867d1 | 543 | TFT.printf("%04.0f", Ireal); // выводим значение с A1 (ток) | 
| sinrab | 0:ed1ba99f7b14 | 544 | |
| sinrab | 2:d20b1ef35d3f | 545 | |
| sinrab | 3:791cf9a867d1 | 546 | TFT.background(0x2104); // выводим мощность W | 
| sinrab | 2:d20b1ef35d3f | 547 | TFT.foreground(0xE71C);//текст | 
| sinrab | 0:ed1ba99f7b14 | 548 | TFT.set_font((unsigned char*) Lucida13x21); | 
| sinrab | 7:8410439dee73 | 549 | TFT.locate(7, 162); // TFT.locate(11, 162); | 
| sinrab | 7:8410439dee73 | 550 | if (Pcapbool) { | 
| sinrab | 7:8410439dee73 | 551 | //mah = mah + (U5 * Ireal / 3600); | 
| sinrab | 7:8410439dee73 | 552 | TFT.printf(" "); | 
| sinrab | 7:8410439dee73 | 553 | TFT.locate(7, 162); | 
| sinrab | 7:8410439dee73 | 554 | Pcapbool = false; | 
| sinrab | 7:8410439dee73 | 555 | if (Pcapbool2 == 1) { | 
| sinrab | 7:8410439dee73 | 556 | float temp = U30*Ireal/1000; | 
| sinrab | 7:8410439dee73 | 557 | if (temp < 0 ) temp = 0; | 
| sinrab | 7:8410439dee73 | 558 | TFT.printf("%3.2f W", temp); // мощность текущая ватт | 
| sinrab | 7:8410439dee73 | 559 | } else if (Pcapbool2 == 2){ | 
| sinrab | 7:8410439dee73 | 560 | TFT.printf("%4.0fmah", mah); // миллиампер час емкость 3.7 вольт | 
| sinrab | 7:8410439dee73 | 561 | } else { | 
| sinrab | 7:8410439dee73 | 562 | TFT.printf("%2.2f wh", wh); // ватт часы | 
| sinrab | 7:8410439dee73 | 563 | } | 
| sinrab | 7:8410439dee73 | 564 | } | 
| sinrab | 7:8410439dee73 | 565 | //TFT.printf("%05.2f W", U30*Ireal/1000); | 
| sinrab | 5:0b3c71d7e475 | 566 | //TFT.printf("%f", fanspeed*100); | 
| sinrab | 0:ed1ba99f7b14 | 567 | |
| sinrab | 4:776f59129c24 | 568 | TFT.background(0x2104); // выводим время включеной нагрузки | 
| sinrab | 2:d20b1ef35d3f | 569 | TFT.foreground(0xE71C);//текст | 
| sinrab | 0:ed1ba99f7b14 | 570 | TFT.set_font((unsigned char*) Lucida13x21); | 
| sinrab | 3:791cf9a867d1 | 571 | TFT.locate(7, 187); | 
| sinrab | 0:ed1ba99f7b14 | 572 | timeConvert(); | 
| sinrab | 0:ed1ba99f7b14 | 573 | TFT.printf("%02d:%02d:%02d", h, m, s); | 
| sinrab | 0:ed1ba99f7b14 | 574 | |
| sinrab | 0:ed1ba99f7b14 | 575 | |
| sinrab | 3:791cf9a867d1 | 576 | if (powerMosfet==0 & pb==0) { // выводим OFF | 
| sinrab | 3:791cf9a867d1 | 577 | TFT.background(Black); | 
| sinrab | 2:d20b1ef35d3f | 578 | TFT.foreground(0xA514); | 
| sinrab | 3:791cf9a867d1 | 579 | TFT.fillrect(215,161,312,231,Black); | 
| sinrab | 0:ed1ba99f7b14 | 580 | TFT.set_font((unsigned char*) Consolas26x49); | 
| sinrab | 3:791cf9a867d1 | 581 | TFT.locate(227, 174); | 
| sinrab | 0:ed1ba99f7b14 | 582 | TFT.printf("OFF"); | 
| sinrab | 0:ed1ba99f7b14 | 583 | pb=1; | 
| sinrab | 0:ed1ba99f7b14 | 584 | } | 
| sinrab | 3:791cf9a867d1 | 585 | if (powerMosfet==1 & pb==0) { // выводим ON | 
| sinrab | 3:791cf9a867d1 | 586 | TFT.background(color_back_on); | 
| sinrab | 3:791cf9a867d1 | 587 | TFT.foreground(color_text_on); | 
| sinrab | 3:791cf9a867d1 | 588 | TFT.fillrect(215,161,312,231,color_back_on); | 
| sinrab | 0:ed1ba99f7b14 | 589 | TFT.set_font((unsigned char*) Consolas26x49); | 
| sinrab | 3:791cf9a867d1 | 590 | TFT.locate(238, 174); | 
| sinrab | 0:ed1ba99f7b14 | 591 | TFT.printf("ON"); | 
| sinrab | 0:ed1ba99f7b14 | 592 | pb=1; | 
| sinrab | 0:ed1ba99f7b14 | 593 | } | 
| sinrab | 4:776f59129c24 | 594 | |
| sinrab | 4:776f59129c24 | 595 | int xscale1 = map(U30, 0, umax, 0, 298); | 
| sinrab | 2:d20b1ef35d3f | 596 | if (xscale1>297) xscale1=298; | 
| sinrab | 4:776f59129c24 | 597 | TFT.fillrect(11, 63, (xscale1+10), 75, color_scale1); //0x04C9 // аналоговая шкала Напряжение | 
| sinrab | 2:d20b1ef35d3f | 598 | TFT.fillrect((xscale1+12), 63, 308, 75, Black); | 
| sinrab | 4:776f59129c24 | 599 | |
| sinrab | 4:776f59129c24 | 600 | int xscale2 = map(Ireal, 0, imax*1000, 0, 298); | 
| sinrab | 2:d20b1ef35d3f | 601 | if (xscale2>297) xscale2=298; | 
| sinrab | 3:791cf9a867d1 | 602 | TFT.fillrect(11, 138, (xscale2+10), 150, color_scale2); //0x9A60 // аналоговая шкала Ток | 
| sinrab | 3:791cf9a867d1 | 603 | TFT.fillrect((xscale2+11), 138, 308, 150, Black); | 
| sinrab | 4:776f59129c24 | 604 | |
| sinrab | 3:791cf9a867d1 | 605 | //int zxc = int(Iset); | 
| sinrab | 3:791cf9a867d1 | 606 | //if (zxc>295) zxc=295; | 
| sinrab | 3:791cf9a867d1 | 607 | //if (zxc<0) zxc=0; | 
| sinrab | 3:791cf9a867d1 | 608 | //TFT.fillrect(11+zxc,138, 13+zxc, 150, Red); // шкала I set | 
| sinrab | 0:ed1ba99f7b14 | 609 | |
| sinrab | 5:0b3c71d7e475 | 610 | //fps.stop(); | 
| sinrab | 5:0b3c71d7e475 | 611 | //TFT.set_font((unsigned char*) Courier8x13); // FPS | 
| sinrab | 5:0b3c71d7e475 | 612 | //TFT.locate(169,81); | 
| sinrab | 5:0b3c71d7e475 | 613 | //printf("%0.2f", (1/fps.read())); | 
| sinrab | 4:776f59129c24 | 614 | |
| sinrab | 3:791cf9a867d1 | 615 | TFT.background(0x2104); | 
| sinrab | 3:791cf9a867d1 | 616 | TFT.foreground(White); | 
| sinrab | 4:776f59129c24 | 617 | TFT.set_font((unsigned char*) Lucida13x21); //выводим Температуру | 
| sinrab | 4:776f59129c24 | 618 | TFT.locate(11, 211); | 
| sinrab | 3:791cf9a867d1 | 619 | TFT.printf(" %d 'C ", temperature); | 
| sinrab | 4:776f59129c24 | 620 | |
| sinrab | 3:791cf9a867d1 | 621 | /* | 
| sinrab | 3:791cf9a867d1 | 622 | if (dinCC==1 & cc_one==1){ | 
| sinrab | 3:791cf9a867d1 | 623 | cc=1; | 
| sinrab | 3:791cf9a867d1 | 624 | pm=0; | 
| sinrab | 3:791cf9a867d1 | 625 | cc_one=0; | 
| sinrab | 3:791cf9a867d1 | 626 | } | 
| sinrab | 3:791cf9a867d1 | 627 | if (dinCC==0 & cc_one==0){ | 
| sinrab | 3:791cf9a867d1 | 628 | cc=0; | 
| sinrab | 3:791cf9a867d1 | 629 | pm=0; | 
| sinrab | 3:791cf9a867d1 | 630 | cc_one=1; | 
| sinrab | 3:791cf9a867d1 | 631 | } | 
| sinrab | 3:791cf9a867d1 | 632 | */ | 
| sinrab | 4:776f59129c24 | 633 | if(cc==1 & ccc==1) { // защелка для отображения сс сv | 
| sinrab | 3:791cf9a867d1 | 634 | pm=0; | 
| sinrab | 3:791cf9a867d1 | 635 | ccc=0; | 
| sinrab | 4:776f59129c24 | 636 | } | 
| sinrab | 4:776f59129c24 | 637 | if(cc==0 & ccc==0) { | 
| sinrab | 3:791cf9a867d1 | 638 | pm=0; | 
| sinrab | 3:791cf9a867d1 | 639 | ccc=1; | 
| sinrab | 4:776f59129c24 | 640 | } | 
| sinrab | 4:776f59129c24 | 641 | |
| sinrab | 4:776f59129c24 | 642 | if(cc==0 & pm==0) { // c.c | 
| sinrab | 2:d20b1ef35d3f | 643 | TFT.fillrect(240,10,304,53,Black);//c.v стереть | 
| sinrab | 2:d20b1ef35d3f | 644 | TFT.fillrect(240,85,304,128,0x6000);//c.c | 
| sinrab | 3:791cf9a867d1 | 645 | TFT.rect(240,85,304,128,0xC800); | 
| sinrab | 2:d20b1ef35d3f | 646 | TFT.background(0x6000); | 
| sinrab | 2:d20b1ef35d3f | 647 | TFT.foreground(Red); | 
| sinrab | 2:d20b1ef35d3f | 648 | TFT.set_font((unsigned char*) Consolas19x35); | 
| sinrab | 2:d20b1ef35d3f | 649 | TFT.locate(246, 89); | 
| sinrab | 2:d20b1ef35d3f | 650 | TFT.printf("C.C"); | 
| sinrab | 2:d20b1ef35d3f | 651 | pm=1; | 
| sinrab | 2:d20b1ef35d3f | 652 | } | 
| sinrab | 4:776f59129c24 | 653 | if(cc==1 & pm==0) { // c.v | 
| sinrab | 2:d20b1ef35d3f | 654 | TFT.fillrect(240,85,304,128,Black);//c.c стереть | 
| sinrab | 4:776f59129c24 | 655 | TFT.fillrect(240,10,304,53,0x0180);//c.v | 
| sinrab | 4:776f59129c24 | 656 | TFT.rect(240,10,304,53,0x04C0); | 
| sinrab | 2:d20b1ef35d3f | 657 | TFT.background(0x0180); | 
| sinrab | 2:d20b1ef35d3f | 658 | TFT.foreground(Green); | 
| sinrab | 2:d20b1ef35d3f | 659 | TFT.set_font((unsigned char*) Consolas19x35); | 
| sinrab | 2:d20b1ef35d3f | 660 | TFT.locate(246, 14); | 
| sinrab | 2:d20b1ef35d3f | 661 | TFT.printf("C.V"); | 
| sinrab | 2:d20b1ef35d3f | 662 | pm=1; | 
| sinrab | 2:d20b1ef35d3f | 663 | } | 
| sinrab | 0:ed1ba99f7b14 | 664 | |
| sinrab | 0:ed1ba99f7b14 | 665 | |
| sinrab | 0:ed1ba99f7b14 | 666 | } | 
| sinrab | 0:ed1ba99f7b14 | 667 | //------------------------------------------------------------------------------------------------------------ | 
| sinrab | 0:ed1ba99f7b14 | 668 | void drawScreen2(void) // экран 2 Data analo in, noise | 
| sinrab | 0:ed1ba99f7b14 | 669 | { | 
| sinrab | 0:ed1ba99f7b14 | 670 | if (complit==0) { | 
| sinrab | 0:ed1ba99f7b14 | 671 | TFT.background(back2); | 
| sinrab | 0:ed1ba99f7b14 | 672 | TFT.foreground(text2); | 
| sinrab | 0:ed1ba99f7b14 | 673 | TFT.cls(); | 
| sinrab | 0:ed1ba99f7b14 | 674 | complit = 1; // прорисовали! | 
| sinrab | 0:ed1ba99f7b14 | 675 | } | 
| sinrab | 0:ed1ba99f7b14 | 676 | |
| sinrab | 0:ed1ba99f7b14 | 677 | TFT.background(back2); | 
| sinrab | 0:ed1ba99f7b14 | 678 | TFT.foreground(text2); | 
| sinrab | 0:ed1ba99f7b14 | 679 | TFT.set_font((unsigned char*) Courier8x13); | 
| sinrab | 0:ed1ba99f7b14 | 680 | TFT.locate(0, 0); | 
| sinrab | 0:ed1ba99f7b14 | 681 | printf("--------- Data Analog In --------- \n"); | 
| sinrab | 4:776f59129c24 | 682 | printf("U.5 A0 noise= %0.1f, avg= %0.5f \n", noisea0, in0); | 
| sinrab | 4:776f59129c24 | 683 | printf("U= %06.4f \n coeff. k=%f, a=%f \n", U5, a0k, a0a); // A0 U real | 
| sinrab | 0:ed1ba99f7b14 | 684 | printf("---------------------------------- \n"); | 
| sinrab | 4:776f59129c24 | 685 | printf("I.real A1 noise= %0.1f, avg= %0.5f \n", noisea1, in1); | 
| sinrab | 4:776f59129c24 | 686 | printf("I= %06.2f \n coeff. k=%f, a=%f \n", Ireal, a1k, a1a); // A1 I real | 
| sinrab | 4:776f59129c24 | 687 | printf("---------------------------------- \n"); | 
| sinrab | 4:776f59129c24 | 688 | printf("U.30 A2 noise= %0.1f, avg= %0.5f \n", noisea2, in2); | 
| sinrab | 4:776f59129c24 | 689 | printf("U= %06.3f \n coeff. k=%f, a=%f \n", U30, a2k, a2a); // A2 U set | 
| sinrab | 4:776f59129c24 | 690 | printf("---------------------------------- \n"); | 
| sinrab | 4:776f59129c24 | 691 | printf("Temp A3 noise= %0.1f, avg= %0.5f \n", noisea3, in3); | 
| sinrab | 0:ed1ba99f7b14 | 692 | } | 
| sinrab | 0:ed1ba99f7b14 | 693 | //------------------------------------------------------------------------------------------------------------ | 
| sinrab | 1:7bc0f280c259 | 694 | void drawScreen3(void) // экран 3 установка часов | 
| sinrab | 0:ed1ba99f7b14 | 695 | { | 
| sinrab | 0:ed1ba99f7b14 | 696 | if (complit==0) { | 
| sinrab | 1:7bc0f280c259 | 697 | TFT.background(back5); | 
| sinrab | 1:7bc0f280c259 | 698 | TFT.foreground(text5); | 
| sinrab | 0:ed1ba99f7b14 | 699 | TFT.cls(); | 
| sinrab | 0:ed1ba99f7b14 | 700 | complit = 1; // прорисовали! | 
| sinrab | 0:ed1ba99f7b14 | 701 | } | 
| sinrab | 1:7bc0f280c259 | 702 | TFT.background(back5); | 
| sinrab | 1:7bc0f280c259 | 703 | TFT.foreground(text5); | 
| sinrab | 0:ed1ba99f7b14 | 704 | TFT.set_font((unsigned char*) Lucida13x21); | 
| sinrab | 1:7bc0f280c259 | 705 | char buffer[32]; | 
| sinrab | 1:7bc0f280c259 | 706 | seconds=time(NULL); | 
| sinrab | 1:7bc0f280c259 | 707 | strftime(buffer, 32, "%H:%M:%S %d.%m.%Y", localtime(&seconds)); | 
| sinrab | 1:7bc0f280c259 | 708 | TFT.locate (0,0); | 
| sinrab | 1:7bc0f280c259 | 709 | printf("------- Set Time --------\n"); | 
| sinrab | 1:7bc0f280c259 | 710 | TFT.background(back5_i); | 
| sinrab | 1:7bc0f280c259 | 711 | TFT.foreground(text5_i); | 
| sinrab | 1:7bc0f280c259 | 712 | TFT.locate (30,25); | 
| sinrab | 1:7bc0f280c259 | 713 | printf("%s", buffer); //вывод реального времени | 
| sinrab | 1:7bc0f280c259 | 714 | TFT.background(back5); | 
| sinrab | 1:7bc0f280c259 | 715 | TFT.foreground(text5); | 
| sinrab | 1:7bc0f280c259 | 716 | TFT.locate (28,86); | 
| sinrab | 1:7bc0f280c259 | 717 | printf("%02d:%02d:%02d %02d.%02d.%04d",hour, min, sec, day, mon, year); //вывод то что установим | 
| sinrab | 1:7bc0f280c259 | 718 | //-----------------------------------1 | 
| sinrab | 1:7bc0f280c259 | 719 | if (nline==1) { | 
| sinrab | 1:7bc0f280c259 | 720 | if (pmenu==1) { | 
| sinrab | 1:7bc0f280c259 | 721 | TFT.background(back5_iset); | 
| sinrab | 1:7bc0f280c259 | 722 | TFT.foreground(text5_i); | 
| sinrab | 1:7bc0f280c259 | 723 | } else { | 
| sinrab | 1:7bc0f280c259 | 724 | TFT.background(back5_i); | 
| sinrab | 1:7bc0f280c259 | 725 | TFT.foreground(text5_i); | 
| sinrab | 1:7bc0f280c259 | 726 | } | 
| sinrab | 1:7bc0f280c259 | 727 | TFT.locate(28,64); | 
| sinrab | 1:7bc0f280c259 | 728 | printf(" "); | 
| sinrab | 1:7bc0f280c259 | 729 | } else { | 
| sinrab | 1:7bc0f280c259 | 730 | TFT.locate(28,64); | 
| sinrab | 1:7bc0f280c259 | 731 | TFT.background(back5); | 
| sinrab | 1:7bc0f280c259 | 732 | TFT.foreground(back5); | 
| sinrab | 1:7bc0f280c259 | 733 | printf(" "); | 
| sinrab | 1:7bc0f280c259 | 734 | } | 
| sinrab | 1:7bc0f280c259 | 735 | //-----------------------------------2 | 
| sinrab | 1:7bc0f280c259 | 736 | if (nline==2) { | 
| sinrab | 1:7bc0f280c259 | 737 | if (pmenu==1) { | 
| sinrab | 1:7bc0f280c259 | 738 | TFT.background(back5_iset); | 
| sinrab | 1:7bc0f280c259 | 739 | TFT.foreground(text5_i); | 
| sinrab | 1:7bc0f280c259 | 740 | } else { | 
| sinrab | 1:7bc0f280c259 | 741 | TFT.background(back5_i); | 
| sinrab | 1:7bc0f280c259 | 742 | TFT.foreground(text5_i); | 
| sinrab | 1:7bc0f280c259 | 743 | } | 
| sinrab | 1:7bc0f280c259 | 744 | TFT.locate(64,64); | 
| sinrab | 1:7bc0f280c259 | 745 | printf(" "); | 
| sinrab | 1:7bc0f280c259 | 746 | } else { | 
| sinrab | 1:7bc0f280c259 | 747 | TFT.locate(64,64); | 
| sinrab | 1:7bc0f280c259 | 748 | TFT.background(back5); | 
| sinrab | 1:7bc0f280c259 | 749 | TFT.foreground(back5); | 
| sinrab | 1:7bc0f280c259 | 750 | printf(" "); | 
| sinrab | 1:7bc0f280c259 | 751 | } | 
| sinrab | 1:7bc0f280c259 | 752 | //-----------------------------------3 | 
| sinrab | 1:7bc0f280c259 | 753 | if (nline==3) { | 
| sinrab | 1:7bc0f280c259 | 754 | if (pmenu==1) { | 
| sinrab | 1:7bc0f280c259 | 755 | TFT.background(back5_iset); | 
| sinrab | 1:7bc0f280c259 | 756 | TFT.foreground(text5_i); | 
| sinrab | 1:7bc0f280c259 | 757 | } else { | 
| sinrab | 1:7bc0f280c259 | 758 | TFT.background(back5_i); | 
| sinrab | 1:7bc0f280c259 | 759 | TFT.foreground(text5_i); | 
| sinrab | 1:7bc0f280c259 | 760 | } | 
| sinrab | 1:7bc0f280c259 | 761 | TFT.locate(100,64); | 
| sinrab | 1:7bc0f280c259 | 762 | printf(" "); | 
| sinrab | 1:7bc0f280c259 | 763 | } else { | 
| sinrab | 1:7bc0f280c259 | 764 | TFT.locate(100,64); | 
| sinrab | 1:7bc0f280c259 | 765 | TFT.background(back5); | 
| sinrab | 1:7bc0f280c259 | 766 | TFT.foreground(back5); | 
| sinrab | 1:7bc0f280c259 | 767 | printf(" "); | 
| sinrab | 1:7bc0f280c259 | 768 | } | 
| sinrab | 1:7bc0f280c259 | 769 | //-----------------------------------4 | 
| sinrab | 1:7bc0f280c259 | 770 | if (nline==4) { | 
| sinrab | 1:7bc0f280c259 | 771 | if (pmenu==1) { | 
| sinrab | 1:7bc0f280c259 | 772 | TFT.background(back5_iset); | 
| sinrab | 1:7bc0f280c259 | 773 | TFT.foreground(text5_i); | 
| sinrab | 1:7bc0f280c259 | 774 | } else { | 
| sinrab | 1:7bc0f280c259 | 775 | TFT.background(back5_i); | 
| sinrab | 1:7bc0f280c259 | 776 | TFT.foreground(text5_i); | 
| sinrab | 1:7bc0f280c259 | 777 | } | 
| sinrab | 1:7bc0f280c259 | 778 | TFT.locate(135,64); | 
| sinrab | 1:7bc0f280c259 | 779 | printf(" "); | 
| sinrab | 1:7bc0f280c259 | 780 | } else { | 
| sinrab | 1:7bc0f280c259 | 781 | TFT.locate(135,64); | 
| sinrab | 1:7bc0f280c259 | 782 | TFT.background(back5); | 
| sinrab | 1:7bc0f280c259 | 783 | TFT.foreground(back5); | 
| sinrab | 1:7bc0f280c259 | 784 | printf(" "); | 
| sinrab | 1:7bc0f280c259 | 785 | } | 
| sinrab | 1:7bc0f280c259 | 786 | //-----------------------------------5 | 
| sinrab | 1:7bc0f280c259 | 787 | if (nline==5) { | 
| sinrab | 1:7bc0f280c259 | 788 | if (pmenu==1) { | 
| sinrab | 1:7bc0f280c259 | 789 | TFT.background(back5_iset); | 
| sinrab | 1:7bc0f280c259 | 790 | TFT.foreground(text5_i); | 
| sinrab | 1:7bc0f280c259 | 791 | } else { | 
| sinrab | 1:7bc0f280c259 | 792 | TFT.background(back5_i); | 
| sinrab | 1:7bc0f280c259 | 793 | TFT.foreground(text5_i); | 
| sinrab | 1:7bc0f280c259 | 794 | } | 
| sinrab | 1:7bc0f280c259 | 795 | TFT.locate(170,64); | 
| sinrab | 1:7bc0f280c259 | 796 | printf(" "); | 
| sinrab | 1:7bc0f280c259 | 797 | } else { | 
| sinrab | 1:7bc0f280c259 | 798 | TFT.locate(170,64); | 
| sinrab | 1:7bc0f280c259 | 799 | TFT.background(back5); | 
| sinrab | 1:7bc0f280c259 | 800 | TFT.foreground(back5); | 
| sinrab | 1:7bc0f280c259 | 801 | printf(" "); | 
| sinrab | 1:7bc0f280c259 | 802 | } | 
| sinrab | 1:7bc0f280c259 | 803 | //-----------------------------------6 | 
| sinrab | 1:7bc0f280c259 | 804 | if (nline==6) { | 
| sinrab | 1:7bc0f280c259 | 805 | if (pmenu==1) { | 
| sinrab | 1:7bc0f280c259 | 806 | TFT.background(back5_iset); | 
| sinrab | 1:7bc0f280c259 | 807 | TFT.foreground(text5_i); | 
| sinrab | 1:7bc0f280c259 | 808 | } else { | 
| sinrab | 1:7bc0f280c259 | 809 | TFT.background(back5_i); | 
| sinrab | 1:7bc0f280c259 | 810 | TFT.foreground(text5_i); | 
| sinrab | 1:7bc0f280c259 | 811 | } | 
| sinrab | 1:7bc0f280c259 | 812 | TFT.locate(205,64); | 
| sinrab | 1:7bc0f280c259 | 813 | printf(" "); | 
| sinrab | 1:7bc0f280c259 | 814 | } else { | 
| sinrab | 1:7bc0f280c259 | 815 | TFT.locate(205,64); | 
| sinrab | 1:7bc0f280c259 | 816 | TFT.background(back5); | 
| sinrab | 1:7bc0f280c259 | 817 | TFT.foreground(back5); | 
| sinrab | 1:7bc0f280c259 | 818 | printf(" "); | 
| sinrab | 1:7bc0f280c259 | 819 | } | 
| sinrab | 1:7bc0f280c259 | 820 | //-----------------------------------7 | 
| sinrab | 1:7bc0f280c259 | 821 | if (nline==7) { | 
| sinrab | 1:7bc0f280c259 | 822 | if (pmenu==1) { | 
| sinrab | 1:7bc0f280c259 | 823 | TFT.background(back5_iset); | 
| sinrab | 1:7bc0f280c259 | 824 | TFT.foreground(text5_i); | 
| sinrab | 1:7bc0f280c259 | 825 | } else { | 
| sinrab | 1:7bc0f280c259 | 826 | TFT.background(back5_i); | 
| sinrab | 1:7bc0f280c259 | 827 | TFT.foreground(text5_i); | 
| sinrab | 1:7bc0f280c259 | 828 | } | 
| sinrab | 1:7bc0f280c259 | 829 | TFT.locate(30,120); | 
| sinrab | 1:7bc0f280c259 | 830 | printf("Set!"); | 
| sinrab | 1:7bc0f280c259 | 831 | } else { | 
| sinrab | 1:7bc0f280c259 | 832 | TFT.locate(30,120); | 
| sinrab | 1:7bc0f280c259 | 833 | TFT.background(back5); | 
| sinrab | 1:7bc0f280c259 | 834 | TFT.foreground(text5); | 
| sinrab | 1:7bc0f280c259 | 835 | printf("Set!"); | 
| sinrab | 1:7bc0f280c259 | 836 | } | 
| sinrab | 1:7bc0f280c259 | 837 | //----------------------------------- | 
| sinrab | 1:7bc0f280c259 | 838 | //-----------------------------------7 | 
| sinrab | 1:7bc0f280c259 | 839 | if (nline==8) { | 
| sinrab | 1:7bc0f280c259 | 840 | if (pmenu==1) { | 
| sinrab | 1:7bc0f280c259 | 841 | TFT.background(back5_iset); | 
| sinrab | 1:7bc0f280c259 | 842 | TFT.foreground(text5_i); | 
| sinrab | 1:7bc0f280c259 | 843 | } else { | 
| sinrab | 1:7bc0f280c259 | 844 | TFT.background(0xFB2C); | 
| sinrab | 1:7bc0f280c259 | 845 | TFT.foreground(text5_i); | 
| sinrab | 1:7bc0f280c259 | 846 | } | 
| sinrab | 1:7bc0f280c259 | 847 | TFT.locate(30,170); | 
| sinrab | 1:7bc0f280c259 | 848 | printf("Exit"); | 
| sinrab | 1:7bc0f280c259 | 849 | } else { | 
| sinrab | 1:7bc0f280c259 | 850 | TFT.locate(30,170); | 
| sinrab | 1:7bc0f280c259 | 851 | TFT.background(back5); | 
| sinrab | 1:7bc0f280c259 | 852 | TFT.foreground(text5); | 
| sinrab | 1:7bc0f280c259 | 853 | printf("Exit"); | 
| sinrab | 1:7bc0f280c259 | 854 | } | 
| sinrab | 1:7bc0f280c259 | 855 | //----------------------------------- | 
| sinrab | 1:7bc0f280c259 | 856 | |
| sinrab | 0:ed1ba99f7b14 | 857 | } | 
| sinrab | 0:ed1ba99f7b14 | 858 | //------------------------------------------------------------------------------------------------------------ | 
| sinrab | 0:ed1ba99f7b14 | 859 | void drawScreen4(void) // экран 4 калибровка | 
| sinrab | 0:ed1ba99f7b14 | 860 | { | 
| sinrab | 0:ed1ba99f7b14 | 861 | if (complit==0) { | 
| sinrab | 0:ed1ba99f7b14 | 862 | TFT.background(back4); | 
| sinrab | 0:ed1ba99f7b14 | 863 | TFT.foreground(text4); | 
| sinrab | 0:ed1ba99f7b14 | 864 | TFT.cls(); | 
| sinrab | 0:ed1ba99f7b14 | 865 | complit = 1; // прорисовали! | 
| sinrab | 0:ed1ba99f7b14 | 866 | } | 
| sinrab | 0:ed1ba99f7b14 | 867 | //---------------------------------------------------------------- text4 back4 text4_i back4_i | 
| sinrab | 0:ed1ba99f7b14 | 868 | TFT.background(back4); | 
| sinrab | 0:ed1ba99f7b14 | 869 | TFT.foreground(text4); | 
| sinrab | 0:ed1ba99f7b14 | 870 | TFT.locate(0, 0); | 
| sinrab | 0:ed1ba99f7b14 | 871 | TFT.set_font((unsigned char*) Courier8x13); | 
| sinrab | 0:ed1ba99f7b14 | 872 | printf(" Calibration. Enter - set. \n"); | 
| sinrab | 0:ed1ba99f7b14 | 873 | printf("--------------------------- \n"); | 
| sinrab | 0:ed1ba99f7b14 | 874 | //---------------------------------------------------------------- | 
| sinrab | 0:ed1ba99f7b14 | 875 | if (kline==1) { | 
| sinrab | 0:ed1ba99f7b14 | 876 | TFT.background(back4_i); | 
| sinrab | 0:ed1ba99f7b14 | 877 | TFT.foreground(text4_i); | 
| sinrab | 0:ed1ba99f7b14 | 878 | } else { | 
| sinrab | 0:ed1ba99f7b14 | 879 | TFT.background(back4); | 
| sinrab | 0:ed1ba99f7b14 | 880 | TFT.foreground(text4); | 
| sinrab | 0:ed1ba99f7b14 | 881 | } | 
| sinrab | 3:791cf9a867d1 | 882 | printf(" U 5v = %06.3f set zero \n", U5); // U real A0 zero | 
| sinrab | 0:ed1ba99f7b14 | 883 | //---------------------------------------------------------------- | 
| sinrab | 0:ed1ba99f7b14 | 884 | if (kline==2) { | 
| sinrab | 0:ed1ba99f7b14 | 885 | TFT.background(back4_i); | 
| sinrab | 0:ed1ba99f7b14 | 886 | TFT.foreground(text4_i); | 
| sinrab | 0:ed1ba99f7b14 | 887 | } else { | 
| sinrab | 0:ed1ba99f7b14 | 888 | TFT.background(back4); | 
| sinrab | 0:ed1ba99f7b14 | 889 | TFT.foreground(text4); | 
| sinrab | 0:ed1ba99f7b14 | 890 | } | 
| sinrab | 4:776f59129c24 | 891 | printf(" U 5v = %06.3f set up \n", U5); // U real A0 hi | 
| sinrab | 0:ed1ba99f7b14 | 892 | //---------------------------------------------------------------- | 
| sinrab | 0:ed1ba99f7b14 | 893 | if (kline==3) { | 
| sinrab | 0:ed1ba99f7b14 | 894 | TFT.background(back4_i); | 
| sinrab | 0:ed1ba99f7b14 | 895 | TFT.foreground(text4_i); | 
| sinrab | 0:ed1ba99f7b14 | 896 | } else { | 
| sinrab | 0:ed1ba99f7b14 | 897 | TFT.background(back4); | 
| sinrab | 0:ed1ba99f7b14 | 898 | TFT.foreground(text4); | 
| sinrab | 0:ed1ba99f7b14 | 899 | } | 
| sinrab | 4:776f59129c24 | 900 | printf(" I real = %06.1f set zero \n", Ireal); // I real A1 zero | 
| sinrab | 0:ed1ba99f7b14 | 901 | //---------------------------------------------------------------- | 
| sinrab | 0:ed1ba99f7b14 | 902 | if (kline==4) { | 
| sinrab | 0:ed1ba99f7b14 | 903 | TFT.background(back4_i); | 
| sinrab | 0:ed1ba99f7b14 | 904 | TFT.foreground(text4_i); | 
| sinrab | 0:ed1ba99f7b14 | 905 | } else { | 
| sinrab | 0:ed1ba99f7b14 | 906 | TFT.background(back4); | 
| sinrab | 0:ed1ba99f7b14 | 907 | TFT.foreground(text4); | 
| sinrab | 0:ed1ba99f7b14 | 908 | } | 
| sinrab | 4:776f59129c24 | 909 | printf(" I real = %06.1f set up \n", Ireal); // I real A1 hi | 
| sinrab | 0:ed1ba99f7b14 | 910 | //---------------------------------------------------------------- | 
| sinrab | 0:ed1ba99f7b14 | 911 | if (kline==5) { | 
| sinrab | 0:ed1ba99f7b14 | 912 | TFT.background(back4_i); | 
| sinrab | 0:ed1ba99f7b14 | 913 | TFT.foreground(text4_i); | 
| sinrab | 0:ed1ba99f7b14 | 914 | } else { | 
| sinrab | 0:ed1ba99f7b14 | 915 | TFT.background(back4); | 
| sinrab | 0:ed1ba99f7b14 | 916 | TFT.foreground(text4); | 
| sinrab | 0:ed1ba99f7b14 | 917 | } | 
| sinrab | 4:776f59129c24 | 918 | printf(" U high v = %06.3f set zero\n", U30); // U set A2 zero | 
| sinrab | 0:ed1ba99f7b14 | 919 | //---------------------------------------------------------------- | 
| sinrab | 0:ed1ba99f7b14 | 920 | if (kline==6) { | 
| sinrab | 0:ed1ba99f7b14 | 921 | TFT.background(back4_i); | 
| sinrab | 0:ed1ba99f7b14 | 922 | TFT.foreground(text4_i); | 
| sinrab | 0:ed1ba99f7b14 | 923 | } else { | 
| sinrab | 0:ed1ba99f7b14 | 924 | TFT.background(back4); | 
| sinrab | 0:ed1ba99f7b14 | 925 | TFT.foreground(text4); | 
| sinrab | 0:ed1ba99f7b14 | 926 | } | 
| sinrab | 4:776f59129c24 | 927 | printf(" U high v = %06.3f set up \n", U30); // U set A2 hi | 
| sinrab | 0:ed1ba99f7b14 | 928 | //---------------------------------------------------------------- | 
| sinrab | 0:ed1ba99f7b14 | 929 | if (kline==7) { | 
| sinrab | 0:ed1ba99f7b14 | 930 | TFT.background(back4_i); | 
| sinrab | 0:ed1ba99f7b14 | 931 | TFT.foreground(text4_i); | 
| sinrab | 0:ed1ba99f7b14 | 932 | } else { | 
| sinrab | 0:ed1ba99f7b14 | 933 | TFT.background(back4); | 
| sinrab | 0:ed1ba99f7b14 | 934 | TFT.foreground(text4); | 
| sinrab | 0:ed1ba99f7b14 | 935 | } | 
| sinrab | 4:776f59129c24 | 936 | printf(" -\n"); // I set A3 zero | 
| sinrab | 0:ed1ba99f7b14 | 937 | //---------------------------------------------------------------- | 
| sinrab | 0:ed1ba99f7b14 | 938 | if (kline==8) { | 
| sinrab | 0:ed1ba99f7b14 | 939 | TFT.background(back4_i); | 
| sinrab | 0:ed1ba99f7b14 | 940 | TFT.foreground(text4_i); | 
| sinrab | 0:ed1ba99f7b14 | 941 | } else { | 
| sinrab | 0:ed1ba99f7b14 | 942 | TFT.background(back4); | 
| sinrab | 0:ed1ba99f7b14 | 943 | TFT.foreground(text4); | 
| sinrab | 0:ed1ba99f7b14 | 944 | } | 
| sinrab | 4:776f59129c24 | 945 | printf(" -\n"); // I set A3 hi | 
| sinrab | 0:ed1ba99f7b14 | 946 | //---------------------------------------------------------------- | 
| sinrab | 0:ed1ba99f7b14 | 947 | if (kline==9) { | 
| sinrab | 0:ed1ba99f7b14 | 948 | TFT.background(back4_i); | 
| sinrab | 0:ed1ba99f7b14 | 949 | TFT.foreground(text4_i); | 
| sinrab | 0:ed1ba99f7b14 | 950 | } else { | 
| sinrab | 0:ed1ba99f7b14 | 951 | TFT.background(back4); | 
| sinrab | 0:ed1ba99f7b14 | 952 | TFT.foreground(text4); | 
| sinrab | 0:ed1ba99f7b14 | 953 | } | 
| sinrab | 4:776f59129c24 | 954 | printf(" -\n"); // U usb A4 zero | 
| sinrab | 0:ed1ba99f7b14 | 955 | //---------------------------------------------------------------- | 
| sinrab | 0:ed1ba99f7b14 | 956 | if (kline==10) { | 
| sinrab | 0:ed1ba99f7b14 | 957 | TFT.background(back4_i); | 
| sinrab | 0:ed1ba99f7b14 | 958 | TFT.foreground(text4_i); | 
| sinrab | 0:ed1ba99f7b14 | 959 | } else { | 
| sinrab | 0:ed1ba99f7b14 | 960 | TFT.background(back4); | 
| sinrab | 0:ed1ba99f7b14 | 961 | TFT.foreground(text4); | 
| sinrab | 0:ed1ba99f7b14 | 962 | } | 
| sinrab | 5:0b3c71d7e475 | 963 | printf(" -.\n"); // U usb A4 hi | 
| sinrab | 0:ed1ba99f7b14 | 964 | //---------------------------------------------------------------- | 
| sinrab | 0:ed1ba99f7b14 | 965 | if (kline==11) { | 
| sinrab | 0:ed1ba99f7b14 | 966 | TFT.background(back4_i); | 
| sinrab | 0:ed1ba99f7b14 | 967 | TFT.foreground(text4_i); | 
| sinrab | 0:ed1ba99f7b14 | 968 | } else { | 
| sinrab | 0:ed1ba99f7b14 | 969 | TFT.background(back4); | 
| sinrab | 0:ed1ba99f7b14 | 970 | TFT.foreground(text4); | 
| sinrab | 0:ed1ba99f7b14 | 971 | } | 
| sinrab | 5:0b3c71d7e475 | 972 | printf(" -,\n"); // I usb A5 zero | 
| sinrab | 0:ed1ba99f7b14 | 973 | //---------------------------------------------------------------- | 
| sinrab | 0:ed1ba99f7b14 | 974 | if (kline==12) { | 
| sinrab | 0:ed1ba99f7b14 | 975 | TFT.background(back4_i); | 
| sinrab | 0:ed1ba99f7b14 | 976 | TFT.foreground(text4_i); | 
| sinrab | 0:ed1ba99f7b14 | 977 | } else { | 
| sinrab | 0:ed1ba99f7b14 | 978 | TFT.background(back4); | 
| sinrab | 0:ed1ba99f7b14 | 979 | TFT.foreground(text4); | 
| sinrab | 0:ed1ba99f7b14 | 980 | } | 
| sinrab | 4:776f59129c24 | 981 | printf(" -\n"); // I usb A5 hi | 
| sinrab | 0:ed1ba99f7b14 | 982 | //---------------------------------------------------------------- | 
| sinrab | 0:ed1ba99f7b14 | 983 | if (kline==13) { | 
| sinrab | 0:ed1ba99f7b14 | 984 | TFT.background(back4_i); | 
| sinrab | 0:ed1ba99f7b14 | 985 | TFT.foreground(text4_i); | 
| sinrab | 0:ed1ba99f7b14 | 986 | } else { | 
| sinrab | 0:ed1ba99f7b14 | 987 | TFT.background(back4); | 
| sinrab | 0:ed1ba99f7b14 | 988 | TFT.foreground(text4); | 
| sinrab | 0:ed1ba99f7b14 | 989 | } | 
| sinrab | 5:0b3c71d7e475 | 990 | //printf(" Load Default \n"); | 
| sinrab | 5:0b3c71d7e475 | 991 | printf(" Load Default calibration \n"); | 
| sinrab | 0:ed1ba99f7b14 | 992 | //---------------------------------------------------------------- | 
| sinrab | 0:ed1ba99f7b14 | 993 | if (kline==14) { | 
| sinrab | 0:ed1ba99f7b14 | 994 | TFT.background(back4_i); | 
| sinrab | 0:ed1ba99f7b14 | 995 | TFT.foreground(text4_i); | 
| sinrab | 0:ed1ba99f7b14 | 996 | } else { | 
| sinrab | 0:ed1ba99f7b14 | 997 | TFT.background(back4); | 
| sinrab | 0:ed1ba99f7b14 | 998 | TFT.foreground(text4); | 
| sinrab | 0:ed1ba99f7b14 | 999 | } | 
| sinrab | 5:0b3c71d7e475 | 1000 | //printf(" Save all to flash memory \n"); | 
| sinrab | 5:0b3c71d7e475 | 1001 | printf(" Save calibration to flash memory\n"); | 
| sinrab | 0:ed1ba99f7b14 | 1002 | //---------------------------------------------------------------- | 
| sinrab | 0:ed1ba99f7b14 | 1003 | if (kline==15) { | 
| sinrab | 0:ed1ba99f7b14 | 1004 | TFT.background(back4_i); | 
| sinrab | 0:ed1ba99f7b14 | 1005 | TFT.foreground(text4_i); | 
| sinrab | 0:ed1ba99f7b14 | 1006 | } else { | 
| sinrab | 0:ed1ba99f7b14 | 1007 | TFT.background(back4); | 
| sinrab | 0:ed1ba99f7b14 | 1008 | TFT.foreground(text4); | 
| sinrab | 0:ed1ba99f7b14 | 1009 | } | 
| sinrab | 0:ed1ba99f7b14 | 1010 | printf(" Exit \n"); | 
| sinrab | 0:ed1ba99f7b14 | 1011 | //---------------------------------------------------------------- | 
| sinrab | 0:ed1ba99f7b14 | 1012 | TFT.background(back4); | 
| sinrab | 0:ed1ba99f7b14 | 1013 | TFT.foreground(text4); | 
| sinrab | 0:ed1ba99f7b14 | 1014 | printf("--------------------------- \n"); | 
| sinrab | 0:ed1ba99f7b14 | 1015 | |
| sinrab | 0:ed1ba99f7b14 | 1016 | |
| sinrab | 0:ed1ba99f7b14 | 1017 | } | 
| sinrab | 0:ed1ba99f7b14 | 1018 | //------------------------------------------------------------------------------------------------------------ | 
| sinrab | 0:ed1ba99f7b14 | 1019 | void drawScreen5(void) //экран 5 Настройки главная | 
| sinrab | 0:ed1ba99f7b14 | 1020 | { | 
| sinrab | 0:ed1ba99f7b14 | 1021 | if (complit==0) { | 
| sinrab | 0:ed1ba99f7b14 | 1022 | TFT.background(back5); | 
| sinrab | 0:ed1ba99f7b14 | 1023 | TFT.foreground(text5); | 
| sinrab | 0:ed1ba99f7b14 | 1024 | TFT.cls(); | 
| sinrab | 0:ed1ba99f7b14 | 1025 | complit = 1; // прорисовали! | 
| sinrab | 0:ed1ba99f7b14 | 1026 | } | 
| sinrab | 0:ed1ba99f7b14 | 1027 | |
| sinrab | 0:ed1ba99f7b14 | 1028 | //---------------------------------------------------------------- | 
| sinrab | 0:ed1ba99f7b14 | 1029 | TFT.background(back5); | 
| sinrab | 0:ed1ba99f7b14 | 1030 | TFT.foreground(text5); | 
| sinrab | 0:ed1ba99f7b14 | 1031 | TFT.locate(0, 0); | 
| sinrab | 0:ed1ba99f7b14 | 1032 | TFT.set_font((unsigned char*) Courier8x13); | 
| sinrab | 3:791cf9a867d1 | 1033 | printf(" Settings \n"); | 
| sinrab | 3:791cf9a867d1 | 1034 | printf("--------------------------------------- \n"); | 
| sinrab | 0:ed1ba99f7b14 | 1035 | //---------------------------------------------------------------- | 
| sinrab | 0:ed1ba99f7b14 | 1036 | if (mline==1) { | 
| sinrab | 0:ed1ba99f7b14 | 1037 | TFT.background(back5_i); | 
| sinrab | 0:ed1ba99f7b14 | 1038 | TFT.foreground(text5_i); | 
| sinrab | 0:ed1ba99f7b14 | 1039 | } else { | 
| sinrab | 0:ed1ba99f7b14 | 1040 | TFT.background(back5); | 
| sinrab | 0:ed1ba99f7b14 | 1041 | TFT.foreground(text5); | 
| sinrab | 0:ed1ba99f7b14 | 1042 | } | 
| sinrab | 3:791cf9a867d1 | 1043 | printf(" Set Time \n"); // 1 | 
| sinrab | 0:ed1ba99f7b14 | 1044 | //---------------------------------------------------------------- | 
| sinrab | 0:ed1ba99f7b14 | 1045 | if (mline==2) { | 
| sinrab | 0:ed1ba99f7b14 | 1046 | if (pmenu==1) { | 
| sinrab | 0:ed1ba99f7b14 | 1047 | TFT.background(back5_iset); | 
| sinrab | 0:ed1ba99f7b14 | 1048 | TFT.foreground(text5_i); | 
| sinrab | 0:ed1ba99f7b14 | 1049 | } else { | 
| sinrab | 0:ed1ba99f7b14 | 1050 | TFT.background(back5_i); | 
| sinrab | 0:ed1ba99f7b14 | 1051 | TFT.foreground(text5_i); | 
| sinrab | 0:ed1ba99f7b14 | 1052 | } | 
| sinrab | 0:ed1ba99f7b14 | 1053 | } else { | 
| sinrab | 0:ed1ba99f7b14 | 1054 | TFT.background(back5); | 
| sinrab | 0:ed1ba99f7b14 | 1055 | TFT.foreground(text5); | 
| sinrab | 0:ed1ba99f7b14 | 1056 | } | 
| sinrab | 4:776f59129c24 | 1057 | printf(" Backlight brightness = %03.0f \n", brightness*100); // 1 | 
| sinrab | 0:ed1ba99f7b14 | 1058 | //------------------------------------*--------------------------- | 
| sinrab | 0:ed1ba99f7b14 | 1059 | if (mline==3) { | 
| sinrab | 4:776f59129c24 | 1060 | if (pmenu==1) { | 
| sinrab | 4:776f59129c24 | 1061 | TFT.background(back5_iset); | 
| sinrab | 4:776f59129c24 | 1062 | TFT.foreground(text5_i); | 
| sinrab | 4:776f59129c24 | 1063 | } else { | 
| sinrab | 4:776f59129c24 | 1064 | TFT.background(back5_i); | 
| sinrab | 4:776f59129c24 | 1065 | TFT.foreground(text5_i); | 
| sinrab | 4:776f59129c24 | 1066 | } | 
| sinrab | 0:ed1ba99f7b14 | 1067 | } else { | 
| sinrab | 0:ed1ba99f7b14 | 1068 | TFT.background(back5); | 
| sinrab | 0:ed1ba99f7b14 | 1069 | TFT.foreground(text5); | 
| sinrab | 0:ed1ba99f7b14 | 1070 | } | 
| sinrab | 4:776f59129c24 | 1071 | if (beeper==1) { | 
| sinrab | 4:776f59129c24 | 1072 | printf(" Sound beep %s \n", ron); | 
| sinrab | 4:776f59129c24 | 1073 | } else { | 
| sinrab | 4:776f59129c24 | 1074 | printf(" Sound beep %s \n", roff); | 
| sinrab | 4:776f59129c24 | 1075 | } | 
| sinrab | 0:ed1ba99f7b14 | 1076 | //------------------------------------*--------------------------- | 
| sinrab | 0:ed1ba99f7b14 | 1077 | if (mline==4) { | 
| sinrab | 3:791cf9a867d1 | 1078 | if (pmenu==1) { | 
| sinrab | 3:791cf9a867d1 | 1079 | TFT.background(back5_iset); | 
| sinrab | 3:791cf9a867d1 | 1080 | TFT.foreground(text5_i); | 
| sinrab | 3:791cf9a867d1 | 1081 | } else { | 
| sinrab | 3:791cf9a867d1 | 1082 | TFT.background(back5_i); | 
| sinrab | 3:791cf9a867d1 | 1083 | TFT.foreground(text5_i); | 
| sinrab | 3:791cf9a867d1 | 1084 | } | 
| sinrab | 0:ed1ba99f7b14 | 1085 | } else { | 
| sinrab | 0:ed1ba99f7b14 | 1086 | TFT.background(back5); | 
| sinrab | 0:ed1ba99f7b14 | 1087 | TFT.foreground(text5); | 
| sinrab | 0:ed1ba99f7b14 | 1088 | } | 
| sinrab | 4:776f59129c24 | 1089 | printf(" Fan start - t %02d 'c \n", tempstart); // 1 tempstart | 
| sinrab | 0:ed1ba99f7b14 | 1090 | //------------------------------------*--------------------------- | 
| sinrab | 0:ed1ba99f7b14 | 1091 | if (mline==5) { | 
| sinrab | 3:791cf9a867d1 | 1092 | if (pmenu==1) { | 
| sinrab | 3:791cf9a867d1 | 1093 | TFT.background(back5_iset); | 
| sinrab | 3:791cf9a867d1 | 1094 | TFT.foreground(text5_i); | 
| sinrab | 3:791cf9a867d1 | 1095 | } else { | 
| sinrab | 3:791cf9a867d1 | 1096 | TFT.background(back5_i); | 
| sinrab | 3:791cf9a867d1 | 1097 | TFT.foreground(text5_i); | 
| sinrab | 3:791cf9a867d1 | 1098 | } | 
| sinrab | 0:ed1ba99f7b14 | 1099 | } else { | 
| sinrab | 0:ed1ba99f7b14 | 1100 | TFT.background(back5); | 
| sinrab | 0:ed1ba99f7b14 | 1101 | TFT.foreground(text5); | 
| sinrab | 0:ed1ba99f7b14 | 1102 | } | 
| sinrab | 4:776f59129c24 | 1103 | printf(" Fan full speed - t %02d 'c \n", tempfull); // 1 tempfull | 
| sinrab | 0:ed1ba99f7b14 | 1104 | //------------------------------------*--------------------------- | 
| sinrab | 0:ed1ba99f7b14 | 1105 | if (mline==6) { | 
| sinrab | 3:791cf9a867d1 | 1106 | if (pmenu==1) { | 
| sinrab | 3:791cf9a867d1 | 1107 | TFT.background(back5_iset); | 
| sinrab | 3:791cf9a867d1 | 1108 | TFT.foreground(text5_i); | 
| sinrab | 3:791cf9a867d1 | 1109 | } else { | 
| sinrab | 3:791cf9a867d1 | 1110 | TFT.background(back5_i); | 
| sinrab | 3:791cf9a867d1 | 1111 | TFT.foreground(text5_i); | 
| sinrab | 3:791cf9a867d1 | 1112 | } | 
| sinrab | 0:ed1ba99f7b14 | 1113 | } else { | 
| sinrab | 0:ed1ba99f7b14 | 1114 | TFT.background(back5); | 
| sinrab | 0:ed1ba99f7b14 | 1115 | TFT.foreground(text5); | 
| sinrab | 0:ed1ba99f7b14 | 1116 | } | 
| sinrab | 4:776f59129c24 | 1117 | printf(" Power cut off - t %02d 'c \n", tempcutoff); // 1 tempcutoff | 
| sinrab | 0:ed1ba99f7b14 | 1118 | //------------------------------------*--------------------------- | 
| sinrab | 0:ed1ba99f7b14 | 1119 | if (mline==7) { | 
| sinrab | 3:791cf9a867d1 | 1120 | if (pmenu==1) { | 
| sinrab | 3:791cf9a867d1 | 1121 | TFT.background(back5_iset); | 
| sinrab | 3:791cf9a867d1 | 1122 | TFT.foreground(text5_i); | 
| sinrab | 3:791cf9a867d1 | 1123 | } else { | 
| sinrab | 3:791cf9a867d1 | 1124 | TFT.background(back5_i); | 
| sinrab | 3:791cf9a867d1 | 1125 | TFT.foreground(text5_i); | 
| sinrab | 3:791cf9a867d1 | 1126 | } | 
| sinrab | 0:ed1ba99f7b14 | 1127 | } else { | 
| sinrab | 0:ed1ba99f7b14 | 1128 | TFT.background(back5); | 
| sinrab | 0:ed1ba99f7b14 | 1129 | TFT.foreground(text5); | 
| sinrab | 0:ed1ba99f7b14 | 1130 | } | 
| sinrab | 4:776f59129c24 | 1131 | if (rdown_on==1) { | 
| sinrab | 3:791cf9a867d1 | 1132 | printf(" Voltmeter adjustment on R %s \n", ron); // падение на R вкл выкл | 
| sinrab | 3:791cf9a867d1 | 1133 | } else { | 
| sinrab | 3:791cf9a867d1 | 1134 | printf(" Voltmeter adjustment on R %s \n", roff); | 
| sinrab | 3:791cf9a867d1 | 1135 | } | 
| sinrab | 0:ed1ba99f7b14 | 1136 | //------------------------------------*--------------------------- | 
| sinrab | 0:ed1ba99f7b14 | 1137 | if (mline==8) { | 
| sinrab | 3:791cf9a867d1 | 1138 | if (pmenu==1) { | 
| sinrab | 3:791cf9a867d1 | 1139 | TFT.background(back5_iset); | 
| sinrab | 3:791cf9a867d1 | 1140 | TFT.foreground(text5_i); | 
| sinrab | 3:791cf9a867d1 | 1141 | } else { | 
| sinrab | 3:791cf9a867d1 | 1142 | TFT.background(back5_i); | 
| sinrab | 3:791cf9a867d1 | 1143 | TFT.foreground(text5_i); | 
| sinrab | 3:791cf9a867d1 | 1144 | } | 
| sinrab | 0:ed1ba99f7b14 | 1145 | } else { | 
| sinrab | 0:ed1ba99f7b14 | 1146 | TFT.background(back5); | 
| sinrab | 0:ed1ba99f7b14 | 1147 | TFT.foreground(text5); | 
| sinrab | 0:ed1ba99f7b14 | 1148 | } | 
| sinrab | 3:791cf9a867d1 | 1149 | printf(" Current sense shunt, R = %05.3f om\n", rdown); // значения сопротивления шунта | 
| sinrab | 0:ed1ba99f7b14 | 1150 | //------- -----------------------------*--------------------------- | 
| sinrab | 0:ed1ba99f7b14 | 1151 | if (mline==9) { | 
| sinrab | 0:ed1ba99f7b14 | 1152 | TFT.background(back5_i); | 
| sinrab | 0:ed1ba99f7b14 | 1153 | TFT.foreground(text5_i); | 
| sinrab | 0:ed1ba99f7b14 | 1154 | } else { | 
| sinrab | 0:ed1ba99f7b14 | 1155 | TFT.background(back5); | 
| sinrab | 0:ed1ba99f7b14 | 1156 | TFT.foreground(text5); | 
| sinrab | 0:ed1ba99f7b14 | 1157 | } | 
| sinrab | 3:791cf9a867d1 | 1158 | printf(" Calibration I, U \n"); // 1 | 
| sinrab | 0:ed1ba99f7b14 | 1159 | //------------------------------------*--------------------------- | 
| sinrab | 0:ed1ba99f7b14 | 1160 | if (mline==10) { | 
| sinrab | 0:ed1ba99f7b14 | 1161 | TFT.background(back5_i); | 
| sinrab | 0:ed1ba99f7b14 | 1162 | TFT.foreground(text5_i); | 
| sinrab | 0:ed1ba99f7b14 | 1163 | } else { | 
| sinrab | 0:ed1ba99f7b14 | 1164 | TFT.background(back5); | 
| sinrab | 0:ed1ba99f7b14 | 1165 | TFT.foreground(text5); | 
| sinrab | 0:ed1ba99f7b14 | 1166 | } | 
| sinrab | 3:791cf9a867d1 | 1167 | printf(" Data analog in, noise \n"); // 1 | 
| sinrab | 0:ed1ba99f7b14 | 1168 | //------------------------------------*--------------------------- | 
| sinrab | 0:ed1ba99f7b14 | 1169 | if (mline==11) { | 
| sinrab | 3:791cf9a867d1 | 1170 | if (pmenu==1) { | 
| sinrab | 3:791cf9a867d1 | 1171 | TFT.background(back5_iset); | 
| sinrab | 3:791cf9a867d1 | 1172 | TFT.foreground(text5_i); | 
| sinrab | 3:791cf9a867d1 | 1173 | } else { | 
| sinrab | 3:791cf9a867d1 | 1174 | TFT.background(back5_i); | 
| sinrab | 3:791cf9a867d1 | 1175 | TFT.foreground(text5_i); | 
| sinrab | 3:791cf9a867d1 | 1176 | } | 
| sinrab | 0:ed1ba99f7b14 | 1177 | } else { | 
| sinrab | 0:ed1ba99f7b14 | 1178 | TFT.background(back5); | 
| sinrab | 0:ed1ba99f7b14 | 1179 | TFT.foreground(text5); | 
| sinrab | 0:ed1ba99f7b14 | 1180 | } | 
| sinrab | 4:776f59129c24 | 1181 | printf(" U max %02.0d V \n", umax); // U max | 
| sinrab | 0:ed1ba99f7b14 | 1182 | //------------------------------------*--------------------------- | 
| sinrab | 0:ed1ba99f7b14 | 1183 | if (mline==12) { | 
| sinrab | 4:776f59129c24 | 1184 | if (pmenu==1) { | 
| sinrab | 4:776f59129c24 | 1185 | TFT.background(back5_iset); | 
| sinrab | 4:776f59129c24 | 1186 | TFT.foreground(text5_i); | 
| sinrab | 4:776f59129c24 | 1187 | } else { | 
| sinrab | 4:776f59129c24 | 1188 | TFT.background(back5_i); | 
| sinrab | 4:776f59129c24 | 1189 | TFT.foreground(text5_i); | 
| sinrab | 4:776f59129c24 | 1190 | } | 
| sinrab | 0:ed1ba99f7b14 | 1191 | } else { | 
| sinrab | 0:ed1ba99f7b14 | 1192 | TFT.background(back5); | 
| sinrab | 0:ed1ba99f7b14 | 1193 | TFT.foreground(text5); | 
| sinrab | 0:ed1ba99f7b14 | 1194 | } | 
| sinrab | 4:776f59129c24 | 1195 | printf(" I max %03.1f A \n", imax); // I max | 
| sinrab | 0:ed1ba99f7b14 | 1196 | //------------------------------------*--------------------------- | 
| sinrab | 0:ed1ba99f7b14 | 1197 | if (mline==13) { | 
| sinrab | 4:776f59129c24 | 1198 | if (pmenu==1) { | 
| sinrab | 4:776f59129c24 | 1199 | TFT.background(back5_iset); | 
| sinrab | 4:776f59129c24 | 1200 | TFT.foreground(text5_i); | 
| sinrab | 4:776f59129c24 | 1201 | } else { | 
| sinrab | 4:776f59129c24 | 1202 | TFT.background(back5_i); | 
| sinrab | 4:776f59129c24 | 1203 | TFT.foreground(text5_i); | 
| sinrab | 4:776f59129c24 | 1204 | } | 
| sinrab | 0:ed1ba99f7b14 | 1205 | } else { | 
| sinrab | 0:ed1ba99f7b14 | 1206 | TFT.background(back5); | 
| sinrab | 0:ed1ba99f7b14 | 1207 | TFT.foreground(text5); | 
| sinrab | 0:ed1ba99f7b14 | 1208 | } | 
| sinrab | 4:776f59129c24 | 1209 | printf(" Screen saver %d \n", screensaver); // Screen saver | 
| sinrab | 0:ed1ba99f7b14 | 1210 | //------------------------------------*--------------------------- | 
| sinrab | 0:ed1ba99f7b14 | 1211 | if (mline==14) { | 
| sinrab | 4:776f59129c24 | 1212 | if (pmenu==1) { | 
| sinrab | 4:776f59129c24 | 1213 | TFT.background(back5_iset); | 
| sinrab | 4:776f59129c24 | 1214 | TFT.foreground(text5_i); | 
| sinrab | 4:776f59129c24 | 1215 | } else { | 
| sinrab | 4:776f59129c24 | 1216 | TFT.background(back5_i); | 
| sinrab | 4:776f59129c24 | 1217 | TFT.foreground(text5_i); | 
| sinrab | 4:776f59129c24 | 1218 | } | 
| sinrab | 0:ed1ba99f7b14 | 1219 | } else { | 
| sinrab | 0:ed1ba99f7b14 | 1220 | TFT.background(back5); | 
| sinrab | 0:ed1ba99f7b14 | 1221 | TFT.foreground(text5); | 
| sinrab | 0:ed1ba99f7b14 | 1222 | } | 
| sinrab | 4:776f59129c24 | 1223 | printf(" Load default settings and save to flash\n"); // 1 | 
| sinrab | 0:ed1ba99f7b14 | 1224 | //------------------------------------*--------------------------- | 
| sinrab | 0:ed1ba99f7b14 | 1225 | if (mline==15) { | 
| sinrab | 0:ed1ba99f7b14 | 1226 | TFT.background(0xFB2C); | 
| sinrab | 0:ed1ba99f7b14 | 1227 | TFT.foreground(text5_i); | 
| sinrab | 0:ed1ba99f7b14 | 1228 | } else { | 
| sinrab | 0:ed1ba99f7b14 | 1229 | TFT.background(back5); | 
| sinrab | 0:ed1ba99f7b14 | 1230 | TFT.foreground(text5); | 
| sinrab | 0:ed1ba99f7b14 | 1231 | } | 
| sinrab | 3:791cf9a867d1 | 1232 | printf(" Exit \n"); | 
| sinrab | 0:ed1ba99f7b14 | 1233 | //--------------------------------------*------------------------- | 
| sinrab | 0:ed1ba99f7b14 | 1234 | TFT.background(back5); | 
| sinrab | 0:ed1ba99f7b14 | 1235 | TFT.foreground(text5); | 
| sinrab | 3:791cf9a867d1 | 1236 | printf("--------------------------------------- \n"); | 
| sinrab | 0:ed1ba99f7b14 | 1237 | |
| sinrab | 0:ed1ba99f7b14 | 1238 | |
| sinrab | 0:ed1ba99f7b14 | 1239 | } | 
| sinrab | 0:ed1ba99f7b14 | 1240 | //------------------------------------------------------------------------------------------------------------ | 
| sinrab | 0:ed1ba99f7b14 | 1241 | void drawScreen6(void) //экран 6 | 
| sinrab | 0:ed1ba99f7b14 | 1242 | { | 
| sinrab | 0:ed1ba99f7b14 | 1243 | if (complit==0) { | 
| sinrab | 3:791cf9a867d1 | 1244 | TFT.background(Black); | 
| sinrab | 3:791cf9a867d1 | 1245 | TFT.foreground(White); | 
| sinrab | 0:ed1ba99f7b14 | 1246 | TFT.cls(); | 
| sinrab | 0:ed1ba99f7b14 | 1247 | complit = 1; // прорисовали! | 
| sinrab | 0:ed1ba99f7b14 | 1248 | } | 
| sinrab | 3:791cf9a867d1 | 1249 | TFT.set_font((unsigned char*) digi36x44); | 
| sinrab | 3:791cf9a867d1 | 1250 | TFT.foreground(Green); | 
| sinrab | 3:791cf9a867d1 | 1251 | TFT.locate(10, 10); | 
| sinrab | 3:791cf9a867d1 | 1252 | TFT.printf("%06.1f", Ireal); | 
| sinrab | 3:791cf9a867d1 | 1253 | TFT.locate(10, 85); | 
| sinrab | 3:791cf9a867d1 | 1254 | TFT.printf("%05.3f", U5); | 
| sinrab | 4:776f59129c24 | 1255 | |
| sinrab | 3:791cf9a867d1 | 1256 | TFT.locate(10, 150); | 
| sinrab | 3:791cf9a867d1 | 1257 | TFT.printf("%d", int(U30)); | 
| sinrab | 0:ed1ba99f7b14 | 1258 | |
| sinrab | 0:ed1ba99f7b14 | 1259 | |
| sinrab | 0:ed1ba99f7b14 | 1260 | } | 
| sinrab | 0:ed1ba99f7b14 | 1261 | //------------------------------------------------------------------------------------------------------------ | 
| sinrab | 0:ed1ba99f7b14 | 1262 | void drawScreen7(void) //экран 7 | 
| sinrab | 0:ed1ba99f7b14 | 1263 | { | 
| sinrab | 0:ed1ba99f7b14 | 1264 | if (complit==0) { | 
| sinrab | 0:ed1ba99f7b14 | 1265 | TFT.background(Blue); | 
| sinrab | 4:776f59129c24 | 1266 | TFT.foreground(White); | 
| sinrab | 0:ed1ba99f7b14 | 1267 | TFT.cls(); | 
| sinrab | 0:ed1ba99f7b14 | 1268 | complit = 1; // прорисовали! | 
| sinrab | 4:776f59129c24 | 1269 | |
| sinrab | 4:776f59129c24 | 1270 | TFT.line(0,40,319,40,Black); | 
| sinrab | 4:776f59129c24 | 1271 | TFT.line(0,80,319,80,Black); | 
| sinrab | 4:776f59129c24 | 1272 | TFT.line(0,120,319,120,Black); | 
| sinrab | 4:776f59129c24 | 1273 | TFT.line(0,160,319,160,Black); | 
| sinrab | 4:776f59129c24 | 1274 | TFT.line(0,200,319,200,Black); | 
| sinrab | 0:ed1ba99f7b14 | 1275 | } | 
| sinrab | 4:776f59129c24 | 1276 | |
| sinrab | 4:776f59129c24 | 1277 | TFT.background(Blue); | 
| sinrab | 4:776f59129c24 | 1278 | TFT.foreground(White); | 
| sinrab | 4:776f59129c24 | 1279 | iiii++; | 
| sinrab | 4:776f59129c24 | 1280 | if (iiii==320) { | 
| sinrab | 4:776f59129c24 | 1281 | iiii=0; | 
| sinrab | 4:776f59129c24 | 1282 | TFT.background(Blue); | 
| sinrab | 4:776f59129c24 | 1283 | TFT.foreground(White); | 
| sinrab | 4:776f59129c24 | 1284 | TFT.cls(); | 
| sinrab | 4:776f59129c24 | 1285 | TFT.line(0,40,319,40,Black); | 
| sinrab | 4:776f59129c24 | 1286 | TFT.line(0,80,319,80,Black); | 
| sinrab | 4:776f59129c24 | 1287 | TFT.line(0,120,319,120,Black); | 
| sinrab | 4:776f59129c24 | 1288 | TFT.line(0,160,319,160,Black); | 
| sinrab | 4:776f59129c24 | 1289 | TFT.line(0,200,319,200,Black); | 
| sinrab | 4:776f59129c24 | 1290 | } | 
| sinrab | 4:776f59129c24 | 1291 | int b = noisea1*40; | 
| sinrab | 4:776f59129c24 | 1292 | TFT.locate(5,5); | 
| sinrab | 4:776f59129c24 | 1293 | TFT.set_font((unsigned char*) Courier8x13); | 
| sinrab | 4:776f59129c24 | 1294 | printf("I A1 noise= %0.1f, avg= %0.5f \n", noisea1, in1); | 
| sinrab | 4:776f59129c24 | 1295 | printf(" I real = %06.1f set zero \n", Ireal); | 
| sinrab | 4:776f59129c24 | 1296 | TFT.line(iiii,245-b,iiii,240-b, White); | 
| sinrab | 4:776f59129c24 | 1297 | //TFT.pixel(iiii,240-b,White); | 
| sinrab | 4:776f59129c24 | 1298 | |
| sinrab | 4:776f59129c24 | 1299 | wait(0.01); | 
| sinrab | 0:ed1ba99f7b14 | 1300 | } | 
| sinrab | 0:ed1ba99f7b14 | 1301 | //------------------------------------------------------------------------------------------------------------ | 
| sinrab | 0:ed1ba99f7b14 | 1302 | void drawScreen8(void) //экран 8 | 
| sinrab | 0:ed1ba99f7b14 | 1303 | { | 
| sinrab | 0:ed1ba99f7b14 | 1304 | if (complit==0) { | 
| sinrab | 4:776f59129c24 | 1305 | TFT.background(Black); | 
| sinrab | 4:776f59129c24 | 1306 | TFT.foreground(White); | 
| sinrab | 0:ed1ba99f7b14 | 1307 | TFT.cls(); | 
| sinrab | 0:ed1ba99f7b14 | 1308 | complit = 1; // прорисовали! | 
| sinrab | 0:ed1ba99f7b14 | 1309 | } | 
| sinrab | 0:ed1ba99f7b14 | 1310 | |
| sinrab | 4:776f59129c24 | 1311 | TFT.set_font((unsigned char*) Lucida13x21); | 
| sinrab | 4:776f59129c24 | 1312 | char buffer[32]; | 
| sinrab | 4:776f59129c24 | 1313 | seconds=time(NULL); | 
| sinrab | 4:776f59129c24 | 1314 | strftime(buffer, 32, "%H:%M:%S %d.%m.%Y", localtime(&seconds)); | 
| sinrab | 4:776f59129c24 | 1315 | TFT.background(back5_i); | 
| sinrab | 4:776f59129c24 | 1316 | TFT.foreground(text5_i); | 
| sinrab | 4:776f59129c24 | 1317 | TFT.locate (30,25); | 
| sinrab | 4:776f59129c24 | 1318 | printf("%s", buffer); //вывод реального времени | 
| sinrab | 0:ed1ba99f7b14 | 1319 | } | 
| sinrab | 0:ed1ba99f7b14 | 1320 | //------------------------------------------------------------------------------------------------------------ | 
| sinrab | 2:d20b1ef35d3f | 1321 | float map(float x, float in_min, float in_max, float out_min, float out_max) // функция масштабирования | 
| sinrab | 0:ed1ba99f7b14 | 1322 | { | 
| sinrab | 0:ed1ba99f7b14 | 1323 | return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min; | 
| sinrab | 0:ed1ba99f7b14 | 1324 | } | 
| sinrab | 0:ed1ba99f7b14 | 1325 | //------------------------------------------------------------------------------------------------------------ | 
| sinrab | 0:ed1ba99f7b14 | 1326 | float avgAin0() // функция среднего значения с входа A0 | 
| sinrab | 0:ed1ba99f7b14 | 1327 | { | 
| sinrab | 0:ed1ba99f7b14 | 1328 | int m = 100; | 
| sinrab | 0:ed1ba99f7b14 | 1329 | float value[m]; | 
| sinrab | 0:ed1ba99f7b14 | 1330 | float max; | 
| sinrab | 0:ed1ba99f7b14 | 1331 | float min; | 
| sinrab | 0:ed1ba99f7b14 | 1332 | double itg; | 
| sinrab | 0:ed1ba99f7b14 | 1333 | max = itg = 0.0; | 
| sinrab | 0:ed1ba99f7b14 | 1334 | min = 3.3; | 
| sinrab | 0:ed1ba99f7b14 | 1335 | for (int i=0; i<m; i++) { | 
| sinrab | 0:ed1ba99f7b14 | 1336 | value[i] = ainA0; | 
| sinrab | 0:ed1ba99f7b14 | 1337 | if (value[i] > max) max = value[i]; | 
| sinrab | 0:ed1ba99f7b14 | 1338 | if (value[i] < min) min = value[i]; | 
| sinrab | 0:ed1ba99f7b14 | 1339 | itg += value[i]; | 
| sinrab | 0:ed1ba99f7b14 | 1340 | } | 
| sinrab | 0:ed1ba99f7b14 | 1341 | noisea0 = (max - min)*1000; | 
| sinrab | 0:ed1ba99f7b14 | 1342 | return itg/m; | 
| sinrab | 0:ed1ba99f7b14 | 1343 | } | 
| sinrab | 0:ed1ba99f7b14 | 1344 | //------------------------------------------------------------------------------------------------------------ | 
| sinrab | 0:ed1ba99f7b14 | 1345 | float avgAin1() // функция среднего значения с входа A1 | 
| sinrab | 0:ed1ba99f7b14 | 1346 | { | 
| sinrab | 0:ed1ba99f7b14 | 1347 | float value[100]; | 
| sinrab | 0:ed1ba99f7b14 | 1348 | float max; | 
| sinrab | 0:ed1ba99f7b14 | 1349 | float min; | 
| sinrab | 0:ed1ba99f7b14 | 1350 | double itg; | 
| sinrab | 0:ed1ba99f7b14 | 1351 | max = itg = 0.0; | 
| sinrab | 0:ed1ba99f7b14 | 1352 | min = 3.3; | 
| sinrab | 0:ed1ba99f7b14 | 1353 | for (int i=0; i<100; i++) { | 
| sinrab | 0:ed1ba99f7b14 | 1354 | value[i] = ainA1; | 
| sinrab | 0:ed1ba99f7b14 | 1355 | if (value[i] > max) max = value[i]; | 
| sinrab | 0:ed1ba99f7b14 | 1356 | if (value[i] < min) min = value[i]; | 
| sinrab | 0:ed1ba99f7b14 | 1357 | itg += value[i]; | 
| sinrab | 0:ed1ba99f7b14 | 1358 | } | 
| sinrab | 0:ed1ba99f7b14 | 1359 | noisea1 = (max - min)*1000; | 
| sinrab | 0:ed1ba99f7b14 | 1360 | return itg/100; | 
| sinrab | 0:ed1ba99f7b14 | 1361 | } | 
| sinrab | 0:ed1ba99f7b14 | 1362 | //------------------------------------------------------------------------------------------------------------ | 
| sinrab | 0:ed1ba99f7b14 | 1363 | float avgAin2() // функция среднего значения с входа A2 | 
| sinrab | 0:ed1ba99f7b14 | 1364 | { | 
| sinrab | 0:ed1ba99f7b14 | 1365 | float value[100]; | 
| sinrab | 0:ed1ba99f7b14 | 1366 | float max; | 
| sinrab | 0:ed1ba99f7b14 | 1367 | float min; | 
| sinrab | 0:ed1ba99f7b14 | 1368 | double itg; | 
| sinrab | 0:ed1ba99f7b14 | 1369 | max = itg = 0.0; | 
| sinrab | 0:ed1ba99f7b14 | 1370 | min = 3.3; | 
| sinrab | 0:ed1ba99f7b14 | 1371 | for (int i=0; i<100; i++) { | 
| sinrab | 0:ed1ba99f7b14 | 1372 | value[i] = ainA2; | 
| sinrab | 0:ed1ba99f7b14 | 1373 | if (value[i] > max) max = value[i]; | 
| sinrab | 0:ed1ba99f7b14 | 1374 | if (value[i] < min) min = value[i]; | 
| sinrab | 0:ed1ba99f7b14 | 1375 | itg += value[i]; | 
| sinrab | 0:ed1ba99f7b14 | 1376 | } | 
| sinrab | 0:ed1ba99f7b14 | 1377 | noisea2 = (max - min)*1000; | 
| sinrab | 0:ed1ba99f7b14 | 1378 | return itg/100; | 
| sinrab | 0:ed1ba99f7b14 | 1379 | } | 
| sinrab | 0:ed1ba99f7b14 | 1380 | //------------------------------------------------------------------------------------------------------------ | 
| sinrab | 0:ed1ba99f7b14 | 1381 | float avgAin3() // функция среднего значения с входа A3 | 
| sinrab | 0:ed1ba99f7b14 | 1382 | { | 
| sinrab | 0:ed1ba99f7b14 | 1383 | float value[100]; | 
| sinrab | 0:ed1ba99f7b14 | 1384 | float max; | 
| sinrab | 0:ed1ba99f7b14 | 1385 | float min; | 
| sinrab | 0:ed1ba99f7b14 | 1386 | double itg; | 
| sinrab | 0:ed1ba99f7b14 | 1387 | max = itg = 0.0; | 
| sinrab | 0:ed1ba99f7b14 | 1388 | min = 3.3; | 
| sinrab | 0:ed1ba99f7b14 | 1389 | for (int i=0; i<100; i++) { | 
| sinrab | 0:ed1ba99f7b14 | 1390 | value[i] = ainA3; | 
| sinrab | 0:ed1ba99f7b14 | 1391 | if (value[i] > max) max = value[i]; | 
| sinrab | 0:ed1ba99f7b14 | 1392 | if (value[i] < min) min = value[i]; | 
| sinrab | 0:ed1ba99f7b14 | 1393 | itg += value[i]; | 
| sinrab | 0:ed1ba99f7b14 | 1394 | } | 
| sinrab | 0:ed1ba99f7b14 | 1395 | noisea3 = (max - min)*1000; | 
| sinrab | 0:ed1ba99f7b14 | 1396 | return itg/100; | 
| sinrab | 0:ed1ba99f7b14 | 1397 | } | 
| sinrab | 0:ed1ba99f7b14 | 1398 | //------------------------------------------------------------------------------------------------------------ | 
| sinrab | 0:ed1ba99f7b14 | 1399 | void dataProcessing(void) // обработка и подготовка данных с аналоговых входов | 
| sinrab | 0:ed1ba99f7b14 | 1400 | { | 
| sinrab | 0:ed1ba99f7b14 | 1401 | /*t.reset();// FPS | 
| sinrab | 0:ed1ba99f7b14 | 1402 | t.start();// FPS*/ | 
| sinrab | 0:ed1ba99f7b14 | 1403 | |
| sinrab | 0:ed1ba99f7b14 | 1404 | in0 = avgAin0(); | 
| sinrab | 0:ed1ba99f7b14 | 1405 | in1 = avgAin1(); | 
| sinrab | 0:ed1ba99f7b14 | 1406 | in2 = avgAin2(); | 
| sinrab | 0:ed1ba99f7b14 | 1407 | in3 = avgAin3(); | 
| sinrab | 3:791cf9a867d1 | 1408 | //in4 = avgAin4(); | 
| sinrab | 3:791cf9a867d1 | 1409 | //in5 = avgAin5(); | 
| sinrab | 0:ed1ba99f7b14 | 1410 | |
| sinrab | 0:ed1ba99f7b14 | 1411 | // A0 U real U = (avgAin0() - a0a) * a0k | 
| sinrab | 0:ed1ba99f7b14 | 1412 | // A1 I real I = (avgAin1() - a1a) * a1k | 
| sinrab | 0:ed1ba99f7b14 | 1413 | // A2 U set U = (avgAin2() - a2a) * a2k | 
| sinrab | 0:ed1ba99f7b14 | 1414 | // A3 I set I = (avgAin3() - a3a) * a3k | 
| sinrab | 0:ed1ba99f7b14 | 1415 | // A4 U usb U = (avgAin4() - a4a) * a4k | 
| sinrab | 0:ed1ba99f7b14 | 1416 | // A5 I usb I = (avgAin5() - a5a) * a5k | 
| sinrab | 0:ed1ba99f7b14 | 1417 | |
| sinrab | 4:776f59129c24 | 1418 | Ireal = a1k*1000*(in1-a1a); | 
| sinrab | 4:776f59129c24 | 1419 | |
| sinrab | 5:0b3c71d7e475 | 1420 | temperature = map(in3, 0.228, 0.188 , 0, 90); //(in3, 0.232, 0.188 , 0, 90); //преобразование температуры | 
| sinrab | 4:776f59129c24 | 1421 | |
| sinrab | 4:776f59129c24 | 1422 | if (rdown_on==1) { | 
| sinrab | 4:776f59129c24 | 1423 | U5 = a0k*(in0-a0a)+Ireal*rdown/1000; | 
| sinrab | 4:776f59129c24 | 1424 | U30 = a2k*(in2-a2a)+Ireal*rdown/1000; | 
| sinrab | 4:776f59129c24 | 1425 | } else { | 
| sinrab | 4:776f59129c24 | 1426 | U5 = a0k*(in0-a0a); | 
| sinrab | 4:776f59129c24 | 1427 | U30 = a2k*(in2-a2a); | 
| sinrab | 4:776f59129c24 | 1428 | } | 
| sinrab | 4:776f59129c24 | 1429 | |
| sinrab | 3:791cf9a867d1 | 1430 | if (cc==1) ledcc=0; | 
| sinrab | 3:791cf9a867d1 | 1431 | if (cc==0) ledcc=1; | 
| sinrab | 0:ed1ba99f7b14 | 1432 | |
| sinrab | 0:ed1ba99f7b14 | 1433 | /*t.stop();// FPS | 
| sinrab | 0:ed1ba99f7b14 | 1434 | TFT.background(Black);// FPS | 
| sinrab | 0:ed1ba99f7b14 | 1435 | TFT.foreground(Green);// FPS | 
| sinrab | 0:ed1ba99f7b14 | 1436 | TFT.set_font((unsigned char*) Courier8x13);// FPS | 
| sinrab | 0:ed1ba99f7b14 | 1437 | TFT.locate(260,225);// FPS | 
| sinrab | 0:ed1ba99f7b14 | 1438 | TFT.printf("%0.2f", (1/t.read()));// FPS*/ | 
| sinrab | 0:ed1ba99f7b14 | 1439 | } | 
| sinrab | 0:ed1ba99f7b14 | 1440 | //------------------------------------------------------------------------------------------------------------ | 
| sinrab | 0:ed1ba99f7b14 | 1441 | void buttonUse(void) // обработка нажатий кнопок | 
| sinrab | 0:ed1ba99f7b14 | 1442 | { | 
| sinrab | 4:776f59129c24 | 1443 | if (beeper==1) { | 
| sinrab | 4:776f59129c24 | 1444 | |
| sinrab | 4:776f59129c24 | 1445 | if (buttonEnter==0) { | 
| sinrab | 4:776f59129c24 | 1446 | buzzer.beep(300,0.01); | 
| sinrab | 4:776f59129c24 | 1447 | } | 
| sinrab | 4:776f59129c24 | 1448 | if (buttonDown==0) { | 
| sinrab | 4:776f59129c24 | 1449 | buzzer.beep(300,0.01); | 
| sinrab | 4:776f59129c24 | 1450 | } | 
| sinrab | 4:776f59129c24 | 1451 | if (buttonUp==0) { | 
| sinrab | 4:776f59129c24 | 1452 | buzzer.beep(300,0.01); | 
| sinrab | 4:776f59129c24 | 1453 | } | 
| sinrab | 4:776f59129c24 | 1454 | } | 
| sinrab | 4:776f59129c24 | 1455 | |
| sinrab | 4:776f59129c24 | 1456 | |
| sinrab | 4:776f59129c24 | 1457 | |
| sinrab | 4:776f59129c24 | 1458 | |
| sinrab | 0:ed1ba99f7b14 | 1459 | int one=0; // для обработки одной кнопки за раз | 
| sinrab | 0:ed1ba99f7b14 | 1460 | //------------------------------------------------------------------ | 
| sinrab | 0:ed1ba99f7b14 | 1461 | if (Screen==1 & one==0) { //главный экран | 
| sinrab | 0:ed1ba99f7b14 | 1462 | if (buttonEnter==0) { // Enter | 
| sinrab | 0:ed1ba99f7b14 | 1463 | //wait(1); | 
| sinrab | 0:ed1ba99f7b14 | 1464 | Screen=5; // 5 главная настройки | 
| sinrab | 0:ed1ba99f7b14 | 1465 | complit=0; | 
| sinrab | 0:ed1ba99f7b14 | 1466 | } | 
| sinrab | 0:ed1ba99f7b14 | 1467 | if (buttonDown==0) { // Down | 
| sinrab | 7:8410439dee73 | 1468 | if (powerMosfet==0){ | 
| sinrab | 7:8410439dee73 | 1469 | a1a = in1 - 0.000100f; // 2 | 
| sinrab | 7:8410439dee73 | 1470 | complit=0; | 
| sinrab | 7:8410439dee73 | 1471 | } else { | 
| sinrab | 7:8410439dee73 | 1472 | Pcapbool2++; | 
| sinrab | 7:8410439dee73 | 1473 | if (Pcapbool2 == 4 ) Pcapbool2 = 1; | 
| sinrab | 7:8410439dee73 | 1474 | //complit=0; | 
| sinrab | 7:8410439dee73 | 1475 | } | 
| sinrab | 4:776f59129c24 | 1476 | } | 
| sinrab | 0:ed1ba99f7b14 | 1477 | if (buttonUp==0) { // Up | 
| sinrab | 0:ed1ba99f7b14 | 1478 | powerProtect=!powerProtect; | 
| sinrab | 0:ed1ba99f7b14 | 1479 | pp=0; | 
| sinrab | 0:ed1ba99f7b14 | 1480 | wait(0.2); | 
| sinrab | 0:ed1ba99f7b14 | 1481 | } | 
| sinrab | 0:ed1ba99f7b14 | 1482 | one=1; | 
| sinrab | 0:ed1ba99f7b14 | 1483 | } | 
| sinrab | 0:ed1ba99f7b14 | 1484 | //------------------------------------------------------------------ | 
| sinrab | 0:ed1ba99f7b14 | 1485 | if (Screen==2 & one==0) { //экран 2 analog in, noise | 
| sinrab | 0:ed1ba99f7b14 | 1486 | if (buttonEnter==0) { // Enter | 
| sinrab | 0:ed1ba99f7b14 | 1487 | //wait(1); | 
| sinrab | 0:ed1ba99f7b14 | 1488 | Screen=5; //3 | 
| sinrab | 0:ed1ba99f7b14 | 1489 | complit=0; | 
| sinrab | 0:ed1ba99f7b14 | 1490 | } | 
| sinrab | 5:0b3c71d7e475 | 1491 | if (buttonDown==0) { // Down | 
| sinrab | 5:0b3c71d7e475 | 1492 | Screen=7; | 
| sinrab | 5:0b3c71d7e475 | 1493 | iiii=0; | 
| sinrab | 5:0b3c71d7e475 | 1494 | complit=0; | 
| sinrab | 5:0b3c71d7e475 | 1495 | } | 
| sinrab | 0:ed1ba99f7b14 | 1496 | one=1; | 
| sinrab | 0:ed1ba99f7b14 | 1497 | } | 
| sinrab | 0:ed1ba99f7b14 | 1498 | //------------------------------------------------------------------ | 
| sinrab | 0:ed1ba99f7b14 | 1499 | if (Screen==3 & one==0) { //экран 3 | 
| sinrab | 4:776f59129c24 | 1500 | if(nline==7 & pmenu==1) { | 
| sinrab | 4:776f59129c24 | 1501 | wait(0.2); | 
| sinrab | 4:776f59129c24 | 1502 | pmenu=0; | 
| sinrab | 1:7bc0f280c259 | 1503 | } | 
| sinrab | 1:7bc0f280c259 | 1504 | if (buttonEnter==0 & pmenu==0) { // Enter | 
| sinrab | 1:7bc0f280c259 | 1505 | pmenu=1; | 
| sinrab | 1:7bc0f280c259 | 1506 | wait(0.2); | 
| sinrab | 4:776f59129c24 | 1507 | if(nline==7) { | 
| sinrab | 1:7bc0f280c259 | 1508 | mon=mon-1; | 
| sinrab | 1:7bc0f280c259 | 1509 | SetDateTime(); | 
| sinrab | 1:7bc0f280c259 | 1510 | mon=mon+1; | 
| sinrab | 1:7bc0f280c259 | 1511 | } | 
| sinrab | 4:776f59129c24 | 1512 | if(nline==8) { | 
| sinrab | 1:7bc0f280c259 | 1513 | pmenu=0; | 
| sinrab | 1:7bc0f280c259 | 1514 | Screen=5; | 
| sinrab | 1:7bc0f280c259 | 1515 | complit=0; | 
| sinrab | 1:7bc0f280c259 | 1516 | } | 
| sinrab | 1:7bc0f280c259 | 1517 | } | 
| sinrab | 1:7bc0f280c259 | 1518 | if (buttonUp==0 & pmenu==0) { // Up | 
| sinrab | 1:7bc0f280c259 | 1519 | nline--; | 
| sinrab | 1:7bc0f280c259 | 1520 | wait(0.2); | 
| sinrab | 1:7bc0f280c259 | 1521 | if (nline==0) nline=8; | 
| sinrab | 1:7bc0f280c259 | 1522 | } | 
| sinrab | 1:7bc0f280c259 | 1523 | if (buttonDown==0 & pmenu==0) { // Down | 
| sinrab | 1:7bc0f280c259 | 1524 | nline++; | 
| sinrab | 1:7bc0f280c259 | 1525 | wait(0.2); | 
| sinrab | 1:7bc0f280c259 | 1526 | if (nline==9) nline=1; | 
| sinrab | 0:ed1ba99f7b14 | 1527 | } | 
| sinrab | 1:7bc0f280c259 | 1528 | |
| sinrab | 1:7bc0f280c259 | 1529 | if (pmenu==1) { | 
| sinrab | 1:7bc0f280c259 | 1530 | if (buttonEnter==0) { | 
| sinrab | 1:7bc0f280c259 | 1531 | pmenu=0; | 
| sinrab | 1:7bc0f280c259 | 1532 | wait(0.2); | 
| sinrab | 1:7bc0f280c259 | 1533 | } | 
| sinrab | 1:7bc0f280c259 | 1534 | if (buttonUp==0) { | 
| sinrab | 1:7bc0f280c259 | 1535 | if (nline==1) { | 
| sinrab | 1:7bc0f280c259 | 1536 | hour++; | 
| sinrab | 1:7bc0f280c259 | 1537 | wait(0.1); | 
| sinrab | 1:7bc0f280c259 | 1538 | } | 
| sinrab | 1:7bc0f280c259 | 1539 | if (nline==2) { | 
| sinrab | 1:7bc0f280c259 | 1540 | min++; | 
| sinrab | 1:7bc0f280c259 | 1541 | wait(0.1); | 
| sinrab | 1:7bc0f280c259 | 1542 | } | 
| sinrab | 1:7bc0f280c259 | 1543 | if (nline==3) { | 
| sinrab | 1:7bc0f280c259 | 1544 | sec++; | 
| sinrab | 1:7bc0f280c259 | 1545 | wait(0.1); | 
| sinrab | 1:7bc0f280c259 | 1546 | } | 
| sinrab | 1:7bc0f280c259 | 1547 | if (nline==4) { | 
| sinrab | 1:7bc0f280c259 | 1548 | day++; | 
| sinrab | 1:7bc0f280c259 | 1549 | wait(0.1); | 
| sinrab | 1:7bc0f280c259 | 1550 | } | 
| sinrab | 1:7bc0f280c259 | 1551 | if (nline==5) { | 
| sinrab | 1:7bc0f280c259 | 1552 | mon++; | 
| sinrab | 1:7bc0f280c259 | 1553 | wait(0.1); | 
| sinrab | 1:7bc0f280c259 | 1554 | } | 
| sinrab | 1:7bc0f280c259 | 1555 | if (nline==6) { | 
| sinrab | 1:7bc0f280c259 | 1556 | year++; | 
| sinrab | 1:7bc0f280c259 | 1557 | wait(0.1); | 
| sinrab | 1:7bc0f280c259 | 1558 | } | 
| sinrab | 1:7bc0f280c259 | 1559 | } | 
| sinrab | 1:7bc0f280c259 | 1560 | if (buttonDown==0) { | 
| sinrab | 1:7bc0f280c259 | 1561 | if (nline==1) { | 
| sinrab | 1:7bc0f280c259 | 1562 | hour--; | 
| sinrab | 1:7bc0f280c259 | 1563 | wait(0.1); | 
| sinrab | 1:7bc0f280c259 | 1564 | } | 
| sinrab | 1:7bc0f280c259 | 1565 | if (nline==2) { | 
| sinrab | 1:7bc0f280c259 | 1566 | min--; | 
| sinrab | 1:7bc0f280c259 | 1567 | wait(0.1); | 
| sinrab | 1:7bc0f280c259 | 1568 | } | 
| sinrab | 1:7bc0f280c259 | 1569 | if (nline==3) { | 
| sinrab | 1:7bc0f280c259 | 1570 | sec--; | 
| sinrab | 1:7bc0f280c259 | 1571 | wait(0.1); | 
| sinrab | 1:7bc0f280c259 | 1572 | } | 
| sinrab | 1:7bc0f280c259 | 1573 | if (nline==4) { | 
| sinrab | 1:7bc0f280c259 | 1574 | day--; | 
| sinrab | 1:7bc0f280c259 | 1575 | wait(0.1); | 
| sinrab | 1:7bc0f280c259 | 1576 | } | 
| sinrab | 1:7bc0f280c259 | 1577 | if (nline==5) { | 
| sinrab | 1:7bc0f280c259 | 1578 | mon--; | 
| sinrab | 1:7bc0f280c259 | 1579 | wait(0.1); | 
| sinrab | 1:7bc0f280c259 | 1580 | } | 
| sinrab | 1:7bc0f280c259 | 1581 | if (nline==6) { | 
| sinrab | 1:7bc0f280c259 | 1582 | year--; | 
| sinrab | 1:7bc0f280c259 | 1583 | wait(0.1); | 
| sinrab | 1:7bc0f280c259 | 1584 | } | 
| sinrab | 1:7bc0f280c259 | 1585 | } | 
| sinrab | 1:7bc0f280c259 | 1586 | |
| sinrab | 1:7bc0f280c259 | 1587 | one=1; | 
| sinrab | 1:7bc0f280c259 | 1588 | } | 
| sinrab | 0:ed1ba99f7b14 | 1589 | } | 
| sinrab | 0:ed1ba99f7b14 | 1590 | //------------------------------------------------------------------ | 
| sinrab | 0:ed1ba99f7b14 | 1591 | if (Screen==4 & one==0) { //экран меню Калибровка | 
| sinrab | 0:ed1ba99f7b14 | 1592 | if (buttonEnter==0) { // Enter set! | 
| sinrab | 4:776f59129c24 | 1593 | |
| sinrab | 4:776f59129c24 | 1594 | if (kline==1) a0a = in0; | 
| sinrab | 4:776f59129c24 | 1595 | if (kline==2) a0k = 1.900f/(in0-a0a); //a0k = umax/(in0-a0a); | 
| sinrab | 4:776f59129c24 | 1596 | |
| sinrab | 4:776f59129c24 | 1597 | if (kline==3) a1a = in1 - 0.000100f; // a1a = avgAin1() - 0.00004 | 
| sinrab | 4:776f59129c24 | 1598 | if (kline==4) a1k = 0.2f/(in1 - a1a); //a1k = 1000/(avgAin1() - a1a) при 1амперах | 
| sinrab | 4:776f59129c24 | 1599 | |
| sinrab | 4:776f59129c24 | 1600 | if (kline==5) a2a = in2; // U high v | 
| sinrab | 5:0b3c71d7e475 | 1601 | if (kline==6) a2k = 19.00f/(in2-a2a); // U high v | 
| sinrab | 5:0b3c71d7e475 | 1602 | |
| sinrab | 5:0b3c71d7e475 | 1603 | if (kline==10) | 
| sinrab | 5:0b3c71d7e475 | 1604 | { | 
| sinrab | 5:0b3c71d7e475 | 1605 | ledshort=1; // 1 раз моргнуло - начало записи | 
| sinrab | 5:0b3c71d7e475 | 1606 | wait(0.02); | 
| sinrab | 5:0b3c71d7e475 | 1607 | ledshort=0; | 
| sinrab | 5:0b3c71d7e475 | 1608 | wait(0.05); | 
| sinrab | 5:0b3c71d7e475 | 1609 | int s=1; | 
| sinrab | 5:0b3c71d7e475 | 1610 | int s1=0; | 
| sinrab | 5:0b3c71d7e475 | 1611 | eeprom.nbyte_write(0, (char*)&s, sizeof(s)); | 
| sinrab | 5:0b3c71d7e475 | 1612 | eeprom.nbyte_write(4, (char*)&s1, sizeof(s1)); | 
| sinrab | 5:0b3c71d7e475 | 1613 | ledshort=1; | 
| sinrab | 5:0b3c71d7e475 | 1614 | wait(0.02); | 
| sinrab | 5:0b3c71d7e475 | 1615 | ledshort=0; | 
| sinrab | 5:0b3c71d7e475 | 1616 | } | 
| sinrab | 5:0b3c71d7e475 | 1617 | if (kline==11) | 
| sinrab | 5:0b3c71d7e475 | 1618 | { | 
| sinrab | 5:0b3c71d7e475 | 1619 | ledshort=1; // 1 раз моргнуло - начало записи | 
| sinrab | 5:0b3c71d7e475 | 1620 | wait(0.02); | 
| sinrab | 5:0b3c71d7e475 | 1621 | ledshort=0; | 
| sinrab | 5:0b3c71d7e475 | 1622 | wait(0.05); | 
| sinrab | 5:0b3c71d7e475 | 1623 | int s=0; | 
| sinrab | 5:0b3c71d7e475 | 1624 | int s1=1; | 
| sinrab | 5:0b3c71d7e475 | 1625 | eeprom.nbyte_write(0, (char*)&s, sizeof(s)); | 
| sinrab | 5:0b3c71d7e475 | 1626 | eeprom.nbyte_write(4, (char*)&s1, sizeof(s1)); | 
| sinrab | 5:0b3c71d7e475 | 1627 | ledshort=1; | 
| sinrab | 5:0b3c71d7e475 | 1628 | wait(0.02); | 
| sinrab | 5:0b3c71d7e475 | 1629 | ledshort=0; | 
| sinrab | 5:0b3c71d7e475 | 1630 | } | 
| sinrab | 4:776f59129c24 | 1631 | |
| sinrab | 4:776f59129c24 | 1632 | if (kline==13) { // load | 
| sinrab | 4:776f59129c24 | 1633 | |
| sinrab | 4:776f59129c24 | 1634 | a0a = 0.000679; | 
| sinrab | 4:776f59129c24 | 1635 | a0k = 5.006402; | 
| sinrab | 4:776f59129c24 | 1636 | a1a = 0.143353; | 
| sinrab | 4:776f59129c24 | 1637 | a1k = 3.224676; | 
| sinrab | 4:776f59129c24 | 1638 | a2a = 0.000015; | 
| sinrab | 4:776f59129c24 | 1639 | a2k = 33.627953; | 
| sinrab | 4:776f59129c24 | 1640 | } | 
| sinrab | 4:776f59129c24 | 1641 | if (kline==14) { // save | 
| sinrab | 4:776f59129c24 | 1642 | ledshort=1; // 1 раз моргнуло - начало записи | 
| sinrab | 4:776f59129c24 | 1643 | wait(0.02); | 
| sinrab | 4:776f59129c24 | 1644 | ledshort=0; | 
| sinrab | 4:776f59129c24 | 1645 | wait(0.05); | 
| sinrab | 4:776f59129c24 | 1646 | eeprom.nbyte_write(8, (char*)&a0a, sizeof(a0a)); // a0a float - 4 байта | 
| sinrab | 4:776f59129c24 | 1647 | eeprom.nbyte_write(12, (char*)&a0k, sizeof(a0k)); // a0k float - 4 байта | 
| sinrab | 4:776f59129c24 | 1648 | eeprom.nbyte_write(16, (char*)&a1a, sizeof(a1a)); // a1a float - 4 байта | 
| sinrab | 4:776f59129c24 | 1649 | eeprom.nbyte_write(20, (char*)&a1k, sizeof(a1k)); // a1k float - 4 байта | 
| sinrab | 4:776f59129c24 | 1650 | eeprom.nbyte_write(24, (char*)&a2a, sizeof(a2a)); // a2a float - 4 байта | 
| sinrab | 4:776f59129c24 | 1651 | eeprom.nbyte_write(28, (char*)&a2k, sizeof(a2k)); // a2k float - 4 байта | 
| sinrab | 4:776f59129c24 | 1652 | ledshort=1; // 2 раз моргнуло - записалось | 
| sinrab | 4:776f59129c24 | 1653 | wait(0.02); | 
| sinrab | 4:776f59129c24 | 1654 | ledshort=0; | 
| sinrab | 4:776f59129c24 | 1655 | wait(0.1); | 
| sinrab | 4:776f59129c24 | 1656 | } | 
| sinrab | 3:791cf9a867d1 | 1657 | if (kline==15) Screen=5; //exit | 
| sinrab | 0:ed1ba99f7b14 | 1658 | complit=0; | 
| sinrab | 0:ed1ba99f7b14 | 1659 | } | 
| sinrab | 0:ed1ba99f7b14 | 1660 | |
| sinrab | 0:ed1ba99f7b14 | 1661 | if (buttonUp==0) { // Up | 
| sinrab | 0:ed1ba99f7b14 | 1662 | kline--; //- | 
| sinrab | 0:ed1ba99f7b14 | 1663 | if (kline==0) kline=15; | 
| sinrab | 0:ed1ba99f7b14 | 1664 | } | 
| sinrab | 0:ed1ba99f7b14 | 1665 | |
| sinrab | 0:ed1ba99f7b14 | 1666 | if (buttonDown==0) { // Down | 
| sinrab | 0:ed1ba99f7b14 | 1667 | kline++; //+ | 
| sinrab | 0:ed1ba99f7b14 | 1668 | if (kline==16) kline=1; | 
| sinrab | 0:ed1ba99f7b14 | 1669 | } | 
| sinrab | 0:ed1ba99f7b14 | 1670 | one=1; | 
| sinrab | 0:ed1ba99f7b14 | 1671 | } | 
| sinrab | 0:ed1ba99f7b14 | 1672 | //------------------------------------------------------------------ | 
| sinrab | 0:ed1ba99f7b14 | 1673 | if (Screen==5 & one==0) { //экран 5 Настройки главная------------------------------------------------------- | 
| sinrab | 0:ed1ba99f7b14 | 1674 | if (buttonEnter==0 & pmenu==0) { // Enter | 
| sinrab | 4:776f59129c24 | 1675 | |
| sinrab | 0:ed1ba99f7b14 | 1676 | if (mline==1) { | 
| sinrab | 1:7bc0f280c259 | 1677 | Screen=3; | 
| sinrab | 0:ed1ba99f7b14 | 1678 | complit=0; | 
| sinrab | 0:ed1ba99f7b14 | 1679 | } | 
| sinrab | 4:776f59129c24 | 1680 | |
| sinrab | 0:ed1ba99f7b14 | 1681 | if (mline==2) { | 
| sinrab | 0:ed1ba99f7b14 | 1682 | mline2=1; | 
| sinrab | 0:ed1ba99f7b14 | 1683 | pmenu=1; | 
| sinrab | 0:ed1ba99f7b14 | 1684 | one=1; | 
| sinrab | 0:ed1ba99f7b14 | 1685 | wait(0.2); | 
| sinrab | 0:ed1ba99f7b14 | 1686 | } | 
| sinrab | 4:776f59129c24 | 1687 | |
| sinrab | 4:776f59129c24 | 1688 | if (mline==3) { // sound beeper | 
| sinrab | 4:776f59129c24 | 1689 | beeper=!beeper; | 
| sinrab | 4:776f59129c24 | 1690 | ledshort=1; | 
| sinrab | 4:776f59129c24 | 1691 | wait(0.02); | 
| sinrab | 4:776f59129c24 | 1692 | ledshort=0; | 
| sinrab | 4:776f59129c24 | 1693 | wait(0.05); | 
| sinrab | 4:776f59129c24 | 1694 | eeprom.nbyte_write(44, (char*)&beeper, sizeof(beeper)); // beeper float - 4 байта | 
| sinrab | 4:776f59129c24 | 1695 | ledshort=1; | 
| sinrab | 4:776f59129c24 | 1696 | wait(0.02); | 
| sinrab | 4:776f59129c24 | 1697 | ledshort=0; | 
| sinrab | 4:776f59129c24 | 1698 | mline7=1; | 
| sinrab | 4:776f59129c24 | 1699 | pmenu=1; | 
| sinrab | 4:776f59129c24 | 1700 | one=1; | 
| sinrab | 4:776f59129c24 | 1701 | wait(0.2); | 
| sinrab | 4:776f59129c24 | 1702 | } | 
| sinrab | 4:776f59129c24 | 1703 | |
| sinrab | 3:791cf9a867d1 | 1704 | if (mline==4) { // вентилятор старт | 
| sinrab | 3:791cf9a867d1 | 1705 | mline4=1; | 
| sinrab | 3:791cf9a867d1 | 1706 | pmenu=1; | 
| sinrab | 3:791cf9a867d1 | 1707 | one=1; | 
| sinrab | 3:791cf9a867d1 | 1708 | wait(0.2); | 
| sinrab | 3:791cf9a867d1 | 1709 | } | 
| sinrab | 4:776f59129c24 | 1710 | |
| sinrab | 3:791cf9a867d1 | 1711 | if (mline==5) { // вентилятор full | 
| sinrab | 3:791cf9a867d1 | 1712 | mline5=1; | 
| sinrab | 3:791cf9a867d1 | 1713 | pmenu=1; | 
| sinrab | 3:791cf9a867d1 | 1714 | one=1; | 
| sinrab | 3:791cf9a867d1 | 1715 | wait(0.2); | 
| sinrab | 3:791cf9a867d1 | 1716 | } | 
| sinrab | 4:776f59129c24 | 1717 | |
| sinrab | 3:791cf9a867d1 | 1718 | if (mline==6) { // температура отключения нагрузки | 
| sinrab | 3:791cf9a867d1 | 1719 | mline6=1; | 
| sinrab | 3:791cf9a867d1 | 1720 | pmenu=1; | 
| sinrab | 3:791cf9a867d1 | 1721 | one=1; | 
| sinrab | 3:791cf9a867d1 | 1722 | wait(0.2); | 
| sinrab | 3:791cf9a867d1 | 1723 | } | 
| sinrab | 4:776f59129c24 | 1724 | |
| sinrab | 3:791cf9a867d1 | 1725 | if (mline==7) { // R падение U вкл выкл | 
| sinrab | 3:791cf9a867d1 | 1726 | rdown_on=!rdown_on; | 
| sinrab | 4:776f59129c24 | 1727 | ledshort=1; | 
| sinrab | 4:776f59129c24 | 1728 | wait(0.02); | 
| sinrab | 4:776f59129c24 | 1729 | ledshort=0; | 
| sinrab | 4:776f59129c24 | 1730 | wait(0.05); | 
| sinrab | 4:776f59129c24 | 1731 | eeprom.nbyte_write(48, (char*)&rdown_on, sizeof(rdown_on)); // rdown_on float - 4 байта | 
| sinrab | 4:776f59129c24 | 1732 | ledshort=1; | 
| sinrab | 4:776f59129c24 | 1733 | wait(0.02); | 
| sinrab | 4:776f59129c24 | 1734 | ledshort=0; | 
| sinrab | 3:791cf9a867d1 | 1735 | mline7=1; | 
| sinrab | 3:791cf9a867d1 | 1736 | pmenu=1; | 
| sinrab | 3:791cf9a867d1 | 1737 | one=1; | 
| sinrab | 3:791cf9a867d1 | 1738 | wait(0.2); | 
| sinrab | 3:791cf9a867d1 | 1739 | } | 
| sinrab | 4:776f59129c24 | 1740 | |
| sinrab | 3:791cf9a867d1 | 1741 | if (mline==8) { // сопротивление R номинал | 
| sinrab | 3:791cf9a867d1 | 1742 | mline8=1; | 
| sinrab | 3:791cf9a867d1 | 1743 | pmenu=1; | 
| sinrab | 3:791cf9a867d1 | 1744 | one=1; | 
| sinrab | 3:791cf9a867d1 | 1745 | wait(0.2); | 
| sinrab | 3:791cf9a867d1 | 1746 | } | 
| sinrab | 4:776f59129c24 | 1747 | |
| sinrab | 0:ed1ba99f7b14 | 1748 | if (mline==9) { // меню калибровки | 
| sinrab | 0:ed1ba99f7b14 | 1749 | Screen=4; | 
| sinrab | 0:ed1ba99f7b14 | 1750 | complit=0; | 
| sinrab | 0:ed1ba99f7b14 | 1751 | } | 
| sinrab | 4:776f59129c24 | 1752 | |
| sinrab | 0:ed1ba99f7b14 | 1753 | if (mline==10) { // меню analog in, noise | 
| sinrab | 0:ed1ba99f7b14 | 1754 | Screen=2; | 
| sinrab | 0:ed1ba99f7b14 | 1755 | complit=0; | 
| sinrab | 0:ed1ba99f7b14 | 1756 | } | 
| sinrab | 4:776f59129c24 | 1757 | |
| sinrab | 3:791cf9a867d1 | 1758 | if (mline==11) { // U максимальная | 
| sinrab | 3:791cf9a867d1 | 1759 | mline11=1; | 
| sinrab | 3:791cf9a867d1 | 1760 | pmenu=1; | 
| sinrab | 3:791cf9a867d1 | 1761 | one=1; | 
| sinrab | 3:791cf9a867d1 | 1762 | wait(0.2); | 
| sinrab | 3:791cf9a867d1 | 1763 | } | 
| sinrab | 4:776f59129c24 | 1764 | |
| sinrab | 4:776f59129c24 | 1765 | if (mline==12) { // I max | 
| sinrab | 4:776f59129c24 | 1766 | mline12=1; | 
| sinrab | 4:776f59129c24 | 1767 | pmenu=1; | 
| sinrab | 4:776f59129c24 | 1768 | one=1; | 
| sinrab | 4:776f59129c24 | 1769 | wait(0.2); | 
| sinrab | 4:776f59129c24 | 1770 | } | 
| sinrab | 4:776f59129c24 | 1771 | |
| sinrab | 4:776f59129c24 | 1772 | if (mline==13) { // screen saver | 
| sinrab | 4:776f59129c24 | 1773 | mline13=1; | 
| sinrab | 4:776f59129c24 | 1774 | pmenu=1; | 
| sinrab | 4:776f59129c24 | 1775 | one=1; | 
| sinrab | 4:776f59129c24 | 1776 | wait(0.2); | 
| sinrab | 4:776f59129c24 | 1777 | } | 
| sinrab | 4:776f59129c24 | 1778 | |
| sinrab | 4:776f59129c24 | 1779 | if (mline==14) { // загрузить в память настройки по умолчанию и нужно перезагрузиться | 
| sinrab | 4:776f59129c24 | 1780 | savedefaulttoflash(); | 
| sinrab | 4:776f59129c24 | 1781 | mline14=1; | 
| sinrab | 4:776f59129c24 | 1782 | pmenu=1; | 
| sinrab | 4:776f59129c24 | 1783 | one=1; | 
| sinrab | 4:776f59129c24 | 1784 | wait(0.2); | 
| sinrab | 4:776f59129c24 | 1785 | } | 
| sinrab | 4:776f59129c24 | 1786 | |
| sinrab | 0:ed1ba99f7b14 | 1787 | if (mline==15) { | 
| sinrab | 0:ed1ba99f7b14 | 1788 | Screen=1; | 
| sinrab | 0:ed1ba99f7b14 | 1789 | complit=0; | 
| sinrab | 0:ed1ba99f7b14 | 1790 | } | 
| sinrab | 0:ed1ba99f7b14 | 1791 | } | 
| sinrab | 0:ed1ba99f7b14 | 1792 | |
| sinrab | 0:ed1ba99f7b14 | 1793 | if (buttonUp==0 & pmenu==0) { // Up | 
| sinrab | 0:ed1ba99f7b14 | 1794 | mline--; //- | 
| sinrab | 0:ed1ba99f7b14 | 1795 | if (mline==0) mline=15; | 
| sinrab | 0:ed1ba99f7b14 | 1796 | } | 
| sinrab | 0:ed1ba99f7b14 | 1797 | |
| sinrab | 0:ed1ba99f7b14 | 1798 | if (buttonDown==0 & pmenu==0) { // Down | 
| sinrab | 0:ed1ba99f7b14 | 1799 | mline++; //+ | 
| sinrab | 0:ed1ba99f7b14 | 1800 | if (mline==16) mline=1; | 
| sinrab | 0:ed1ba99f7b14 | 1801 | } | 
| sinrab | 0:ed1ba99f7b14 | 1802 | |
| sinrab | 0:ed1ba99f7b14 | 1803 | //---------подменю яркость подсветки | 
| sinrab | 0:ed1ba99f7b14 | 1804 | if (mline2==1) { | 
| sinrab | 0:ed1ba99f7b14 | 1805 | int i=0; | 
| sinrab | 4:776f59129c24 | 1806 | if (buttonUp==0 && brightness<1) { | 
| sinrab | 4:776f59129c24 | 1807 | if(brightness >= 0.09f && i==0) { | 
| sinrab | 4:776f59129c24 | 1808 | brightness+=0.1f; | 
| sinrab | 4:776f59129c24 | 1809 | pinbrightness=brightness; | 
| sinrab | 0:ed1ba99f7b14 | 1810 | i=1; | 
| sinrab | 0:ed1ba99f7b14 | 1811 | } | 
| sinrab | 4:776f59129c24 | 1812 | if(brightness < 0.09f && i==0) { | 
| sinrab | 4:776f59129c24 | 1813 | brightness+=0.01f; | 
| sinrab | 4:776f59129c24 | 1814 | pinbrightness=brightness; | 
| sinrab | 0:ed1ba99f7b14 | 1815 | i=1; | 
| sinrab | 0:ed1ba99f7b14 | 1816 | } | 
| sinrab | 0:ed1ba99f7b14 | 1817 | |
| sinrab | 0:ed1ba99f7b14 | 1818 | } | 
| sinrab | 0:ed1ba99f7b14 | 1819 | |
| sinrab | 4:776f59129c24 | 1820 | if (buttonDown==0 && brightness>0.01f) { | 
| sinrab | 4:776f59129c24 | 1821 | if(brightness <= 0.1f && i==0) { | 
| sinrab | 4:776f59129c24 | 1822 | brightness-=0.01f; | 
| sinrab | 4:776f59129c24 | 1823 | pinbrightness=brightness; | 
| sinrab | 0:ed1ba99f7b14 | 1824 | i=1; | 
| sinrab | 0:ed1ba99f7b14 | 1825 | } | 
| sinrab | 4:776f59129c24 | 1826 | if(brightness > 0.1f && i==0) { | 
| sinrab | 4:776f59129c24 | 1827 | brightness-=0.1f; | 
| sinrab | 4:776f59129c24 | 1828 | pinbrightness=brightness; | 
| sinrab | 0:ed1ba99f7b14 | 1829 | i=1; | 
| sinrab | 0:ed1ba99f7b14 | 1830 | } | 
| sinrab | 0:ed1ba99f7b14 | 1831 | } | 
| sinrab | 0:ed1ba99f7b14 | 1832 | |
| sinrab | 0:ed1ba99f7b14 | 1833 | if (buttonEnter==0) { | 
| sinrab | 4:776f59129c24 | 1834 | ledshort=1; | 
| sinrab | 4:776f59129c24 | 1835 | wait(0.02); | 
| sinrab | 4:776f59129c24 | 1836 | ledshort=0; | 
| sinrab | 4:776f59129c24 | 1837 | wait(0.05); | 
| sinrab | 4:776f59129c24 | 1838 | eeprom.nbyte_write(40, (char*)&brightness, sizeof(brightness)); // brightness float - 4 байта | 
| sinrab | 4:776f59129c24 | 1839 | ledshort=1; | 
| sinrab | 4:776f59129c24 | 1840 | wait(0.02); | 
| sinrab | 4:776f59129c24 | 1841 | ledshort=0; | 
| sinrab | 0:ed1ba99f7b14 | 1842 | mline2=0; | 
| sinrab | 0:ed1ba99f7b14 | 1843 | pmenu=0; | 
| sinrab | 0:ed1ba99f7b14 | 1844 | } | 
| sinrab | 0:ed1ba99f7b14 | 1845 | } | 
| sinrab | 4:776f59129c24 | 1846 | //------------------------------------ tempstart | 
| sinrab | 3:791cf9a867d1 | 1847 | if (mline4==1) { | 
| sinrab | 4:776f59129c24 | 1848 | if (buttonUp==0) { | 
| sinrab | 3:791cf9a867d1 | 1849 | tempstart++; | 
| sinrab | 3:791cf9a867d1 | 1850 | wait(0.1); | 
| sinrab | 3:791cf9a867d1 | 1851 | } | 
| sinrab | 4:776f59129c24 | 1852 | if (buttonDown==0) { | 
| sinrab | 3:791cf9a867d1 | 1853 | tempstart--; | 
| sinrab | 3:791cf9a867d1 | 1854 | wait(0.1); | 
| sinrab | 3:791cf9a867d1 | 1855 | } | 
| sinrab | 3:791cf9a867d1 | 1856 | if (buttonEnter==0) { | 
| sinrab | 4:776f59129c24 | 1857 | ledshort=1; | 
| sinrab | 4:776f59129c24 | 1858 | wait(0.02); | 
| sinrab | 4:776f59129c24 | 1859 | ledshort=0; | 
| sinrab | 4:776f59129c24 | 1860 | wait(0.05); | 
| sinrab | 4:776f59129c24 | 1861 | eeprom.nbyte_write(56, (char*)&tempstart, sizeof(tempstart)); // tempstart float - 4 байта | 
| sinrab | 4:776f59129c24 | 1862 | ledshort=1; | 
| sinrab | 4:776f59129c24 | 1863 | wait(0.02); | 
| sinrab | 4:776f59129c24 | 1864 | ledshort=0; | 
| sinrab | 3:791cf9a867d1 | 1865 | mline4=0; | 
| sinrab | 3:791cf9a867d1 | 1866 | pmenu=0; | 
| sinrab | 3:791cf9a867d1 | 1867 | } | 
| sinrab | 3:791cf9a867d1 | 1868 | } | 
| sinrab | 3:791cf9a867d1 | 1869 | //------------------------------------ tempfull | 
| sinrab | 3:791cf9a867d1 | 1870 | if (mline5==1) { | 
| sinrab | 4:776f59129c24 | 1871 | if (buttonUp==0) { | 
| sinrab | 3:791cf9a867d1 | 1872 | tempfull++; | 
| sinrab | 3:791cf9a867d1 | 1873 | wait(0.1); | 
| sinrab | 3:791cf9a867d1 | 1874 | } | 
| sinrab | 4:776f59129c24 | 1875 | if (buttonDown==0) { | 
| sinrab | 3:791cf9a867d1 | 1876 | tempfull--; | 
| sinrab | 3:791cf9a867d1 | 1877 | wait(0.1); | 
| sinrab | 3:791cf9a867d1 | 1878 | } | 
| sinrab | 3:791cf9a867d1 | 1879 | if (buttonEnter==0) { | 
| sinrab | 4:776f59129c24 | 1880 | ledshort=1; | 
| sinrab | 4:776f59129c24 | 1881 | wait(0.02); | 
| sinrab | 4:776f59129c24 | 1882 | ledshort=0; | 
| sinrab | 4:776f59129c24 | 1883 | wait(0.05); | 
| sinrab | 4:776f59129c24 | 1884 | eeprom.nbyte_write(60, (char*)&tempfull, sizeof(tempfull)); // tempfull float - 4 байта | 
| sinrab | 4:776f59129c24 | 1885 | ledshort=1; | 
| sinrab | 4:776f59129c24 | 1886 | wait(0.02); | 
| sinrab | 4:776f59129c24 | 1887 | ledshort=0; | 
| sinrab | 3:791cf9a867d1 | 1888 | mline5=0; | 
| sinrab | 3:791cf9a867d1 | 1889 | pmenu=0; | 
| sinrab | 3:791cf9a867d1 | 1890 | } | 
| sinrab | 3:791cf9a867d1 | 1891 | } | 
| sinrab | 3:791cf9a867d1 | 1892 | //------------------------------------ tempcutoff | 
| sinrab | 3:791cf9a867d1 | 1893 | if (mline6==1) { | 
| sinrab | 4:776f59129c24 | 1894 | if (buttonUp==0) { | 
| sinrab | 3:791cf9a867d1 | 1895 | tempcutoff++; | 
| sinrab | 3:791cf9a867d1 | 1896 | wait(0.1); | 
| sinrab | 3:791cf9a867d1 | 1897 | } | 
| sinrab | 4:776f59129c24 | 1898 | if (buttonDown==0) { | 
| sinrab | 3:791cf9a867d1 | 1899 | tempcutoff--; | 
| sinrab | 3:791cf9a867d1 | 1900 | wait(0.1); | 
| sinrab | 3:791cf9a867d1 | 1901 | } | 
| sinrab | 3:791cf9a867d1 | 1902 | if (buttonEnter==0) { | 
| sinrab | 4:776f59129c24 | 1903 | ledshort=1; | 
| sinrab | 4:776f59129c24 | 1904 | wait(0.02); | 
| sinrab | 4:776f59129c24 | 1905 | ledshort=0; | 
| sinrab | 4:776f59129c24 | 1906 | wait(0.05); | 
| sinrab | 4:776f59129c24 | 1907 | eeprom.nbyte_write(64, (char*)&tempcutoff, sizeof(tempcutoff)); // tempcutoff float - 4 байта | 
| sinrab | 4:776f59129c24 | 1908 | ledshort=1; | 
| sinrab | 4:776f59129c24 | 1909 | wait(0.02); | 
| sinrab | 4:776f59129c24 | 1910 | ledshort=0; | 
| sinrab | 3:791cf9a867d1 | 1911 | mline6=0; | 
| sinrab | 3:791cf9a867d1 | 1912 | pmenu=0; | 
| sinrab | 3:791cf9a867d1 | 1913 | } | 
| sinrab | 3:791cf9a867d1 | 1914 | } | 
| sinrab | 3:791cf9a867d1 | 1915 | //------------------------------------ падение на R вкл выкл | 
| sinrab | 3:791cf9a867d1 | 1916 | if (mline7==1 & one==0) { | 
| sinrab | 4:776f59129c24 | 1917 | wait(0.1); | 
| sinrab | 4:776f59129c24 | 1918 | mline7=0; | 
| sinrab | 4:776f59129c24 | 1919 | pmenu=0; | 
| sinrab | 3:791cf9a867d1 | 1920 | } | 
| sinrab | 3:791cf9a867d1 | 1921 | //------------------------------------ сопротивление резистора | 
| sinrab | 3:791cf9a867d1 | 1922 | if (mline8==1) { | 
| sinrab | 4:776f59129c24 | 1923 | if (buttonUp==0) { | 
| sinrab | 3:791cf9a867d1 | 1924 | rdown=rdown+0.001f; | 
| sinrab | 3:791cf9a867d1 | 1925 | wait(0.1); | 
| sinrab | 3:791cf9a867d1 | 1926 | } | 
| sinrab | 4:776f59129c24 | 1927 | if (buttonDown==0) { | 
| sinrab | 3:791cf9a867d1 | 1928 | rdown=rdown-0.001f; | 
| sinrab | 3:791cf9a867d1 | 1929 | wait(0.1); | 
| sinrab | 3:791cf9a867d1 | 1930 | } | 
| sinrab | 3:791cf9a867d1 | 1931 | if (buttonEnter==0) { | 
| sinrab | 4:776f59129c24 | 1932 | ledshort=1; | 
| sinrab | 4:776f59129c24 | 1933 | wait(0.02); | 
| sinrab | 4:776f59129c24 | 1934 | ledshort=0; | 
| sinrab | 4:776f59129c24 | 1935 | wait(0.05); | 
| sinrab | 4:776f59129c24 | 1936 | eeprom.nbyte_write(36, (char*)&rdown, sizeof(rdown)); // rdown float - 4 байта | 
| sinrab | 4:776f59129c24 | 1937 | ledshort=1; | 
| sinrab | 4:776f59129c24 | 1938 | wait(0.02); | 
| sinrab | 4:776f59129c24 | 1939 | ledshort=0; | 
| sinrab | 3:791cf9a867d1 | 1940 | mline8=0; | 
| sinrab | 3:791cf9a867d1 | 1941 | pmenu=0; | 
| sinrab | 3:791cf9a867d1 | 1942 | } | 
| sinrab | 3:791cf9a867d1 | 1943 | } | 
| sinrab | 3:791cf9a867d1 | 1944 | //------------------------------------ U max | 
| sinrab | 3:791cf9a867d1 | 1945 | if (mline11==1) { | 
| sinrab | 4:776f59129c24 | 1946 | if (buttonUp==0) { | 
| sinrab | 3:791cf9a867d1 | 1947 | umax++; | 
| sinrab | 3:791cf9a867d1 | 1948 | wait(0.1); | 
| sinrab | 3:791cf9a867d1 | 1949 | } | 
| sinrab | 4:776f59129c24 | 1950 | if (buttonDown==0) { | 
| sinrab | 3:791cf9a867d1 | 1951 | umax--; | 
| sinrab | 3:791cf9a867d1 | 1952 | wait(0.1); | 
| sinrab | 3:791cf9a867d1 | 1953 | } | 
| sinrab | 3:791cf9a867d1 | 1954 | if (buttonEnter==0) { | 
| sinrab | 4:776f59129c24 | 1955 | ledshort=1; | 
| sinrab | 4:776f59129c24 | 1956 | wait(0.02); | 
| sinrab | 4:776f59129c24 | 1957 | ledshort=0; | 
| sinrab | 4:776f59129c24 | 1958 | wait(0.05); | 
| sinrab | 4:776f59129c24 | 1959 | eeprom.nbyte_write(52, (char*)&umax, sizeof(umax)); // umax float - 4 байта | 
| sinrab | 4:776f59129c24 | 1960 | ledshort=1; | 
| sinrab | 4:776f59129c24 | 1961 | wait(0.02); | 
| sinrab | 4:776f59129c24 | 1962 | ledshort=0; | 
| sinrab | 3:791cf9a867d1 | 1963 | mline11=0; | 
| sinrab | 3:791cf9a867d1 | 1964 | pmenu=0; | 
| sinrab | 3:791cf9a867d1 | 1965 | } | 
| sinrab | 3:791cf9a867d1 | 1966 | } | 
| sinrab | 4:776f59129c24 | 1967 | //------------------------------------ I max | 
| sinrab | 4:776f59129c24 | 1968 | if (mline12==1) { | 
| sinrab | 4:776f59129c24 | 1969 | if (buttonUp==0) { | 
| sinrab | 4:776f59129c24 | 1970 | imax=imax+0.1f; | 
| sinrab | 4:776f59129c24 | 1971 | wait(0.05); | 
| sinrab | 4:776f59129c24 | 1972 | } | 
| sinrab | 4:776f59129c24 | 1973 | if (buttonDown==0) { | 
| sinrab | 4:776f59129c24 | 1974 | imax=imax-0.1f; | 
| sinrab | 4:776f59129c24 | 1975 | wait(0.05); | 
| sinrab | 4:776f59129c24 | 1976 | } | 
| sinrab | 4:776f59129c24 | 1977 | if (buttonEnter==0) { | 
| sinrab | 4:776f59129c24 | 1978 | ledshort=1; | 
| sinrab | 4:776f59129c24 | 1979 | wait(0.02); | 
| sinrab | 4:776f59129c24 | 1980 | ledshort=0; | 
| sinrab | 4:776f59129c24 | 1981 | wait(0.05); | 
| sinrab | 4:776f59129c24 | 1982 | eeprom.nbyte_write(32, (char*)&imax, sizeof(imax)); // imax float - 4 байта | 
| sinrab | 4:776f59129c24 | 1983 | ledshort=1; | 
| sinrab | 4:776f59129c24 | 1984 | wait(0.02); | 
| sinrab | 4:776f59129c24 | 1985 | ledshort=0; | 
| sinrab | 4:776f59129c24 | 1986 | mline12=0; | 
| sinrab | 4:776f59129c24 | 1987 | pmenu=0; | 
| sinrab | 4:776f59129c24 | 1988 | } | 
| sinrab | 4:776f59129c24 | 1989 | } | 
| sinrab | 4:776f59129c24 | 1990 | //------------------------------------ screensaver | 
| sinrab | 4:776f59129c24 | 1991 | if (mline13==1) { | 
| sinrab | 4:776f59129c24 | 1992 | if (buttonUp==0) { | 
| sinrab | 4:776f59129c24 | 1993 | screensaver++; | 
| sinrab | 4:776f59129c24 | 1994 | if (screensaver==4) screensaver=0; | 
| sinrab | 4:776f59129c24 | 1995 | wait(0.1); | 
| sinrab | 4:776f59129c24 | 1996 | } | 
| sinrab | 4:776f59129c24 | 1997 | if (buttonDown==0) { | 
| sinrab | 4:776f59129c24 | 1998 | screensaver--; | 
| sinrab | 4:776f59129c24 | 1999 | if (screensaver==-1) screensaver=3; | 
| sinrab | 4:776f59129c24 | 2000 | wait(0.1); | 
| sinrab | 4:776f59129c24 | 2001 | } | 
| sinrab | 4:776f59129c24 | 2002 | if (buttonEnter==0) { | 
| sinrab | 4:776f59129c24 | 2003 | ledshort=1; | 
| sinrab | 4:776f59129c24 | 2004 | wait(0.02); | 
| sinrab | 4:776f59129c24 | 2005 | ledshort=0; | 
| sinrab | 4:776f59129c24 | 2006 | wait(0.05); | 
| sinrab | 4:776f59129c24 | 2007 | eeprom.nbyte_write(68, (char*)&screensaver, sizeof(screensaver)); // screensaver float - 1 байт | 
| sinrab | 4:776f59129c24 | 2008 | ledshort=1; | 
| sinrab | 4:776f59129c24 | 2009 | wait(0.02); | 
| sinrab | 4:776f59129c24 | 2010 | ledshort=0; | 
| sinrab | 4:776f59129c24 | 2011 | mline13=0; | 
| sinrab | 4:776f59129c24 | 2012 | pmenu=0; | 
| sinrab | 4:776f59129c24 | 2013 | } | 
| sinrab | 4:776f59129c24 | 2014 | } | 
| sinrab | 4:776f59129c24 | 2015 | //------------------------------------ | 
| sinrab | 4:776f59129c24 | 2016 | if (mline14==1 & one==0) { | 
| sinrab | 4:776f59129c24 | 2017 | wait(0.1); | 
| sinrab | 4:776f59129c24 | 2018 | mline14=0; | 
| sinrab | 4:776f59129c24 | 2019 | pmenu=0; | 
| sinrab | 4:776f59129c24 | 2020 | } | 
| sinrab | 0:ed1ba99f7b14 | 2021 | //------------------------------------ | 
| sinrab | 0:ed1ba99f7b14 | 2022 | one=1; | 
| sinrab | 3:791cf9a867d1 | 2023 | //------------------------------------ | 
| sinrab | 0:ed1ba99f7b14 | 2024 | |
| sinrab | 0:ed1ba99f7b14 | 2025 | } | 
| sinrab | 0:ed1ba99f7b14 | 2026 | //------------------------------------------------------------------ | 
| sinrab | 0:ed1ba99f7b14 | 2027 | if (Screen==6 & one==0) { //экран 6 | 
| sinrab | 0:ed1ba99f7b14 | 2028 | if (buttonEnter==0) { // Enter | 
| sinrab | 4:776f59129c24 | 2029 | Screen=1; | 
| sinrab | 4:776f59129c24 | 2030 | complit=0; | 
| sinrab | 0:ed1ba99f7b14 | 2031 | } | 
| sinrab | 0:ed1ba99f7b14 | 2032 | |
| sinrab | 0:ed1ba99f7b14 | 2033 | if (buttonUp==0) { // Up | 
| sinrab | 0:ed1ba99f7b14 | 2034 | } | 
| sinrab | 0:ed1ba99f7b14 | 2035 | |
| sinrab | 0:ed1ba99f7b14 | 2036 | if (buttonDown==0) { // Down | 
| sinrab | 0:ed1ba99f7b14 | 2037 | } | 
| sinrab | 0:ed1ba99f7b14 | 2038 | one=1; | 
| sinrab | 0:ed1ba99f7b14 | 2039 | |
| sinrab | 0:ed1ba99f7b14 | 2040 | } | 
| sinrab | 0:ed1ba99f7b14 | 2041 | //------------------------------------------------------------------ | 
| sinrab | 0:ed1ba99f7b14 | 2042 | if (Screen==7 & one==0) { //экран 7 | 
| sinrab | 0:ed1ba99f7b14 | 2043 | if (buttonEnter==0) { // Enter | 
| sinrab | 5:0b3c71d7e475 | 2044 | Screen=2; | 
| sinrab | 5:0b3c71d7e475 | 2045 | complit=0; | 
| sinrab | 0:ed1ba99f7b14 | 2046 | } | 
| sinrab | 0:ed1ba99f7b14 | 2047 | |
| sinrab | 0:ed1ba99f7b14 | 2048 | if (buttonUp==0) { // Up | 
| sinrab | 5:0b3c71d7e475 | 2049 | Screen=2; | 
| sinrab | 5:0b3c71d7e475 | 2050 | complit=0; | 
| sinrab | 0:ed1ba99f7b14 | 2051 | } | 
| sinrab | 0:ed1ba99f7b14 | 2052 | |
| sinrab | 0:ed1ba99f7b14 | 2053 | if (buttonDown==0) { // Down | 
| sinrab | 5:0b3c71d7e475 | 2054 | Screen=2; | 
| sinrab | 4:776f59129c24 | 2055 | complit=0; | 
| sinrab | 0:ed1ba99f7b14 | 2056 | } | 
| sinrab | 0:ed1ba99f7b14 | 2057 | one=1; | 
| sinrab | 0:ed1ba99f7b14 | 2058 | |
| sinrab | 0:ed1ba99f7b14 | 2059 | } | 
| sinrab | 0:ed1ba99f7b14 | 2060 | //------------------------------------------------------------------ | 
| sinrab | 0:ed1ba99f7b14 | 2061 | if (Screen==8 & one==0) { //экран 8 | 
| sinrab | 0:ed1ba99f7b14 | 2062 | if (buttonEnter==0) { // Enter | 
| sinrab | 0:ed1ba99f7b14 | 2063 | } | 
| sinrab | 0:ed1ba99f7b14 | 2064 | |
| sinrab | 0:ed1ba99f7b14 | 2065 | if (buttonUp==0) { // Up | 
| sinrab | 0:ed1ba99f7b14 | 2066 | } | 
| sinrab | 0:ed1ba99f7b14 | 2067 | |
| sinrab | 0:ed1ba99f7b14 | 2068 | if (buttonDown==0) { // Down | 
| sinrab | 0:ed1ba99f7b14 | 2069 | } | 
| sinrab | 0:ed1ba99f7b14 | 2070 | one=1; | 
| sinrab | 0:ed1ba99f7b14 | 2071 | |
| sinrab | 0:ed1ba99f7b14 | 2072 | } | 
| sinrab | 0:ed1ba99f7b14 | 2073 | //------------------------------------------------------------------ | 
| sinrab | 0:ed1ba99f7b14 | 2074 | } | 
| sinrab | 0:ed1ba99f7b14 | 2075 | //------------------------------------------------------------------------------------------------------------ | 
| sinrab | 0:ed1ba99f7b14 | 2076 | void grid(void) | 
| sinrab | 0:ed1ba99f7b14 | 2077 | { | 
| sinrab | 0:ed1ba99f7b14 | 2078 | TFT.cls(); | 
| sinrab | 0:ed1ba99f7b14 | 2079 | for (int i=0; i<240; i=i+5) { | 
| sinrab | 0:ed1ba99f7b14 | 2080 | TFT.line(0,i,320,i, White); | 
| sinrab | 0:ed1ba99f7b14 | 2081 | } | 
| sinrab | 0:ed1ba99f7b14 | 2082 | for (int i=2; i<240; i=i+5) { | 
| sinrab | 0:ed1ba99f7b14 | 2083 | TFT.line(4,i,320,i, White); | 
| sinrab | 0:ed1ba99f7b14 | 2084 | } | 
| sinrab | 0:ed1ba99f7b14 | 2085 | for (int i=3; i<240; i=i+5) { | 
| sinrab | 0:ed1ba99f7b14 | 2086 | TFT.line(4,i,320,i, White); | 
| sinrab | 0:ed1ba99f7b14 | 2087 | } | 
| sinrab | 0:ed1ba99f7b14 | 2088 | |
| sinrab | 0:ed1ba99f7b14 | 2089 | } | 
| sinrab | 1:7bc0f280c259 | 2090 | //------------------------------------------------------------------------------------------------------------ | 
| sinrab | 0:ed1ba99f7b14 | 2091 | void timeConvert(void) //показывает час с минуты с секундами начинают идти с часа и одной минуты | 
| sinrab | 0:ed1ba99f7b14 | 2092 | { | 
| sinrab | 0:ed1ba99f7b14 | 2093 | if (powerMosfet==1) treal = time(NULL); | 
| sinrab | 0:ed1ba99f7b14 | 2094 | t = treal - tstart; | 
| sinrab | 0:ed1ba99f7b14 | 2095 | h= t/3600; | 
| sinrab | 0:ed1ba99f7b14 | 2096 | m= (t-h*3600)/60; | 
| sinrab | 0:ed1ba99f7b14 | 2097 | s= (t-h*3600)-m*60; | 
| sinrab | 0:ed1ba99f7b14 | 2098 | if (t == 359999) tstart=treal; | 
| sinrab | 1:7bc0f280c259 | 2099 | } | 
| sinrab | 1:7bc0f280c259 | 2100 | //------------------------------------------------------------------------------------------------------------ | 
| sinrab | 1:7bc0f280c259 | 2101 | void SetDateTime (void) | 
| sinrab | 1:7bc0f280c259 | 2102 | { | 
| sinrab | 1:7bc0f280c259 | 2103 | struct tm Clock; | 
| sinrab | 1:7bc0f280c259 | 2104 | Clock.tm_year = year - 1900; | 
| sinrab | 1:7bc0f280c259 | 2105 | Clock.tm_mon = mon; | 
| sinrab | 1:7bc0f280c259 | 2106 | Clock.tm_mday = day; | 
| sinrab | 1:7bc0f280c259 | 2107 | Clock.tm_hour = hour; | 
| sinrab | 1:7bc0f280c259 | 2108 | Clock.tm_min = min; | 
| sinrab | 1:7bc0f280c259 | 2109 | Clock.tm_sec = sec; | 
| sinrab | 1:7bc0f280c259 | 2110 | time_t epoch = mktime(&Clock); | 
| sinrab | 1:7bc0f280c259 | 2111 | set_time(epoch); | 
| sinrab | 1:7bc0f280c259 | 2112 | } | 
| sinrab | 4:776f59129c24 | 2113 | //------------------------------------------------------------------------------------------------------------*/ | 
| sinrab | 4:776f59129c24 | 2114 | void powerButton(void) // при нажатии кнопки питания | 
| sinrab | 4:776f59129c24 | 2115 | { | 
| sinrab | 4:776f59129c24 | 2116 | if (onepower==0) { | 
| sinrab | 4:776f59129c24 | 2117 | timerforpoweriddle.attach(&keypoweriddle, 0.5); | 
| sinrab | 1:7bc0f280c259 | 2118 | |
| sinrab | 4:776f59129c24 | 2119 | if (saveractive==0) { | 
| sinrab | 4:776f59129c24 | 2120 | powerMosfet=!powerMosfet; | 
| sinrab | 4:776f59129c24 | 2121 | iddletimesaver.detach(); | 
| sinrab | 4:776f59129c24 | 2122 | onesaver=0; | 
| sinrab | 4:776f59129c24 | 2123 | saveractive=0; | 
| sinrab | 4:776f59129c24 | 2124 | } else { | 
| sinrab | 4:776f59129c24 | 2125 | iddletimesaver.detach(); | 
| sinrab | 4:776f59129c24 | 2126 | onesaver=0; | 
| sinrab | 4:776f59129c24 | 2127 | saveractive=0; | 
| sinrab | 4:776f59129c24 | 2128 | } | 
| sinrab | 1:7bc0f280c259 | 2129 | |
| sinrab | 4:776f59129c24 | 2130 | if (beeper==1) { | 
| sinrab | 4:776f59129c24 | 2131 | buzzer.beep(1600,0.05); | 
| sinrab | 4:776f59129c24 | 2132 | } | 
| sinrab | 4:776f59129c24 | 2133 | onepower=1; | 
| sinrab | 4:776f59129c24 | 2134 | pb=0; | 
| sinrab | 1:7bc0f280c259 | 2135 | |
| sinrab | 4:776f59129c24 | 2136 | } | 
| sinrab | 4:776f59129c24 | 2137 | if (powerMosfet==1) { | 
| sinrab | 4:776f59129c24 | 2138 | tstart = treal = time(NULL); | 
| sinrab | 4:776f59129c24 | 2139 | h=m=s=0; | 
| sinrab | 7:8410439dee73 | 2140 | mah = 0; | 
| sinrab | 7:8410439dee73 | 2141 | wh = 0; | 
| sinrab | 4:776f59129c24 | 2142 | } | 
| sinrab | 4:776f59129c24 | 2143 | } | 
| sinrab | 4:776f59129c24 | 2144 | //------------------------------------------------------------------------------------------------------------ | 
| sinrab | 4:776f59129c24 | 2145 | void fans(void) | 
| sinrab | 4:776f59129c24 | 2146 | { | 
| sinrab | 4:776f59129c24 | 2147 | if (temperature < (tempstart-2)) { | 
| sinrab | 4:776f59129c24 | 2148 | fst=0; | 
| sinrab | 4:776f59129c24 | 2149 | fst2=0; | 
| sinrab | 4:776f59129c24 | 2150 | fan = 0.0f; | 
| sinrab | 5:0b3c71d7e475 | 2151 | //fan2 = 0.0f; | 
| sinrab | 4:776f59129c24 | 2152 | } | 
| sinrab | 1:7bc0f280c259 | 2153 | |
| sinrab | 4:776f59129c24 | 2154 | if (temperature >= tempstart && fst == 0) { | 
| sinrab | 4:776f59129c24 | 2155 | fan = 1.0f; | 
| sinrab | 5:0b3c71d7e475 | 2156 | //fan2 = 1.0f; | 
| sinrab | 4:776f59129c24 | 2157 | timerforfanstart.attach(&fanstart, 2.0); | 
| sinrab | 4:776f59129c24 | 2158 | fst=1; | 
| sinrab | 4:776f59129c24 | 2159 | } | 
| sinrab | 1:7bc0f280c259 | 2160 | |
| sinrab | 4:776f59129c24 | 2161 | if (fst2==1) { | 
| sinrab | 4:776f59129c24 | 2162 | fanspeed = map (temperature, tempstart, tempfull, 0.4, 1); | 
| sinrab | 4:776f59129c24 | 2163 | fan = fanspeed; | 
| sinrab | 5:0b3c71d7e475 | 2164 | //fanspeed2 = map (temperature, tempstart, tempfull, 0.4, 1); | 
| sinrab | 5:0b3c71d7e475 | 2165 | //fan2 = fanspeed2; | 
| sinrab | 4:776f59129c24 | 2166 | } | 
| sinrab | 1:7bc0f280c259 | 2167 | |
| sinrab | 4:776f59129c24 | 2168 | if (temperature >= tempcutoff) { | 
| sinrab | 4:776f59129c24 | 2169 | powerMosfet=0; | 
| sinrab | 4:776f59129c24 | 2170 | pb=0; | 
| sinrab | 4:776f59129c24 | 2171 | } | 
| sinrab | 1:7bc0f280c259 | 2172 | |
| sinrab | 4:776f59129c24 | 2173 | } | 
| sinrab | 4:776f59129c24 | 2174 | //------------------------------------------------------------------------------------------------------------ | 
| sinrab | 4:776f59129c24 | 2175 | void fanstart(void) | 
| sinrab | 4:776f59129c24 | 2176 | { | 
| sinrab | 4:776f59129c24 | 2177 | fst2=1; | 
| sinrab | 4:776f59129c24 | 2178 | } | 
| sinrab | 4:776f59129c24 | 2179 | //------------------------------------------------------------------------------------------------------------ | 
| sinrab | 4:776f59129c24 | 2180 | void keypoweriddle(void) | 
| sinrab | 4:776f59129c24 | 2181 | { | 
| sinrab | 4:776f59129c24 | 2182 | onepower=0; | 
| sinrab | 4:776f59129c24 | 2183 | } | 
| sinrab | 4:776f59129c24 | 2184 | //------------------------------------------------------------------------------------------------------------ | 
| sinrab | 4:776f59129c24 | 2185 | void Protect(void) | 
| sinrab | 4:776f59129c24 | 2186 | { | 
| sinrab | 4:776f59129c24 | 2187 | // powerProtect==0 pp==0 защита от кз | 
| sinrab | 4:776f59129c24 | 2188 | // cs==0 csp==0 прорисовка короткого замыкания | 
| sinrab | 4:776f59129c24 | 2189 | if (U5<0.9f && cc==0) { | 
| sinrab | 4:776f59129c24 | 2190 | shortline=1; | 
| sinrab | 4:776f59129c24 | 2191 | } else { | 
| sinrab | 4:776f59129c24 | 2192 | shortline=0; | 
| sinrab | 4:776f59129c24 | 2193 | } | 
| sinrab | 4:776f59129c24 | 2194 | if (shm==!shortline) { | 
| sinrab | 4:776f59129c24 | 2195 | shl=0; | 
| sinrab | 4:776f59129c24 | 2196 | } | 
| sinrab | 1:7bc0f280c259 | 2197 | |
| sinrab | 4:776f59129c24 | 2198 | if (shortline==1 && shl==0) { | 
| sinrab | 4:776f59129c24 | 2199 | cs=1; | 
| sinrab | 4:776f59129c24 | 2200 | csp=0; | 
| sinrab | 4:776f59129c24 | 2201 | shl=1; | 
| sinrab | 4:776f59129c24 | 2202 | shm=shortline; | 
| sinrab | 4:776f59129c24 | 2203 | ledshort=1; | 
| sinrab | 4:776f59129c24 | 2204 | } | 
| sinrab | 1:7bc0f280c259 | 2205 | |
| sinrab | 4:776f59129c24 | 2206 | if (shortline==0 && shl==0) { | 
| sinrab | 4:776f59129c24 | 2207 | cs=0; | 
| sinrab | 4:776f59129c24 | 2208 | csp=0; | 
| sinrab | 4:776f59129c24 | 2209 | shl=1; | 
| sinrab | 4:776f59129c24 | 2210 | shm=shortline; | 
| sinrab | 4:776f59129c24 | 2211 | ledshort=0; | 
| sinrab | 4:776f59129c24 | 2212 | } | 
| sinrab | 1:7bc0f280c259 | 2213 | |
| sinrab | 4:776f59129c24 | 2214 | if (powerProtect==1) { | 
| sinrab | 4:776f59129c24 | 2215 | if (U5<0.9f && cc==0) { | 
| sinrab | 4:776f59129c24 | 2216 | powerMosfet=0; | 
| sinrab | 4:776f59129c24 | 2217 | pb=0; | 
| sinrab | 4:776f59129c24 | 2218 | if (beeper==1) { | 
| sinrab | 4:776f59129c24 | 2219 | buzzer.beep(480,0.3); | 
| sinrab | 4:776f59129c24 | 2220 | } | 
| sinrab | 4:776f59129c24 | 2221 | } | 
| sinrab | 4:776f59129c24 | 2222 | } | 
| sinrab | 4:776f59129c24 | 2223 | } | 
| sinrab | 4:776f59129c24 | 2224 | //------------------------------------------------------------------------------------------------------------ | 
| sinrab | 4:776f59129c24 | 2225 | void ScreenSaver(void) | 
| sinrab | 4:776f59129c24 | 2226 | { | 
| sinrab | 4:776f59129c24 | 2227 | if (screensaver != 0) { | 
| sinrab | 4:776f59129c24 | 2228 | if (buttonEnter==0) { | 
| sinrab | 4:776f59129c24 | 2229 | iddletimesaver.detach(); | 
| sinrab | 4:776f59129c24 | 2230 | onesaver=0; | 
| sinrab | 4:776f59129c24 | 2231 | saveractive=0; | 
| sinrab | 4:776f59129c24 | 2232 | } | 
| sinrab | 4:776f59129c24 | 2233 | if (buttonDown==0) { | 
| sinrab | 4:776f59129c24 | 2234 | iddletimesaver.detach(); | 
| sinrab | 4:776f59129c24 | 2235 | onesaver=0; | 
| sinrab | 4:776f59129c24 | 2236 | saveractive=0; | 
| sinrab | 4:776f59129c24 | 2237 | } | 
| sinrab | 4:776f59129c24 | 2238 | if (buttonUp==0) { | 
| sinrab | 4:776f59129c24 | 2239 | iddletimesaver.detach(); | 
| sinrab | 4:776f59129c24 | 2240 | onesaver=0; | 
| sinrab | 4:776f59129c24 | 2241 | saveractive=0; | 
| sinrab | 4:776f59129c24 | 2242 | } | 
| sinrab | 4:776f59129c24 | 2243 | } | 
| sinrab | 4:776f59129c24 | 2244 | if (Screen==8 && saveractive==0) { | 
| sinrab | 4:776f59129c24 | 2245 | Screen=1; | 
| sinrab | 4:776f59129c24 | 2246 | complit=0; | 
| sinrab | 4:776f59129c24 | 2247 | } | 
| sinrab | 4:776f59129c24 | 2248 | if (Screen == 1 && onesaver==0) { | 
| sinrab | 4:776f59129c24 | 2249 | if (powerMosfet == 0 && screensaver != 0) { | 
| sinrab | 4:776f59129c24 | 2250 | iddletimesaver.attach(&screensaverstart, 10.0); | 
| sinrab | 4:776f59129c24 | 2251 | onesaver=1; | 
| sinrab | 4:776f59129c24 | 2252 | } | 
| sinrab | 4:776f59129c24 | 2253 | } | 
| sinrab | 4:776f59129c24 | 2254 | } | 
| sinrab | 4:776f59129c24 | 2255 | //------------------------------------------------------------------------------------------------------------ | 
| sinrab | 4:776f59129c24 | 2256 | void screensaverstart(void) | 
| sinrab | 4:776f59129c24 | 2257 | { | 
| sinrab | 4:776f59129c24 | 2258 | saveractive=1; | 
| sinrab | 4:776f59129c24 | 2259 | Screen=8; | 
| sinrab | 4:776f59129c24 | 2260 | complit=0; | 
| sinrab | 4:776f59129c24 | 2261 | } | 
| sinrab | 7:8410439dee73 | 2262 | //------------------------------------------------------------------------------------------------------------ | 
| sinrab | 7:8410439dee73 | 2263 | void Pcap(void) | 
| sinrab | 7:8410439dee73 | 2264 | { | 
| sinrab | 7:8410439dee73 | 2265 | double ttt = U5 * Ireal / 3600; | 
| sinrab | 7:8410439dee73 | 2266 | wh = wh + (ttt / 1000); // ватт часы | 
| sinrab | 7:8410439dee73 | 2267 | mah = mah + (ttt / 3.7); // а тут уже миллиампер часы | 
| sinrab | 7:8410439dee73 | 2268 | Pcapbool = !Pcapbool; | 
| sinrab | 7:8410439dee73 | 2269 | } | 
| sinrab | 7:8410439dee73 | 2270 | //------------------------------------------------------------------------------------------------------------ | 
| sinrab | 7:8410439dee73 | 2271 | |
| sinrab | 7:8410439dee73 | 2272 | |
| sinrab | 7:8410439dee73 | 2273 | |
| sinrab | 7:8410439dee73 | 2274 | |
| sinrab | 7:8410439dee73 | 2275 | |
| sinrab | 7:8410439dee73 | 2276 |