From f1299071c132f6fe0c03decd75dee48ea33d86da Mon Sep 17 00:00:00 2001 From: Siwat Sirichai Date: Sun, 10 Sep 2023 14:24:27 +0700 Subject: [PATCH] fix pwm >12 value bug --- platformio.ini | 2 +- src/main.cpp | 14 ++++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/platformio.ini b/platformio.ini index 5e158bc..5dd47f9 100644 --- a/platformio.ini +++ b/platformio.ini @@ -12,7 +12,7 @@ platform = espressif32 board = wt32-eth01 framework = arduino -lib_deps = siwats/espmegapror3@^1.0.2 +lib_deps = siwats/ESPMegaPROR3@^1.1.2 knolleary/PubSubClient@^2.8 ivanseidel/ArduinoThread@^2.1.1 arduino-libraries/Arduino_BuiltIn@^1.0.0 diff --git a/src/main.cpp b/src/main.cpp index 6d06a51..5c486a1 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -40,8 +40,9 @@ unsigned long virtual_interupt_timer[VINT_COUNT]; const int pwm_pins[PWM_COUNT] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}; int pwm_states[PWM_COUNT]; int pwm_values[PWM_COUNT]; -const float pwm_linear_scaling_m[PWM_COUNT] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}; -const float pwm_linear_scaling_c[PWM_COUNT] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; +// output = m*input+c +const float pwm_linear_scaling_m[PWM_COUNT] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}; +const float pwm_linear_scaling_c[PWM_COUNT] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; #define PWM_CYCLE_VALUES_COUNT 3 const int PWM_CYCLE_VALUES[PWM_CYCLE_VALUES_COUNT] = {50, 125, 255}; char PWM_SET_STATE_TOPIC[75] = MQTT_BASE_TOPIC "/pwm/00/set/state"; @@ -173,6 +174,11 @@ void setup() thread_initialization(); Serial.println("Initialization Completed."); Serial.println("Jumping to User Code."); + // Begin User Code + + /* + Pre-NTP Implementation + */ lcd_send_command("page dashboard"); } @@ -682,7 +688,8 @@ void lcd_refresh() } void lcd_top_bar_update() { - panel.writeStr("time.txt", "NO RTC!"); + String time_str = String(rtc.getHour())+":"+String(rtc.getMinute()); + panel.writeStr("time.txt", time_str); panel.writeNum("server.pic", standalone ? 4 : 5); panel.writeNum("lan.pic", ETH.linkUp() ? 3 : 2); } @@ -729,7 +736,6 @@ void trigger2() void trigger3() { int value = panel.readNumber("pwm_value.val"); - Serial.println(value); lcd_send_stop_bit(); pwm_set_value(lcd_pwmAdj_id, value); }