0
0
Fork 0
mirror of https://github.com/MarlinFirmware/Marlin.git synced 2025-01-22 17:52:57 +00:00

MAX7219_REINIT_ON_POWERUP (#26163)

This commit is contained in:
Manuel McLure 2024-03-17 12:23:12 -07:00 committed by GitHub
parent 983aee5718
commit ea6a891038
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 52 additions and 6 deletions

View file

@ -4308,6 +4308,7 @@
// See class CodeProfiler.
//#define MAX7219_DEBUG_MULTISTEPPING 6 // Show multi-stepping 1 to 128 on this LED matrix row.
//#define MAX7219_DEBUG_SLOWDOWN 6 // Count (mod 16) how many times SLOWDOWN has reduced print speed.
//#define MAX7219_REINIT_ON_POWERUP // Re-initialize MAX7129 when power supply turns on
#endif
/**

View file

@ -72,6 +72,26 @@
uint16_t CodeProfiler::call_count = 0;
#endif
#if defined(MAX7219_DEBUG_PLANNER_HEAD) && defined(MAX7219_DEBUG_PLANNER_TAIL) && MAX7219_DEBUG_PLANNER_HEAD == MAX7219_DEBUG_PLANNER_TAIL
static int16_t last_head_cnt = 0xF, last_tail_cnt = 0xF;
#else
#ifdef MAX7219_DEBUG_PLANNER_HEAD
static int16_t last_head_cnt = 0x1;
#endif
#ifdef MAX7219_DEBUG_PLANNER_TAIL
static int16_t last_tail_cnt = 0x1;
#endif
#endif
#ifdef MAX7219_DEBUG_PLANNER_QUEUE
static int16_t last_depth = 0;
#endif
#ifdef MAX7219_DEBUG_PROFILE
static uint8_t last_time_fraction = 0;
#endif
#ifdef MAX7219_DEBUG_MULTISTEPPING
static uint8_t last_multistepping = 0;
#endif
Max7219 max7219;
uint8_t Max7219::led_line[MAX7219_LINES]; // = { 0 };
@ -550,6 +570,29 @@ void Max7219::init() {
#if MAX7219_INIT_TEST
start_test_pattern();
#endif
#ifdef MAX7219_REINIT_ON_POWERUP
#if defined(MAX7219_DEBUG_PLANNER_HEAD) && defined(MAX7219_DEBUG_PLANNER_TAIL) && MAX7219_DEBUG_PLANNER_HEAD == MAX7219_DEBUG_PLANNER_TAIL
last_head_cnt = 0xF;
last_tail_cnt = 0xF;
#else
#ifdef MAX7219_DEBUG_PLANNER_HEAD
last_head_cnt = 0x1;
#endif
#ifdef MAX7219_DEBUG_PLANNER_TAIL
last_tail_cnt = 0x1;
#endif
#endif
#ifdef MAX7219_DEBUG_PLANNER_QUEUE
last_depth = 0;
#endif
#ifdef MAX7219_DEBUG_PROFILE
last_time_fraction = 0;
#endif
#ifdef MAX7219_DEBUG_MULTISTEPPING
last_multistepping = 0;
#endif
#endif
}
/**
@ -676,8 +719,6 @@ void Max7219::idle_tasks() {
#if defined(MAX7219_DEBUG_PLANNER_HEAD) && defined(MAX7219_DEBUG_PLANNER_TAIL) && MAX7219_DEBUG_PLANNER_HEAD == MAX7219_DEBUG_PLANNER_TAIL
static int16_t last_head_cnt = 0xF, last_tail_cnt = 0xF;
if (last_head_cnt != head || last_tail_cnt != tail) {
range16(MAX7219_DEBUG_PLANNER_HEAD, last_tail_cnt, tail, last_head_cnt, head, &row_change_mask);
last_head_cnt = head;
@ -687,7 +728,6 @@ void Max7219::idle_tasks() {
#else
#ifdef MAX7219_DEBUG_PLANNER_HEAD
static int16_t last_head_cnt = 0x1;
if (last_head_cnt != head) {
mark16(MAX7219_DEBUG_PLANNER_HEAD, last_head_cnt, head, &row_change_mask);
last_head_cnt = head;
@ -695,7 +735,6 @@ void Max7219::idle_tasks() {
#endif
#ifdef MAX7219_DEBUG_PLANNER_TAIL
static int16_t last_tail_cnt = 0x1;
if (last_tail_cnt != tail) {
mark16(MAX7219_DEBUG_PLANNER_TAIL, last_tail_cnt, tail, &row_change_mask);
last_tail_cnt = tail;
@ -714,7 +753,6 @@ void Max7219::idle_tasks() {
#endif
#ifdef MAX7219_DEBUG_PROFILE
static uint8_t last_time_fraction = 0;
const uint8_t current_time_fraction = (uint16_t(CodeProfiler::get_time_fraction()) * MAX7219_NUMBER_UNITS + 8) / 16;
if (current_time_fraction != last_time_fraction) {
quantity(MAX7219_DEBUG_PROFILE, last_time_fraction, current_time_fraction, &row_change_mask);

View file

@ -34,6 +34,10 @@
#include "../module/temperature.h"
#include "../MarlinCore.h"
#if ENABLED(MAX7219_REINIT_ON_POWERUP)
#include "max7219.h"
#endif
#if ENABLED(PS_OFF_SOUND)
#include "../libs/buzzer.h"
#endif
@ -100,6 +104,9 @@ void Power::power_on() {
safe_delay(PSU_POWERUP_DELAY);
restore_stepper_drivers();
TERN_(MAX7219_REINIT_ON_POWERUP, max7219.init());
TERN_(HAS_TRINAMIC_CONFIG, safe_delay(PSU_POWERUP_DELAY));
#ifdef PSU_POWERUP_GCODE

View file

@ -27,7 +27,7 @@ opt_enable S_CURVE_ACCELERATION EEPROM_SETTINGS GCODE_MACROS \
FWRETRACT ARC_SUPPORT ARC_P_CIRCLES CNC_WORKSPACE_PLANES CNC_COORDINATE_SYSTEMS \
PSU_CONTROL AUTO_POWER_CONTROL E_DUAL_STEPPER_DRIVERS \
PIDTEMPBED SLOW_PWM_HEATERS THERMAL_PROTECTION_CHAMBER \
PINS_DEBUGGING MAX7219_DEBUG M114_DETAIL \
PINS_DEBUGGING MAX7219_DEBUG M114_DETAIL MAX7219_REINIT_ON_POWERUP \
EXTENSIBLE_UI
opt_add EXTUI_EXAMPLE
exec_test $1 $2 "RAMPS4DUE_EFB with ABL (Bilinear), ExtUI, S-Curve, many options." "$3"