From 67b8c9a23a1ff672a0b9accc9ecedc0bbb861857 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Xose=20P=C3=A9rez?= Date: Sat, 2 Dec 2017 11:05:22 +0100 Subject: [PATCH] Fix PWM WDT resets by increasing period and chaning back to TIMER1 interrupts --- code/espurna/config/general.h | 6 +----- code/espurna/config/hardware.h | 2 ++ code/espurna/{power.h => libs/MedianFilter.h} | 0 code/espurna/{settings.h => libs/StreamInjector.h} | 0 code/espurna/{ws.h => libs/WebSocketIncommingBuffer.h} | 0 code/espurna/{ => libs}/pwm.c | 2 +- code/espurna/{ => libs}/pwm.h | 0 code/espurna/light.ino | 2 +- code/espurna/power.ino | 2 +- code/espurna/settings.ino | 4 ++-- code/espurna/ws.ino | 2 +- code/platformio.ini | 8 ++++---- 12 files changed, 13 insertions(+), 15 deletions(-) rename code/espurna/{power.h => libs/MedianFilter.h} (100%) rename code/espurna/{settings.h => libs/StreamInjector.h} (100%) rename code/espurna/{ws.h => libs/WebSocketIncommingBuffer.h} (100%) rename code/espurna/{ => libs}/pwm.c (99%) rename code/espurna/{ => libs}/pwm.h (100%) diff --git a/code/espurna/config/general.h b/code/espurna/config/general.h index b8ea90b9..71bbe350 100644 --- a/code/espurna/config/general.h +++ b/code/espurna/config/general.h @@ -514,10 +514,6 @@ PROGMEM const char* const custom_reset_string[] = { #define LIGHT_SAVE_DELAY 5 // Persist color after 5 seconds to avoid wearing out -#ifndef LIGHT_PWM_FREQUENCY -#define LIGHT_PWM_FREQUENCY 1000 // PWM frequency -#endif - #ifndef LIGHT_MAX_PWM #if LIGHT_PROVIDER == LIGHT_PROVIDER_MY92XX @@ -525,7 +521,7 @@ PROGMEM const char* const custom_reset_string[] = { #endif #if LIGHT_PROVIDER == LIGHT_PROVIDER_DIMMER -#define LIGHT_MAX_PWM 1000 +#define LIGHT_MAX_PWM 5000 // 5000 * 200ns => 1 kHz #endif #endif // LIGHT_MAX_PWM diff --git a/code/espurna/config/hardware.h b/code/espurna/config/hardware.h index db8defbd..3c00c510 100644 --- a/code/espurna/config/hardware.h +++ b/code/espurna/config/hardware.h @@ -789,6 +789,7 @@ #define RELAY_PROVIDER RELAY_PROVIDER_LIGHT #define LIGHT_PROVIDER LIGHT_PROVIDER_DIMMER #define DUMMY_RELAY_COUNT 1 + #define DEBUG_PORT Serial1 // LEDs #define LED1_PIN 5 @@ -815,6 +816,7 @@ #define RELAY_PROVIDER RELAY_PROVIDER_LIGHT #define LIGHT_PROVIDER LIGHT_PROVIDER_DIMMER #define DUMMY_RELAY_COUNT 1 + #define DEBUG_PORT Serial1 // Light #define LIGHT_CHANNELS 4 diff --git a/code/espurna/power.h b/code/espurna/libs/MedianFilter.h similarity index 100% rename from code/espurna/power.h rename to code/espurna/libs/MedianFilter.h diff --git a/code/espurna/settings.h b/code/espurna/libs/StreamInjector.h similarity index 100% rename from code/espurna/settings.h rename to code/espurna/libs/StreamInjector.h diff --git a/code/espurna/ws.h b/code/espurna/libs/WebSocketIncommingBuffer.h similarity index 100% rename from code/espurna/ws.h rename to code/espurna/libs/WebSocketIncommingBuffer.h diff --git a/code/espurna/pwm.c b/code/espurna/libs/pwm.c similarity index 99% rename from code/espurna/pwm.c rename to code/espurna/libs/pwm.c index 9a316bb8..5b5f306b 100644 --- a/code/espurna/pwm.c +++ b/code/espurna/libs/pwm.c @@ -25,7 +25,7 @@ #define PWM_MAX_CHANNELS 8 #endif #define PWM_DEBUG 0 -#define PWM_USE_NMI 1 +#define PWM_USE_NMI 0 /* no user servicable parts beyond this point */ diff --git a/code/espurna/pwm.h b/code/espurna/libs/pwm.h similarity index 100% rename from code/espurna/pwm.h rename to code/espurna/libs/pwm.h diff --git a/code/espurna/light.ino b/code/espurna/light.ino index 018b9c25..b35c8ff9 100644 --- a/code/espurna/light.ino +++ b/code/espurna/light.ino @@ -15,7 +15,7 @@ Copyright (C) 2016-2017 by Xose Pérez #if LIGHT_PROVIDER == LIGHT_PROVIDER_DIMMER #define PWM_CHANNEL_NUM_MAX LIGHT_CHANNELS extern "C" { - #include "pwm.h" + #include "libs/pwm.h" } #endif diff --git a/code/espurna/power.ino b/code/espurna/power.ino index 298ee3fe..8c68b4ac 100644 --- a/code/espurna/power.ino +++ b/code/espurna/power.ino @@ -12,7 +12,7 @@ Copyright (C) 2016-2017 by Xose Pérez // MODULE GLOBALS AND CACHE // ----------------------------------------------------------------------------- -#include "power.h" +#include "libs/MedianFilter.h" #include #include diff --git a/code/espurna/settings.ino b/code/espurna/settings.ino index c0d94764..cd61a15c 100644 --- a/code/espurna/settings.ino +++ b/code/espurna/settings.ino @@ -12,7 +12,7 @@ Copyright (C) 2016-2017 by Xose Pérez #include #if TELNET_SUPPORT - #include "settings.h" + #include "libs/StreamInjector.h" #ifdef DEBUG_PORT StreamInjector _serial = StreamInjector(DEBUG_PORT); #else @@ -139,7 +139,7 @@ void settingsSetup() { DEBUG_MSG_P(PSTR("+OK\n")); }); #endif - + Embedis::command( F("INFO"), [](Embedis* e) { welcome(); DEBUG_MSG_P(PSTR("+OK\n")); diff --git a/code/espurna/ws.ino b/code/espurna/ws.ino index 55a98619..a103bb24 100644 --- a/code/espurna/ws.ino +++ b/code/espurna/ws.ino @@ -13,7 +13,7 @@ Copyright (C) 2016-2017 by Xose Pérez #include #include #include -#include "ws.h" +#include "libs/WebSocketIncommingBuffer.h" AsyncWebSocket _ws("/ws"); Ticker _web_defer; diff --git a/code/platformio.ini b/code/platformio.ini index bc79457f..6091fd53 100644 --- a/code/platformio.ini +++ b/code/platformio.ini @@ -781,7 +781,7 @@ board = esp01_1m board_flash_mode = dout lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = -g -Wl,-Tesp8266.flash.1m0.ld -DHUACANXING_H801 -DDEBUG_PORT=Serial1 +build_flags = -g -Wl,-Tesp8266.flash.1m0.ld -DHUACANXING_H801 monitor_baud = 115200 [env:huacanxing-h801-ota] @@ -791,7 +791,7 @@ board = esp01_1m board_flash_mode = dout lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = -g -Wl,-Tesp8266.flash.1m0.ld -DHUACANXING_H801 -DDEBUG_PORT=Serial1 +build_flags = -g -Wl,-Tesp8266.flash.1m0.ld -DHUACANXING_H801 upload_speed = 115200 upload_port = "192.168.4.1" upload_flags = --auth=fibonacci --port 8266 @@ -804,7 +804,7 @@ board = esp01_1m board_flash_mode = dout lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = -g -Wl,-Tesp8266.flash.1m0.ld -DHUACANXING_H802 -DDEBUG_PORT=Serial1 +build_flags = -g -Wl,-Tesp8266.flash.1m0.ld -DHUACANXING_H802 monitor_baud = 115200 [env:huacanxing-h802-ota] @@ -814,7 +814,7 @@ board = esp01_1m board_flash_mode = dout lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = -g -Wl,-Tesp8266.flash.1m0.ld -DHUACANXING_H802 -DDEBUG_PORT=Serial1 +build_flags = -g -Wl,-Tesp8266.flash.1m0.ld -DHUACANXING_H802 upload_speed = 115200 upload_port = "192.168.4.1" upload_flags = --auth=fibonacci --port 8266