Power monitor and display (#17437)

This commit is contained in:
Scott Lahteine
2020-06-18 15:23:03 -05:00
committed by GitHub
parent c8e99d572c
commit 424569b4c4
32 changed files with 652 additions and 28 deletions

View File

@ -0,0 +1,70 @@
/**
* Marlin 3D Printer Firmware
* Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#include "../../../inc/MarlinConfig.h"
#if HAS_POWER_MONITOR
#include "../../../feature/power_monitor.h"
#include "../../../Marlin.h"
#include "../../gcode.h"
/**
* M430: Enable/disable current LCD display
* With no parameters report the system current draw (in Amps)
*
* I[bool] - Set Display of current on the LCD
* V[bool] - Set Display of voltage on the LCD
* W[bool] - Set Display of power on the LCD
*/
void GcodeSuite::M430() {
bool do_report = true;
#if HAS_SPI_LCD
#if ENABLED(POWER_MONITOR_CURRENT)
if (parser.seen('I')) { power_monitor.set_current_display(parser.value_bool()); do_report = false; }
#endif
#if HAS_POWER_MONITOR_VREF
if (parser.seen('V')) { power_monitor.set_voltage_display(parser.value_bool()); do_report = false; }
#endif
#if HAS_POWER_MONITOR_WATTS
if (parser.seen('W')) { power_monitor.set_power_display(parser.value_bool()); do_report = false; }
#endif
#endif
if (do_report) {
SERIAL_ECHOLNPAIR(
#if ENABLED(POWER_MONITOR_CURRENT)
"Current: ", power_monitor.getAmps(), "A"
#if HAS_POWER_MONITOR_VREF
" "
#endif
#endif
#if HAS_POWER_MONITOR_VREF
"Voltage: ", power_monitor.getVolts(), "V"
#endif
#if HAS_POWER_MONITOR_WATTS
" Power: ", power_monitor.getPower(), "W"
#endif
);
}
}
#endif // HAS_POWER_MONITOR

View File

@ -720,6 +720,10 @@ void GcodeSuite::process_parsed_command(const bool no_ok/*=false*/) {
case 428: M428(); break; // M428: Apply current_position to home_offset
#endif
#if HAS_POWER_MONITOR
case 430: M430(); break; // M430: Read the system current (A), voltage (V), and power (W)
#endif
#if ENABLED(CANCEL_OBJECTS)
case 486: M486(); break; // M486: Identify and cancel objects
#endif

View File

@ -217,6 +217,7 @@
* M422 - Set Z Stepper automatic alignment position using probe. X<units> Y<units> A<axis> (Requires Z_STEPPER_AUTO_ALIGN)
* M425 - Enable/Disable and tune backlash correction. (Requires BACKLASH_COMPENSATION and BACKLASH_GCODE)
* M428 - Set the home_offset based on the current_position. Nearest edge applies. (Disabled by NO_WORKSPACE_OFFSETS or DELTA)
* M430 - Read the system current, voltage, and power (Requires POWER_MONITOR_CURRENT, POWER_MONITOR_VOLTAGE, or POWER_MONITOR_FIXED_VOLTAGE)
* M486 - Identify and cancel objects. (Requires CANCEL_OBJECTS)
* M500 - Store parameters in EEPROM. (Requires EEPROM_SETTINGS)
* M501 - Restore parameters from EEPROM. (Requires EEPROM_SETTINGS)
@ -735,6 +736,8 @@ private:
TERN_(HAS_M206_COMMAND, static void M428());
TERN_(HAS_POWER_MONITOR, static void M430());
TERN_(CANCEL_OBJECTS, static void M486());
static void M500();