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