Skip to content

Commit

Permalink
🎨 Misc. cleanup (from MMU3 PR)
Browse files Browse the repository at this point in the history
Co-Authored-By: Erkan Ozgur Yilmaz <1786804+eoyilmaz@users.noreply.github.com>
  • Loading branch information
thinkyhead and eoyilmaz committed Aug 20, 2024
1 parent 8c78315 commit 0cd9643
Show file tree
Hide file tree
Showing 19 changed files with 60 additions and 64 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ vc-fileutils.settings
# Visual Studio Code
.vscode/*
!.vscode/extensions.json
*.code-workspace

# Simulation files
imgui.ini
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/HAL/DUE/Servo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
static Flags<_Nbr_16timers> DisablePending; // ISR should disable the timer at the next timer reset

// ------------------------
/// Interrupt handler for the TC0 channel 1.
// Interrupt handler for the TC0 channel 1.
// ------------------------
void Servo_Handler(const timer16_Sequence_t, Tc*, const uint8_t);

Expand Down
4 changes: 2 additions & 2 deletions Marlin/src/core/serial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ template <> void SERIAL_ECHO(const p_float_t pf) { SERIAL_IMPL.print(pf.value, p
template <> void SERIAL_ECHO(const w_float_t wf) { char f1[20]; SERIAL_IMPL.print(dtostrf(wf.value, wf.width, wf.prec, f1)); }

// Specializations for F-string
template <> void SERIAL_ECHO(const FSTR_P fstr) { SERIAL_ECHO_P(FTOP(fstr)); }
template <> void SERIAL_ECHOLN(const FSTR_P fstr) { SERIAL_ECHOLN_P(FTOP(fstr)); }
template <> void SERIAL_ECHO(FSTR_P const fstr) { SERIAL_ECHO_P(FTOP(fstr)); }
template <> void SERIAL_ECHOLN(FSTR_P const fstr) { SERIAL_ECHOLN_P(FTOP(fstr)); }

void SERIAL_CHAR(char a) { SERIAL_IMPL.write(a); }
void SERIAL_EOL() { SERIAL_CHAR('\n'); }
Expand Down
4 changes: 2 additions & 2 deletions Marlin/src/core/serial.h
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,8 @@ template<> void SERIAL_ECHO(const p_float_t pf);
template<> void SERIAL_ECHO(const w_float_t wf);

// Specializations for F-string
template<> void SERIAL_ECHO(const FSTR_P fstr);
template<> void SERIAL_ECHOLN(const FSTR_P fstr);
template<> void SERIAL_ECHO(FSTR_P const fstr);
template<> void SERIAL_ECHOLN(FSTR_P const fstr);

// Print any number of items with arbitrary types (except loose PROGMEM strings)
template <typename T, typename ... Args>
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/feature/leds/leds.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ void LEDLights::setup() {
if (i == 1 && PWM_PIN(RGB_LED_G_PIN)) hal.set_pwm_duty(pin_t(RGB_LED_G_PIN), led_pwm); else WRITE(RGB_LED_G_PIN, b < 100 ? HIGH : LOW);
if (i == 2 && PWM_PIN(RGB_LED_B_PIN)) hal.set_pwm_duty(pin_t(RGB_LED_B_PIN), led_pwm); else WRITE(RGB_LED_B_PIN, b < 100 ? HIGH : LOW);
#if ENABLED(RGBW_LED)
if (i == 3){
if (i == 3) {
if (PWM_PIN(RGB_LED_W_PIN)) hal.set_pwm_duty(pin_t(RGB_LED_W_PIN), led_pwm);
else WRITE(RGB_LED_W_PIN, b < 100 ? HIGH : LOW);
delay(RGB_STARTUP_TEST_INNER_MS);//More slowing for ending
Expand Down
39 changes: 16 additions & 23 deletions Marlin/src/gcode/gcode_d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ void GcodeSuite::D(const int16_t dcode) {
} break;

#if ENABLED(EEPROM_SETTINGS)

case 3: { // D3 Read / Write EEPROM
uint8_t *pointer = parser.hex_adr_val('A');
uint16_t len = parser.ushortval('C', 1);
Expand All @@ -107,35 +108,27 @@ void GcodeSuite::D(const int16_t dcode) {
NOMORE(len, persistentStore.capacity() - addr);
if (parser.seenval('X')) {
uint16_t val = parser.hex_val('X');
#if ENABLED(EEPROM_SETTINGS)
persistentStore.access_start();
while (len--) {
int pos = 0;
persistentStore.write_data(pos, (uint8_t *)&val, sizeof(val));
}
SERIAL_EOL();
persistentStore.access_finish();
#else
SERIAL_ECHOLNPGM("NO EEPROM");
#endif
persistentStore.access_start();
while (len--) {
int pos = 0;
persistentStore.write_data(pos, (uint8_t *)&val, sizeof(val));
}
SERIAL_EOL();
persistentStore.access_finish();
}
else {
// Read bytes from EEPROM
#if ENABLED(EEPROM_SETTINGS)
persistentStore.access_start();
int pos = 0;
uint8_t val;
while (len--) if (!persistentStore.read_data(pos, &val, 1)) print_hex_byte(val);
SERIAL_EOL();
persistentStore.access_finish();
#else
SERIAL_ECHOLNPGM("NO EEPROM");
len = 0;
#endif
persistentStore.access_start();
int pos = 0;
uint8_t val;
while (len--) if (!persistentStore.read_data(pos, &val, 1)) print_hex_byte(val);
SERIAL_EOL();
persistentStore.access_finish();
SERIAL_EOL();
}
} break;
#endif

#endif // EEPROM_SETTINGS

case 4: { // D4 Read / Write PIN
//const bool is_out = parser.boolval('F');
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/lcd/e3v2/proui/dwin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1811,7 +1811,7 @@ void dwinPrintFinished() {
// Print was aborted
void dwinPrintAborted() {
#ifndef EVENT_GCODE_SD_ABORT
if (all_axes_homed()) {
if (ExtUI::isMachineHomed()) {
queue.inject(
#if ENABLED(NOZZLE_PARK_FEATURE)
F("G27")
Expand Down
6 changes: 3 additions & 3 deletions Marlin/src/lcd/extui/dgus/DGUSDisplay.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,11 @@ extern DGUSDisplay dgus;
// compile-time x^y
constexpr float cpow(const float x, const int y) { return y == 0 ? 1.0 : x * cpow(x, y - 1); }

///
//
const uint16_t* findScreenVPMapList(uint8_t screen);

/// Find the flash address of a DGUS_VP_Variable for the VP.
// Find the flash address of a DGUS_VP_Variable for the VP.
const DGUS_VP_Variable* findVPVar(const uint16_t vp);

/// Helper to populate a DGUS_VP_Variable for a given VP. Return false if not found.
// Helper to populate a DGUS_VP_Variable for a given VP. Return false if not found.
bool populate_VPVar(const uint16_t VP, DGUS_VP_Variable * const ramcopy);
4 changes: 2 additions & 2 deletions Marlin/src/lcd/extui/dgus/fysetc/DGUSDisplayDef.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ enum DGUS_ScreenID : uint8_t {
DGUS_SCREEN_Z_OFFSET = 222,
DGUS_SCREEN_INFOS = 36,
DGUS_SCREEN_CONFIRM = 240,
DGUS_SCREEN_KILL = 250, ///< Kill Screen. Must always be 250 (to be able to display "Error wrong LCD Version")
DGUS_SCREEN_KILL = 250, //!< Kill Screen. Must always be 250 (to be able to display "Error wrong LCD Version")
DGUS_SCREEN_WAITING = 251,
DGUS_SCREEN_POPUP = 252, ///< special target, popup screen will also return this code to say "return to previous screen"
DGUS_SCREEN_POPUP = 252, //!< special target, popup screen will also return this code to say "return to previous screen"
DGUS_SCREEN_UNUSED = 255
};

Expand Down
4 changes: 2 additions & 2 deletions Marlin/src/lcd/extui/dgus/hiprecy/DGUSDisplayDef.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ enum DGUS_ScreenID : uint8_t {
DGUS_SCREEN_PID_BED = 128,
DGUS_SCREEN_INFOS = 131,
DGUS_SCREEN_CONFIRM = 240,
DGUS_SCREEN_KILL = 250, ///< Kill Screen. Must always be 250 (to be able to display "Error wrong LCD Version")
DGUS_SCREEN_KILL = 250, //!< Kill Screen. Must always be 250 (to be able to display "Error wrong LCD Version")
DGUS_SCREEN_WAITING = 251,
DGUS_SCREEN_POPUP = 252, ///< special target, popup screen will also return this code to say "return to previous screen"
DGUS_SCREEN_POPUP = 252, //!< special target, popup screen will also return this code to say "return to previous screen"
DGUS_SCREEN_UNUSED = 255
};

Expand Down
4 changes: 2 additions & 2 deletions Marlin/src/lcd/extui/dgus/mks/DGUSDisplayDef.h
Original file line number Diff line number Diff line change
Expand Up @@ -235,9 +235,9 @@ enum DGUS_ScreenID : uint8_t {
#endif

DGUS_SCREEN_CONFIRM = 240,
DGUS_SCREEN_KILL = 250, ///< Kill Screen. Must always be 250 (to be able to display "Error wrong LCD Version")
DGUS_SCREEN_KILL = 250, //!< Kill Screen. Must always be 250 (to be able to display "Error wrong LCD Version")
DGUS_SCREEN_WAITING = 251,
DGUS_SCREEN_POPUP = 252, ///< special target, popup screen will also return this code to say "return to previous screen"
DGUS_SCREEN_POPUP = 252, //!< special target, popup screen will also return this code to say "return to previous screen"
DGUS_SCREEN_UNUSED = 255
};

Expand Down
4 changes: 2 additions & 2 deletions Marlin/src/lcd/extui/dgus/origin/DGUSDisplayDef.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ enum DGUS_ScreenID : uint8_t {
DGUS_SCREEN_FILAMENT_UNLOADING = 158,
DGUS_SCREEN_SDPRINTTUNE = 170,
DGUS_SCREEN_CONFIRM = 240,
DGUS_SCREEN_KILL = 250, ///< Kill Screen. Must always be 250 (to be able to display "Error wrong LCD Version")
DGUS_SCREEN_KILL = 250, //!< Kill Screen. Must always be 250 (to be able to display "Error wrong LCD Version")
DGUS_SCREEN_WAITING = 251,
DGUS_SCREEN_POPUP = 252, ///< special target, popup screen will also return this code to say "return to previous screen"
DGUS_SCREEN_POPUP = 252, //!< special target, popup screen will also return this code to say "return to previous screen"
DGUS_SCREEN_UNUSED = 255
};

Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/lcd/extui/dgus_e3s1pro/DGUSDisplay.h
Original file line number Diff line number Diff line change
Expand Up @@ -159,5 +159,5 @@ class DGUSDisplay {

extern DGUSDisplay dgus;

/// Helper to populate a DGUS_VP for a given VP. Return false if not found.
// Helper to populate a DGUS_VP for a given VP. Return false if not found.
extern bool DGUS_PopulateVP(const DGUS_Addr addr, DGUS_VP * const buffer);
6 changes: 3 additions & 3 deletions Marlin/src/lcd/extui/dgus_e3s1pro/DGUSScreenHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,11 @@ class DGUSScreenHandler {
#endif

#if HAS_MEDIA
/// Marlin informed us that a new SD has been inserted.
// Marlin informed us that a new SD has been inserted.
static void sdCardInserted();
/// Marlin informed us that the SD Card has been removed().
// Marlin informed us that the SD Card has been removed().
static void sdCardRemoved();
/// Marlin informed us about a bad SD Card.
// Marlin informed us about a bad SD Card.
static void sdCardError();

static const char* getSDCardPrintFilename() { return sdPrintFilename; }
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/lcd/extui/dgus_reloaded/DGUSDisplay.h
Original file line number Diff line number Diff line change
Expand Up @@ -178,5 +178,5 @@ template<> inline uint16_t DGUSDisplay::swapBytes(const uint16_t value) {

extern DGUSDisplay dgus;

/// Helper to populate a DGUS_VP for a given VP. Return false if not found.
// Helper to populate a DGUS_VP for a given VP. Return false if not found.
extern bool populateVP(const DGUS_Addr addr, DGUS_VP * const buffer);
6 changes: 3 additions & 3 deletions Marlin/src/lcd/extui/dgus_reloaded/DGUSScreenHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@ class DGUSScreenHandler {
static void filamentRunout(const ExtUI::extruder_t extruder);

#if HAS_MEDIA
/// Marlin informed us that a new SD has been inserted.
// Marlin informed us that a new SD has been inserted.
static void sdCardInserted();
/// Marlin informed us that the SD Card has been removed().
// Marlin informed us that the SD Card has been removed().
static void sdCardRemoved();
/// Marlin informed us about a bad SD Card.
// Marlin informed us about a bad SD Card.
static void sdCardError();
#endif

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ void StatusScreen::send_buffer(CommandProcessor &cmd, const void *data, uint16_t
memcpy_P(block, ptr, nBytes);
cmd.write((const void*)block, nBytes);
cmd.execute();
if(cmd.has_fault()) {
if (cmd.has_fault()) {
SERIAL_ECHOLNPGM("Recovering from fault: ");
cmd.reset();
delay(1000);
Expand Down
28 changes: 15 additions & 13 deletions Marlin/src/module/temperature.h
Original file line number Diff line number Diff line change
Expand Up @@ -161,12 +161,14 @@ typedef struct { float p, i, d, c, f; } raw_pidcf_t;
#define scalePID_d(d) ( float(d) / PID_dT )
#define unscalePID_d(d) ( float(d) * PID_dT )

/// @brief The default PID class, only has Kp, Ki, Kd, other classes extend this one
/// @tparam MIN_POW output when current is above target by functional_range
/// @tparam MAX_POW output when current is below target by functional_range
/// @details This class has methods for Kc and Kf terms, but returns constant default values
/// PID classes that implement these features are expected to override these methods
/// Since the finally used PID class is typedef-d, there is no need to use virtual functions
/**
* @brief The default PID class, only has Kp, Ki, Kd, other classes extend this one
* @tparam MIN_POW output when current is above target by functional_range
* @tparam MAX_POW output when current is below target by functional_range
* @details This class has methods for Kc and Kf terms, but returns constant default values.
* PID classes that implement these features are expected to override these methods.
* Since the eventual PID class is typedef-d, there is no need to use virtual functions.
*/
template<int MIN_POW, int MAX_POW>
struct PID_t {
protected:
Expand Down Expand Up @@ -241,7 +243,7 @@ typedef struct { float p, i, d, c, f; } raw_pidcf_t;

#if ENABLED(PIDTEMP)

/// @brief Extrusion scaled PID class
// @brief Extrusion scaled PID class
template<int MIN_POW, int MAX_POW, int LPQ_ARR_SZ>
struct PIDC_t : public PID_t<MIN_POW, MAX_POW> {
private:
Expand Down Expand Up @@ -293,11 +295,11 @@ typedef struct { float p, i, d, c, f; } raw_pidcf_t;
}
};

/// @brief Fan scaled PID, this class implements the get_fan_scale_output() method
/// @tparam MIN_POW @see PID_t
/// @tparam MAX_POW @see PID_t
/// @tparam SCALE_MIN_SPEED parameter from Configuration_adv.h
/// @tparam SCALE_LIN_FACTOR parameter from Configuration_adv.h
// @brief Fan scaled PID, this class implements the get_fan_scale_output() method
// @tparam MIN_POW @see PID_t
// @tparam MAX_POW @see PID_t
// @tparam SCALE_MIN_SPEED parameter from Configuration_adv.h
// @tparam SCALE_LIN_FACTOR parameter from Configuration_adv.h
template<int MIN_POW, int MAX_POW, int SCALE_MIN_SPEED, int SCALE_LIN_FACTOR>
struct PIDF_t : public PID_t<MIN_POW, MAX_POW> {
private:
Expand Down Expand Up @@ -327,7 +329,7 @@ typedef struct { float p, i, d, c, f; } raw_pidcf_t;
}
};

/// @brief Inherits PID and PIDC - can't use proper diamond inheritance w/o virtual
// @brief Inherits PID and PIDC - can't use proper diamond inheritance w/o virtual
template<int MIN_POW, int MAX_POW, int LPQ_ARR_SZ, int SCALE_MIN_SPEED, int SCALE_LIN_FACTOR>
struct PIDCF_t : public PIDC_t<MIN_POW, MAX_POW, LPQ_ARR_SZ> {
private:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ extern "C" {
#define PH1 50 // | 50 | | | | | | OSC_OUT |
// |---------|------------|------------|-----------------------|----------------------|-----------------------------------|-----------|

/// This must be a literal
// This must be a literal
#define NUM_DIGITAL_PINS 51
#define NUM_ANALOG_INPUTS 16

Expand Down

0 comments on commit 0cd9643

Please sign in to comment.