diff --git a/src/hal/bl602/hal_pins_bl602.c b/src/hal/bl602/hal_pins_bl602.c index 2948b9538..7e83bd417 100644 --- a/src/hal/bl602/hal_pins_bl602.c +++ b/src/hal/bl602/hal_pins_bl602.c @@ -85,8 +85,11 @@ void HAL_PIN_PWM_Start(int index) { if(pwm == -1) { return; - } - bl_pwm_init(pwm, index, 1000); + } + + addLogAdv(LOG_INFO, LOG_FEATURE_MAIN,"HAL_PIN_PWM_Start: pin %i chose pwm %i\r\n",index,pwm); + // Frequency must be between 2000 and 800000 + bl_pwm_init(pwm, index, 2000); bl_pwm_start(pwm); } @@ -99,7 +102,13 @@ void HAL_PIN_PWM_Update(int index, int value) { if(pwm == -1) { return; } - duty = value * 0.01f; + duty = value; +/*duty is the PWM Duty Cycle (0 to 100). When duty=25, it means that in every PWM Cycle... +--> PWM Ouput is 1 (High) for the initial 25% of the PWM Cycle +--> Followed by PWM Output 0 (Low) for the remaining 75% of the PWM Cycle +*/ + + addLogAdv(LOG_INFO, LOG_FEATURE_MAIN,"HAL_PIN_PWM_Update: pin %i had pwm %i, set %i\r\n",index,pwm,value); bl_pwm_set_duty(pwm, duty); } diff --git a/src/httpserver/http_fns.c b/src/httpserver/http_fns.c index 6b6f9cf0f..88504acae 100644 --- a/src/httpserver/http_fns.c +++ b/src/httpserver/http_fns.c @@ -82,7 +82,7 @@ int http_fn_empty_url(http_request_t *request) { } int h_isChannelPWM(int tg_ch){ int i; - for(i = 0; i < GPIO_MAX; i++) { + for(i = 0; i < PLATFORM_GPIO_MAX; i++) { int ch = PIN_GetPinChannelForPinIndex(i); if(tg_ch != ch) continue; @@ -95,7 +95,7 @@ int h_isChannelPWM(int tg_ch){ } int h_isChannelRelay(int tg_ch) { int i; - for(i = 0; i < GPIO_MAX; i++) { + for(i = 0; i < PLATFORM_GPIO_MAX; i++) { int ch = PIN_GetPinChannelForPinIndex(i); if(tg_ch != ch) continue; @@ -314,7 +314,7 @@ int http_fn_cfg_mqtt_set(http_request_t *request) { CFG_SetMQTTBrokerName(tmpA); } - CFG_Save_IfThereArePendingChanges(); + CFG_Save_SetupTimer(); poststr(request,"Please wait for module to connect... if there is problem, restart it from Index html page..."); @@ -492,9 +492,7 @@ int http_fn_cfg_wifi_set(http_request_t *request) { } poststr(request,"WiFi mode set: connect to WLAN."); } - addLogAdv(LOG_INFO, LOG_FEATURE_HTTP,"HTTP_ProcessPacket: calling CFG_Save_IfThereArePendingChanges \r\n"); - CFG_Save_IfThereArePendingChanges(); - addLogAdv(LOG_INFO, LOG_FEATURE_HTTP,"HTTP_ProcessPacket: done CFG_Save_IfThereArePendingChanges \r\n"); + CFG_Save_SetupTimer(); poststr(request,"Please wait for module to reset..."); RESET_ScheduleModuleReset(3); @@ -847,7 +845,7 @@ int http_fn_cfg_ha(http_request_t *request) { poststr(request,"