mirror of
https://github.com/OpenEPaperLink/OpenEPaperLink.git
synced 2026-03-21 10:06:07 +01:00
added wifi power and time zone to APconfig
- added wifi transmit power option - added time zone config option - small fixes
This commit is contained in:
@@ -116,6 +116,65 @@ Latency will be around 40 seconds.">
|
||||
<option value="1">yes</option>
|
||||
</select>
|
||||
</p>
|
||||
<p title="Wifi transmit power">
|
||||
<label for="apcwifipower">Wifi power</label>
|
||||
<select id="apcwifipower">
|
||||
<option value="78">19.5 dBm</option>
|
||||
<option value="76">19.0 dBm</option>
|
||||
<option value="74">18.5 dBm</option>
|
||||
<option value="68">17.0 dBm</option>
|
||||
<option value="60">15.0 dBm</option>
|
||||
<option value="52">13.0 dBm</option>
|
||||
<option value="44">11.0 dBm</option>
|
||||
<option value="34">8.5 dBm</option>
|
||||
<option value="28">7.0 dBm</option>
|
||||
<option value="20">5.0 dBm</option>
|
||||
<option value="8">2.0 dBm</option>
|
||||
</select>
|
||||
</p>
|
||||
<p title="Your local time zone">
|
||||
<label for="apctimezone">Local time zone</label>
|
||||
<select id="apctimezone">
|
||||
<optgroup label="Europe">
|
||||
<option value="CET-1CEST-2,M3.5.0/02:00:00,M10.5.0/03:00:00">Central European Time</option>
|
||||
<option value="EET-2EEST-3,M3.5.0/03:00:00,M10.5.0/04:00:00">Athens, Greece</option>
|
||||
<option value="GMT+0IST-1,M3.5.0/01:00:00,M10.5.0/02:00:00">Dublin, Ireland</option>
|
||||
<option value="EET-2EEST-3,M3.5.0/03:00:00,M10.5.0/04:00:00">Helsinki, Finland</option>
|
||||
<option value="WET-0WEST-1,M3.5.0/01:00:00,M10.5.0/02:00:00">Lisbon, Portugal</option>
|
||||
<option value="GMT+0BST-1,M3.5.0/01:00:00,M10.5.0/02:00:00">London, Great Britain</option>
|
||||
<option value="EET-2EEST,M3.5.0/3,M10.5.0/4">Kyiv, Ukraine</option>
|
||||
</optgroup>
|
||||
<optgroup label="USA / Canada">
|
||||
<option value="HAW10">Hawaii Time</option>
|
||||
<option value="AKST9AKDT">Alaska Time</option>
|
||||
<option value="PST8PDT">Pacific Time</option>
|
||||
<option value="MST7MDT">Mountain Time</option>
|
||||
<option value="MST7">Arizona, no DST</option>
|
||||
<option value="CST6CDT">Central Time</option>
|
||||
<option value="EST5EDT">Eastern Time</option>
|
||||
</optgroup>
|
||||
<optgroup label="Australia / New Zealand">
|
||||
<option value="EST-10EDT-11,M10.5.0/02:00:00,M3.5.0/03:00:00">Melbourne, Sydney</option>
|
||||
<option value="WST-8">Perth</option>
|
||||
<option value="EST-10">Brisbane</option>
|
||||
<option value="CST-9:30CDT-10:30,M10.5.0/02:00:00,M3.5.0/03:00:00">Adelaide</option>
|
||||
<option value="CST-9:30">Darwin</option>
|
||||
<option value="EST-10EDT-11,M10.1.0/02:00:00,M3.5.0/03:00:00">Hobart</option>
|
||||
<option value="NZST-12NZDT-13,M9.4.0/02:00:00,M4.1.0/03:00:00">New Zealand</option>
|
||||
</optgroup>
|
||||
<optgroup label="Asia">
|
||||
<option value="WIB-7">Jakarta</option>
|
||||
<option value="GMT+2">Jerusalem</option>
|
||||
<option value="SGT-8">Singapore</option>
|
||||
<option value="ULAT-8ULAST,M3.5.0/2,M9.5.0/2">Ulaanbaatar, Mongolia</option>
|
||||
</optgroup>
|
||||
<optgroup label="Central and South America">
|
||||
<option value="BRST+3BRDT+2,M10.3.0,M2.3.0">Brazil, Sao Paulo</option>
|
||||
<option value="UTC+3">Argentina</option>
|
||||
<option value="CST+6">Central America</option>
|
||||
</optgroup>
|
||||
</select>
|
||||
</p>
|
||||
<p>
|
||||
<input type="button" value="Save" id="apcfgsave">
|
||||
</p>
|
||||
|
||||
@@ -94,7 +94,7 @@ function connect() {
|
||||
processTags(msg.tags);
|
||||
}
|
||||
if (msg.sys) {
|
||||
$('#sysinfo').innerHTML = 'free heap: ' + msg.sys.heap + ' bytes ┇ db size: ' + convertSize(msg.sys.dbsize) + " ("+ msg.sys.dbsize + ' bytes) ┇ db record count: ' + msg.sys.recordcount + ' ┇ filesystem free: ' + convertSize(msg.sys.littlefsfree);
|
||||
$('#sysinfo').innerHTML = 'free heap: ' + convertSize(msg.sys.heap) + ' ┇ db size: ' + convertSize(msg.sys.dbsize) + ' ┇ db record count: ' + msg.sys.recordcount + ' ┇ filesystem free: ' + convertSize(msg.sys.littlefsfree);
|
||||
if (msg.sys.apstate) {
|
||||
$("#apstatecolor").style.color = apstate[msg.sys.apstate].color;
|
||||
$("#apstate").innerHTML = apstate[msg.sys.apstate].state;
|
||||
@@ -452,6 +452,8 @@ $('#apconfigbutton').onclick = function () {
|
||||
$("#apcfglanguage").value = data.language;
|
||||
$("#apclatency").value = data.maxsleep;
|
||||
$("#apcpreventsleep").value = data.stopsleep;
|
||||
$("#apcwifipower").value = data.wifipower;
|
||||
$("#apctimezone").value = data.timezone;
|
||||
})
|
||||
$('#apconfigbox').style.display = 'block'
|
||||
}
|
||||
@@ -464,6 +466,8 @@ $('#apcfgsave').onclick = function () {
|
||||
formData.append('language', $('#apcfglanguage').value);
|
||||
formData.append('maxsleep', $('#apclatency').value);
|
||||
formData.append('stopsleep', $('#apcpreventsleep').value);
|
||||
formData.append('wifipower', $('#apcwifipower').value);
|
||||
formData.append('timezone', $('#apctimezone').value);
|
||||
fetch("/save_apcfg", {
|
||||
method: "POST",
|
||||
body: formData
|
||||
|
||||
@@ -63,6 +63,8 @@ struct Config {
|
||||
uint8_t maxsleep;
|
||||
uint8_t stopsleep;
|
||||
uint8_t runStatus;
|
||||
uint8_t wifiPower;
|
||||
char timeZone[52];
|
||||
};
|
||||
|
||||
// extern SemaphoreHandle_t tagDBOwner;
|
||||
|
||||
@@ -511,7 +511,7 @@ void drawWeather(String &filename, JsonObject &cfgobj, tagRecord *&taginfo, imgP
|
||||
drawString(spr, String(tmpOutput), loc["temp"][0], loc["temp"][1], loc["temp"][2], TL_DATUM, (temperature < 0 ? PAL_RED : PAL_BLACK));
|
||||
|
||||
spr.loadFont(loc["icon"][2], *contentFS);
|
||||
if (weathercode == 55 || weathercode == 65 || weathercode == 75 || weathercode == 82 || weathercode == 86 || weathercode == 95 || weathercode == 99) {
|
||||
if (weathercode == 55 || weathercode == 65 || weathercode == 75 || weathercode == 82 || weathercode == 86 || weathercode == 95 || weathercode == 96 || weathercode == 99) {
|
||||
spr.setTextColor(PAL_RED, PAL_WHITE);
|
||||
} else {
|
||||
spr.setTextColor(PAL_BLACK, PAL_WHITE);
|
||||
@@ -584,7 +584,7 @@ void drawForecast(String &filename, JsonObject &cfgobj, tagRecord *&taginfo, img
|
||||
uint8_t weathercode = doc["daily"]["weathercode"][dag].as<int>();
|
||||
if (weathercode > 40) weathercode -= 40;
|
||||
spr.loadFont(loc["icon"][2], *contentFS);
|
||||
if (weathercode == 55 || weathercode == 65 || weathercode == 75 || weathercode == 82 || weathercode == 86 || weathercode == 95 || weathercode == 99) {
|
||||
if (weathercode == 55 || weathercode == 65 || weathercode == 75 || weathercode == 82 || weathercode == 86 || weathercode == 95 || weathercode == 96 || weathercode == 99) {
|
||||
spr.setTextColor(PAL_RED, PAL_WHITE);
|
||||
} else {
|
||||
spr.setTextColor(PAL_BLACK, PAL_WHITE);
|
||||
@@ -775,7 +775,6 @@ bool getCalFeed(String &filename, String URL, String title, tagRecord *&taginfo,
|
||||
for (int i = 0; i < n; i++) {
|
||||
JsonObject obj = doc[i];
|
||||
String eventtitle = obj["title"];
|
||||
String startz = obj["start"];
|
||||
time_t starttime = obj["start"];
|
||||
time_t endtime = obj["end"];
|
||||
setU8G2Font(loc["line"][3], u8f);
|
||||
|
||||
@@ -35,13 +35,13 @@ void delayedStart(void* parameter) {
|
||||
|
||||
void timeTask(void* parameter) {
|
||||
wsSendSysteminfo();
|
||||
Serial.printf("Free heap: %.2f KB\n", ESP.getFreeHeap() / 1024.0f);
|
||||
Serial.printf("Free heap: %.2f kB\n", ESP.getFreeHeap() / 1024.0f);
|
||||
while (1) {
|
||||
time_t now;
|
||||
time(&now);
|
||||
|
||||
if (now % 5 == 0 || apInfo.state != AP_STATE_ONLINE || config.runStatus != RUNSTATUS_RUN) wsSendSysteminfo();
|
||||
if (now % 5 == 0) Serial.printf("Free heap: %.2f KB\n", ESP.getFreeHeap() / 1024.0f);
|
||||
if (now % 5 == 0) Serial.printf("Free heap: %.2f kB\n", ESP.getFreeHeap() / 1024.0f);
|
||||
if (now % 300 == 6 && config.runStatus != RUNSTATUS_STOP) saveDB("/current/tagDB.json");
|
||||
|
||||
if (apInfo.state == AP_STATE_ONLINE) contentRunner();
|
||||
@@ -55,8 +55,8 @@ void setup() {
|
||||
xTaskCreate(ledTask, "ledhandler", 2000, NULL, 2, NULL);
|
||||
vTaskDelay(10 / portTICK_PERIOD_MS);
|
||||
|
||||
// show a nice pattern to indicate the AP is booting / waiting for WiFi setup
|
||||
#ifdef HAS_RGB_LED
|
||||
// show a nice pattern to indicate the AP is booting / waiting for WiFi setup
|
||||
showColorPattern(CRGB::Aqua, CRGB::Green, CRGB::Blue);
|
||||
#endif
|
||||
|
||||
@@ -122,10 +122,10 @@ void setup() {
|
||||
xTaskCreate(usbFlasherTask, "usbflasher", 10000, NULL, configMAX_PRIORITIES - 10, NULL);
|
||||
#endif
|
||||
|
||||
configTzTime("CET-1CEST,M3.5.0,M10.5.0/3", "0.nl.pool.ntp.org", "europe.pool.ntp.org", "time.nist.gov");
|
||||
initAPconfig();
|
||||
configTzTime(config.timeZone, "0.nl.pool.ntp.org", "europe.pool.ntp.org", "time.nist.gov");
|
||||
// https://github.com/nayarsystems/posix_tz_db/blob/master/zones.csv
|
||||
|
||||
initAPconfig();
|
||||
updateLanguageFromConfig();
|
||||
updateBrightnessFromConfig();
|
||||
|
||||
|
||||
@@ -219,8 +219,10 @@ void spr2buffer(TFT_eSprite &spr, String &fileout, imgParam &imageParams) {
|
||||
free(blackBuffer);
|
||||
if (imageParams.hasRed) {
|
||||
uint8_t *redBuffer = (uint8_t*) spr2color(spr, imageParams, &bufferSize, true);
|
||||
if(!redBuffer)
|
||||
if(!redBuffer) {
|
||||
imageParams.hasRed = false;
|
||||
return;
|
||||
}
|
||||
f_out.write(redBuffer, bufferSize);
|
||||
free(redBuffer);
|
||||
}
|
||||
|
||||
@@ -30,6 +30,14 @@ void logLine(String text) {
|
||||
|
||||
File logFile = contentFS->open("/log.txt", "a");
|
||||
if (logFile) {
|
||||
if (logFile.size() >= 10 * 1024) {
|
||||
logFile.close();
|
||||
contentFS->remove("/logold.txt");
|
||||
contentFS->rename("/log.txt", "/logold.txt");
|
||||
logFile = contentFS->open("/log.txt", "a");
|
||||
if (!logFile) return;
|
||||
}
|
||||
|
||||
logFile.print(timeStr);
|
||||
logFile.println(text);
|
||||
logFile.close();
|
||||
|
||||
@@ -286,6 +286,14 @@ void initAPconfig() {
|
||||
config.language = APconfig["language"] | getDefaultLanguage();
|
||||
config.maxsleep = APconfig["maxsleep"] | 10;
|
||||
config.stopsleep = APconfig["stopsleep"] | 1;
|
||||
// default wifi power 8.5 dbM
|
||||
// see https://github.com/espressif/arduino-esp32/blob/master/libraries/WiFi/src/WiFiGeneric.h#L111
|
||||
config.wifiPower = APconfig["wifipower"] | 34;
|
||||
if (APconfig["timezone"]) {
|
||||
strlcpy(config.timeZone, APconfig["timezone"], sizeof(config.timeZone));
|
||||
} else {
|
||||
strlcpy(config.timeZone, "CET-1CEST,M3.5.0,M10.5.0/3", sizeof(config.timeZone));
|
||||
}
|
||||
}
|
||||
|
||||
void saveAPconfig() {
|
||||
@@ -297,6 +305,8 @@ void saveAPconfig() {
|
||||
APconfig["language"] = config.language;
|
||||
APconfig["maxsleep"] = config.maxsleep;
|
||||
APconfig["stopsleep"] = config.stopsleep;
|
||||
APconfig["wifipower"] = config.wifiPower;
|
||||
APconfig["timezone"] = config.timeZone;
|
||||
serializeJsonPretty(APconfig, configFile);
|
||||
configFile.close();
|
||||
}
|
||||
@@ -235,18 +235,13 @@ void init_web() {
|
||||
|
||||
WiFiManager wm;
|
||||
bool res;
|
||||
#if defined(OPENEPAPERLINK_MINI_AP_PCB) || defined(OPENEPAPERLINK_NANO_AP_PCB)
|
||||
WiFi.setTxPower(WIFI_POWER_15dBm);
|
||||
#endif
|
||||
WiFi.setTxPower(static_cast<wifi_power_t>(config.wifiPower));
|
||||
wm.setWiFiAutoReconnect(true);
|
||||
res = wm.autoConnect("OpenEPaperLink Setup");
|
||||
if (!res) {
|
||||
Serial.println("Failed to connect");
|
||||
ESP.restart();
|
||||
}
|
||||
#if defined(OPENEPAPERLINK_MINI_AP_PCB) || defined(OPENEPAPERLINK_NANO_AP_PCB)
|
||||
WiFi.setTxPower(WIFI_POWER_19_5dBm);
|
||||
#endif
|
||||
Serial.print("Connected! IP address: ");
|
||||
Serial.println(WiFi.localIP());
|
||||
|
||||
@@ -419,6 +414,16 @@ void init_web() {
|
||||
if (request->hasParam("stopsleep", true)) {
|
||||
config.stopsleep = static_cast<uint8_t>(request->getParam("stopsleep", true)->value().toInt());
|
||||
}
|
||||
if (request->hasParam("wifipower", true)) {
|
||||
config.wifiPower = static_cast<uint8_t>(request->getParam("wifipower", true)->value().toInt());
|
||||
WiFi.setTxPower(static_cast<wifi_power_t>(config.wifiPower));
|
||||
}
|
||||
if (request->hasParam("timezone", true)) {
|
||||
strncpy(config.timeZone, request->getParam("timezone", true)->value().c_str(), sizeof(config.timeZone) - 1);
|
||||
config.timeZone[sizeof(config.timeZone) - 1] = '\0';
|
||||
setenv("TZ", config.timeZone, 1);
|
||||
tzset();
|
||||
}
|
||||
saveAPconfig();
|
||||
setAPchannel();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user