Update and fix POWER_MONITOR (#18561)
This commit is contained in:
parent
ea8c3a9388
commit
12e7106a8a
@ -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
|
||||
|
@ -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
|
||||
|
||||
|
@ -25,7 +25,7 @@
|
||||
#if HAS_POWER_MONITOR
|
||||
|
||||
#include "../../../feature/power_monitor.h"
|
||||
#include "../../../Marlin.h"
|
||||
#include "../../../MarlinCore.h"
|
||||
#include "../../gcode.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)
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
|
||||
|
@ -94,7 +94,7 @@
|
||||
#include "../feature/powerloss.h"
|
||||
#endif
|
||||
|
||||
#if ENABLED(POWER_MONITOR)
|
||||
#if HAS_POWER_MONITOR
|
||||
#include "../feature/power_monitor.h"
|
||||
#endif
|
||||
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user