diff --git a/Marlin/src/feature/power_monitor.cpp b/Marlin/src/feature/power_monitor.cpp index 30b19a99e1..cf8ff1139b 100644 --- a/Marlin/src/feature/power_monitor.cpp +++ b/Marlin/src/feature/power_monitor.cpp @@ -28,6 +28,7 @@ #include "../lcd/ultralcd.h" #include "../lcd/lcdprint.h" +#include "../libs/numtostr.h" uint8_t PowerMonitor::flags; // = 0 @@ -48,7 +49,7 @@ PowerMonitor power_monitor; // Single instance - this calls the constructor #if ENABLED(POWER_MONITOR_CURRENT) void PowerMonitor::draw_current() { const float amps = getAmps(); - lcd_put_u8str(amps < 100 ? ftostr21ns(amps) : ui16tostr4((uint16_t)amps)); + lcd_put_u8str(amps < 100 ? ftostr31ns(amps) : ui16tostr4rj((uint16_t)amps)); lcd_put_wchar('A'); } #endif @@ -56,7 +57,7 @@ PowerMonitor power_monitor; // Single instance - this calls the constructor #if HAS_POWER_MONITOR_VREF void PowerMonitor::draw_voltage() { const float volts = getVolts(); - lcd_put_u8str(volts < 100 ? ftostr21ns(volts) : ui16tostr4((uint16_t)volts)); + lcd_put_u8str(volts < 100 ? ftostr31ns(volts) : ui16tostr4rj((uint16_t)volts)); lcd_put_wchar('V'); } #endif @@ -64,7 +65,7 @@ PowerMonitor power_monitor; // Single instance - this calls the constructor #if HAS_POWER_MONITOR_WATTS void PowerMonitor::draw_power() { const float power = getPower(); - lcd_put_u8str(power < 100 ? ftostr21ns(power) : ui16tostr4((uint16_t)power)); + lcd_put_u8str(power < 100 ? ftostr31ns(power) : ui16tostr4rj((uint16_t)power)); lcd_put_wchar('W'); } #endif diff --git a/Marlin/src/feature/power_monitor.h b/Marlin/src/feature/power_monitor.h index fc7a23b8f3..00b45b0f9a 100644 --- a/Marlin/src/feature/power_monitor.h +++ b/Marlin/src/feature/power_monitor.h @@ -100,13 +100,13 @@ public: static void draw_voltage(); FORCE_INLINE static bool voltage_display_enabled() { return TEST(flags, PM_DISP_BIT_V); } FORCE_INLINE static void set_voltage_display(const bool b) { SET_BIT_TO(flags, PM_DISP_BIT_V, b); } - FORCE_INLINE static void toggle_voltage_display() { TBI(flags, PM_DISP_BIT_I); } + FORCE_INLINE static void toggle_voltage_display() { TBI(flags, PM_DISP_BIT_V); } #endif #if HAS_POWER_MONITOR_WATTS static void draw_power(); FORCE_INLINE static bool power_display_enabled() { return TEST(flags, PM_DISP_BIT_P); } FORCE_INLINE static void set_power_display(const bool b) { SET_BIT_TO(flags, PM_DISP_BIT_P, b); } - FORCE_INLINE static void toggle_power_display() { TBI(flags, PM_DISP_BIT_I); } + FORCE_INLINE static void toggle_power_display() { TBI(flags, PM_DISP_BIT_P); } #endif #endif diff --git a/Marlin/src/gcode/feature/power_monitor/M430.cpp b/Marlin/src/gcode/feature/power_monitor/M430.cpp index 50bb146c78..356fe67495 100644 --- a/Marlin/src/gcode/feature/power_monitor/M430.cpp +++ b/Marlin/src/gcode/feature/power_monitor/M430.cpp @@ -25,7 +25,7 @@ #if HAS_POWER_MONITOR #include "../../../feature/power_monitor.h" -#include "../../../Marlin.h" +#include "../../../MarlinCore.h" #include "../../gcode.h" /** diff --git a/Marlin/src/inc/Conditionals_adv.h b/Marlin/src/inc/Conditionals_adv.h index 41cad412a4..3e5cef9dc3 100644 --- a/Marlin/src/inc/Conditionals_adv.h +++ b/Marlin/src/inc/Conditionals_adv.h @@ -356,7 +356,7 @@ #if EITHER(POWER_MONITOR_CURRENT, POWER_MONITOR_VOLTAGE) #define HAS_POWER_MONITOR 1 #endif -#if ENABLED(POWER_MONITOR_VOLTAGE) || defined(POWER_MONITOR_FIXED_VOLTAGE) +#if ENABLED(POWER_MONITOR_VOLTAGE) && defined(POWER_MONITOR_FIXED_VOLTAGE) #define HAS_POWER_MONITOR_VREF 1 #endif #if BOTH(HAS_POWER_MONITOR_VREF, POWER_MONITOR_CURRENT) diff --git a/Marlin/src/lcd/dogm/status_screen_DOGM.cpp b/Marlin/src/lcd/dogm/status_screen_DOGM.cpp index 8be9b27dda..ae8952ab33 100644 --- a/Marlin/src/lcd/dogm/status_screen_DOGM.cpp +++ b/Marlin/src/lcd/dogm/status_screen_DOGM.cpp @@ -113,22 +113,26 @@ lcd_moveto(x, y); + #if HAS_POWER_MONITOR_WATTS + const bool wflag = power_monitor.power_display_enabled(); + #endif #if ENABLED(POWER_MONITOR_CURRENT) const bool iflag = power_monitor.current_display_enabled(); #endif #if HAS_POWER_MONITOR_VREF const bool vflag = power_monitor.voltage_display_enabled(); #endif - #if HAS_POWER_MONITOR_WATTS - const bool wflag = power_monitor.power_display_enabled(); - #endif - #if ENABLED(POWER_MONITOR_CURRENT) || HAS_POWER_MONITOR_VREF - // cycle between current, voltage, and power + #if HAS_POWER_MONITOR_WATTS + // Cycle between current, voltage, and power if (ELAPSED(millis(), power_monitor.display_item_ms)) { power_monitor.display_item_ms = millis() + 1000UL; ++power_monitor.display_item; } + #elif ENABLED(POWER_MONITOR_CURRENT) + power_monitor.display_item = 0; + #elif HAS_POWER_MONITOR_VREF + power_monitor.display_item = 1; #endif // ensure we have the right one selected for display @@ -139,7 +143,7 @@ #if HAS_POWER_MONITOR_VREF if (power_monitor.display_item == 1 && !vflag) ++power_monitor.display_item; #endif - #if ENABLED(POWER_MONITOR_CURRENT) + #if HAS_POWER_MONITOR_WATTS if (power_monitor.display_item == 2 && !wflag) ++power_monitor.display_item; #endif if (power_monitor.display_item >= 3) power_monitor.display_item = 0; diff --git a/Marlin/src/lcd/menu/menu_power_monitor.cpp b/Marlin/src/lcd/menu/menu_power_monitor.cpp index 7055f01c31..3486d54a57 100644 --- a/Marlin/src/lcd/menu/menu_power_monitor.cpp +++ b/Marlin/src/lcd/menu/menu_power_monitor.cpp @@ -33,26 +33,26 @@ void menu_power_monitor() { START_MENU(); - MENU_BACK(MSG_MAIN); + BACK_ITEM(MSG_MAIN); #if ENABLED(POWER_MONITOR_CURRENT) { bool ena = power_monitor.current_display_enabled(); - MENU_ITEM_EDIT_CALLBACK(bool, MSG_CURRENT, &ena, power_monitor.toggle_current_display); + EDIT_ITEM(bool, MSG_CURRENT, &ena, power_monitor.toggle_current_display); } #endif #if HAS_POWER_MONITOR_VREF { bool ena = power_monitor.voltage_display_enabled(); - MENU_ITEM_EDIT_CALLBACK(bool, MSG_VOLTAGE, &ena, power_monitor.toggle_voltage_display); + EDIT_ITEM(bool, MSG_VOLTAGE, &ena, power_monitor.toggle_voltage_display); } #endif #if HAS_POWER_MONITOR_WATTS { bool ena = power_monitor.power_display_enabled(); - MENU_ITEM_EDIT_CALLBACK(bool, MSG_POWER, &ena, power_monitor.toggle_power_display); + EDIT_ITEM(bool, MSG_POWER, &ena, power_monitor.toggle_power_display); } #endif diff --git a/Marlin/src/module/configuration_store.cpp b/Marlin/src/module/configuration_store.cpp index 0915c0451a..6c4c13f830 100644 --- a/Marlin/src/module/configuration_store.cpp +++ b/Marlin/src/module/configuration_store.cpp @@ -94,7 +94,7 @@ #include "../feature/powerloss.h" #endif -#if ENABLED(POWER_MONITOR) +#if HAS_POWER_MONITOR #include "../feature/power_monitor.h" #endif diff --git a/buildroot/tests/mega1280-tests b/buildroot/tests/mega1280-tests index c9caf7d852..6bd9cda605 100644 --- a/buildroot/tests/mega1280-tests +++ b/buildroot/tests/mega1280-tests @@ -18,13 +18,16 @@ set -e restore_configs opt_set LCD_LANGUAGE an opt_enable SPINDLE_FEATURE ULTIMAKERCONTROLLER LCD_BED_LEVELING \ + EEPROM_SETTINGS EEPROM_BOOT_SILENT EEPROM_AUTO_INIT \ SENSORLESS_BACKOFF_MM HOMING_BACKOFF_POST_MM HOME_Y_BEFORE_X CODEPENDENT_XY_HOMING \ MESH_BED_LEVELING ENABLE_LEVELING_FADE_HEIGHT MESH_G28_REST_ORIGIN \ G26_MESH_VALIDATION MESH_EDIT_MENU GCODE_QUOTED_STRINGS \ - EXTERNAL_CLOSED_LOOP_CONTROLLER + EXTERNAL_CLOSED_LOOP_CONTROLLER POWER_MONITOR_CURRENT POWER_MONITOR_VOLTAGE +opt_set POWER_MONITOR_CURRENT_PIN 14 +opt_set POWER_MONITOR_VOLTAGE_PIN 15 opt_set CLOSED_LOOP_ENABLE_PIN 44 opt_set CLOSED_LOOP_MOVE_COMPLETE_PIN 45 -exec_test $1 $2 "Spindle, MESH_BED_LEVELING, closed loop, and LCD" +exec_test $1 $2 "Spindle, MESH_BED_LEVELING, closed loop, Power Monitor, and LCD" # # Test DUAL_X_CARRIAGE