- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
- 73
- 74
- 75
- 76
- 77
- 78
- 79
- 80
- 81
- 82
- 83
- 84
- 85
- 86
- 87
- 88
- 89
- 90
- 91
- 92
- 93
- 94
- 95
- 96
- 97
- 98
/*
xdrv_96_blacklist.ino - Blacklist for Tasmota
SPDX-FileCopyrightText: 2022 Theo Arends
SPDX-License-Identifier: GPL-3.0-only
*/
#define USE_BLACKLIST
#ifdef USE_BLACKLIST
/*********************************************************************************************\
* Blacklist support
*
* Check language and user set latitude/longitude against blacklist table
\*********************************************************************************************/
#define XDRV_96 96
typedef struct {
int16_t latitude_tl; // - 8999 to 8999
int16_t longitude_tl; // -17999 to 17999
int16_t latitude_br;
int16_t longitude_br;
uint16_t lcid;
} tBlArray;
//const char BlacklistText[] PROGMEM = "Stop war - Free Ukrain|Stop war - Free Ukrain|";
const char BlacklistText[] PROGMEM = "Stop war, Free Ukrain";
// lat_tl lon_tl lat_br lon_br lcid
tBlArray BlArray[] { 5900, 3200, 5300, 4400, 1049, // Around Moscow
5450, 2633, 5280, 2900, 1049 // Around Minsk
};
uint8_t blist_show = 0;
void BListEverySecond(void) {
if (Rtc.utc_time < 1648771200) { // Only until 2022-04-01
if (0 == (TasmotaGlobal.uptime % 20)) { // Only every 20 seconds
if (TasmotaGlobal.power) { // Only if any power on
uint32_t latitude = Settings->latitude / 10000;
uint32_t longitude = Settings->longitude / 10000;
uint32_t count = sizeof(BlArray) / sizeof(tBlArray);
for (uint32_t i = 0; i < count; i++) {
// Currently only supports top-right quarter of the earth
if ((LANGUAGE_LCID == BlArray[i].lcid) && // Check language id
(latitude < BlArray[i].latitude_tl) && // Check user set latitude and longitude against table
(latitude > BlArray[i].latitude_br) &&
(longitude > BlArray[i].longitude_tl) &&
(longitude < BlArray[i].longitude_br)) {
// char bl_text[100];
// snprintf_P(bl_text, sizeof(bl_text), PSTR("Power0 0")); // Turn all power off - annoying
// snprintf_P(bl_text, sizeof(bl_text), PSTR("Restart 1")); // Restart - more annoying
// snprintf_P(bl_text, sizeof(bl_text), PSTR("Reset 1")); // Reset - disastrous
// ExecuteCommand(bl_text, SRC_IGNORE);
// char bl_text[100];
// AddLog(LOG_LEVEL_NONE, PSTR("**** %s ****"), GetTextIndexed(bl_text, sizeof(bl_text), i, BlacklistText));
AddLog(LOG_LEVEL_NONE, PSTR("**** %s ****"), BlacklistText);
blist_show = i +1; // Set GUI message id
break;
}
}
}
} else if (0 == (TasmotaGlobal.uptime % 10)) { // Only every 10 seconds
blist_show = 0; // Reset GUI message id after 10 seconds
}
}
}
void BListShow(bool json) {
if (blist_show) {
// char bl_text[100];
// WSContentSend_PD(PSTR("{s}**** %s ****{m}{e}"), GetTextIndexed(bl_text, sizeof(bl_text), blist_show -1, BlacklistText));
WSContentSend_P(PSTR("{s}**** %s ****{m}{e}"), BlacklistText);
}
}
/*********************************************************************************************\
* Interface
\*********************************************************************************************/
bool Xdrv96(uint8_t function) {
bool result = false;
switch (function) {
case FUNC_EVERY_SECOND:
BListEverySecond();
break;
#ifdef USE_WEBSERVER
case FUNC_WEB_SENSOR:
BListShow(0);
break;
#endif // USE_WEBSERVER
}
return result;
}
https://github.com/arendst/Tasmota/commit/98cbf2587a1a914bbd16996ebb48dd451d3da448
guest6 05.03.2022 16:01 # 0
ObeseYoung 05.03.2022 16:23 # 0
Это в ассеблер?
DaveMustAim 05.03.2022 19:41 # 0
DaveMustAim 05.03.2022 19:41 # 0
bormand 05.03.2022 19:46 # +1
Земля таки плоская? Какой багор )))
DaveMustAim 06.03.2022 11:22 # 0
Steve_Brown 09.03.2022 13:02 # 0
(как сделать географу больно)
bormand 09.03.2022 13:12 # 0
Soul_re@ver 09.03.2022 13:16 # 0