Skip to content

Commit ea6a891

Browse files
authored
✨ MAX7219_REINIT_ON_POWERUP (MarlinFirmware#26163)
1 parent 983aee5 commit ea6a891

File tree

4 files changed

+52
-6
lines changed

4 files changed

+52
-6
lines changed

Marlin/Configuration_adv.h

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

43134314
/**

Marlin/src/feature/max7219.cpp

+43-5
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,26 @@
7272
uint16_t CodeProfiler::call_count = 0;
7373
#endif
7474

75+
#if defined(MAX7219_DEBUG_PLANNER_HEAD) && defined(MAX7219_DEBUG_PLANNER_TAIL) && MAX7219_DEBUG_PLANNER_HEAD == MAX7219_DEBUG_PLANNER_TAIL
76+
static int16_t last_head_cnt = 0xF, last_tail_cnt = 0xF;
77+
#else
78+
#ifdef MAX7219_DEBUG_PLANNER_HEAD
79+
static int16_t last_head_cnt = 0x1;
80+
#endif
81+
#ifdef MAX7219_DEBUG_PLANNER_TAIL
82+
static int16_t last_tail_cnt = 0x1;
83+
#endif
84+
#endif
85+
#ifdef MAX7219_DEBUG_PLANNER_QUEUE
86+
static int16_t last_depth = 0;
87+
#endif
88+
#ifdef MAX7219_DEBUG_PROFILE
89+
static uint8_t last_time_fraction = 0;
90+
#endif
91+
#ifdef MAX7219_DEBUG_MULTISTEPPING
92+
static uint8_t last_multistepping = 0;
93+
#endif
94+
7595
Max7219 max7219;
7696

7797
uint8_t Max7219::led_line[MAX7219_LINES]; // = { 0 };
@@ -550,6 +570,29 @@ void Max7219::init() {
550570
#if MAX7219_INIT_TEST
551571
start_test_pattern();
552572
#endif
573+
574+
#ifdef MAX7219_REINIT_ON_POWERUP
575+
#if defined(MAX7219_DEBUG_PLANNER_HEAD) && defined(MAX7219_DEBUG_PLANNER_TAIL) && MAX7219_DEBUG_PLANNER_HEAD == MAX7219_DEBUG_PLANNER_TAIL
576+
last_head_cnt = 0xF;
577+
last_tail_cnt = 0xF;
578+
#else
579+
#ifdef MAX7219_DEBUG_PLANNER_HEAD
580+
last_head_cnt = 0x1;
581+
#endif
582+
#ifdef MAX7219_DEBUG_PLANNER_TAIL
583+
last_tail_cnt = 0x1;
584+
#endif
585+
#endif
586+
#ifdef MAX7219_DEBUG_PLANNER_QUEUE
587+
last_depth = 0;
588+
#endif
589+
#ifdef MAX7219_DEBUG_PROFILE
590+
last_time_fraction = 0;
591+
#endif
592+
#ifdef MAX7219_DEBUG_MULTISTEPPING
593+
last_multistepping = 0;
594+
#endif
595+
#endif
553596
}
554597

555598
/**
@@ -676,8 +719,6 @@ void Max7219::idle_tasks() {
676719

677720
#if defined(MAX7219_DEBUG_PLANNER_HEAD) && defined(MAX7219_DEBUG_PLANNER_TAIL) && MAX7219_DEBUG_PLANNER_HEAD == MAX7219_DEBUG_PLANNER_TAIL
678721

679-
static int16_t last_head_cnt = 0xF, last_tail_cnt = 0xF;
680-
681722
if (last_head_cnt != head || last_tail_cnt != tail) {
682723
range16(MAX7219_DEBUG_PLANNER_HEAD, last_tail_cnt, tail, last_head_cnt, head, &row_change_mask);
683724
last_head_cnt = head;
@@ -687,15 +728,13 @@ void Max7219::idle_tasks() {
687728
#else
688729

689730
#ifdef MAX7219_DEBUG_PLANNER_HEAD
690-
static int16_t last_head_cnt = 0x1;
691731
if (last_head_cnt != head) {
692732
mark16(MAX7219_DEBUG_PLANNER_HEAD, last_head_cnt, head, &row_change_mask);
693733
last_head_cnt = head;
694734
}
695735
#endif
696736

697737
#ifdef MAX7219_DEBUG_PLANNER_TAIL
698-
static int16_t last_tail_cnt = 0x1;
699738
if (last_tail_cnt != tail) {
700739
mark16(MAX7219_DEBUG_PLANNER_TAIL, last_tail_cnt, tail, &row_change_mask);
701740
last_tail_cnt = tail;
@@ -714,7 +753,6 @@ void Max7219::idle_tasks() {
714753
#endif
715754

716755
#ifdef MAX7219_DEBUG_PROFILE
717-
static uint8_t last_time_fraction = 0;
718756
const uint8_t current_time_fraction = (uint16_t(CodeProfiler::get_time_fraction()) * MAX7219_NUMBER_UNITS + 8) / 16;
719757
if (current_time_fraction != last_time_fraction) {
720758
quantity(MAX7219_DEBUG_PROFILE, last_time_fraction, current_time_fraction, &row_change_mask);

Marlin/src/feature/power.cpp

+7
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@
3434
#include "../module/temperature.h"
3535
#include "../MarlinCore.h"
3636

37+
#if ENABLED(MAX7219_REINIT_ON_POWERUP)
38+
#include "max7219.h"
39+
#endif
40+
3741
#if ENABLED(PS_OFF_SOUND)
3842
#include "../libs/buzzer.h"
3943
#endif
@@ -100,6 +104,9 @@ void Power::power_on() {
100104
safe_delay(PSU_POWERUP_DELAY);
101105

102106
restore_stepper_drivers();
107+
108+
TERN_(MAX7219_REINIT_ON_POWERUP, max7219.init());
109+
103110
TERN_(HAS_TRINAMIC_CONFIG, safe_delay(PSU_POWERUP_DELAY));
104111

105112
#ifdef PSU_POWERUP_GCODE

buildroot/tests/DUE

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ opt_enable S_CURVE_ACCELERATION EEPROM_SETTINGS GCODE_MACROS \
2727
FWRETRACT ARC_SUPPORT ARC_P_CIRCLES CNC_WORKSPACE_PLANES CNC_COORDINATE_SYSTEMS \
2828
PSU_CONTROL AUTO_POWER_CONTROL E_DUAL_STEPPER_DRIVERS \
2929
PIDTEMPBED SLOW_PWM_HEATERS THERMAL_PROTECTION_CHAMBER \
30-
PINS_DEBUGGING MAX7219_DEBUG M114_DETAIL \
30+
PINS_DEBUGGING MAX7219_DEBUG M114_DETAIL MAX7219_REINIT_ON_POWERUP \
3131
EXTENSIBLE_UI
3232
opt_add EXTUI_EXAMPLE
3333
exec_test $1 $2 "RAMPS4DUE_EFB with ABL (Bilinear), ExtUI, S-Curve, many options." "$3"

0 commit comments

Comments
 (0)