TEST2
Dependencies: LCD_DISCO_F746NG QSPI_DISCO_F746NG TS_DISCO_F746NG
main.cpp@4:f872c1d94463, 2017-12-14 (annotated)
- Committer:
- tribal91
- Date:
- Thu Dec 14 10:06:46 2017 +0000
- Revision:
- 4:f872c1d94463
- Parent:
- 2:1d503ae10977
test
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
yefremovv | 0:011a309655b5 | 1 | #include "main.h" |
yefremovv | 2:1d503ae10977 | 2 | // TEST 4 |
yefremovv | 0:011a309655b5 | 3 | //поток на работу с Eth |
yefremovv | 0:011a309655b5 | 4 | void workEth(){ |
tribal91 | 4:f872c1d94463 | 5 | int test = 0; |
yefremovv | 0:011a309655b5 | 6 | time_t unixtime; //unix-время из udp-пакета |
yefremovv | 0:011a309655b5 | 7 | tm tmu; //для unix-времени |
yefremovv | 0:011a309655b5 | 8 | int stat_b; //№ пути |
yefremovv | 0:011a309655b5 | 9 | |
yefremovv | 0:011a309655b5 | 10 | idThread2 = osThreadGetId(); //получаем id потока |
yefremovv | 0:011a309655b5 | 11 | //настройка соединения |
yefremovv | 0:011a309655b5 | 12 | eth.set_network(ip, Mask, Gateway); |
yefremovv | 0:011a309655b5 | 13 | //иниц. eth |
yefremovv | 0:011a309655b5 | 14 | eth.connect(); |
yefremovv | 0:011a309655b5 | 15 | //иниц. udp |
yefremovv | 0:011a309655b5 | 16 | sock9003.open(ð); |
yefremovv | 0:011a309655b5 | 17 | sock9003.bind(9003); |
yefremovv | 0:011a309655b5 | 18 | sock9003.set_blocking(false); //неблокир. режим |
yefremovv | 0:011a309655b5 | 19 | sock9006.open(ð); |
yefremovv | 0:011a309655b5 | 20 | sock9006.bind(9006); |
yefremovv | 0:011a309655b5 | 21 | sock9006.set_blocking(false); |
yefremovv | 0:011a309655b5 | 22 | //таймер таймаута связи с сервером |
yefremovv | 0:011a309655b5 | 23 | tickerConn.attach(&workConn, 30); |
yefremovv | 0:011a309655b5 | 24 | |
yefremovv | 0:011a309655b5 | 25 | char ppp[46]; |
yefremovv | 0:011a309655b5 | 26 | time_t create_message_t, train_start_t; //время формирования сообщения, время отправления |
yefremovv | 0:011a309655b5 | 27 | |
yefremovv | 0:011a309655b5 | 28 | while(1) |
yefremovv | 0:011a309655b5 | 29 | { |
yefremovv | 0:011a309655b5 | 30 | //пакет со временем |
yefremovv | 0:011a309655b5 | 31 | if(sock9003.recvfrom(&sockAddr, ppp, LEN_PACK_9003) == LEN_PACK_9003 && ppp[3] == 143) |
yefremovv | 0:011a309655b5 | 32 | { |
yefremovv | 0:011a309655b5 | 33 | flEth = 1; //флаг подтверждения связи |
yefremovv | 0:011a309655b5 | 34 | tickerConn.detach(); //перезапускаем таймер |
yefremovv | 0:011a309655b5 | 35 | tickerConn.attach(&workConn, 30); |
yefremovv | 0:011a309655b5 | 36 | unixtime = (ppp[7]<<24) + (ppp[6]<<16) + (ppp[5]<<8) + ppp[4]; |
yefremovv | 0:011a309655b5 | 37 | //конвертация unix-времени в нормальный вид |
yefremovv | 0:011a309655b5 | 38 | tmu = *localtime(&unixtime); |
yefremovv | 0:011a309655b5 | 39 | if((abs(tmu.tm_sec - t.tm_sec) > 1) || (tmu.tm_min != t.tm_min) || ((tmu.tm_hour) != t.tm_hour)) //сравниваем времена |
yefremovv | 0:011a309655b5 | 40 | { |
yefremovv | 0:011a309655b5 | 41 | //устанавливаем новое время |
yefremovv | 0:011a309655b5 | 42 | t.tm_hour = tmu.tm_hour; |
yefremovv | 0:011a309655b5 | 43 | t.tm_min = tmu.tm_min; |
yefremovv | 0:011a309655b5 | 44 | t.tm_sec = tmu.tm_sec; |
yefremovv | 0:011a309655b5 | 45 | sTime = mktime(&t); |
yefremovv | 0:011a309655b5 | 46 | sTime = sTime - (7 * 3600); |
yefremovv | 0:011a309655b5 | 47 | set_time(sTime); |
yefremovv | 0:011a309655b5 | 48 | } |
yefremovv | 0:011a309655b5 | 49 | memset(ppp, 0, LEN_PACK_9003); |
yefremovv | 0:011a309655b5 | 50 | } |
yefremovv | 0:011a309655b5 | 51 | |
yefremovv | 0:011a309655b5 | 52 | //пакет с инфой для ПУИ |
yefremovv | 0:011a309655b5 | 53 | if(sock9006.recvfrom(&sockAddr, ppp, LEN_PACK_9006) == LEN_PACK_9006) |
yefremovv | 0:011a309655b5 | 54 | { |
yefremovv | 0:011a309655b5 | 55 | create_message_t = (ppp[7]<<24) + (ppp[6]<<16) + (ppp[5]<<8) + ppp[4]; |
yefremovv | 0:011a309655b5 | 56 | train_start_t = (ppp[30]<<24) + (ppp[29]<<16) + (ppp[28]<<8) + ppp[27]; |
yefremovv | 0:011a309655b5 | 57 | stat_b = ppp[14]; |
yefremovv | 0:011a309655b5 | 58 | |
yefremovv | 0:011a309655b5 | 59 | if(train_start_t > create_message_t) |
yefremovv | 0:011a309655b5 | 60 | { |
yefremovv | 0:011a309655b5 | 61 | train_start_t = train_start_t - create_message_t; |
yefremovv | 0:011a309655b5 | 62 | tmuPui = *localtime(&train_start_t); |
yefremovv | 0:011a309655b5 | 63 | |
yefremovv | 0:011a309655b5 | 64 | switch(stat_b) |
yefremovv | 0:011a309655b5 | 65 | { |
yefremovv | 0:011a309655b5 | 66 | case 1: |
yefremovv | 0:011a309655b5 | 67 | //время |
yefremovv | 0:011a309655b5 | 68 | sec1 = tmuPui.tm_min * 60 + tmuPui.tm_sec; //получаем секунды до отправления |
yefremovv | 0:011a309655b5 | 69 | flMut.lock(); |
yefremovv | 0:011a309655b5 | 70 | flRecT1 = 1; |
yefremovv | 0:011a309655b5 | 71 | flMut.unlock(); |
yefremovv | 0:011a309655b5 | 72 | flWorkT1 = fl1NP = 1; |
yefremovv | 0:011a309655b5 | 73 | pui1SetTime(train_start_t); |
yefremovv | 0:011a309655b5 | 74 | //станция |
yefremovv | 0:011a309655b5 | 75 | numStat1 = (ppp[25] / 16) * 16 * 16 * 16 + (ppp[25] % 16) * 16 * 16 + (ppp[26] / 16) * 16 + ppp[26] % 16; |
yefremovv | 0:011a309655b5 | 76 | flMut.lock(); |
yefremovv | 0:011a309655b5 | 77 | flRec1 = 1; |
yefremovv | 0:011a309655b5 | 78 | flMut.unlock(); |
yefremovv | 0:011a309655b5 | 79 | sendStatPui1(numStat1); |
yefremovv | 0:011a309655b5 | 80 | break; |
yefremovv | 0:011a309655b5 | 81 | |
yefremovv | 0:011a309655b5 | 82 | case 2: |
yefremovv | 0:011a309655b5 | 83 | //время |
yefremovv | 0:011a309655b5 | 84 | sec2 = tmuPui.tm_min * 60 + tmuPui.tm_sec; //получаем секунды до отправления |
yefremovv | 0:011a309655b5 | 85 | flMut.lock(); |
yefremovv | 0:011a309655b5 | 86 | flRecT2 = 1; |
yefremovv | 0:011a309655b5 | 87 | flMut.unlock(); |
yefremovv | 0:011a309655b5 | 88 | fl2NP = flWorkT2 = 1; |
yefremovv | 0:011a309655b5 | 89 | pui2SetTime(train_start_t); |
yefremovv | 0:011a309655b5 | 90 | //станция |
yefremovv | 0:011a309655b5 | 91 | numStat2 = (ppp[25] / 16) * 16 * 16 * 16 + (ppp[25] % 16) * 16 * 16 + (ppp[26] / 16) * 16 + ppp[26] % 16; |
yefremovv | 0:011a309655b5 | 92 | flMut.lock(); |
yefremovv | 0:011a309655b5 | 93 | flRec2 = 1; |
yefremovv | 0:011a309655b5 | 94 | flMut.unlock(); |
yefremovv | 0:011a309655b5 | 95 | sendStatPui2(numStat2); |
yefremovv | 0:011a309655b5 | 96 | break; |
yefremovv | 0:011a309655b5 | 97 | } |
yefremovv | 0:011a309655b5 | 98 | } |
yefremovv | 0:011a309655b5 | 99 | memset(ppp, 0, LEN_PACK_9006); |
yefremovv | 0:011a309655b5 | 100 | } |
yefremovv | 0:011a309655b5 | 101 | } |
yefremovv | 0:011a309655b5 | 102 | } |
yefremovv | 0:011a309655b5 | 103 | |
yefremovv | 0:011a309655b5 | 104 | int main(){ |
yefremovv | 0:011a309655b5 | 105 | StartIWDG(5000); //иниц. и запуск. wdt |
yefremovv | 0:011a309655b5 | 106 | //эмблема |
yefremovv | 0:011a309655b5 | 107 | logo(); |
yefremovv | 0:011a309655b5 | 108 | //иниц. тачпада |
yefremovv | 0:011a309655b5 | 109 | ts.Init(lcd.GetXSize(), lcd.GetYSize()); |
yefremovv | 0:011a309655b5 | 110 | //иниц. qspi |
yefremovv | 0:011a309655b5 | 111 | qspi.Init(); |
yefremovv | 0:011a309655b5 | 112 | //загрузка ip из флеш |
yefremovv | 0:011a309655b5 | 113 | qspi.Read((uint8_t*)readBuf, WRITE_READ_ADDR, 16); |
yefremovv | 0:011a309655b5 | 114 | readBuf[15] = '\0'; |
yefremovv | 0:011a309655b5 | 115 | //формируем буфер на отображение |
yefremovv | 0:011a309655b5 | 116 | int len = strlen(readBuf)+1; |
yefremovv | 0:011a309655b5 | 117 | r = new char[len]; |
yefremovv | 0:011a309655b5 | 118 | for(int i=0; i<len; i++) |
yefremovv | 0:011a309655b5 | 119 | r[i] = readBuf[i]; |
yefremovv | 0:011a309655b5 | 120 | r[len] = 0; |
yefremovv | 0:011a309655b5 | 121 | //проверка ip |
yefremovv | 0:011a309655b5 | 122 | if(checkIP(r)) //если есть |
yefremovv | 0:011a309655b5 | 123 | threadEth.start(workEth); //заводим второй поток |
yefremovv | 0:011a309655b5 | 124 | |
yefremovv | 0:011a309655b5 | 125 | lcd.SetFont(&FontNum); |
yefremovv | 0:011a309655b5 | 126 | //установка часов RTC |
yefremovv | 0:011a309655b5 | 127 | setClock(); |
yefremovv | 0:011a309655b5 | 128 | //отправка яркости на экран |
yefremovv | 0:011a309655b5 | 129 | brightness1 = !brightness1; |
yefremovv | 0:011a309655b5 | 130 | brightness2 = !brightness2; |
yefremovv | 0:011a309655b5 | 131 | //сохр. отправленные пакеты |
yefremovv | 0:011a309655b5 | 132 | bufSend1[0] = 32; |
yefremovv | 0:011a309655b5 | 133 | bufSend1[1] = 15; |
yefremovv | 0:011a309655b5 | 134 | bufSend1[2] = '\0'; |
yefremovv | 0:011a309655b5 | 135 | memmove(bufSend2, bufSend1, 2); |
yefremovv | 0:011a309655b5 | 136 | //ожидание ответа от ПУИ1/ПУИ2 |
yefremovv | 0:011a309655b5 | 137 | ansPui1(); |
yefremovv | 0:011a309655b5 | 138 | ansPui2(); |
yefremovv | 0:011a309655b5 | 139 | //отрисовка главного окна |
yefremovv | 0:011a309655b5 | 140 | mainWindow(); |
yefremovv | 0:011a309655b5 | 141 | |
yefremovv | 0:011a309655b5 | 142 | short st1 = 0, st2 = 0; //для анализа очистки полей станций |
yefremovv | 0:011a309655b5 | 143 | |
yefremovv | 0:011a309655b5 | 144 | while(1) |
yefremovv | 0:011a309655b5 | 145 | { |
yefremovv | 0:011a309655b5 | 146 | HAL_IWDG_Refresh(&IwdgHandle); //сброс wdt |
yefremovv | 0:011a309655b5 | 147 | wait_ms(50); |
yefremovv | 0:011a309655b5 | 148 | |
yefremovv | 0:011a309655b5 | 149 | if(flWdtTh) //опрос флага зависания дочернего потока |
yefremovv | 0:011a309655b5 | 150 | { |
yefremovv | 0:011a309655b5 | 151 | flWdtTh = 0; |
yefremovv | 0:011a309655b5 | 152 | if(osThreadGetState(idThread2) < 0) |
yefremovv | 0:011a309655b5 | 153 | NVIC_SystemReset(); |
yefremovv | 0:011a309655b5 | 154 | } |
yefremovv | 0:011a309655b5 | 155 | |
yefremovv | 0:011a309655b5 | 156 | //мониторим флаги flEth, flRec1, flRec2 |
yefremovv | 0:011a309655b5 | 157 | if(fl1 != flEth) //если есть связь по eth |
yefremovv | 0:011a309655b5 | 158 | { |
yefremovv | 0:011a309655b5 | 159 | fl1 = flEth; |
yefremovv | 0:011a309655b5 | 160 | lcd.Clear(LCD_COLOR_BLACK); |
yefremovv | 0:011a309655b5 | 161 | mainWindow(); |
yefremovv | 0:011a309655b5 | 162 | } |
yefremovv | 0:011a309655b5 | 163 | |
yefremovv | 0:011a309655b5 | 164 | if(flRecT1) //если отобразить секунды1 |
yefremovv | 0:011a309655b5 | 165 | { |
yefremovv | 0:011a309655b5 | 166 | flRecT1 = 0; |
yefremovv | 0:011a309655b5 | 167 | flSec1 = 1; |
yefremovv | 0:011a309655b5 | 168 | } |
yefremovv | 0:011a309655b5 | 169 | |
yefremovv | 0:011a309655b5 | 170 | if(flRecT2) //если отобразить секунды2 |
yefremovv | 0:011a309655b5 | 171 | { |
yefremovv | 0:011a309655b5 | 172 | flRecT2 = 0; |
yefremovv | 0:011a309655b5 | 173 | if(visible) //только для 2 пути, т.к. накладывается на меню |
yefremovv | 0:011a309655b5 | 174 | flSec2 = 1; |
yefremovv | 0:011a309655b5 | 175 | } |
yefremovv | 0:011a309655b5 | 176 | |
yefremovv | 0:011a309655b5 | 177 | if(flRec1) //если отобразить название станции1 |
yefremovv | 0:011a309655b5 | 178 | { |
yefremovv | 0:011a309655b5 | 179 | flRec1 = 0; |
yefremovv | 0:011a309655b5 | 180 | flWork1 = 1; |
yefremovv | 0:011a309655b5 | 181 | if(st1 != numStat1) //чистим строку экрана |
yefremovv | 0:011a309655b5 | 182 | { |
yefremovv | 0:011a309655b5 | 183 | lcd.SetTextColor(LCD_COLOR_BLACK); |
yefremovv | 0:011a309655b5 | 184 | lcd.FillRect(5, 250, 235, 20); |
yefremovv | 0:011a309655b5 | 185 | lcd.SetTextColor(LCD_COLOR_LIGHTGREEN); //white |
yefremovv | 0:011a309655b5 | 186 | st1 = numStat1; |
yefremovv | 0:011a309655b5 | 187 | } |
yefremovv | 0:011a309655b5 | 188 | viewStation(numStat1, 0); |
yefremovv | 0:011a309655b5 | 189 | } |
yefremovv | 0:011a309655b5 | 190 | |
yefremovv | 0:011a309655b5 | 191 | if(flRec2) //если отобразить название станции2 |
yefremovv | 0:011a309655b5 | 192 | { |
yefremovv | 0:011a309655b5 | 193 | flRec2 = 0; |
yefremovv | 0:011a309655b5 | 194 | flWork2 = 1; |
yefremovv | 0:011a309655b5 | 195 | if(st2 != numStat2) //чистим строку экрана |
yefremovv | 0:011a309655b5 | 196 | { |
yefremovv | 0:011a309655b5 | 197 | lcd.SetTextColor(LCD_COLOR_BLACK); |
yefremovv | 0:011a309655b5 | 198 | lcd.FillRect(241, 250, 236, 20); |
yefremovv | 0:011a309655b5 | 199 | lcd.SetTextColor(LCD_COLOR_LIGHTGREEN); //white |
yefremovv | 0:011a309655b5 | 200 | st2 = numStat2; |
yefremovv | 0:011a309655b5 | 201 | if(!visible) |
yefremovv | 0:011a309655b5 | 202 | settingBut(); |
yefremovv | 0:011a309655b5 | 203 | } |
yefremovv | 0:011a309655b5 | 204 | if(visible) |
yefremovv | 0:011a309655b5 | 205 | viewStation(numStat2, 1); |
yefremovv | 0:011a309655b5 | 206 | } |
yefremovv | 0:011a309655b5 | 207 | |
yefremovv | 0:011a309655b5 | 208 | ts.GetState(&TS_State); |
yefremovv | 0:011a309655b5 | 209 | if(TS_State.touchDetected) |
yefremovv | 0:011a309655b5 | 210 | { |
yefremovv | 0:011a309655b5 | 211 | wait_ms(50); |
yefremovv | 0:011a309655b5 | 212 | |
yefremovv | 0:011a309655b5 | 213 | for(uint8_t ind = 0; ind < TS_State.touchDetected; ind++) |
yefremovv | 0:011a309655b5 | 214 | { |
yefremovv | 0:011a309655b5 | 215 | uint16_t x = TS_State.touchX[ind]; |
yefremovv | 0:011a309655b5 | 216 | uint16_t y = TS_State.touchY[ind]; |
yefremovv | 0:011a309655b5 | 217 | if((x >= 434 && x <= 479) && (y >= 1 && y <= 45)) //второй экран |
yefremovv | 0:011a309655b5 | 218 | { |
yefremovv | 0:011a309655b5 | 219 | if(flTest) |
yefremovv | 0:011a309655b5 | 220 | { |
yefremovv | 0:011a309655b5 | 221 | flTest = flSec1 = flSec2 = 0; |
yefremovv | 0:011a309655b5 | 222 | fl1NP = fl2NP = 1; |
yefremovv | 0:011a309655b5 | 223 | sec1 = sec2 = 0; |
yefremovv | 0:011a309655b5 | 224 | //зачищаем старую кнопку |
yefremovv | 0:011a309655b5 | 225 | lcd.SetTextColor(LCD_COLOR_BLACK); |
yefremovv | 0:011a309655b5 | 226 | lcd.FillRect(434, 0, 45, 45); |
yefremovv | 0:011a309655b5 | 227 | lcd.SetTextColor(LCD_COLOR_LIGHTGREEN); //white |
yefremovv | 0:011a309655b5 | 228 | mainWindow(); |
yefremovv | 0:011a309655b5 | 229 | break; |
yefremovv | 0:011a309655b5 | 230 | } |
yefremovv | 0:011a309655b5 | 231 | |
yefremovv | 0:011a309655b5 | 232 | if(visible) |
yefremovv | 0:011a309655b5 | 233 | { |
yefremovv | 0:011a309655b5 | 234 | flSec2 = 0; |
yefremovv | 0:011a309655b5 | 235 | settingBut(); |
yefremovv | 0:011a309655b5 | 236 | } |
yefremovv | 0:011a309655b5 | 237 | else |
yefremovv | 0:011a309655b5 | 238 | { |
yefremovv | 0:011a309655b5 | 239 | if(flTest || flWorkT2) |
yefremovv | 0:011a309655b5 | 240 | flSec2 = 1; |
yefremovv | 0:011a309655b5 | 241 | lcd.Clear(LCD_COLOR_BLACK); |
yefremovv | 0:011a309655b5 | 242 | mainWindow(); |
yefremovv | 0:011a309655b5 | 243 | } |
yefremovv | 0:011a309655b5 | 244 | visible = !visible; |
yefremovv | 0:011a309655b5 | 245 | wait_ms(80); |
yefremovv | 0:011a309655b5 | 246 | } |
yefremovv | 0:011a309655b5 | 247 | |
yefremovv | 0:011a309655b5 | 248 | if((x >= 319 && x <= 476) && (y >= 49 && y <= 119) && !visible) //тест |
yefremovv | 0:011a309655b5 | 249 | { |
yefremovv | 0:011a309655b5 | 250 | flWork1 = flWork2 = 0; //перекрываем отображ. станций |
yefremovv | 0:011a309655b5 | 251 | flWorkT1 = flWorkT2 = 0; //останавливаем рабочий режим |
yefremovv | 0:011a309655b5 | 252 | //отправка команд на уст-во |
yefremovv | 0:011a309655b5 | 253 | bufSend1[0] = 64; |
yefremovv | 0:011a309655b5 | 254 | bufSend1[1] = 10; |
yefremovv | 0:011a309655b5 | 255 | memmove(bufSend2, bufSend1, 3); |
yefremovv | 0:011a309655b5 | 256 | //1-ая команда |
yefremovv | 0:011a309655b5 | 257 | ansPui1(); |
yefremovv | 0:011a309655b5 | 258 | ansPui2(); |
yefremovv | 0:011a309655b5 | 259 | wait_ms(80); |
yefremovv | 0:011a309655b5 | 260 | |
yefremovv | 0:011a309655b5 | 261 | bufSend1[0] = 128; |
yefremovv | 0:011a309655b5 | 262 | bufSend1[1] = 31; |
yefremovv | 0:011a309655b5 | 263 | memmove(bufSend2, bufSend1, 3); |
yefremovv | 0:011a309655b5 | 264 | //2-ая команда |
yefremovv | 0:011a309655b5 | 265 | ansPui1(); |
yefremovv | 0:011a309655b5 | 266 | ansPui2(); |
yefremovv | 0:011a309655b5 | 267 | wait_ms(80); //????????? |
yefremovv | 0:011a309655b5 | 268 | |
yefremovv | 0:011a309655b5 | 269 | //запуск у себя |
yefremovv | 0:011a309655b5 | 270 | fl2NP = fl1NP = 1; |
yefremovv | 0:011a309655b5 | 271 | sec2 = sec1 = 30; //выставляем кол-во тестовых секунд |
yefremovv | 0:011a309655b5 | 272 | flTest = flTime = flSec1 = flSec2 = 1; //уст-ка флагов таймеров |
yefremovv | 0:011a309655b5 | 273 | visible = 1; |
yefremovv | 0:011a309655b5 | 274 | lcd.Clear(LCD_COLOR_BLACK); |
yefremovv | 0:011a309655b5 | 275 | lcd.SetTextColor(LCD_COLOR_YELLOW); |
yefremovv | 0:011a309655b5 | 276 | mainWindow(); |
yefremovv | 0:011a309655b5 | 277 | } |
yefremovv | 0:011a309655b5 | 278 | |
yefremovv | 0:011a309655b5 | 279 | if((x >= 319 && x <= 476) && (y >= 120 && y <= 190) && !visible) //яркость |
yefremovv | 0:011a309655b5 | 280 | drawSelector(); |
yefremovv | 0:011a309655b5 | 281 | |
yefremovv | 0:011a309655b5 | 282 | if((x >= 319 && x <= 476) && (y >= 191 && y <= 261) && !visible) //конфигурация |
yefremovv | 0:011a309655b5 | 283 | configWindow(); |
yefremovv | 0:011a309655b5 | 284 | } |
yefremovv | 0:011a309655b5 | 285 | } |
yefremovv | 0:011a309655b5 | 286 | } |
yefremovv | 0:011a309655b5 | 287 | } |
yefremovv | 0:011a309655b5 | 288 | |
yefremovv | 0:011a309655b5 | 289 | //отрисовка главного окна |
yefremovv | 0:011a309655b5 | 290 | void mainWindow(){ |
yefremovv | 0:011a309655b5 | 291 | //рамка |
yefremovv | 0:011a309655b5 | 292 | lcd.DrawRect(0, 0, 479, 271); |
yefremovv | 0:011a309655b5 | 293 | lcd.DrawRect(1, 1, 477, 269); |
yefremovv | 0:011a309655b5 | 294 | lcd.DrawRect(2, 2, 475, 267); |
yefremovv | 0:011a309655b5 | 295 | //разделители |
yefremovv | 0:011a309655b5 | 296 | lcd.DrawHLine(0, 100, 479); |
yefremovv | 0:011a309655b5 | 297 | lcd.DrawVLine(240, 100, 171); |
yefremovv | 0:011a309655b5 | 298 | |
yefremovv | 0:011a309655b5 | 299 | if(flTest || flWorkT1 || flWorkT2) |
yefremovv | 0:011a309655b5 | 300 | { |
yefremovv | 0:011a309655b5 | 301 | lcd.SetFont(&FontNum); |
yefremovv | 0:011a309655b5 | 302 | strftime(buf, 10, "%H:%M:%S", localtime(&sTime)); |
yefremovv | 0:011a309655b5 | 303 | lcd.DisplayStringAt(38, 50, (uint8_t *)buf, LEFT_MODE); |
yefremovv | 0:011a309655b5 | 304 | //отрисовка секундомеров |
yefremovv | 0:011a309655b5 | 305 | if(fl1NP) |
yefremovv | 0:011a309655b5 | 306 | strftime(buf1, 10, "%M:%S ", localtime(&s1Time)); //пробел ОБЯЗАТЕЛЕН |
yefremovv | 0:011a309655b5 | 307 | else |
yefremovv | 0:011a309655b5 | 308 | strftime(buf1, 10, "-%M:%S", localtime(&s1Time)); |
yefremovv | 0:011a309655b5 | 309 | |
yefremovv | 0:011a309655b5 | 310 | if(fl2NP) |
yefremovv | 0:011a309655b5 | 311 | strftime(buf2, 10, " %M:%S", localtime(&s2Time)); |
yefremovv | 0:011a309655b5 | 312 | else |
yefremovv | 0:011a309655b5 | 313 | strftime(buf2, 10, "-%M:%S", localtime(&s2Time)); |
yefremovv | 0:011a309655b5 | 314 | lcd.DisplayStringAt(50, 180, (uint8_t *)buf1, LEFT_MODE); |
yefremovv | 0:011a309655b5 | 315 | lcd.DisplayStringAt(60, 180, (uint8_t *)buf2, RIGHT_MODE); |
yefremovv | 0:011a309655b5 | 316 | } |
yefremovv | 0:011a309655b5 | 317 | else |
yefremovv | 0:011a309655b5 | 318 | { |
yefremovv | 0:011a309655b5 | 319 | if(!flSec1) |
yefremovv | 0:011a309655b5 | 320 | { |
yefremovv | 0:011a309655b5 | 321 | flSec1 = 1; |
yefremovv | 0:011a309655b5 | 322 | viewTimerSec(); |
yefremovv | 0:011a309655b5 | 323 | flSec1 = 0; |
yefremovv | 0:011a309655b5 | 324 | } |
yefremovv | 0:011a309655b5 | 325 | if(!flSec2) |
yefremovv | 0:011a309655b5 | 326 | { |
yefremovv | 0:011a309655b5 | 327 | flSec2 = 1; |
yefremovv | 0:011a309655b5 | 328 | viewTimerSec(); |
yefremovv | 0:011a309655b5 | 329 | flSec2 = 0; |
yefremovv | 0:011a309655b5 | 330 | } |
yefremovv | 0:011a309655b5 | 331 | } |
yefremovv | 0:011a309655b5 | 332 | |
yefremovv | 0:011a309655b5 | 333 | //вывод названий станций |
yefremovv | 0:011a309655b5 | 334 | if(flWork1) |
yefremovv | 0:011a309655b5 | 335 | viewStation(numStat1, 0); |
yefremovv | 0:011a309655b5 | 336 | if(flWork2) |
yefremovv | 0:011a309655b5 | 337 | viewStation(numStat2, 1); |
yefremovv | 0:011a309655b5 | 338 | //главные служебные значки |
yefremovv | 0:011a309655b5 | 339 | lcd.DisplayStringAt(10, 10, (uint8_t *)"\"", LEFT_MODE); |
yefremovv | 0:011a309655b5 | 340 | if(flEth) |
yefremovv | 0:011a309655b5 | 341 | lcd.DisplayStringAt(38, 10, (uint8_t *)"&", LEFT_MODE); //если есть связь |
yefremovv | 0:011a309655b5 | 342 | else |
yefremovv | 0:011a309655b5 | 343 | lcd.DisplayStringAt(38, 10, (uint8_t *)"%", LEFT_MODE); //если нет связи |
yefremovv | 0:011a309655b5 | 344 | |
yefremovv | 0:011a309655b5 | 345 | //путь 1 |
yefremovv | 0:011a309655b5 | 346 | if(brightness1) |
yefremovv | 0:011a309655b5 | 347 | lcd.DisplayStringAt(10, 115, (uint8_t *)"#", LEFT_MODE); //если ярче |
yefremovv | 0:011a309655b5 | 348 | else |
yefremovv | 0:011a309655b5 | 349 | lcd.DisplayStringAt(10, 115, (uint8_t *)"$", LEFT_MODE); //если тусклее |
yefremovv | 0:011a309655b5 | 350 | if(flCon1) |
yefremovv | 0:011a309655b5 | 351 | lcd.DisplayStringAt(38, 115, (uint8_t *)"'", LEFT_MODE); //если есть связь |
yefremovv | 0:011a309655b5 | 352 | else |
yefremovv | 0:011a309655b5 | 353 | lcd.DisplayStringAt(38, 115, (uint8_t *)"%", LEFT_MODE); //если нет связи |
yefremovv | 0:011a309655b5 | 354 | //путь 2 |
yefremovv | 0:011a309655b5 | 355 | if(brightness2) |
yefremovv | 0:011a309655b5 | 356 | lcd.DisplayStringAt(210, 115, (uint8_t *)"#", RIGHT_MODE); //если ярче |
yefremovv | 0:011a309655b5 | 357 | else |
yefremovv | 0:011a309655b5 | 358 | lcd.DisplayStringAt(210, 115, (uint8_t *)"$", RIGHT_MODE); //если тусклее |
yefremovv | 0:011a309655b5 | 359 | if(flCon2) |
yefremovv | 0:011a309655b5 | 360 | lcd.DisplayStringAt(182, 115, (uint8_t *)"'", RIGHT_MODE); //если есть связь |
yefremovv | 0:011a309655b5 | 361 | else |
yefremovv | 0:011a309655b5 | 362 | lcd.DisplayStringAt(182, 115, (uint8_t *)"%", RIGHT_MODE); //если нет связи |
yefremovv | 0:011a309655b5 | 363 | //подписи путей |
yefremovv | 0:011a309655b5 | 364 | lcd.SetFont(&FontRus); |
yefremovv | 0:011a309655b5 | 365 | lcd.DisplayStringAt(170, 115, (uint8_t *)"1 PTSc", LEFT_MODE); //1 путь |
yefremovv | 0:011a309655b5 | 366 | lcd.DisplayStringAt(15, 115, (uint8_t *)"2 PTSc", RIGHT_MODE); //2 путь |
yefremovv | 0:011a309655b5 | 367 | |
yefremovv | 0:011a309655b5 | 368 | if(flTest) |
yefremovv | 0:011a309655b5 | 369 | { |
yefremovv | 0:011a309655b5 | 370 | //кнопка "Назад" |
yefremovv | 0:011a309655b5 | 371 | lcd.SetFont(&FontBigRus); |
yefremovv | 0:011a309655b5 | 372 | lcd.DisplayStringAt(0, 5, (uint8_t *)"SFRS", CENTER_MODE); |
yefremovv | 0:011a309655b5 | 373 | lcd.SetFont(&FontRus); |
yefremovv | 0:011a309655b5 | 374 | Point pt_[3]; |
yefremovv | 0:011a309655b5 | 375 | pt_[0] = (Point){441, 22}; |
yefremovv | 0:011a309655b5 | 376 | pt_[1] = (Point){472, 10}; |
yefremovv | 0:011a309655b5 | 377 | pt_[2] = (Point){472, 35}; |
yefremovv | 0:011a309655b5 | 378 | lcd.FillPolygon(pt_, 3); |
yefremovv | 0:011a309655b5 | 379 | } |
yefremovv | 0:011a309655b5 | 380 | else |
yefremovv | 0:011a309655b5 | 381 | { |
yefremovv | 0:011a309655b5 | 382 | //кнопка "Настройки" |
yefremovv | 0:011a309655b5 | 383 | lcd.SetFont(&FontBigRus); |
yefremovv | 0:011a309655b5 | 384 | lcd.DisplayStringAt(0, 5, (uint8_t *)"QABOSA", CENTER_MODE); |
yefremovv | 0:011a309655b5 | 385 | lcd.SetFont(&FontRus); |
yefremovv | 0:011a309655b5 | 386 | lcd.FillRect(440, 7, 33, 3); //линия 1 //4 |
yefremovv | 0:011a309655b5 | 387 | lcd.FillRect(440, 21, 33, 3); //линия 2 |
yefremovv | 0:011a309655b5 | 388 | lcd.FillRect(440, 36,33, 3); //линия 3 |
yefremovv | 0:011a309655b5 | 389 | } |
yefremovv | 0:011a309655b5 | 390 | } |
yefremovv | 0:011a309655b5 | 391 | |
yefremovv | 0:011a309655b5 | 392 | //меню настроек |
yefremovv | 0:011a309655b5 | 393 | void settingBut(){ |
yefremovv | 0:011a309655b5 | 394 | lcd.SetFont(&FontBigRus); |
yefremovv | 0:011a309655b5 | 395 | lcd.DrawRect(315, 46, 164, 218); |
yefremovv | 0:011a309655b5 | 396 | lcd.FillRect(319, 49, 157, 70); //кнопка 1 |
yefremovv | 0:011a309655b5 | 397 | lcd.FillRect(319, 120, 157, 70); //кнопка 2 |
yefremovv | 0:011a309655b5 | 398 | lcd.FillRect(319, 191, 157, 70); //кнопка 3 |
yefremovv | 0:011a309655b5 | 399 | //надписи на кнопках |
yefremovv | 0:011a309655b5 | 400 | lcd.SetBackColor(LCD_COLOR_LIGHTGREEN); //white |
yefremovv | 0:011a309655b5 | 401 | lcd.SetTextColor(LCD_COLOR_BLACK); |
yefremovv | 0:011a309655b5 | 402 | |
yefremovv | 0:011a309655b5 | 403 | lcd.DisplayChar(362, 74, 0x53); //T |
yefremovv | 0:011a309655b5 | 404 | lcd.DisplayChar(379, 74, 0x46); //E |
yefremovv | 0:011a309655b5 | 405 | lcd.DisplayChar(396, 74, 0x52); //S |
yefremovv | 0:011a309655b5 | 406 | lcd.DisplayChar(413, 74, 0x53); //T |
yefremovv | 0:011a309655b5 | 407 | // |
yefremovv | 0:011a309655b5 | 408 | lcd.DisplayChar(337, 144, 0x66); //Я |
yefremovv | 0:011a309655b5 | 409 | lcd.DisplayChar(354, 144, 0x51); //Р |
yefremovv | 0:011a309655b5 | 410 | lcd.DisplayChar(371, 144, 0x4B); //К |
yefremovv | 0:011a309655b5 | 411 | lcd.DisplayChar(388, 144, 0x4F); //О |
yefremovv | 0:011a309655b5 | 412 | lcd.DisplayChar(405, 144, 0x52); //С |
yefremovv | 0:011a309655b5 | 413 | lcd.DisplayChar(422, 144, 0x53); //Т |
yefremovv | 0:011a309655b5 | 414 | lcd.DisplayChar(439, 144, 0x63); //Ь |
yefremovv | 0:011a309655b5 | 415 | // |
yefremovv | 0:011a309655b5 | 416 | lcd.DisplayChar(362, 214, 0x52); //O |
yefremovv | 0:011a309655b5 | 417 | lcd.DisplayChar(379, 214, 0x46); //N |
yefremovv | 0:011a309655b5 | 418 | lcd.DisplayChar(396, 214, 0x53); //F |
yefremovv | 0:011a309655b5 | 419 | lcd.DisplayChar(413, 214, 0x63); //I |
yefremovv | 0:011a309655b5 | 420 | |
yefremovv | 0:011a309655b5 | 421 | lcd.SetBackColor(LCD_COLOR_BLACK); |
yefremovv | 0:011a309655b5 | 422 | lcd.SetTextColor(LCD_COLOR_LIGHTGREEN); //white |
yefremovv | 0:011a309655b5 | 423 | lcd.SetFont(&FontNum); |
yefremovv | 0:011a309655b5 | 424 | } |
yefremovv | 0:011a309655b5 | 425 | |
yefremovv | 0:011a309655b5 | 426 | //окно настройки сети |
yefremovv | 0:011a309655b5 | 427 | void configWindow(){ |
yefremovv | 0:011a309655b5 | 428 | flNetW = 1; |
yefremovv | 0:011a309655b5 | 429 | visible = 1; |
yefremovv | 0:011a309655b5 | 430 | flTime = 0; |
yefremovv | 0:011a309655b5 | 431 | if(flSec1) |
yefremovv | 0:011a309655b5 | 432 | flSec1 = 0; |
yefremovv | 0:011a309655b5 | 433 | if(flSec2) |
yefremovv | 0:011a309655b5 | 434 | flSec2 = 0; |
yefremovv | 0:011a309655b5 | 435 | bool done = 0; //флаг выхода из фун-ии |
yefremovv | 0:011a309655b5 | 436 | lcd.Clear(LCD_COLOR_BLACK); |
yefremovv | 0:011a309655b5 | 437 | lcd.SetTextColor(LCD_COLOR_RED); |
yefremovv | 0:011a309655b5 | 438 | //рамка |
yefremovv | 0:011a309655b5 | 439 | lcd.DrawRect(0, 0, 479, 271); |
yefremovv | 0:011a309655b5 | 440 | lcd.DrawRect(1, 1, 477, 269); |
yefremovv | 0:011a309655b5 | 441 | lcd.DrawRect(2, 2, 475, 267); |
yefremovv | 0:011a309655b5 | 442 | //главные служебные значки |
yefremovv | 0:011a309655b5 | 443 | lcd.SetFont(&FontNum); |
yefremovv | 0:011a309655b5 | 444 | lcd.DisplayStringAt(10, 10, (uint8_t *)"\"", LEFT_MODE); |
yefremovv | 0:011a309655b5 | 445 | if(flEth) |
yefremovv | 0:011a309655b5 | 446 | lcd.DisplayStringAt(38, 10, (uint8_t *)"&", LEFT_MODE); //если есть связь |
yefremovv | 0:011a309655b5 | 447 | else |
yefremovv | 0:011a309655b5 | 448 | lcd.DisplayStringAt(38, 10, (uint8_t *)"%", LEFT_MODE); //если нет связи |
yefremovv | 0:011a309655b5 | 449 | //заголовок |
yefremovv | 0:011a309655b5 | 450 | lcd.SetFont(&FontBigRus); |
yefremovv | 0:011a309655b5 | 451 | lcd.DisplayStringAt(0, 5, (uint8_t *)"RFSc", CENTER_MODE); |
yefremovv | 0:011a309655b5 | 452 | lcd.SetFont(&Font24); |
yefremovv | 0:011a309655b5 | 453 | wait_ms(80); //100 |
yefremovv | 0:011a309655b5 | 454 | //IP адрес + кнопки |
yefremovv | 0:011a309655b5 | 455 | drawIP(); |
yefremovv | 0:011a309655b5 | 456 | //кнопка "назад" |
yefremovv | 0:011a309655b5 | 457 | Point pt_[3]; |
yefremovv | 0:011a309655b5 | 458 | pt_[0] = (Point){441, 22}; |
yefremovv | 0:011a309655b5 | 459 | pt_[1] = (Point){472, 10}; |
yefremovv | 0:011a309655b5 | 460 | pt_[2] = (Point){472, 35}; |
yefremovv | 0:011a309655b5 | 461 | lcd.FillPolygon(pt_, 3); |
yefremovv | 0:011a309655b5 | 462 | |
yefremovv | 0:011a309655b5 | 463 | while(!done) |
yefremovv | 0:011a309655b5 | 464 | { |
yefremovv | 0:011a309655b5 | 465 | HAL_IWDG_Refresh(&IwdgHandle); //сброс wdt |
yefremovv | 0:011a309655b5 | 466 | wait_ms(50); |
yefremovv | 0:011a309655b5 | 467 | |
yefremovv | 0:011a309655b5 | 468 | if(fl1 != flEth) //если есть связь по eth |
yefremovv | 0:011a309655b5 | 469 | { |
yefremovv | 0:011a309655b5 | 470 | fl1 = flEth; |
yefremovv | 0:011a309655b5 | 471 | lcd.SetTextColor(LCD_COLOR_BLACK); |
yefremovv | 0:011a309655b5 | 472 | lcd.FillRect(38, 10, 19, 29); |
yefremovv | 0:011a309655b5 | 473 | lcd.SetTextColor(LCD_COLOR_RED); |
yefremovv | 0:011a309655b5 | 474 | lcd.SetFont(&FontNum); |
yefremovv | 0:011a309655b5 | 475 | if(flEth) |
yefremovv | 0:011a309655b5 | 476 | lcd.DisplayStringAt(38, 10, (uint8_t *)"&", LEFT_MODE); //если есть связь |
yefremovv | 0:011a309655b5 | 477 | else |
yefremovv | 0:011a309655b5 | 478 | lcd.DisplayStringAt(38, 10, (uint8_t *)"%", LEFT_MODE); //если нет связи |
yefremovv | 0:011a309655b5 | 479 | lcd.SetFont(&Font24); |
yefremovv | 0:011a309655b5 | 480 | } |
yefremovv | 0:011a309655b5 | 481 | |
yefremovv | 0:011a309655b5 | 482 | ts.GetState(&TS_State); |
yefremovv | 0:011a309655b5 | 483 | if(TS_State.touchDetected) |
yefremovv | 0:011a309655b5 | 484 | { |
yefremovv | 0:011a309655b5 | 485 | wait_ms(50); |
yefremovv | 0:011a309655b5 | 486 | for(uint8_t ind = 0; ind < TS_State.touchDetected; ind++) |
yefremovv | 0:011a309655b5 | 487 | { |
yefremovv | 0:011a309655b5 | 488 | uint16_t x = TS_State.touchX[ind]; |
yefremovv | 0:011a309655b5 | 489 | uint16_t y = TS_State.touchY[ind]; |
yefremovv | 0:011a309655b5 | 490 | |
yefremovv | 0:011a309655b5 | 491 | if((x >= 300 && x<=459) && (y>=50 && y<= 258)) //набор ip-адреса //+-10 |
yefremovv | 0:011a309655b5 | 492 | { |
yefremovv | 0:011a309655b5 | 493 | wait_ms(80); |
yefremovv | 0:011a309655b5 | 494 | viewSymbol(defSymbol(x, y)); |
yefremovv | 0:011a309655b5 | 495 | } |
yefremovv | 0:011a309655b5 | 496 | |
yefremovv | 0:011a309655b5 | 497 | if((x >= 434 && x <= 479) && (y >= 1 && y <= 45)) //назад |
yefremovv | 0:011a309655b5 | 498 | { |
yefremovv | 0:011a309655b5 | 499 | backFunc(); |
yefremovv | 0:011a309655b5 | 500 | done = 1; |
yefremovv | 0:011a309655b5 | 501 | } |
yefremovv | 0:011a309655b5 | 502 | } |
yefremovv | 0:011a309655b5 | 503 | } |
yefremovv | 0:011a309655b5 | 504 | } |
yefremovv | 0:011a309655b5 | 505 | flNetW = 0; |
yefremovv | 0:011a309655b5 | 506 | } |
yefremovv | 0:011a309655b5 | 507 | |
yefremovv | 0:011a309655b5 | 508 | //выбор яркости |
yefremovv | 0:011a309655b5 | 509 | void drawSelector(){ |
yefremovv | 0:011a309655b5 | 510 | bool done = 0; |
yefremovv | 0:011a309655b5 | 511 | flLight = 1; |
yefremovv | 0:011a309655b5 | 512 | |
yefremovv | 0:011a309655b5 | 513 | lcd.SetFont(&FontBigRus); |
yefremovv | 0:011a309655b5 | 514 | lcd.DrawRect(171, 79, 144, 145); |
yefremovv | 0:011a309655b5 | 515 | lcd.FillRect(175, 82, 137, 70); //кнопка 1 |
yefremovv | 0:011a309655b5 | 516 | lcd.FillRect(175, 153, 137, 70); //кнопка 2 |
yefremovv | 0:011a309655b5 | 517 | //надписи на кнопках |
yefremovv | 0:011a309655b5 | 518 | lcd.SetBackColor(LCD_COLOR_LIGHTGREEN); //white |
yefremovv | 0:011a309655b5 | 519 | lcd.SetTextColor(LCD_COLOR_BLACK); |
yefremovv | 0:011a309655b5 | 520 | //1 |
yefremovv | 0:011a309655b5 | 521 | lcd.DisplayChar(200, 107, 0x50); //П |
yefremovv | 0:011a309655b5 | 522 | lcd.DisplayChar(217, 107, 0x54); //У |
yefremovv | 0:011a309655b5 | 523 | lcd.DisplayChar(234, 107, 0x49); //И |
yefremovv | 0:011a309655b5 | 524 | lcd.DisplayChar(268, 107, 0x31); //1 |
yefremovv | 0:011a309655b5 | 525 | //2 |
yefremovv | 0:011a309655b5 | 526 | lcd.DisplayChar(200, 177, 0x50); //П |
yefremovv | 0:011a309655b5 | 527 | lcd.DisplayChar(217, 177, 0x54); //У |
yefremovv | 0:011a309655b5 | 528 | lcd.DisplayChar(234, 177, 0x49); //И |
yefremovv | 0:011a309655b5 | 529 | lcd.DisplayChar(268, 177, 0x32); //2 |
yefremovv | 0:011a309655b5 | 530 | lcd.SetBackColor(LCD_COLOR_BLACK); |
yefremovv | 0:011a309655b5 | 531 | lcd.SetTextColor(LCD_COLOR_LIGHTGREEN); //white |
yefremovv | 0:011a309655b5 | 532 | lcd.SetFont(&FontNum); |
yefremovv | 0:011a309655b5 | 533 | |
yefremovv | 0:011a309655b5 | 534 | while(!done) |
yefremovv | 0:011a309655b5 | 535 | { |
yefremovv | 0:011a309655b5 | 536 | HAL_IWDG_Refresh(&IwdgHandle); //сброс wdt |
yefremovv | 0:011a309655b5 | 537 | wait_ms(50); |
yefremovv | 0:011a309655b5 | 538 | |
yefremovv | 0:011a309655b5 | 539 | ts.GetState(&TS_State); |
yefremovv | 0:011a309655b5 | 540 | if(TS_State.touchDetected) |
yefremovv | 0:011a309655b5 | 541 | { |
yefremovv | 0:011a309655b5 | 542 | wait_ms(50); |
yefremovv | 0:011a309655b5 | 543 | for(uint8_t ind = 0; ind < TS_State.touchDetected; ind++) |
yefremovv | 0:011a309655b5 | 544 | { |
yefremovv | 0:011a309655b5 | 545 | uint16_t x = TS_State.touchX[ind]; |
yefremovv | 0:011a309655b5 | 546 | uint16_t y = TS_State.touchY[ind]; |
yefremovv | 0:011a309655b5 | 547 | |
yefremovv | 0:011a309655b5 | 548 | if((x >= 175 && x <= 312) && (y >= 82 && y <= 152)) //пуи 1 |
yefremovv | 0:011a309655b5 | 549 | { |
yefremovv | 0:011a309655b5 | 550 | //пеепрключаем состояние |
yefremovv | 0:011a309655b5 | 551 | brightness1 = !brightness1; |
yefremovv | 0:011a309655b5 | 552 | //отправляем в com-порт |
yefremovv | 0:011a309655b5 | 553 | bufSend1[0] = 32; |
yefremovv | 0:011a309655b5 | 554 | if(brightness1) //если ярче |
yefremovv | 0:011a309655b5 | 555 | bufSend1[1] = 15; |
yefremovv | 0:011a309655b5 | 556 | else //если тусклее |
yefremovv | 0:011a309655b5 | 557 | bufSend1[1] = 1; |
yefremovv | 0:011a309655b5 | 558 | ansPui1(); |
yefremovv | 0:011a309655b5 | 559 | wait_ms(80); //????????? |
yefremovv | 0:011a309655b5 | 560 | if(flWorkT2) |
yefremovv | 0:011a309655b5 | 561 | flSec2 = 1; |
yefremovv | 0:011a309655b5 | 562 | visible = 1; |
yefremovv | 0:011a309655b5 | 563 | lcd.Clear(LCD_COLOR_BLACK); |
yefremovv | 0:011a309655b5 | 564 | mainWindow(); |
yefremovv | 0:011a309655b5 | 565 | done = 1; |
yefremovv | 0:011a309655b5 | 566 | } |
yefremovv | 0:011a309655b5 | 567 | |
yefremovv | 0:011a309655b5 | 568 | if((x >= 175 && x <= 312) && (y >= 153 && y <= 223)) //пуи 2 |
yefremovv | 0:011a309655b5 | 569 | { |
yefremovv | 0:011a309655b5 | 570 | //переключаем состояние |
yefremovv | 0:011a309655b5 | 571 | brightness2 = !brightness2; |
yefremovv | 0:011a309655b5 | 572 | //отправка в com-порт |
yefremovv | 0:011a309655b5 | 573 | bufSend2[0] = 32; |
yefremovv | 0:011a309655b5 | 574 | if(brightness2) //если ярче |
yefremovv | 0:011a309655b5 | 575 | bufSend2[1] = 15; |
yefremovv | 0:011a309655b5 | 576 | else //если тусклее |
yefremovv | 0:011a309655b5 | 577 | bufSend2[1] = 1; |
yefremovv | 0:011a309655b5 | 578 | ansPui2(); |
yefremovv | 0:011a309655b5 | 579 | wait_ms(80); |
yefremovv | 0:011a309655b5 | 580 | if(flWorkT2) |
yefremovv | 0:011a309655b5 | 581 | flSec2 = 1; |
yefremovv | 0:011a309655b5 | 582 | visible = 1; |
yefremovv | 0:011a309655b5 | 583 | lcd.Clear(LCD_COLOR_BLACK); |
yefremovv | 0:011a309655b5 | 584 | mainWindow(); |
yefremovv | 0:011a309655b5 | 585 | done = 1; |
yefremovv | 0:011a309655b5 | 586 | } |
yefremovv | 0:011a309655b5 | 587 | |
yefremovv | 0:011a309655b5 | 588 | if((x >= 319 && x <= 476) && (y >= 120 && y <= 190)) //выход из под-меню |
yefremovv | 0:011a309655b5 | 589 | { |
yefremovv | 0:011a309655b5 | 590 | lcd.Clear(LCD_COLOR_BLACK); |
yefremovv | 0:011a309655b5 | 591 | mainWindow(); |
yefremovv | 0:011a309655b5 | 592 | settingBut(); |
yefremovv | 0:011a309655b5 | 593 | done = 1; |
yefremovv | 0:011a309655b5 | 594 | } |
yefremovv | 0:011a309655b5 | 595 | } |
yefremovv | 0:011a309655b5 | 596 | } |
yefremovv | 0:011a309655b5 | 597 | } |
yefremovv | 0:011a309655b5 | 598 | flLight = 0; |
yefremovv | 0:011a309655b5 | 599 | } |
yefremovv | 0:011a309655b5 | 600 | |
yefremovv | 0:011a309655b5 | 601 | //отрисовка эл-ов управления в меню "Сеть" |
yefremovv | 0:011a309655b5 | 602 | void drawIP(){ |
yefremovv | 0:011a309655b5 | 603 | lcd.SetTextColor(LCD_COLOR_WHITE); |
yefremovv | 0:011a309655b5 | 604 | lcd.DrawRect(10, 85, 275, 130); |
yefremovv | 0:011a309655b5 | 605 | lcd.DisplayStringAt(20, 142, (uint8_t *)&bufX, LEFT_MODE); //вспомогат. надпись |
yefremovv | 0:011a309655b5 | 606 | lcd.SetTextColor(LCD_COLOR_RED); |
yefremovv | 0:011a309655b5 | 607 | lcd.DisplayStringAt(20, 97, (uint8_t *)ip, LEFT_MODE); |
yefremovv | 0:011a309655b5 | 608 | lcd.DisplayStringAt(20, 187, (uint8_t *)"9003/9006", LEFT_MODE); |
yefremovv | 0:011a309655b5 | 609 | |
yefremovv | 0:011a309655b5 | 610 | //квадратики |
yefremovv | 0:011a309655b5 | 611 | lcd.SetFont(&FontNum); |
yefremovv | 0:011a309655b5 | 612 | uint16_t tX = 310; |
yefremovv | 0:011a309655b5 | 613 | uint16_t tY = 60; |
yefremovv | 0:011a309655b5 | 614 | |
yefremovv | 0:011a309655b5 | 615 | for(int i=0, k=0; i<3; i++) |
yefremovv | 0:011a309655b5 | 616 | { |
yefremovv | 0:011a309655b5 | 617 | for(int v=0; v<3; v++) |
yefremovv | 0:011a309655b5 | 618 | { |
yefremovv | 0:011a309655b5 | 619 | lcd.DisplayChar(tX, tY, 0x31+k); |
yefremovv | 0:011a309655b5 | 620 | tX = tX + 60; |
yefremovv | 0:011a309655b5 | 621 | k++; |
yefremovv | 0:011a309655b5 | 622 | } |
yefremovv | 0:011a309655b5 | 623 | tX = 310; |
yefremovv | 0:011a309655b5 | 624 | tY = tY + 50; |
yefremovv | 0:011a309655b5 | 625 | } |
yefremovv | 0:011a309655b5 | 626 | lcd.DisplayChar(tX + 60, tY, 0x30); |
yefremovv | 0:011a309655b5 | 627 | lcd.DisplayChar(tX, tY, 0x28); |
yefremovv | 0:011a309655b5 | 628 | tX = tX + 120; //60 |
yefremovv | 0:011a309655b5 | 629 | lcd.DisplayChar(tX, tY, 0x21); |
yefremovv | 0:011a309655b5 | 630 | lcd.SetFont(&Font24); |
yefremovv | 0:011a309655b5 | 631 | } |
yefremovv | 0:011a309655b5 | 632 | |
yefremovv | 0:011a309655b5 | 633 | //определяем выбранный символ в меню "Сеть" |
yefremovv | 0:011a309655b5 | 634 | int defSymbol(uint16_t x, uint16_t y){ |
yefremovv | 0:011a309655b5 | 635 | uint16_t tX = 297; |
yefremovv | 0:011a309655b5 | 636 | uint16_t tY = 53; |
yefremovv | 0:011a309655b5 | 637 | |
yefremovv | 0:011a309655b5 | 638 | //первая строчка |
yefremovv | 0:011a309655b5 | 639 | for(int i=0; i<3; i++) |
yefremovv | 0:011a309655b5 | 640 | { |
yefremovv | 0:011a309655b5 | 641 | if((x > (tX + i * 59)) && (x < (tX + 45 + i * 59)) && (y > tY) && (y <= (tY + 45))) |
yefremovv | 0:011a309655b5 | 642 | return(i + 1); |
yefremovv | 0:011a309655b5 | 643 | } |
yefremovv | 0:011a309655b5 | 644 | tY = tY + 48; |
yefremovv | 0:011a309655b5 | 645 | //вторая строчка |
yefremovv | 0:011a309655b5 | 646 | for(int i=0; i<3; i++) |
yefremovv | 0:011a309655b5 | 647 | { |
yefremovv | 0:011a309655b5 | 648 | if((x > (tX + i * 59)) && (x < (tX + 45 + i * 59)) && (y > tY) && (y <= (tY + 45))) |
yefremovv | 0:011a309655b5 | 649 | return(4 + i); |
yefremovv | 0:011a309655b5 | 650 | } |
yefremovv | 0:011a309655b5 | 651 | tY = tY + 48; |
yefremovv | 0:011a309655b5 | 652 | //третья строчка |
yefremovv | 0:011a309655b5 | 653 | for(int i=0; i<3; i++) |
yefremovv | 0:011a309655b5 | 654 | { |
yefremovv | 0:011a309655b5 | 655 | if((x > (tX + i * 59)) && (x < (tX + 45 + i * 59)) && (y > tY) && (y <= (tY + 45))) |
yefremovv | 0:011a309655b5 | 656 | return(7 + i); |
yefremovv | 0:011a309655b5 | 657 | } |
yefremovv | 0:011a309655b5 | 658 | tY = tY + 48; |
yefremovv | 0:011a309655b5 | 659 | //четвёртая строчка |
yefremovv | 0:011a309655b5 | 660 | for(int i=0; i<3; i++) |
yefremovv | 0:011a309655b5 | 661 | { |
yefremovv | 0:011a309655b5 | 662 | if((x > (tX + i * 59)) && (x < (tX + 45 + i * 59)) && (y > tY) && (y <= (tY + 45))) |
yefremovv | 0:011a309655b5 | 663 | { |
yefremovv | 0:011a309655b5 | 664 | if(i == 0) |
yefremovv | 0:011a309655b5 | 665 | return('='); |
yefremovv | 0:011a309655b5 | 666 | if(i == 1) |
yefremovv | 0:011a309655b5 | 667 | return(0); |
yefremovv | 0:011a309655b5 | 668 | if(i == 2) |
yefremovv | 0:011a309655b5 | 669 | return('x'); |
yefremovv | 0:011a309655b5 | 670 | } |
yefremovv | 0:011a309655b5 | 671 | } |
yefremovv | 0:011a309655b5 | 672 | |
yefremovv | 0:011a309655b5 | 673 | return(255); |
yefremovv | 0:011a309655b5 | 674 | } |
yefremovv | 0:011a309655b5 | 675 | |
yefremovv | 0:011a309655b5 | 676 | //отображаем выбранный символ в меню "Сеть" |
yefremovv | 0:011a309655b5 | 677 | void viewSymbol(short aaa){ |
yefremovv | 0:011a309655b5 | 678 | if(aaa == 255) |
yefremovv | 0:011a309655b5 | 679 | return; |
yefremovv | 0:011a309655b5 | 680 | |
yefremovv | 0:011a309655b5 | 681 | if(ind < 15 && aaa != 120 && aaa != 61) |
yefremovv | 0:011a309655b5 | 682 | { |
yefremovv | 0:011a309655b5 | 683 | switch(aaa) |
yefremovv | 0:011a309655b5 | 684 | { |
yefremovv | 0:011a309655b5 | 685 | case 0: |
yefremovv | 0:011a309655b5 | 686 | bufX[ind] = '0'; |
yefremovv | 0:011a309655b5 | 687 | break; |
yefremovv | 0:011a309655b5 | 688 | |
yefremovv | 0:011a309655b5 | 689 | case 1: |
yefremovv | 0:011a309655b5 | 690 | bufX[ind] = '1'; |
yefremovv | 0:011a309655b5 | 691 | break; |
yefremovv | 0:011a309655b5 | 692 | |
yefremovv | 0:011a309655b5 | 693 | case 2: |
yefremovv | 0:011a309655b5 | 694 | bufX[ind] = '2'; |
yefremovv | 0:011a309655b5 | 695 | break; |
yefremovv | 0:011a309655b5 | 696 | |
yefremovv | 0:011a309655b5 | 697 | case 3: |
yefremovv | 0:011a309655b5 | 698 | bufX[ind] = '3'; |
yefremovv | 0:011a309655b5 | 699 | break; |
yefremovv | 0:011a309655b5 | 700 | |
yefremovv | 0:011a309655b5 | 701 | case 4: |
yefremovv | 0:011a309655b5 | 702 | bufX[ind] = '4'; |
yefremovv | 0:011a309655b5 | 703 | break; |
yefremovv | 0:011a309655b5 | 704 | |
yefremovv | 0:011a309655b5 | 705 | case 5: |
yefremovv | 0:011a309655b5 | 706 | bufX[ind] = '5'; |
yefremovv | 0:011a309655b5 | 707 | break; |
yefremovv | 0:011a309655b5 | 708 | |
yefremovv | 0:011a309655b5 | 709 | case 6: |
yefremovv | 0:011a309655b5 | 710 | bufX[ind] = '6'; |
yefremovv | 0:011a309655b5 | 711 | break; |
yefremovv | 0:011a309655b5 | 712 | |
yefremovv | 0:011a309655b5 | 713 | case 7: |
yefremovv | 0:011a309655b5 | 714 | bufX[ind] = '7'; |
yefremovv | 0:011a309655b5 | 715 | break; |
yefremovv | 0:011a309655b5 | 716 | |
yefremovv | 0:011a309655b5 | 717 | case 8: |
yefremovv | 0:011a309655b5 | 718 | bufX[ind] = '8'; |
yefremovv | 0:011a309655b5 | 719 | break; |
yefremovv | 0:011a309655b5 | 720 | |
yefremovv | 0:011a309655b5 | 721 | case 9: |
yefremovv | 0:011a309655b5 | 722 | bufX[ind] = '9'; |
yefremovv | 0:011a309655b5 | 723 | break; |
yefremovv | 0:011a309655b5 | 724 | } |
yefremovv | 0:011a309655b5 | 725 | |
yefremovv | 0:011a309655b5 | 726 | if(ind==2 || ind==6 || ind==10) |
yefremovv | 0:011a309655b5 | 727 | ind += 2; |
yefremovv | 0:011a309655b5 | 728 | else |
yefremovv | 0:011a309655b5 | 729 | ind++; |
yefremovv | 0:011a309655b5 | 730 | sprintf((char*)bufX, "%c%c%c.%c%c%c.%c%c%c.%c%c%c", bufX[0], bufX[1], bufX[2], bufX[4], bufX[5], bufX[6], bufX[8], bufX[9], bufX[10], bufX[12], bufX[13], bufX[14]); |
yefremovv | 0:011a309655b5 | 731 | } |
yefremovv | 0:011a309655b5 | 732 | |
yefremovv | 0:011a309655b5 | 733 | if(aaa == 120) |
yefremovv | 0:011a309655b5 | 734 | { |
yefremovv | 0:011a309655b5 | 735 | if(ind == 4 || ind == 8 || ind == 12) |
yefremovv | 0:011a309655b5 | 736 | ind -= 2; |
yefremovv | 0:011a309655b5 | 737 | else |
yefremovv | 0:011a309655b5 | 738 | { |
yefremovv | 0:011a309655b5 | 739 | if(ind > 0) |
yefremovv | 0:011a309655b5 | 740 | ind--; |
yefremovv | 0:011a309655b5 | 741 | } |
yefremovv | 0:011a309655b5 | 742 | bufX[ind] = 'X'; |
yefremovv | 0:011a309655b5 | 743 | sprintf((char*)bufX, "%c%c%c.%c%c%c.%c%c%c.%c%c%c", bufX[0], bufX[1], bufX[2], bufX[4], bufX[5], bufX[6], bufX[8], bufX[9], bufX[10], bufX[12], bufX[13], bufX[14]); |
yefremovv | 0:011a309655b5 | 744 | } |
yefremovv | 0:011a309655b5 | 745 | |
yefremovv | 0:011a309655b5 | 746 | if(aaa == 61 && ind == 15) |
yefremovv | 0:011a309655b5 | 747 | { |
yefremovv | 0:011a309655b5 | 748 | //формируем буфер отображения |
yefremovv | 0:011a309655b5 | 749 | int len = strlen(bufX)+1; |
yefremovv | 0:011a309655b5 | 750 | r = new char[len]; |
yefremovv | 0:011a309655b5 | 751 | for(int i=0; i<len; i++) |
yefremovv | 0:011a309655b5 | 752 | r[i] = bufX[i]; |
yefremovv | 0:011a309655b5 | 753 | r[len] = 0; |
yefremovv | 0:011a309655b5 | 754 | //проверка введённого ip |
yefremovv | 0:011a309655b5 | 755 | if(checkIP(r)) //если верно |
yefremovv | 0:011a309655b5 | 756 | { |
yefremovv | 0:011a309655b5 | 757 | ind = 0; |
yefremovv | 0:011a309655b5 | 758 | //запись во флеш нового ip |
yefremovv | 0:011a309655b5 | 759 | qspi.Erase_Block(WRITE_READ_ADDR); //очистка флеш |
yefremovv | 0:011a309655b5 | 760 | qspi.Write((uint8_t*)r, WRITE_READ_ADDR, 16); //запись во флеш |
yefremovv | 0:011a309655b5 | 761 | //перезапуск eth |
yefremovv | 0:011a309655b5 | 762 | sock9003.close(); |
yefremovv | 0:011a309655b5 | 763 | sock9006.close(); |
yefremovv | 0:011a309655b5 | 764 | eth.disconnect(); |
yefremovv | 0:011a309655b5 | 765 | flEth = 0; |
yefremovv | 0:011a309655b5 | 766 | //переназначаем новые настройки сети |
yefremovv | 0:011a309655b5 | 767 | wait_ms(50); |
yefremovv | 0:011a309655b5 | 768 | eth.set_network(ip, Mask, Gateway); |
yefremovv | 0:011a309655b5 | 769 | //иниц. eth |
yefremovv | 0:011a309655b5 | 770 | eth.connect(); |
yefremovv | 0:011a309655b5 | 771 | sock9003.open(ð); |
yefremovv | 0:011a309655b5 | 772 | sock9003.bind(9003); |
yefremovv | 0:011a309655b5 | 773 | sock9003.set_blocking(false); //неблокир. режим |
yefremovv | 0:011a309655b5 | 774 | sock9006.open(ð); |
yefremovv | 0:011a309655b5 | 775 | sock9006.bind(9006); |
yefremovv | 0:011a309655b5 | 776 | sock9006.set_blocking(false); //неблокир. режим |
yefremovv | 0:011a309655b5 | 777 | //убиваем eth-поток |
yefremovv | 0:011a309655b5 | 778 | //int e = threadEth.terminate(); |
yefremovv | 0:011a309655b5 | 779 | //wait_ms(/*50*/1000); //????????????????? |
yefremovv | 0:011a309655b5 | 780 | //запускаем новый поток |
yefremovv | 0:011a309655b5 | 781 | //threadEth.start(workEth); |
yefremovv | 0:011a309655b5 | 782 | //перерисовка окна |
yefremovv | 0:011a309655b5 | 783 | lcd.SetTextColor(LCD_COLOR_BLACK); |
yefremovv | 0:011a309655b5 | 784 | lcd.DisplayStringAt(20, 97, (uint8_t *)"255.255.255.255", LEFT_MODE); |
yefremovv | 0:011a309655b5 | 785 | lcd.SetTextColor(LCD_COLOR_RED); |
yefremovv | 0:011a309655b5 | 786 | //конец перерисовки окна |
yefremovv | 0:011a309655b5 | 787 | lcd.DisplayStringAt(20, 97, (uint8_t *)ip, LEFT_MODE); |
yefremovv | 0:011a309655b5 | 788 | sprintf((char*)bufX, "%c%c%c.%c%c%c.%c%c%c.%c%c%c", 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X'); |
yefremovv | 0:011a309655b5 | 789 | } |
yefremovv | 0:011a309655b5 | 790 | } |
yefremovv | 0:011a309655b5 | 791 | |
yefremovv | 0:011a309655b5 | 792 | lcd.SetTextColor(LCD_COLOR_WHITE); |
yefremovv | 0:011a309655b5 | 793 | lcd.DisplayStringAt(20, 142, (uint8_t *)&bufX, LEFT_MODE); |
yefremovv | 0:011a309655b5 | 794 | lcd.SetTextColor(LCD_COLOR_RED); |
yefremovv | 0:011a309655b5 | 795 | } |
yefremovv | 0:011a309655b5 | 796 | |
yefremovv | 0:011a309655b5 | 797 | //проверка правильности ввода IP-адреса |
yefremovv | 0:011a309655b5 | 798 | bool checkIP(const char *str){ |
yefremovv | 0:011a309655b5 | 799 | char *p; |
yefremovv | 0:011a309655b5 | 800 | int n; |
yefremovv | 0:011a309655b5 | 801 | char num[4]; |
yefremovv | 0:011a309655b5 | 802 | |
yefremovv | 0:011a309655b5 | 803 | for(int i=0; i<4; i++) |
yefremovv | 0:011a309655b5 | 804 | { |
yefremovv | 0:011a309655b5 | 805 | if(!isdigit((unsigned char) *str)) |
yefremovv | 0:011a309655b5 | 806 | return 0; |
yefremovv | 0:011a309655b5 | 807 | n = strtol(str, &p, 10); |
yefremovv | 0:011a309655b5 | 808 | if(n < 0 || n > 255) |
yefremovv | 0:011a309655b5 | 809 | return 0; |
yefremovv | 0:011a309655b5 | 810 | if(i + 1 < 4 && *p != '.') |
yefremovv | 0:011a309655b5 | 811 | return 0; |
yefremovv | 0:011a309655b5 | 812 | num[i] = n; |
yefremovv | 0:011a309655b5 | 813 | str = p + (i + 1 < 4); |
yefremovv | 0:011a309655b5 | 814 | } |
yefremovv | 0:011a309655b5 | 815 | sprintf(r, "%d.%d.%d.%d", num[0], num[1], num[2], num[3]); |
yefremovv | 0:011a309655b5 | 816 | |
yefremovv | 0:011a309655b5 | 817 | if(!strcmp(r, "000.000.000.000")) //если ip = 0.0.0.0 |
yefremovv | 0:011a309655b5 | 818 | ip = "10.114.48.13"; //то дефолтный адрес |
yefremovv | 0:011a309655b5 | 819 | else |
yefremovv | 0:011a309655b5 | 820 | ip = r; |
yefremovv | 0:011a309655b5 | 821 | return 1; |
yefremovv | 0:011a309655b5 | 822 | } |
yefremovv | 0:011a309655b5 | 823 | |
yefremovv | 0:011a309655b5 | 824 | //возврат в основное меню |
yefremovv | 0:011a309655b5 | 825 | void backFunc(){ |
yefremovv | 0:011a309655b5 | 826 | lcd.SetFont(&FontNum); |
yefremovv | 0:011a309655b5 | 827 | lcd.Clear(LCD_COLOR_BLACK); |
yefremovv | 0:011a309655b5 | 828 | lcd.SetTextColor(LCD_COLOR_LIGHTGREEN); |
yefremovv | 0:011a309655b5 | 829 | flTime = 1; |
yefremovv | 0:011a309655b5 | 830 | if(flTest) //если режим теста |
yefremovv | 0:011a309655b5 | 831 | flSec1 = flSec2 = 1; |
yefremovv | 0:011a309655b5 | 832 | if(flWorkT1) //если работает ПУИ1 |
yefremovv | 0:011a309655b5 | 833 | flSec1 = 1; |
yefremovv | 0:011a309655b5 | 834 | if(flWorkT2) //если работает ПУИ2 |
yefremovv | 0:011a309655b5 | 835 | flSec2 = 1; |
yefremovv | 0:011a309655b5 | 836 | mainWindow(); |
yefremovv | 0:011a309655b5 | 837 | } |
yefremovv | 0:011a309655b5 | 838 | |
yefremovv | 0:011a309655b5 | 839 | //секундомер для путей |
yefremovv | 0:011a309655b5 | 840 | void viewTimerSec(){ |
yefremovv | 0:011a309655b5 | 841 | sTime = time(NULL) + (7 * 3600); |
yefremovv | 0:011a309655b5 | 842 | s1Time = sec1; |
yefremovv | 0:011a309655b5 | 843 | s2Time = sec2; |
yefremovv | 0:011a309655b5 | 844 | |
yefremovv | 0:011a309655b5 | 845 | checkTh++; |
yefremovv | 0:011a309655b5 | 846 | |
yefremovv | 0:011a309655b5 | 847 | if(flTime) //часы RTC |
yefremovv | 0:011a309655b5 | 848 | { |
yefremovv | 0:011a309655b5 | 849 | lcd.SetFont(&FontNum); |
yefremovv | 0:011a309655b5 | 850 | strftime(buf, 10, "%H:%M:%S", localtime(&sTime)); |
yefremovv | 0:011a309655b5 | 851 | lcd.DisplayStringAt(38, 50, (uint8_t *)buf, LEFT_MODE); |
yefremovv | 0:011a309655b5 | 852 | } |
yefremovv | 0:011a309655b5 | 853 | //отрисовка секундомеров |
yefremovv | 0:011a309655b5 | 854 | if(flSec1) //таймер ПУИ1 |
yefremovv | 0:011a309655b5 | 855 | { |
yefremovv | 0:011a309655b5 | 856 | if(fl1NP) |
yefremovv | 0:011a309655b5 | 857 | strftime(buf1, 10, "%M:%S ", localtime(&s1Time)); //пробел ОБЯЗАТЕЛЕН |
yefremovv | 0:011a309655b5 | 858 | else |
yefremovv | 0:011a309655b5 | 859 | strftime(buf1, 10, "-%M:%S", localtime(&s1Time)); |
yefremovv | 0:011a309655b5 | 860 | lcd.DisplayStringAt(50, 180, (uint8_t *)buf1, LEFT_MODE); |
yefremovv | 0:011a309655b5 | 861 | } |
yefremovv | 0:011a309655b5 | 862 | if(flSec2) //таймер ПУИ2 |
yefremovv | 0:011a309655b5 | 863 | { |
yefremovv | 0:011a309655b5 | 864 | if(fl2NP) |
yefremovv | 0:011a309655b5 | 865 | strftime(buf2, 10, " %M:%S", localtime(&s2Time)); |
yefremovv | 0:011a309655b5 | 866 | else |
yefremovv | 0:011a309655b5 | 867 | strftime(buf2, 10, "-%M:%S", localtime(&s2Time)); |
yefremovv | 0:011a309655b5 | 868 | lcd.DisplayStringAt(60, 180, (uint8_t *)buf2, RIGHT_MODE); |
yefremovv | 0:011a309655b5 | 869 | } |
yefremovv | 0:011a309655b5 | 870 | |
yefremovv | 0:011a309655b5 | 871 | //режим "Тест" |
yefremovv | 0:011a309655b5 | 872 | if(flTest) |
yefremovv | 0:011a309655b5 | 873 | { |
yefremovv | 0:011a309655b5 | 874 | if(sec1 > 0 && fl1NP) |
yefremovv | 0:011a309655b5 | 875 | sec1--; |
yefremovv | 0:011a309655b5 | 876 | else |
yefremovv | 0:011a309655b5 | 877 | { |
yefremovv | 0:011a309655b5 | 878 | fl2NP = fl1NP = 0; |
yefremovv | 0:011a309655b5 | 879 | sec1++; |
yefremovv | 0:011a309655b5 | 880 | if(sec1 > 30) //конец теста |
yefremovv | 0:011a309655b5 | 881 | { |
yefremovv | 0:011a309655b5 | 882 | flTest = flSec2 = flSec1 = 0; |
yefremovv | 0:011a309655b5 | 883 | fl2NP = fl1NP = 1; |
yefremovv | 0:011a309655b5 | 884 | sec1 = sec2 = 0; |
yefremovv | 0:011a309655b5 | 885 | //зачищаем старую кнопку |
yefremovv | 0:011a309655b5 | 886 | lcd.SetTextColor(LCD_COLOR_BLACK); |
yefremovv | 0:011a309655b5 | 887 | lcd.FillRect(434, 0, 45, 45); |
yefremovv | 0:011a309655b5 | 888 | lcd.SetTextColor(LCD_COLOR_LIGHTGREEN); //white |
yefremovv | 0:011a309655b5 | 889 | mainWindow(); |
yefremovv | 0:011a309655b5 | 890 | } |
yefremovv | 0:011a309655b5 | 891 | } |
yefremovv | 0:011a309655b5 | 892 | sec2 = sec1; |
yefremovv | 0:011a309655b5 | 893 | } |
yefremovv | 0:011a309655b5 | 894 | |
yefremovv | 0:011a309655b5 | 895 | //рабочий режим ПУИ1 |
yefremovv | 0:011a309655b5 | 896 | if(flWorkT1) |
yefremovv | 0:011a309655b5 | 897 | { |
yefremovv | 0:011a309655b5 | 898 | if(sec1 > 0 && fl1NP) |
yefremovv | 0:011a309655b5 | 899 | sec1--; |
yefremovv | 0:011a309655b5 | 900 | else |
yefremovv | 0:011a309655b5 | 901 | { |
yefremovv | 0:011a309655b5 | 902 | fl1NP = 0; |
yefremovv | 0:011a309655b5 | 903 | sec1++; |
yefremovv | 0:011a309655b5 | 904 | if(sec1 > TIMEOUT_MINUS) //тайм-аут 10 мин. |
yefremovv | 0:011a309655b5 | 905 | { |
yefremovv | 0:011a309655b5 | 906 | flSec1 = flWorkT1 = 0; |
yefremovv | 0:011a309655b5 | 907 | fl1NP = 1; |
yefremovv | 0:011a309655b5 | 908 | sec1 = 0; |
yefremovv | 0:011a309655b5 | 909 | } |
yefremovv | 0:011a309655b5 | 910 | } |
yefremovv | 0:011a309655b5 | 911 | } |
yefremovv | 0:011a309655b5 | 912 | |
yefremovv | 0:011a309655b5 | 913 | //рабочий режим ПУИ2 |
yefremovv | 0:011a309655b5 | 914 | if(flWorkT2) |
yefremovv | 0:011a309655b5 | 915 | { |
yefremovv | 0:011a309655b5 | 916 | if(sec2 > 0 && fl2NP) |
yefremovv | 0:011a309655b5 | 917 | sec2--; |
yefremovv | 0:011a309655b5 | 918 | else |
yefremovv | 0:011a309655b5 | 919 | { |
yefremovv | 0:011a309655b5 | 920 | fl2NP = 0; |
yefremovv | 0:011a309655b5 | 921 | sec2++; |
yefremovv | 0:011a309655b5 | 922 | if(sec2 > TIMEOUT_MINUS) //тайм-аут 10 мин |
yefremovv | 0:011a309655b5 | 923 | { |
yefremovv | 0:011a309655b5 | 924 | flSec2 = flWorkT2 = 0; |
yefremovv | 0:011a309655b5 | 925 | fl2NP = 1; |
yefremovv | 0:011a309655b5 | 926 | sec2 = 0; |
yefremovv | 0:011a309655b5 | 927 | } |
yefremovv | 0:011a309655b5 | 928 | } |
yefremovv | 0:011a309655b5 | 929 | } |
yefremovv | 0:011a309655b5 | 930 | |
yefremovv | 0:011a309655b5 | 931 | //надо ли делать проверку дочернего потока |
yefremovv | 0:011a309655b5 | 932 | if(checkTh == 5) |
yefremovv | 0:011a309655b5 | 933 | { |
yefremovv | 0:011a309655b5 | 934 | checkTh = 0; |
yefremovv | 0:011a309655b5 | 935 | flWdtTh = 1; |
yefremovv | 0:011a309655b5 | 936 | } |
yefremovv | 0:011a309655b5 | 937 | } |
yefremovv | 0:011a309655b5 | 938 | |
yefremovv | 0:011a309655b5 | 939 | //установка часов |
yefremovv | 0:011a309655b5 | 940 | void setClock(){ |
yefremovv | 0:011a309655b5 | 941 | t.tm_year = 2017; |
yefremovv | 0:011a309655b5 | 942 | t.tm_mon = 11; |
yefremovv | 0:011a309655b5 | 943 | t.tm_mday = 15; |
yefremovv | 0:011a309655b5 | 944 | t.tm_hour = 13; |
yefremovv | 0:011a309655b5 | 945 | t.tm_min = 27; |
yefremovv | 0:011a309655b5 | 946 | t.tm_sec = 0; |
yefremovv | 0:011a309655b5 | 947 | t.tm_year = t.tm_year - 1900; |
yefremovv | 0:011a309655b5 | 948 | t.tm_mon = t.tm_mon - 1; |
yefremovv | 0:011a309655b5 | 949 | sTime = mktime(&t); |
yefremovv | 0:011a309655b5 | 950 | sTime = sTime - (7 * 3600); |
yefremovv | 0:011a309655b5 | 951 | set_time(sTime); |
yefremovv | 0:011a309655b5 | 952 | //таймер на прерывание |
yefremovv | 0:011a309655b5 | 953 | tickerIrqSec.attach(&viewTimerSec, 1); |
yefremovv | 0:011a309655b5 | 954 | } |
yefremovv | 0:011a309655b5 | 955 | |
yefremovv | 0:011a309655b5 | 956 | //ответ от ПУИ1 |
yefremovv | 0:011a309655b5 | 957 | void ansPui1(){ |
yefremovv | 0:011a309655b5 | 958 | char cntTry1 = 0; |
yefremovv | 0:011a309655b5 | 959 | lcd.SetFont(&FontNum); |
yefremovv | 0:011a309655b5 | 960 | flCon1 = 0; |
yefremovv | 0:011a309655b5 | 961 | while(!flCon1 && cntTry1 < 3) |
yefremovv | 0:011a309655b5 | 962 | { |
yefremovv | 0:011a309655b5 | 963 | cntTry1++; |
yefremovv | 0:011a309655b5 | 964 | //отправляем пакет |
yefremovv | 0:011a309655b5 | 965 | pc1.putc(bufSend1[0]); |
yefremovv | 0:011a309655b5 | 966 | wait_ms(8); |
yefremovv | 0:011a309655b5 | 967 | pc1.putc(bufSend1[1]); |
yefremovv | 0:011a309655b5 | 968 | |
yefremovv | 0:011a309655b5 | 969 | //получаем ответ |
yefremovv | 0:011a309655b5 | 970 | wait_ms(10); |
yefremovv | 0:011a309655b5 | 971 | while(pc1.readable()) |
yefremovv | 0:011a309655b5 | 972 | { |
yefremovv | 0:011a309655b5 | 973 | bufPc1[0] = pc1.getc(); |
yefremovv | 0:011a309655b5 | 974 | bufPc1[1] = pc1.getc(); |
yefremovv | 0:011a309655b5 | 975 | } |
yefremovv | 0:011a309655b5 | 976 | //сравниваем полученное с отправленным |
yefremovv | 0:011a309655b5 | 977 | if(!strcmp(bufSend1, bufPc1)) //если равно |
yefremovv | 0:011a309655b5 | 978 | flCon1 = 1; |
yefremovv | 0:011a309655b5 | 979 | else //если не равно |
yefremovv | 0:011a309655b5 | 980 | flCon1 = 0; |
yefremovv | 0:011a309655b5 | 981 | } |
yefremovv | 0:011a309655b5 | 982 | //выводим на экран резалт |
yefremovv | 0:011a309655b5 | 983 | if(!flNetW) //если не в меню "СЕТЬ" |
yefremovv | 0:011a309655b5 | 984 | { |
yefremovv | 0:011a309655b5 | 985 | lcd.SetTextColor(LCD_COLOR_BLACK); |
yefremovv | 0:011a309655b5 | 986 | lcd.FillRect(38, 115, 19, 29); |
yefremovv | 0:011a309655b5 | 987 | lcd.SetTextColor(LCD_COLOR_LIGHTGREEN); |
yefremovv | 0:011a309655b5 | 988 | if(flCon1) |
yefremovv | 0:011a309655b5 | 989 | lcd.DisplayStringAt(38, 115, (uint8_t *)"'", LEFT_MODE); //есть связь |
yefremovv | 0:011a309655b5 | 990 | else |
yefremovv | 0:011a309655b5 | 991 | lcd.DisplayStringAt(38, 115, (uint8_t *)"%", LEFT_MODE); //нет связи |
yefremovv | 0:011a309655b5 | 992 | } |
yefremovv | 0:011a309655b5 | 993 | lcd.SetFont(&FontRus); |
yefremovv | 0:011a309655b5 | 994 | } |
yefremovv | 0:011a309655b5 | 995 | |
yefremovv | 0:011a309655b5 | 996 | //ответ от ПУИ2 |
yefremovv | 0:011a309655b5 | 997 | void ansPui2(){ |
yefremovv | 0:011a309655b5 | 998 | char cntTry2 = 0; |
yefremovv | 0:011a309655b5 | 999 | lcd.SetFont(&FontNum); |
yefremovv | 0:011a309655b5 | 1000 | flCon2 = 0; |
yefremovv | 0:011a309655b5 | 1001 | while(!flCon2 && cntTry2 < 3) |
yefremovv | 0:011a309655b5 | 1002 | { |
yefremovv | 0:011a309655b5 | 1003 | cntTry2++; |
yefremovv | 0:011a309655b5 | 1004 | //отправляем пакет |
yefremovv | 0:011a309655b5 | 1005 | pc2.putc(bufSend2[0]); |
yefremovv | 0:011a309655b5 | 1006 | wait_ms(8); |
yefremovv | 0:011a309655b5 | 1007 | pc2.putc(bufSend2[1]); |
yefremovv | 0:011a309655b5 | 1008 | |
yefremovv | 0:011a309655b5 | 1009 | //получаем ответ |
yefremovv | 0:011a309655b5 | 1010 | wait_ms(10); |
yefremovv | 0:011a309655b5 | 1011 | while(pc2.readable()) |
yefremovv | 0:011a309655b5 | 1012 | { |
yefremovv | 0:011a309655b5 | 1013 | bufPc2[0] = pc2.getc(); |
yefremovv | 0:011a309655b5 | 1014 | bufPc2[1] = pc2.getc(); |
yefremovv | 0:011a309655b5 | 1015 | } |
yefremovv | 0:011a309655b5 | 1016 | //сравниваем полученное с отправленным |
yefremovv | 0:011a309655b5 | 1017 | if(!strcmp(bufSend2, bufPc2)) //если равно |
yefremovv | 0:011a309655b5 | 1018 | flCon2 = 1; |
yefremovv | 0:011a309655b5 | 1019 | else //если не равно |
yefremovv | 0:011a309655b5 | 1020 | flCon2 = 0; |
yefremovv | 0:011a309655b5 | 1021 | } |
yefremovv | 0:011a309655b5 | 1022 | //выводим на экран резалт |
yefremovv | 0:011a309655b5 | 1023 | if(!flNetW && !flLight) //если не в меню "СЕТЬ" и не в "ЯРКОСТЬ" |
yefremovv | 0:011a309655b5 | 1024 | { |
yefremovv | 0:011a309655b5 | 1025 | lcd.SetTextColor(LCD_COLOR_BLACK); |
yefremovv | 0:011a309655b5 | 1026 | lcd.FillRect(297, 115, 19, 29); |
yefremovv | 0:011a309655b5 | 1027 | lcd.SetTextColor(LCD_COLOR_LIGHTGREEN); |
yefremovv | 0:011a309655b5 | 1028 | if(flCon2) |
yefremovv | 0:011a309655b5 | 1029 | lcd.DisplayStringAt(182, 115, (uint8_t *)"'", RIGHT_MODE); //есть связь |
yefremovv | 0:011a309655b5 | 1030 | else |
yefremovv | 0:011a309655b5 | 1031 | lcd.DisplayStringAt(182, 115, (uint8_t *)"%", RIGHT_MODE); //нет связи |
yefremovv | 0:011a309655b5 | 1032 | } |
yefremovv | 0:011a309655b5 | 1033 | lcd.SetFont(&FontRus); |
yefremovv | 0:011a309655b5 | 1034 | /*cntB2 = 0; |
yefremovv | 0:011a309655b5 | 1035 | while(pc2.readable()) |
yefremovv | 0:011a309655b5 | 1036 | { |
yefremovv | 0:011a309655b5 | 1037 | bufPc2[cntB2] = pc2.getc(); |
yefremovv | 0:011a309655b5 | 1038 | bufPc2[cntB2+1] = pc2.getc(); |
yefremovv | 0:011a309655b5 | 1039 | } |
yefremovv | 0:011a309655b5 | 1040 | lcd.SetFont(&FontNum); |
yefremovv | 0:011a309655b5 | 1041 | if(!flLight && !flNetW) |
yefremovv | 0:011a309655b5 | 1042 | { |
yefremovv | 0:011a309655b5 | 1043 | lcd.SetTextColor(LCD_COLOR_BLACK); |
yefremovv | 0:011a309655b5 | 1044 | lcd.FillRect(297, 115, 19, 29); |
yefremovv | 0:011a309655b5 | 1045 | lcd.SetTextColor(LCD_COLOR_LIGHTGREEN); |
yefremovv | 0:011a309655b5 | 1046 | } |
yefremovv | 0:011a309655b5 | 1047 | if(!strcmp(bufSend2, bufPc2)) |
yefremovv | 0:011a309655b5 | 1048 | { |
yefremovv | 0:011a309655b5 | 1049 | flCon2 = 1; //если равны |
yefremovv | 0:011a309655b5 | 1050 | if(!flLight && !flNetW) |
yefremovv | 0:011a309655b5 | 1051 | lcd.DisplayStringAt(182, 115, (uint8_t *)"'", RIGHT_MODE); |
yefremovv | 0:011a309655b5 | 1052 | } |
yefremovv | 0:011a309655b5 | 1053 | else |
yefremovv | 0:011a309655b5 | 1054 | { |
yefremovv | 0:011a309655b5 | 1055 | flCon2 = 0; //если не равны |
yefremovv | 0:011a309655b5 | 1056 | if(!flLight && !flNetW) |
yefremovv | 0:011a309655b5 | 1057 | lcd.DisplayStringAt(182, 115, (uint8_t *)"%", RIGHT_MODE); |
yefremovv | 0:011a309655b5 | 1058 | } |
yefremovv | 0:011a309655b5 | 1059 | lcd.SetFont(&FontRus);*/ |
yefremovv | 0:011a309655b5 | 1060 | } |
yefremovv | 0:011a309655b5 | 1061 | |
yefremovv | 0:011a309655b5 | 1062 | //отправка времени на ПУИ1 |
yefremovv | 0:011a309655b5 | 1063 | void pui1SetTime(int n){ |
yefremovv | 0:011a309655b5 | 1064 | if ((n > 0) && (n < 255)) |
yefremovv | 0:011a309655b5 | 1065 | { |
yefremovv | 0:011a309655b5 | 1066 | bufSend1[0] = 128; |
yefremovv | 0:011a309655b5 | 1067 | bufSend1[1] = n; |
yefremovv | 0:011a309655b5 | 1068 | } |
yefremovv | 0:011a309655b5 | 1069 | else if ((n > 256) && (n < 511)) |
yefremovv | 0:011a309655b5 | 1070 | { |
yefremovv | 0:011a309655b5 | 1071 | bufSend1[0] = 121; |
yefremovv | 0:011a309655b5 | 1072 | bufSend1[1] = n - 256; |
yefremovv | 0:011a309655b5 | 1073 | } |
yefremovv | 0:011a309655b5 | 1074 | else if ((n > 512) && (n < 767)) |
yefremovv | 0:011a309655b5 | 1075 | { |
yefremovv | 0:011a309655b5 | 1076 | bufSend1[0] = 130; |
yefremovv | 0:011a309655b5 | 1077 | bufSend1[1] = n - 512; |
yefremovv | 0:011a309655b5 | 1078 | } |
yefremovv | 0:011a309655b5 | 1079 | else if ((n > 768) && (n < 961)) |
yefremovv | 0:011a309655b5 | 1080 | { |
yefremovv | 0:011a309655b5 | 1081 | bufSend1[0] = 131; |
yefremovv | 0:011a309655b5 | 1082 | bufSend1[1] = n - 768; |
yefremovv | 0:011a309655b5 | 1083 | } |
yefremovv | 0:011a309655b5 | 1084 | ansPui1(); |
yefremovv | 0:011a309655b5 | 1085 | } |
yefremovv | 0:011a309655b5 | 1086 | |
yefremovv | 0:011a309655b5 | 1087 | //отправка времени на ПУИ2 |
yefremovv | 0:011a309655b5 | 1088 | void pui2SetTime(int n){ |
yefremovv | 0:011a309655b5 | 1089 | if ((n > 0) && (n < 255)) |
yefremovv | 0:011a309655b5 | 1090 | { |
yefremovv | 0:011a309655b5 | 1091 | bufSend2[0] = 128; |
yefremovv | 0:011a309655b5 | 1092 | bufSend2[1] = n + 1; |
yefremovv | 0:011a309655b5 | 1093 | } |
yefremovv | 0:011a309655b5 | 1094 | else if ((n > 256) && (n < 511)) |
yefremovv | 0:011a309655b5 | 1095 | { |
yefremovv | 0:011a309655b5 | 1096 | bufSend2[0] = 129; |
yefremovv | 0:011a309655b5 | 1097 | bufSend2[1] = n - 255; |
yefremovv | 0:011a309655b5 | 1098 | } |
yefremovv | 0:011a309655b5 | 1099 | else if ((n > 512) && (n < 767)) |
yefremovv | 0:011a309655b5 | 1100 | { |
yefremovv | 0:011a309655b5 | 1101 | bufSend2[0] = 130; |
yefremovv | 0:011a309655b5 | 1102 | bufSend2[1] = n - 511; |
yefremovv | 0:011a309655b5 | 1103 | } |
yefremovv | 0:011a309655b5 | 1104 | else if ((n > 768) && (n < 961)) |
yefremovv | 0:011a309655b5 | 1105 | { |
yefremovv | 0:011a309655b5 | 1106 | bufSend2[0] = 131; |
yefremovv | 0:011a309655b5 | 1107 | bufSend2[1] = n - 767; |
yefremovv | 0:011a309655b5 | 1108 | } |
yefremovv | 0:011a309655b5 | 1109 | ansPui2(); |
yefremovv | 0:011a309655b5 | 1110 | } |
yefremovv | 0:011a309655b5 | 1111 | |
yefremovv | 0:011a309655b5 | 1112 | //отправка станции на ПУИ1 |
yefremovv | 0:011a309655b5 | 1113 | void sendStatPui1(short stat){ |
yefremovv | 0:011a309655b5 | 1114 | bufSend1[0] = 64; |
yefremovv | 0:011a309655b5 | 1115 | switch(stat) |
yefremovv | 0:011a309655b5 | 1116 | { |
yefremovv | 0:011a309655b5 | 1117 | case 114: |
yefremovv | 0:011a309655b5 | 1118 | // ABTOBO; |
yefremovv | 0:011a309655b5 | 1119 | bufSend1[1] = 1; |
yefremovv | 0:011a309655b5 | 1120 | break; |
yefremovv | 0:011a309655b5 | 1121 | case 115: |
yefremovv | 0:011a309655b5 | 1122 | // НАРВСКАЯ |
yefremovv | 0:011a309655b5 | 1123 | bufSend1[1] = 3; |
yefremovv | 0:011a309655b5 | 1124 | break; |
yefremovv | 0:011a309655b5 | 1125 | case 117: |
yefremovv | 0:011a309655b5 | 1126 | // ТЕХНОЛОГИЧЕСКИЙ ИНСТИТУТ |
yefremovv | 0:011a309655b5 | 1127 | bufSend1[1] = 7; |
yefremovv | 0:011a309655b5 | 1128 | break; |
yefremovv | 0:011a309655b5 | 1129 | case 120: |
yefremovv | 0:011a309655b5 | 1130 | // ПЛОЩАДЬ ВОССТАНИЯ |
yefremovv | 0:011a309655b5 | 1131 | bufSend1[1] = 6; |
yefremovv | 0:011a309655b5 | 1132 | break; |
yefremovv | 0:011a309655b5 | 1133 | case 122: |
yefremovv | 0:011a309655b5 | 1134 | // ПЛОЩАДЬ ЛЕНИНА |
yefremovv | 0:011a309655b5 | 1135 | bufSend1[1] = 4; |
yefremovv | 0:011a309655b5 | 1136 | break; |
yefremovv | 0:011a309655b5 | 1137 | case 127: |
yefremovv | 0:011a309655b5 | 1138 | // АКАДЕМИЧЕСКАЯ |
yefremovv | 0:011a309655b5 | 1139 | bufSend1[1] = 2; |
yefremovv | 0:011a309655b5 | 1140 | break; |
yefremovv | 0:011a309655b5 | 1141 | |
yefremovv | 0:011a309655b5 | 1142 | case 218: |
yefremovv | 0:011a309655b5 | 1143 | // САДОВАЯ |
yefremovv | 0:011a309655b5 | 1144 | bufSend1[1] = 22; |
yefremovv | 0:011a309655b5 | 1145 | break; |
yefremovv | 0:011a309655b5 | 1146 | |
yefremovv | 0:011a309655b5 | 1147 | case 319: |
yefremovv | 0:011a309655b5 | 1148 | //ОБУХОВО |
yefremovv | 0:011a309655b5 | 1149 | bufSend1[1] = 11; |
yefremovv | 0:011a309655b5 | 1150 | break; |
yefremovv | 0:011a309655b5 | 1151 | case 317: |
yefremovv | 0:011a309655b5 | 1152 | //ЛОМОНОСОВСКАЯ |
yefremovv | 0:011a309655b5 | 1153 | bufSend1[1] = 12; |
yefremovv | 0:011a309655b5 | 1154 | break; |
yefremovv | 0:011a309655b5 | 1155 | case 315: |
yefremovv | 0:011a309655b5 | 1156 | // ПЛ. АЛЕКСАНДРА НЕВСКОГО I |
yefremovv | 0:011a309655b5 | 1157 | bufSend1[1] = 13; |
yefremovv | 0:011a309655b5 | 1158 | break; |
yefremovv | 0:011a309655b5 | 1159 | case 314: |
yefremovv | 0:011a309655b5 | 1160 | // МАЯКОВСКАЯ |
yefremovv | 0:011a309655b5 | 1161 | bufSend1[1] = 14; |
yefremovv | 0:011a309655b5 | 1162 | break; |
yefremovv | 0:011a309655b5 | 1163 | case 312: |
yefremovv | 0:011a309655b5 | 1164 | // ВАСИЛЕОСТРОВСКАЯ |
yefremovv | 0:011a309655b5 | 1165 | bufSend1[1] = 16; |
yefremovv | 0:011a309655b5 | 1166 | break; |
yefremovv | 0:011a309655b5 | 1167 | |
yefremovv | 0:011a309655b5 | 1168 | case 416: |
yefremovv | 0:011a309655b5 | 1169 | // ПЛ. АЛЕКСАНДРА НЕВСКОГО II |
yefremovv | 0:011a309655b5 | 1170 | bufSend1[1] = 21; |
yefremovv | 0:011a309655b5 | 1171 | break; |
yefremovv | 0:011a309655b5 | 1172 | |
yefremovv | 0:011a309655b5 | 1173 | case 522: |
yefremovv | 0:011a309655b5 | 1174 | // ЧКАЛОВСКАЯ |
yefremovv | 0:011a309655b5 | 1175 | bufSend1[1] = 23; |
yefremovv | 0:011a309655b5 | 1176 | break; |
yefremovv | 0:011a309655b5 | 1177 | case 524: |
yefremovv | 0:011a309655b5 | 1178 | // СТАРАЯ ДЕРЕВНЯ |
yefremovv | 0:011a309655b5 | 1179 | bufSend1[1] = 24; |
yefremovv | 0:011a309655b5 | 1180 | break; |
yefremovv | 0:011a309655b5 | 1181 | } |
yefremovv | 0:011a309655b5 | 1182 | ansPui1(); |
yefremovv | 0:011a309655b5 | 1183 | } |
yefremovv | 0:011a309655b5 | 1184 | |
yefremovv | 0:011a309655b5 | 1185 | //отправка станции на ПУИ2 |
yefremovv | 0:011a309655b5 | 1186 | void sendStatPui2(short stat){ |
yefremovv | 0:011a309655b5 | 1187 | bufSend2[0] = 64; |
yefremovv | 0:011a309655b5 | 1188 | switch(stat) |
yefremovv | 0:011a309655b5 | 1189 | { |
yefremovv | 0:011a309655b5 | 1190 | case 114: |
yefremovv | 0:011a309655b5 | 1191 | // ABTOBO; |
yefremovv | 0:011a309655b5 | 1192 | bufSend2[1] = 1; |
yefremovv | 0:011a309655b5 | 1193 | break; |
yefremovv | 0:011a309655b5 | 1194 | case 115: |
yefremovv | 0:011a309655b5 | 1195 | // НАРВСКАЯ |
yefremovv | 0:011a309655b5 | 1196 | bufSend2[1] = 3; |
yefremovv | 0:011a309655b5 | 1197 | break; |
yefremovv | 0:011a309655b5 | 1198 | case 117: |
yefremovv | 0:011a309655b5 | 1199 | // ТЕХНОЛОГИЧЕСКИЙ ИНСТИТУТ |
yefremovv | 0:011a309655b5 | 1200 | bufSend2[1] = 7; |
yefremovv | 0:011a309655b5 | 1201 | break; |
yefremovv | 0:011a309655b5 | 1202 | case 120: |
yefremovv | 0:011a309655b5 | 1203 | // ПЛОЩАДЬ ВОССТАНИЯ |
yefremovv | 0:011a309655b5 | 1204 | bufSend2[1] = 6; |
yefremovv | 0:011a309655b5 | 1205 | break; |
yefremovv | 0:011a309655b5 | 1206 | case 122: |
yefremovv | 0:011a309655b5 | 1207 | // ПЛОЩАДЬ ЛЕНИНА |
yefremovv | 0:011a309655b5 | 1208 | bufSend2[1] = 4; |
yefremovv | 0:011a309655b5 | 1209 | break; |
yefremovv | 0:011a309655b5 | 1210 | case 127: |
yefremovv | 0:011a309655b5 | 1211 | // АКАДЕМИЧЕСКАЯ |
yefremovv | 0:011a309655b5 | 1212 | bufSend2[1] = 2; |
yefremovv | 0:011a309655b5 | 1213 | break; |
yefremovv | 0:011a309655b5 | 1214 | |
yefremovv | 0:011a309655b5 | 1215 | case 218: |
yefremovv | 0:011a309655b5 | 1216 | // САДОВАЯ |
yefremovv | 0:011a309655b5 | 1217 | bufSend2[1] = 22; |
yefremovv | 0:011a309655b5 | 1218 | break; |
yefremovv | 0:011a309655b5 | 1219 | |
yefremovv | 0:011a309655b5 | 1220 | case 319: |
yefremovv | 0:011a309655b5 | 1221 | //ОБУХОВО |
yefremovv | 0:011a309655b5 | 1222 | bufSend2[1] = 11; |
yefremovv | 0:011a309655b5 | 1223 | break; |
yefremovv | 0:011a309655b5 | 1224 | case 317: |
yefremovv | 0:011a309655b5 | 1225 | //ЛОМОНОСОВСКАЯ |
yefremovv | 0:011a309655b5 | 1226 | bufSend2[1] = 12; |
yefremovv | 0:011a309655b5 | 1227 | break; |
yefremovv | 0:011a309655b5 | 1228 | case 315: |
yefremovv | 0:011a309655b5 | 1229 | // ПЛ. АЛЕКСАНДРА НЕВСКОГО I |
yefremovv | 0:011a309655b5 | 1230 | bufSend2[1] = 13; |
yefremovv | 0:011a309655b5 | 1231 | break; |
yefremovv | 0:011a309655b5 | 1232 | case 314: |
yefremovv | 0:011a309655b5 | 1233 | // МАЯКОВСКАЯ |
yefremovv | 0:011a309655b5 | 1234 | bufSend2[1] = 14; |
yefremovv | 0:011a309655b5 | 1235 | break; |
yefremovv | 0:011a309655b5 | 1236 | case 312: |
yefremovv | 0:011a309655b5 | 1237 | // ВАСИЛЕОСТРОВСКАЯ |
yefremovv | 0:011a309655b5 | 1238 | bufSend2[1] = 16; |
yefremovv | 0:011a309655b5 | 1239 | break; |
yefremovv | 0:011a309655b5 | 1240 | |
yefremovv | 0:011a309655b5 | 1241 | case 416: |
yefremovv | 0:011a309655b5 | 1242 | // ПЛ. АЛЕКСАНДРА НЕВСКОГО II |
yefremovv | 0:011a309655b5 | 1243 | bufSend2[1] = 21; |
yefremovv | 0:011a309655b5 | 1244 | break; |
yefremovv | 0:011a309655b5 | 1245 | case 522: |
yefremovv | 0:011a309655b5 | 1246 | // ЧКАЛОВСКАЯ |
yefremovv | 0:011a309655b5 | 1247 | bufSend2[1] = 23; |
yefremovv | 0:011a309655b5 | 1248 | break; |
yefremovv | 0:011a309655b5 | 1249 | case 524: |
yefremovv | 0:011a309655b5 | 1250 | // СТАРАЯ ДЕРЕВНЯ |
yefremovv | 0:011a309655b5 | 1251 | bufSend2[1] = 24; |
yefremovv | 0:011a309655b5 | 1252 | break; |
yefremovv | 0:011a309655b5 | 1253 | } |
yefremovv | 0:011a309655b5 | 1254 | ansPui2(); |
yefremovv | 0:011a309655b5 | 1255 | } |
yefremovv | 0:011a309655b5 | 1256 | |
yefremovv | 0:011a309655b5 | 1257 | //вывод станции на экран |
yefremovv | 0:011a309655b5 | 1258 | void viewStation(short stat, bool fl){ |
yefremovv | 0:011a309655b5 | 1259 | char station[25]; |
yefremovv | 0:011a309655b5 | 1260 | lcd.SetFont(&FontRus); |
yefremovv | 0:011a309655b5 | 1261 | strcpy(&station[0], getStation(stat)); |
yefremovv | 0:011a309655b5 | 1262 | if(!fl) |
yefremovv | 0:011a309655b5 | 1263 | lcd.DisplayStringAt(10, 250, (uint8_t *)&station, LEFT_MODE); |
yefremovv | 0:011a309655b5 | 1264 | else |
yefremovv | 0:011a309655b5 | 1265 | lcd.DisplayStringAt(10, 250, (uint8_t *)&station, RIGHT_MODE); |
yefremovv | 0:011a309655b5 | 1266 | lcd.SetFont(&FontNum); |
yefremovv | 0:011a309655b5 | 1267 | } |
yefremovv | 0:011a309655b5 | 1268 | |
yefremovv | 0:011a309655b5 | 1269 | //определение названия станции |
yefremovv | 0:011a309655b5 | 1270 | char* getStation(short stat){ |
yefremovv | 0:011a309655b5 | 1271 | switch(stat) |
yefremovv | 0:011a309655b5 | 1272 | { |
yefremovv | 0:011a309655b5 | 1273 | case 0: |
yefremovv | 0:011a309655b5 | 1274 | return "[]"; |
yefremovv | 0:011a309655b5 | 1275 | case 112: |
yefremovv | 0:011a309655b5 | 1276 | return "P-KS CFSFQANOC"; //Проспект Ветеранов |
yefremovv | 0:011a309655b5 | 1277 | case 113: |
yefremovv | 0:011a309655b5 | 1278 | return "LFNINRKIJ P-KS"; //Ленинский Проспект |
yefremovv | 0:011a309655b5 | 1279 | case 114: |
yefremovv | 0:011a309655b5 | 1280 | return "ACSOCO"; //Автово |
yefremovv | 0:011a309655b5 | 1281 | case 115: |
yefremovv | 0:011a309655b5 | 1282 | return "NAQCRKAf"; //Нарвская |
yefremovv | 0:011a309655b5 | 1283 | case 116: |
yefremovv | 0:011a309655b5 | 1284 | return "BALSIJRKAf"; //Балтийская |
yefremovv | 0:011a309655b5 | 1285 | case 117: |
yefremovv | 0:011a309655b5 | 1286 | return "SFVNOLODIXFRKIJ I."; //Технологический Институт |
yefremovv | 0:011a309655b5 | 1287 | case 118: |
yefremovv | 0:011a309655b5 | 1288 | return "PTYKINRKAf"; //Пушкинская |
yefremovv | 0:011a309655b5 | 1289 | case 119: |
yefremovv | 0:011a309655b5 | 1290 | return "CLAEIMIQRKAf"; //Владимирская |
yefremovv | 0:011a309655b5 | 1291 | case 120: |
yefremovv | 0:011a309655b5 | 1292 | return "P-Ec CORRSANIf"; //Площадь Восстания |
yefremovv | 0:011a309655b5 | 1293 | case 121: |
yefremovv | 0:011a309655b5 | 1294 | return "XFQNbYFCRKAf"; //Чернышевская |
yefremovv | 0:011a309655b5 | 1295 | case 122: |
yefremovv | 0:011a309655b5 | 1296 | return "P-Ec LFNINA"; //Площадь Ленина |
yefremovv | 0:011a309655b5 | 1297 | case 123: |
yefremovv | 0:011a309655b5 | 1298 | return "CbBOQDRKAf"; //Выборгская |
yefremovv | 0:011a309655b5 | 1299 | case 124: |
yefremovv | 0:011a309655b5 | 1300 | return "LFRNAf"; //Лесная |
yefremovv | 0:011a309655b5 | 1301 | case 125: |
yefremovv | 0:011a309655b5 | 1302 | return "P-Ec MTGFRSCA"; //Площадь Мужества |
yefremovv | 0:011a309655b5 | 1303 | case 126: |
yefremovv | 0:011a309655b5 | 1304 | return "POLISFVNIXFRKAf"; //Политехническая |
yefremovv | 0:011a309655b5 | 1305 | case 127: |
yefremovv | 0:011a309655b5 | 1306 | return "AKAEFMIXFRKAf"; //Академическая |
yefremovv | 0:011a309655b5 | 1307 | case 128: |
yefremovv | 0:011a309655b5 | 1308 | return "DQAGEANRKIJ P-KS"; //Гражданский Проспект |
yefremovv | 0:011a309655b5 | 1309 | case 129: |
yefremovv | 0:011a309655b5 | 1310 | return "EFCfSKINO"; //Девяткино |
yefremovv | 0:011a309655b5 | 1311 | |
yefremovv | 0:011a309655b5 | 1312 | case 211: |
yefremovv | 0:011a309655b5 | 1313 | return "KTPXINO"; //Купчино |
yefremovv | 0:011a309655b5 | 1314 | case 212: |
yefremovv | 0:011a309655b5 | 1315 | return "HCFHENAf"; //Звёздная |
yefremovv | 0:011a309655b5 | 1316 | case 213: |
yefremovv | 0:011a309655b5 | 1317 | return "MORKOCRKAf"; //Московская |
yefremovv | 0:011a309655b5 | 1318 | case 214: |
yefremovv | 0:011a309655b5 | 1319 | return "PAQK POBFEb"; //Парк Победы |
yefremovv | 0:011a309655b5 | 1320 | case 215: |
yefremovv | 0:011a309655b5 | 1321 | return "dLFKSQORILA"; //Электросила |
yefremovv | 0:011a309655b5 | 1322 | case 216: |
yefremovv | 0:011a309655b5 | 1323 | return "UQTNHFNRKAf"; //Фрунзенская |
yefremovv | 0:011a309655b5 | 1324 | case 217: |
yefremovv | 0:011a309655b5 | 1325 | return "SFVNOLODIXFRKIJ I.2"; //Технологический Институт 2 |
yefremovv | 0:011a309655b5 | 1326 | case 218: |
yefremovv | 0:011a309655b5 | 1327 | return "RAEOCAf"; //Садовая |
yefremovv | 0:011a309655b5 | 1328 | |
yefremovv | 0:011a309655b5 | 1329 | case 220: |
yefremovv | 0:011a309655b5 | 1330 | return "NFCRKIJ P-KS"; //Невский Проспект |
yefremovv | 0:011a309655b5 | 1331 | case 221: |
yefremovv | 0:011a309655b5 | 1332 | return "DOQcKOCRKAf"; //Горьковская |
yefremovv | 0:011a309655b5 | 1333 | case 222: |
yefremovv | 0:011a309655b5 | 1334 | return "PFSQODQAERKAf"; //Петроградская |
yefremovv | 0:011a309655b5 | 1335 | case 223: |
yefremovv | 0:011a309655b5 | 1336 | return "XFQNAf QFXKA"; //Чёрная Речка |
yefremovv | 0:011a309655b5 | 1337 | case 224: |
yefremovv | 0:011a309655b5 | 1338 | return "PIONFQRKAf"; //Пионерская |
yefremovv | 0:011a309655b5 | 1339 | case 225: |
yefremovv | 0:011a309655b5 | 1340 | return "TEFLcNAf"; //Удельная |
yefremovv | 0:011a309655b5 | 1341 | case 226: |
yefremovv | 0:011a309655b5 | 1342 | return "OHFQKI"; //Озерки |
yefremovv | 0:011a309655b5 | 1343 | case 227: |
yefremovv | 0:011a309655b5 | 1344 | return "P-KS PQORCFZFNIf"; //Проспект Просвещения |
yefremovv | 0:011a309655b5 | 1345 | case 228: |
yefremovv | 0:011a309655b5 | 1346 | return "PAQNAR"; //Парнас |
yefremovv | 0:011a309655b5 | 1347 | |
yefremovv | 0:011a309655b5 | 1348 | case 320: |
yefremovv | 0:011a309655b5 | 1349 | return "QbBASRKOF"; //Рыбатское |
yefremovv | 0:011a309655b5 | 1350 | case 319: |
yefremovv | 0:011a309655b5 | 1351 | return "OBTVOCO"; //Обухово |
yefremovv | 0:011a309655b5 | 1352 | case 318: |
yefremovv | 0:011a309655b5 | 1353 | return "PQOLFSAQRKAf"; //Пролетарская |
yefremovv | 0:011a309655b5 | 1354 | case 317: |
yefremovv | 0:011a309655b5 | 1355 | return "LOMONOROCRKAf"; //Ломоносовская |
yefremovv | 0:011a309655b5 | 1356 | case 316: |
yefremovv | 0:011a309655b5 | 1357 | return "FLIHAQOCRKAf"; //Елизаровская |
yefremovv | 0:011a309655b5 | 1358 | case 315: |
yefremovv | 0:011a309655b5 | 1359 | return "P-Ec A. NFCRKODO 1"; //Площадь Александра Невского 1 |
yefremovv | 0:011a309655b5 | 1360 | case 314: |
yefremovv | 0:011a309655b5 | 1361 | return "MAfKOCRKAf"; //Маяковская |
yefremovv | 0:011a309655b5 | 1362 | case 313: |
yefremovv | 0:011a309655b5 | 1363 | return "DORSINbJ ECOQ"; //Гостиный Двор |
yefremovv | 0:011a309655b5 | 1364 | case 312: |
yefremovv | 0:011a309655b5 | 1365 | return "CARILFORSQOCRKAf"; //Василеостровская |
yefremovv | 0:011a309655b5 | 1366 | case 311: |
yefremovv | 0:011a309655b5 | 1367 | return "PQIMOQRKAf"; //Приморская |
yefremovv | 0:011a309655b5 | 1368 | |
yefremovv | 0:011a309655b5 | 1369 | case 412: |
yefremovv | 0:011a309655b5 | 1370 | return "EbBFNKO"; //Дыбенко |
yefremovv | 0:011a309655b5 | 1371 | case 413: |
yefremovv | 0:011a309655b5 | 1372 | return "P-KS BOLcYFCIKOC"; //Проспект Большевиков |
yefremovv | 0:011a309655b5 | 1373 | case 414: |
yefremovv | 0:011a309655b5 | 1374 | return "LAEOGRKAf"; //Ладожская |
yefremovv | 0:011a309655b5 | 1375 | case 415: |
yefremovv | 0:011a309655b5 | 1376 | return "NOCOXFQKARRKAf"; //Новочеркасская |
yefremovv | 0:011a309655b5 | 1377 | case 416: |
yefremovv | 0:011a309655b5 | 1378 | return "P-Ec A. NFCRKODO 2"; //Площадь Александра Невского 2 |
yefremovv | 0:011a309655b5 | 1379 | case 417: |
yefremovv | 0:011a309655b5 | 1380 | return "LIDOCRKIJ P-KS"; //Лиговский Проспект |
yefremovv | 0:011a309655b5 | 1381 | case 418: |
yefremovv | 0:011a309655b5 | 1382 | return "RPARRKAf"; //Спасская |
yefremovv | 0:011a309655b5 | 1383 | |
yefremovv | 0:011a309655b5 | 1384 | case 514: |
yefremovv | 0:011a309655b5 | 1385 | return "MFGETNAQOENAf"; //Международная |
yefremovv | 0:011a309655b5 | 1386 | case 515: |
yefremovv | 0:011a309655b5 | 1387 | return "BTVAQFRSRKAf"; //Бухарестская |
yefremovv | 0:011a309655b5 | 1388 | case 516: |
yefremovv | 0:011a309655b5 | 1389 | return "COLKOCRKAf"; //Волковская |
yefremovv | 0:011a309655b5 | 1390 | case 517: |
yefremovv | 0:011a309655b5 | 1391 | return "OBCOENbJ KANAL"; //Обводный Канал |
yefremovv | 0:011a309655b5 | 1392 | case 518: |
yefremovv | 0:011a309655b5 | 1393 | return "HCFNIDOQOERKAf"; //Звенигородская |
yefremovv | 0:011a309655b5 | 1394 | case 519: |
yefremovv | 0:011a309655b5 | 1395 | return "RFNNAf P-Ec"; //Сенная Площадь |
yefremovv | 0:011a309655b5 | 1396 | case 520: |
yefremovv | 0:011a309655b5 | 1397 | return "AEMIQALSFJRKAf"; //Адмиралтейская |
yefremovv | 0:011a309655b5 | 1398 | case 521: |
yefremovv | 0:011a309655b5 | 1399 | return "RPOQSICNAf"; //Спортивная |
yefremovv | 0:011a309655b5 | 1400 | case 522: |
yefremovv | 0:011a309655b5 | 1401 | return "XKALOCRKAf"; //Чкаловская |
yefremovv | 0:011a309655b5 | 1402 | case 523: |
yefremovv | 0:011a309655b5 | 1403 | return "KQFRSOCRKIJ ORSQOC"; //Крестовский Остров |
yefremovv | 0:011a309655b5 | 1404 | case 524: |
yefremovv | 0:011a309655b5 | 1405 | return "RSAQAf EFQFCNf"; //Старая Деревня |
yefremovv | 0:011a309655b5 | 1406 | case 525: |
yefremovv | 0:011a309655b5 | 1407 | return "KOMFNEANSRKIJ P-KS"; //Комендантский Проспект |
yefremovv | 0:011a309655b5 | 1408 | } |
yefremovv | 0:011a309655b5 | 1409 | return "";//'\0'; |
yefremovv | 0:011a309655b5 | 1410 | } |
yefremovv | 0:011a309655b5 | 1411 | |
yefremovv | 0:011a309655b5 | 1412 | //эмблема нии тм |
yefremovv | 0:011a309655b5 | 1413 | void logo(){ |
yefremovv | 0:011a309655b5 | 1414 | lcd.Clear(LCD_COLOR_BLACK); |
yefremovv | 0:011a309655b5 | 1415 | lcd.SetTextColor(LCD_COLOR_BLUE); |
yefremovv | 0:011a309655b5 | 1416 | //круги |
yefremovv | 0:011a309655b5 | 1417 | for(int i=0; i<3; i++) |
yefremovv | 0:011a309655b5 | 1418 | lcd.DrawCircle(240, 136, 75 + i); |
yefremovv | 0:011a309655b5 | 1419 | lcd.DrawCircle(240, 136, 80); |
yefremovv | 0:011a309655b5 | 1420 | //Т |
yefremovv | 0:011a309655b5 | 1421 | lcd.FillRect(214, 81, 52, 7); |
yefremovv | 0:011a309655b5 | 1422 | lcd.DrawHLine(214, 88, 18); |
yefremovv | 0:011a309655b5 | 1423 | lcd.DrawHLine(214, 89, 17); |
yefremovv | 0:011a309655b5 | 1424 | lcd.DrawHLine(215, 90, 15); |
yefremovv | 0:011a309655b5 | 1425 | lcd.DrawHLine(216, 91, 12); |
yefremovv | 0:011a309655b5 | 1426 | lcd.DrawHLine(217, 92, 10); |
yefremovv | 0:011a309655b5 | 1427 | lcd.DrawHLine(218, 93, 9); |
yefremovv | 0:011a309655b5 | 1428 | lcd.DrawHLine(219, 94, 7); |
yefremovv | 0:011a309655b5 | 1429 | lcd.DrawHLine(220, 95, 5); |
yefremovv | 0:011a309655b5 | 1430 | lcd.DrawHLine(246, 88, 20); |
yefremovv | 0:011a309655b5 | 1431 | lcd.DrawHLine(247, 89, 19); |
yefremovv | 0:011a309655b5 | 1432 | lcd.DrawHLine(248, 90, 17); |
yefremovv | 0:011a309655b5 | 1433 | lcd.DrawHLine(250, 91, 14); |
yefremovv | 0:011a309655b5 | 1434 | lcd.DrawHLine(251, 92, 12); |
yefremovv | 0:011a309655b5 | 1435 | lcd.DrawHLine(251, 93, 11); |
yefremovv | 0:011a309655b5 | 1436 | lcd.DrawHLine(253, 94, 8); |
yefremovv | 0:011a309655b5 | 1437 | lcd.DrawHLine(254, 95, 6); |
yefremovv | 0:011a309655b5 | 1438 | lcd.FillRect(235, 88, 8, 75); |
yefremovv | 0:011a309655b5 | 1439 | //M |
yefremovv | 0:011a309655b5 | 1440 | lcd.FillRect(194, 96, 12, 76); |
yefremovv | 0:011a309655b5 | 1441 | lcd.FillRect(275, 96, 12, 76); |
yefremovv | 0:011a309655b5 | 1442 | lcd.DrawHLine(195, 172, 11); |
yefremovv | 0:011a309655b5 | 1443 | lcd.DrawHLine(196, 173, 10); |
yefremovv | 0:011a309655b5 | 1444 | lcd.DrawHLine(197, 174, 9); |
yefremovv | 0:011a309655b5 | 1445 | lcd.DrawHLine(198, 175, 8); |
yefremovv | 0:011a309655b5 | 1446 | lcd.DrawHLine(199, 176, 7); |
yefremovv | 0:011a309655b5 | 1447 | lcd.DrawHLine(200, 177, 6); |
yefremovv | 0:011a309655b5 | 1448 | lcd.DrawHLine(201, 178, 5); |
yefremovv | 0:011a309655b5 | 1449 | lcd.DrawHLine(202, 179, 4); |
yefremovv | 0:011a309655b5 | 1450 | lcd.DrawHLine(203, 180, 3); |
yefremovv | 0:011a309655b5 | 1451 | lcd.DrawHLine(204, 181, 2); |
yefremovv | 0:011a309655b5 | 1452 | lcd.DrawHLine(275, 172, 11); |
yefremovv | 0:011a309655b5 | 1453 | lcd.DrawHLine(275, 173, 10); |
yefremovv | 0:011a309655b5 | 1454 | lcd.DrawHLine(275, 174, 9); |
yefremovv | 0:011a309655b5 | 1455 | lcd.DrawHLine(275, 175, 8); |
yefremovv | 0:011a309655b5 | 1456 | lcd.DrawHLine(275, 176, 7); |
yefremovv | 0:011a309655b5 | 1457 | lcd.DrawHLine(275, 177, 6); |
yefremovv | 0:011a309655b5 | 1458 | lcd.DrawHLine(275, 178, 5); |
yefremovv | 0:011a309655b5 | 1459 | lcd.DrawHLine(275, 179, 4); |
yefremovv | 0:011a309655b5 | 1460 | lcd.DrawHLine(275, 180, 3); |
yefremovv | 0:011a309655b5 | 1461 | lcd.DrawHLine(275, 181, 2); |
yefremovv | 0:011a309655b5 | 1462 | for(int i=0; i<15; i++) |
yefremovv | 0:011a309655b5 | 1463 | { |
yefremovv | 0:011a309655b5 | 1464 | lcd.DrawLine(206, 97 + i, 238, 177 + i); |
yefremovv | 0:011a309655b5 | 1465 | lcd.DrawLine(275, 97 + i, 238, 177 + i); |
yefremovv | 0:011a309655b5 | 1466 | } |
yefremovv | 0:011a309655b5 | 1467 | //прямоугольник |
yefremovv | 0:011a309655b5 | 1468 | lcd.FillRect(226, 148, 27, 15); |
yefremovv | 0:011a309655b5 | 1469 | lcd.SetTextColor(LCD_COLOR_WHITE); |
yefremovv | 0:011a309655b5 | 1470 | //Н |
yefremovv | 0:011a309655b5 | 1471 | lcd.DrawVLine(228, 151, 10); |
yefremovv | 0:011a309655b5 | 1472 | lcd.DrawHLine(228, 155, 7); |
yefremovv | 0:011a309655b5 | 1473 | lcd.DrawVLine(235, 151, 10); |
yefremovv | 0:011a309655b5 | 1474 | //И |
yefremovv | 0:011a309655b5 | 1475 | lcd.DrawVLine(238, 151, 10); |
yefremovv | 0:011a309655b5 | 1476 | lcd.DrawLine(238, 161, 243, 151); |
yefremovv | 0:011a309655b5 | 1477 | lcd.DrawVLine(243, 151, 10); |
yefremovv | 0:011a309655b5 | 1478 | //И |
yefremovv | 0:011a309655b5 | 1479 | lcd.DrawVLine(246, 151, 10); |
yefremovv | 0:011a309655b5 | 1480 | lcd.DrawLine(246, 161, 251, 151); |
yefremovv | 0:011a309655b5 | 1481 | lcd.DrawVLine(251, 151, 10); |
yefremovv | 0:011a309655b5 | 1482 | |
yefremovv | 0:011a309655b5 | 1483 | wait(2); |
yefremovv | 0:011a309655b5 | 1484 | lcd.Clear(LCD_COLOR_BLACK); |
yefremovv | 0:011a309655b5 | 1485 | lcd.SetBackColor(LCD_COLOR_BLACK); |
yefremovv | 0:011a309655b5 | 1486 | lcd.SetTextColor(LCD_COLOR_LIGHTGREEN); //white |
yefremovv | 0:011a309655b5 | 1487 | } |
yefremovv | 0:011a309655b5 | 1488 | |
yefremovv | 0:011a309655b5 | 1489 | //уст-ка флага отсутствия связи с сервером |
yefremovv | 0:011a309655b5 | 1490 | void workConn(){ |
yefremovv | 0:011a309655b5 | 1491 | flEth = 0; |
yefremovv | 0:011a309655b5 | 1492 | } |
yefremovv | 0:011a309655b5 | 1493 | |
yefremovv | 0:011a309655b5 | 1494 | //watchdog-таймер |
yefremovv | 0:011a309655b5 | 1495 | void StartIWDG(int interval_ms) |
yefremovv | 0:011a309655b5 | 1496 | { |
yefremovv | 0:011a309655b5 | 1497 | if(__HAL_RCC_GET_FLAG(RCC_FLAG_IWDGRST) != RESET) |
yefremovv | 0:011a309655b5 | 1498 | __HAL_RCC_CLEAR_RESET_FLAGS(); |
yefremovv | 0:011a309655b5 | 1499 | |
yefremovv | 0:011a309655b5 | 1500 | /* IWDG counter clock Frequency = LsiFreq/256 = LSI_VALUE |
yefremovv | 0:011a309655b5 | 1501 | Counter Reload Value = 250ms/IWDG counter clock period |
yefremovv | 0:011a309655b5 | 1502 | 256/32.000 = 8 ms per cycle (prescaler/LSI) |
yefremovv | 0:011a309655b5 | 1503 | reload = interval_ms / 8; |
yefremovv | 0:011a309655b5 | 1504 | LSI_VALUE = 32000 on the L4 */ |
yefremovv | 0:011a309655b5 | 1505 | int reload_ms = (256 * 1000) / LSI_VALUE; //~ 8 мс |
yefremovv | 0:011a309655b5 | 1506 | int reload_val = interval_ms / reload_ms; |
yefremovv | 0:011a309655b5 | 1507 | if (reload_val <= 0) |
yefremovv | 0:011a309655b5 | 1508 | reload_val = 8; |
yefremovv | 0:011a309655b5 | 1509 | if (reload_val > (1 << 12) - 1) //> 12-битн. счётчик |
yefremovv | 0:011a309655b5 | 1510 | reload_val = (1 << 12) - 1; |
yefremovv | 0:011a309655b5 | 1511 | |
yefremovv | 0:011a309655b5 | 1512 | IwdgHandle.Instance = IWDG; |
yefremovv | 0:011a309655b5 | 1513 | IwdgHandle.Init.Prescaler = IWDG_PRESCALER_256; |
yefremovv | 0:011a309655b5 | 1514 | IwdgHandle.Init.Reload = reload_val; |
yefremovv | 0:011a309655b5 | 1515 | IwdgHandle.Init.Window = IWDG_WINDOW_DISABLE; |
yefremovv | 0:011a309655b5 | 1516 | |
yefremovv | 0:011a309655b5 | 1517 | HAL_IWDG_Init(&IwdgHandle); |
yefremovv | 0:011a309655b5 | 1518 | HAL_IWDG_Refresh(&IwdgHandle); |
yefremovv | 0:011a309655b5 | 1519 | } |