Explorar o código

Log state changes

Scott Bezek %!s(int64=4) %!d(string=hai) anos
pai
achega
812449da04

+ 2 - 2
firmware/src/interface_task.cpp

@@ -120,7 +120,7 @@ static PB_SmartKnobConfig configs[] = {
 };
 
 InterfaceTask::InterfaceTask(const uint8_t task_core, MotorTask& motor_task, DisplayTask* display_task) : 
-        Task("Interface", 2048, 1, task_core),
+        Task("Interface", 3000, 1, task_core),
         stream_(),
         motor_task_(motor_task),
         display_task_(display_task),
@@ -201,7 +201,7 @@ void InterfaceTask::run() {
 
         std::string* log_string;
         while (xQueueReceive(log_queue_, &log_string, 0) == pdTRUE) {
-            stream_.println(log_string->c_str());
+            current_protocol->log(log_string->c_str());
             delete log_string;
         }
 

+ 8 - 0
firmware/src/serial/serial_protocol_plaintext.cpp

@@ -3,7 +3,15 @@
 #include "serial_protocol_plaintext.h"
 
 void SerialProtocolPlaintext::handleState(const PB_SmartKnobState& state) {
+    bool substantial_change = (latest_state_.current_position != state.current_position)
+        || (latest_state_.config.detent_strength_unit != state.config.detent_strength_unit)
+        || (latest_state_.config.endstop_strength_unit != state.config.endstop_strength_unit)
+        || (latest_state_.config.num_positions != state.config.num_positions);
     latest_state_ = state;
+
+    if (substantial_change) {
+        stream_.printf("STATE: %d/%d  (detent strength: %0.2f, width: %0.0f deg, endstop strength: %0.2f)\n", state.current_position, state.config.num_positions - 1, state.config.detent_strength_unit, degrees(state.config.position_width_radians), state.config.endstop_strength_unit);
+    }
 }
 
 void SerialProtocolPlaintext::log(const char* msg) {