From 666ca02bafc331bc8e19259d4471620d7a7322be Mon Sep 17 00:00:00 2001 From: Martin Jaeger <17674105+martinjaeger@users.noreply.github.com> Date: Wed, 17 Apr 2019 08:18:44 +0200 Subject: [PATCH] Min/max recordings added to serial pub message --- src/data_objects.cpp | 2 ++ src/interface_serial.cpp | 4 +++- src/pwm_switch.cpp | 3 ++- src/pwm_switch.h | 6 ++++++ 4 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/data_objects.cpp b/src/data_objects.cpp index 23f6605..343005a 100644 --- a/src/data_objects.cpp +++ b/src/data_objects.cpp @@ -192,6 +192,8 @@ const uint16_t pub_serial[] = { 0x74, 0x76, 0x77, // temperatures 0x04, 0x78, 0x79, // LoadState, ChgState, DCDCState 0xA0, 0xA1, 0xA2, 0xA3, // daily energy throughput + 0x0F, 0x10, // SolarMaxDay_W, LoadMaxDay_W + 0xB1, 0xB2, 0xB3, 0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0xB9, // V, I, T max 0x06, 0xA4 // SOC, coulomb counter }; diff --git a/src/interface_serial.cpp b/src/interface_serial.cpp index dde743b..bccc49f 100644 --- a/src/interface_serial.cpp +++ b/src/interface_serial.cpp @@ -60,10 +60,12 @@ void uart_serial_init(Serial* s) s->attach(uart_serial_isr); } +extern const int PUB_CHANNEL_SERIAL; + void uart_serial_pub() { if (pub_uart_enabled) { - ts.pub_msg_json((char *)buf_resp, sizeof(buf_resp), 4); + ts.pub_msg_json((char *)buf_resp, sizeof(buf_resp), PUB_CHANNEL_SERIAL); ser_uart->printf("%s\n", buf_resp); } } diff --git a/src/pwm_switch.cpp b/src/pwm_switch.cpp index 00582fd..99532ad 100644 --- a/src/pwm_switch.cpp +++ b/src/pwm_switch.cpp @@ -87,7 +87,8 @@ bool pwm_switch_enabled() } float pwm_switch_get_duty_cycle() { - return (float)(TIM3->CCR4) / (_pwm_resolution);; + // TODO: check why we might get > 100 + return (float)(TIM3->CCR4) / (_pwm_resolution); } void pwm_switch_start(float pwm_duty) diff --git a/src/pwm_switch.h b/src/pwm_switch.h index f7f8dc8..bbf7ef4 100644 --- a/src/pwm_switch.h +++ b/src/pwm_switch.h @@ -59,4 +59,10 @@ void pwm_switch_duty_cycle_step(int delta); bool pwm_switch_enabled(); +/** Read the currently set duty cycle + * + * @returns Duty cycle between 0.0 and 1.0 + */ +float pwm_switch_get_duty_cycle(); + #endif /* PWM_SWITCH_H */