🎨 Misc. cleanup Dec 4

This commit is contained in:
Scott Lahteine
2025-12-03 20:02:09 -06:00
parent e819ba832e
commit e42059f34a
19 changed files with 56 additions and 55 deletions
+9 -9
View File
@@ -44,15 +44,15 @@ static void TXBegin() {
#endif
}
static void TX(char b){
#if SERIAL_PORT == -1
USBSerial
#elif SERIAL_PORT == 0
USBSerial
#elif SERIAL_PORT == 1
Serial1
#endif
.write(b);
static void TX(char b) {
#if SERIAL_PORT == -1
USBSerial
#elif SERIAL_PORT == 0
USBSerial
#elif SERIAL_PORT == 1
Serial1
#endif
.write(b);
}
// A SW memory barrier, to ensure GCC does not overoptimize loops
+1 -2
View File
@@ -143,9 +143,8 @@ FORCE_INLINE static void HAL_timer_isr_prologue(const uint8_t timer_num) {
Rtc * const rtc = timer_config[timer_num].pRtc;
// Clear interrupt flag
rtc->MODE0.INTFLAG.reg = RTC_MODE0_INTFLAG_CMP0| RTC_MODE0_INTFLAG_OVF;
}
else if (timer_config[timer_num].type == TimerType::tcc){
else if (timer_config[timer_num].type == TimerType::tcc) {
Tcc * const tc = timer_config[timer_num].pTcc;
// Clear interrupt flag
tc->INTFLAG.reg = TCC_INTFLAG_OVF;
+7 -7
View File
@@ -282,7 +282,7 @@ Marlin marlin;
#endif
// Global state of the firmware
MarlinState Marlin::state = MarlinState::MF_INITIALIZING;
MarlinState Marlin::state = MF_INITIALIZING;
// For M109 and M190, this flag may be cleared (by M108) to exit the wait loop
bool Marlin::wait_for_heatup = false;
@@ -404,8 +404,8 @@ void Marlin::startOrResumeJob() {
}
inline void finishSDPrinting() {
if (queue.enqueue_one(F("M1001"))) { // Keep trying until it gets queued
marlin.setState(MarlinState::MF_RUNNING); // Signal to stop trying
if (queue.enqueue_one(F("M1001"))) { // Keep trying until it gets queued
marlin.setState(MF_RUNNING); // Signal to stop trying
TERN_(PASSWORD_AFTER_SD_PRINT_END, password.lock_machine());
TERN_(DGUS_LCD_UI_MKS, screen.sdPrintingFinished());
}
@@ -803,7 +803,7 @@ void Marlin::idle(const bool no_stepper_sleep/*=false*/) {
TERN_(MAX7219_DEBUG, max7219.idle_tasks());
// Return if setup() isn't completed
if (state == MarlinState::MF_INITIALIZING) goto IDLE_DONE;
if (is(MF_INITIALIZING)) goto IDLE_DONE;
// TODO: Still causing errors
TERN_(TOOL_SENSOR, (void)check_tool_sensor_stats(active_extruder, true));
@@ -996,7 +996,7 @@ void Marlin::stop() {
SERIAL_ERROR_MSG(STR_ERR_STOPPED);
LCD_MESSAGE(MSG_STOPPED);
safe_delay(350); // Allow enough time for messages to get out before stopping
state = MarlinState::MF_STOPPED;
setState(MF_STOPPED);
}
} // Marlin::stop()
@@ -1709,7 +1709,7 @@ void setup() {
SETUP_RUN(ftMotion.init());
#endif
marlin.setState(MarlinState::MF_RUNNING);
marlin.setState(MF_RUNNING);
#ifdef STARTUP_TUNE
// Play a short startup tune before continuing.
@@ -1741,7 +1741,7 @@ void loop() {
#if HAS_MEDIA
if (card.flag.abort_sd_printing) abortSDPrinting();
if (marlin.is(MarlinState::MF_SD_COMPLETE)) finishSDPrinting();
if (marlin.is(MF_SD_COMPLETE)) finishSDPrinting();
#endif
queue.advance();
+3 -3
View File
@@ -28,7 +28,7 @@
#include <stdlib.h>
// Global State of the firmware
enum class MarlinState : uint8_t {
enum MarlinState : uint8_t {
MF_INITIALIZING = 0,
MF_STOPPED,
MF_KILLED,
@@ -54,8 +54,8 @@ public:
static MarlinState state;
static void setState(const MarlinState s) { state = s; }
static bool is(const MarlinState s) { return state == s; }
static bool isStopped() { return is(MarlinState::MF_STOPPED); }
static bool isRunning() { return state >= MarlinState::MF_RUNNING; }
static bool isStopped() { return is(MF_STOPPED); }
static bool isRunning() { return state >= MF_RUNNING; }
static bool printingIsActive();
static bool printJobOngoing();
+1 -1
View File
@@ -36,7 +36,7 @@
* existing command buffer.
*/
void GcodeSuite::M999() {
marlin.setState(MarlinState::MF_RUNNING);
marlin.setState(MF_RUNNING);
ui.reset_alert_level();
if (parser.boolval('S')) return;
@@ -190,7 +190,7 @@ void ChangeFilamentScreen::onRedraw(draw_mode_t what) {
.text(TEXT_POS(E0_TEMP_POS), e0_str)
.colors(normal_btn);
if DISABLED(HAS_MULTI_HOTEND) {
if (DISABLED(HAS_MULTI_HOTEND)) {
cmd.font(font_small).cmd(COLOR_RGB(gray_color_1));
}
else if (getTargetTemp_celsius(H1) > 0) {
@@ -220,7 +220,7 @@ void StatusScreen::draw_temperature(draw_mode_t what) {
}
cmd.tag(5).font(font_medium).button(TEXT_POS(FAN_POS), fan_str);
if DISABLED(HAS_MULTI_HOTEND) {
if (DISABLED(HAS_MULTI_HOTEND)) {
cmd.font(font_xsmall).fgcolor(gray_color_1);
}
else if (getTargetTemp_celsius(H1) > 0) {
@@ -60,12 +60,12 @@ void FileNavigator::reset() {
void FileNavigator::refresh() { filelist.refresh(); }
bool FileNavigator::getIndexisDir(uint16_t index){
bool FileNavigator::getIndexisDir(uint16_t index) {
filelist.seek(index);
return filelist.isDir();
}
const char *FileNavigator::getIndexName(uint16_t index){
const char *FileNavigator::getIndexName(uint16_t index) {
filelist.seek(index);
return filelist.shortFilename();
}
@@ -294,7 +294,7 @@ void setProBarRate() {
lv_label_set_text(bar1ValueText, public_buf_l);
lv_obj_align(bar1ValueText, bar1, LV_ALIGN_CENTER, 0, 0);
if (marlin.is(MarlinState::MF_SD_COMPLETE)) {
if (marlin.is(MF_SD_COMPLETE)) {
if (once_flag == 0) {
stop_print_time();
@@ -309,7 +309,7 @@ void setProBarRate() {
if (gCfgItems.finish_power_off) {
gcode.process_subcommands_now(F("M1001"));
queue.inject(F("M81"));
marlin.setState(MarlinState::MF_RUNNING);
marlin.setState(MF_RUNNING);
}
#endif
}
+1 -1
View File
@@ -757,7 +757,7 @@ void GUI_RefreshPage() {
disp_print_time();
disp_fan_Zpos();
}
if (printing_rate_update_flag || marlin.is(MarlinState::MF_SD_COMPLETE)) {
if (printing_rate_update_flag || marlin.is(MF_SD_COMPLETE)) {
printing_rate_update_flag = false;
if (!gcode_preview_over) setProBarRate();
}
+1 -1
View File
@@ -1112,7 +1112,7 @@ namespace ExtUI {
void onSurviveInKilled() {
thermalManager.disable_all_heaters();
flags.printer_killed = 0;
marlin.setState(MarlinState::MF_RUNNING);
marlin.setState(MF_RUNNING);
//SERIAL_ECHOLNPGM("survived at: ", millis());
}
+6 -4
View File
@@ -1624,15 +1624,17 @@ void RTS::onIdle() {
TERN_(HAS_Z_AXIS, sendData(current_position.z * 10.0f, AXIS_Z_COORD_VP));
#if HAS_HOTEND
if (last_target_temperature[0] != thermalManager.degTargetHotend(0))
if (last_target_temperature[0] != thermalManager.degTargetHotend(0)) {
last_target_temperature[0] = thermalManager.degTargetHotend(0);
updateTempE0();
updateTempE0();
}
#endif
#if HAS_HEATED_BED
if (last_target_temperature_bed != thermalManager.degTargetBed())
if (last_target_temperature_bed != thermalManager.degTargetBed()) {
last_target_temperature_bed = thermalManager.degTargetBed();
updateTempBed();
updateTempBed();
}
#endif
#if HAS_HOTEND
+1 -1
View File
@@ -32,7 +32,7 @@
#else
#define MARLIN_LOGO_CHOSEN(W,H) { (void *)marlin_logo_##W##x##H##x16, W, H, HIGHCOLOR }
#if ENABLED(SHOW_CUSTOM_BOOTSCREEN)
#define _CUSTOM_BOOTSCREEN_CHOSEN(W,H){ (void *)custom_bootscreen_##W##x##H##x16, W, H, HIGHCOLOR }
#define _CUSTOM_BOOTSCREEN_CHOSEN(W,H) { (void *)custom_bootscreen_##W##x##H##x16, W, H, HIGHCOLOR }
#define CUSTOM_BOOTSCREEN_CHOSEN(W,H) _CUSTOM_BOOTSCREEN_CHOSEN(W,H)
#endif
#endif
+5 -5
View File
@@ -114,9 +114,9 @@ typedef struct Shaping {
// Of course things can't be done in the past, so when shaping is applied, the all axes are delayed by largest_delay_samples
// minus their own centroid delay. This makes them all be equally delayed and therefore in synch.
void refresh_largest_delay_samples() { largest_delay_samples = -_MIN(SHAPED_LIST(X.Ni[0], Y.Ni[0], Z.Ni[0], E.Ni[0])); }
void reset(){
#define _RESET_ZI(A) ZERO(A.d_zi);
SHAPED_MAP(_RESET_ZI);
zi_idx = 0;
}
void reset() {
#define _RESET_ZI(A) ZERO(A.d_zi);
SHAPED_MAP(_RESET_ZI);
zi_idx = 0;
}
} shaping_t;
+8 -8
View File
@@ -625,14 +625,14 @@ void report_current_position_projected() {
*/
M_StateEnum grbl_state_for_marlin_state() {
switch (marlin.state) {
case MarlinState::MF_INITIALIZING: return M_INIT;
case MarlinState::MF_SD_COMPLETE: return M_ALARM;
case MarlinState::MF_WAITING: return M_IDLE;
case MarlinState::MF_STOPPED: return M_END;
case MarlinState::MF_RUNNING: return M_RUNNING;
case MarlinState::MF_PAUSED: return M_HOLD;
case MarlinState::MF_KILLED: return M_ERROR;
default: return M_IDLE;
case MF_INITIALIZING: return M_INIT;
case MF_SD_COMPLETE: return M_ALARM;
case MF_WAITING: return M_IDLE;
case MF_STOPPED: return M_END;
case MF_RUNNING: return M_RUNNING;
case MF_PAUSED: return M_HOLD;
case MF_KILLED: return M_ERROR;
default: return M_IDLE;
}
}
+1 -1
View File
@@ -2230,7 +2230,7 @@ void MarlinSettings::postprocess() {
#if ENABLED(PTC_PROBE)
EEPROM_READ(ptc.z_offsets_probe);
#endif
# if ENABLED(PTC_BED)
#if ENABLED(PTC_BED)
EEPROM_READ(ptc.z_offsets_bed);
#endif
#if ENABLED(PTC_HOTEND)
+2 -2
View File
@@ -1556,7 +1556,7 @@ int16_t Temperature::getHeaterPower(const heater_id_t heater_id) {
* @param heater_id: The heater that caused the error
*/
inline void loud_kill(FSTR_P const lcd_msg, const heater_id_t heater_id) {
marlin.setState(MarlinState::MF_KILLED);
marlin.setState(MF_KILLED);
thermalManager.disable_all_heaters();
#if HAS_BEEPER
for (uint8_t i = 20; i--;) {
@@ -2310,7 +2310,7 @@ void Temperature::mintemp_error(const heater_id_t heater_id OPTARG(ERR_INCLUDE_T
* - Update the heated bed PID output value
*/
void Temperature::task() {
if (marlin.is(MarlinState::MF_INITIALIZING)) return hal.watchdog_refresh(); // If Marlin isn't started, at least reset the watchdog!
if (marlin.is(MF_INITIALIZING)) return hal.watchdog_refresh(); // If Marlin isn't started, at least reset the watchdog!
static bool no_reentry = false; // Prevent recursion
if (no_reentry) return;
+1 -1
View File
@@ -924,7 +924,7 @@ void fast_line_to_current(const AxisEnum fr_axis) { _line_to_current(fr_axis, 0.
* Returns TRUE if too cold to move (also echos message: STR_ERR_HOTEND_TOO_COLD)
* Returns FALSE if able to move.
*/
bool too_cold(uint8_t toolID){
bool too_cold(uint8_t toolID) {
if (!DEBUGGING(DRYRUN) && thermalManager.targetTooColdToExtrude(toolID)) {
SERIAL_ECHO_MSG(STR_ERR_HOTEND_TOO_COLD);
return true;
+3 -3
View File
@@ -504,7 +504,7 @@ void CardReader::mount() {
cdroot();
else {
#if ANY(HAS_SD_DETECT, HAS_USB_FLASH_DRIVE)
if (!marlin.is(MarlinState::MF_INITIALIZING)) {
if (!marlin.is(MF_INITIALIZING)) {
if (isSDCardSelected())
LCD_ALERTMESSAGE(MSG_MEDIA_INIT_FAIL_SD);
else if (isFlashDriveSelected())
@@ -1650,8 +1650,8 @@ void CardReader::fileHasFinished() {
endFilePrintNow(TERN_(SD_RESORT, true));
flag.sdprintdone = true; // Stop getting bytes from the SD card
marlin.setState(MarlinState::MF_SD_COMPLETE); // Tell Marlin to enqueue M1001 soon
flag.sdprintdone = true; // Stop getting bytes from the SD card
marlin.setState(MF_SD_COMPLETE); // Tell Marlin to enqueue M1001 soon
}
#if ENABLED(AUTO_REPORT_SD_STATUS)