Reduce need for UNUSED

This commit is contained in:
Scott Lahteine 2019-09-30 21:44:07 -05:00
parent e3ff27c95a
commit e3fd0519b3
31 changed files with 104 additions and 143 deletions

View File

@ -146,8 +146,7 @@ extern "C" {
#define DISABLE_TEMPERATURE_INTERRUPT() CBI(TIMSK0, OCIE0B)
#define TEMPERATURE_ISR_ENABLED() TEST(TIMSK0, OCIE0B)
FORCE_INLINE void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency) {
UNUSED(frequency);
FORCE_INLINE void HAL_timer_start(const uint8_t timer_num, const uint32_t) {
switch (timer_num) {
case STEP_TIMER_NUM:
// waveform generation = 0100 = CTC

View File

@ -184,15 +184,10 @@ void spiBegin() {
// nop to tune soft SPI timing
#define nop asm volatile ("\tnop\n")
// Set SPI rate
void spiInit(uint8_t spiRate) {
UNUSED(spiRate); // nothing to do
}
void spiInit(uint8_t) { /* do nothing */ }
// Begin SPI transaction, set clock, bit order, data mode
void spiBeginTransaction(uint32_t spiClock, uint8_t bitOrder, uint8_t dataMode) {
UNUSED(spiBeginTransaction); // nothing to do
}
void spiBeginTransaction(uint32_t spiClock, uint8_t bitOrder, uint8_t dataMode) { /* do nothing */ }
// Soft SPI receive byte
uint8_t spiRec() {

View File

@ -151,13 +151,12 @@
(((uint32_t)(addr) & 0xF0000000) + 0x02000000 + ((uint32_t)(addr)&0xFFFFF)*32 + (bit)*4)
// run at ~8 .. ~10Mhz - Rx version (Tx line not altered)
static uint8_t spiTransferRx0(uint8_t bout) { // using Mode 0
static uint8_t spiTransferRx0(uint8_t) { // using Mode 0
uint32_t bin = 0;
uint32_t work = 0;
uint32_t BITBAND_MISO_PORT = BITBAND_ADDRESS( ((uint32_t)PORT(MISO_PIN))+0x3C, PIN_SHIFT(MISO_PIN)); /* PDSR of port in bitband area */
uint32_t SCK_PORT_PLUS30 = ((uint32_t) PORT(SCK_PIN)) + 0x30; /* SODR of port */
uint32_t SCK_MASK = PIN_MASK(SCK_PIN);
UNUSED(bout);
/* The software SPI routine */
__asm__ __volatile__(

View File

@ -55,12 +55,9 @@ static int pending_char = -1;
#endif
// Public Methods
void MarlinSerialUSB::begin(const long baud_setting) {
UNUSED(baud_setting);
}
void MarlinSerialUSB::begin(const long) {}
void MarlinSerialUSB::end() {
}
void MarlinSerialUSB::end() {}
int MarlinSerialUSB::peek() {
if (pending_char >= 0)

View File

@ -33,19 +33,12 @@ Ctrl_status sd_mmc_spi_read_capacity(uint32_t *nb_sector) {
return CTRL_GOOD;
}
bool sd_mmc_spi_unload(bool unload) {
UNUSED(unload);
return true;
}
bool sd_mmc_spi_unload(bool) { return true; }
bool sd_mmc_spi_wr_protect() {
return false;
}
bool sd_mmc_spi_wr_protect() { return false; }
bool sd_mmc_spi_removal() {
if (!IS_SD_INSERTED() || IS_SD_PRINTING() || IS_SD_FILE_OPEN() || !card.isMounted())
return true;
return false;
return (!IS_SD_INSERTED() || IS_SD_PRINTING() || IS_SD_FILE_OPEN() || !card.isMounted());
}
#if ACCESS_USB == true

View File

@ -83,7 +83,7 @@ public:
HalSerial() { host_connected = true; }
void begin(int32_t baud) { }
void begin(int32_t) {}
void end() {}

View File

@ -104,17 +104,11 @@ extern "C" {
// ADC
// ------------------------
void HAL_adc_start_conversion(const uint8_t adc_pin) {
HAL_adc_result = analogRead(adc_pin);
}
// TODO: Make sure this doesn't cause any delay
void HAL_adc_start_conversion(const uint8_t adc_pin) { HAL_adc_result = analogRead(adc_pin); }
uint16_t HAL_adc_get_result() {
return HAL_adc_result;
}
uint16_t HAL_adc_get_result() { return HAL_adc_result; }
void flashFirmware(int16_t value) {
UNUSED(value);
NVIC_SystemReset();
}
void flashFirmware(int16_t) { NVIC_SystemReset(); }
#endif // ARDUINO_ARCH_STM32 && !STM32GENERIC

View File

@ -138,8 +138,7 @@ void pca9632_set_led_color(const LEDColor &color) {
#if ENABLED(PCA9632_BUZZER)
void pca9632_buzz(const long duration, const uint16_t freq) {
UNUSED(duration); UNUSED(freq);
void pca9632_buzz(const long, const uint16_t) {
uint8_t data[] = PCA9632_BUZZER_DATA;
Wire.beginTransmission(I2C_ADDRESS(PCA9632_ADDRESS));
Wire.write(data, sizeof(data));

View File

@ -169,7 +169,7 @@ class PrintJobRecovery {
#if ENABLED(DEBUG_POWER_LOSS_RECOVERY)
static void debug(PGM_P const prefix);
#else
static inline void debug(PGM_P const prefix) { UNUSED(prefix); }
static inline void debug(PGM_P const) {}
#endif
private:

View File

@ -266,7 +266,7 @@ class FilamentSensorBase {
}
public:
static inline void block_completed(const block_t* const b) { UNUSED(b); }
static inline void block_completed(const block_t* const) {}
static inline void run() {
const bool out = poll_runout_state(active_extruder);
@ -353,8 +353,8 @@ class FilamentSensorBase {
static inline void reset() { runout_count = runout_threshold; }
static inline void run() { if (runout_count >= 0) runout_count--; }
static inline bool has_run_out() { return runout_count < 0; }
static inline void block_completed(const block_t* const b) { UNUSED(b); }
static inline void filament_present(const uint8_t extruder) { runout_count = runout_threshold; UNUSED(extruder); }
static inline void block_completed(const block_t* const) { }
static inline void filament_present(const uint8_t) { runout_count = runout_threshold; }
};
#endif // !FILAMENT_RUNOUT_DISTANCE_MM

View File

@ -70,7 +70,7 @@ public:
#if ENABLED(SPINDLE_CHANGE_DIR)
static void set_direction(const bool reverse);
#else
static inline void set_direction(const bool reverse) { UNUSED(reverse); }
static inline void set_direction(const bool) {}
#endif
static inline void disable() { set_enabled(false); }

View File

@ -291,8 +291,8 @@ public:
static inline float mm_to_volumetric_unit(const float mm) { return mm; }
static inline float linear_value_to_mm(const float v) { return v; }
static inline float axis_value_to_mm(const AxisEnum axis, const float v) { UNUSED(axis); return v; }
static inline float per_axis_value(const AxisEnum axis, const float v) { UNUSED(axis); return v; }
static inline float axis_value_to_mm(const AxisEnum, const float v) { return v; }
static inline float per_axis_value(const AxisEnum, const float v) { return v; }
#endif

View File

@ -114,8 +114,7 @@ FORCE_INLINE void draw_menu_item_edit_P(const bool sel, const uint8_t row, PGM_P
FORCE_INLINE void draw_menu_item_edit_##NAME (const bool sel, const uint8_t row, PGM_P const pstr, TYPE * const data, ...) { \
DRAW_MENU_ITEM_SETTING_EDIT_GENERIC(STRFUNC(*(data))); \
} \
FORCE_INLINE void draw_menu_item_edit_accessor_##NAME (const bool sel, const uint8_t row, PGM_P const pstr, PGM_P const pstr2, TYPE (*pget)(), void (*pset)(TYPE), ...) { \
UNUSED(pstr2); UNUSED(pset); \
FORCE_INLINE void draw_menu_item_edit_accessor_##NAME (const bool sel, const uint8_t row, PGM_P const pstr, PGM_P const, TYPE (*pget)(), void (*)(TYPE), ...) { \
DRAW_MENU_ITEM_SETTING_EDIT_GENERIC(STRFUNC(pget())); \
} \
typedef void NAME##_void
@ -149,13 +148,12 @@ DEFINE_DRAW_MENU_ITEM_SETTING_EDIT(long5_25); // 12345 right-justif
class MenuItem_back {
public:
static inline void action(PGM_P const dummy=nullptr) {
static inline void action(PGM_P const=nullptr) {
ui.goto_previous_screen(
#if ENABLED(TURBO_BACK_MENU_ITEM)
true
#endif
);
UNUSED(dummy);
}
};

View File

@ -108,6 +108,7 @@ class MenuItem_sdfile {
MenuItem_submenu::action(pstr, menu_sd_confirm);
#else
sdcard_start_selected_file();
UNUSED(pstr);
#endif
}
};

View File

@ -273,7 +273,7 @@ public:
static void init();
static void update();
static void set_alert_status_P(PGM_P message);
static void set_alert_status_P(PGM_P const message);
static char status_message[];
static bool has_status();
@ -393,10 +393,10 @@ public:
static inline void update() {}
static inline void refresh() {}
static inline void return_to_status() {}
static inline void set_alert_status_P(PGM_P message) { UNUSED(message); }
static inline void set_status(const char* const message, const bool persist=false) { UNUSED(message); UNUSED(persist); }
static inline void set_status_P(PGM_P const message, const int8_t level=0) { UNUSED(message); UNUSED(level); }
static inline void status_printf_P(const uint8_t level, PGM_P const fmt, ...) { UNUSED(level); UNUSED(fmt); }
static inline void set_alert_status_P(PGM_P const) {}
static inline void set_status(const char* const, const bool=false) {}
static inline void set_status_P(PGM_P const, const int8_t=0) {}
static inline void status_printf_P(const uint8_t, PGM_P const, ...) {}
static inline void reset_status() {}
static inline void reset_alert_level() {}
static constexpr bool has_status() { return false; }

View File

@ -85,7 +85,7 @@ class MarlinSettings {
static void report(const bool forReplay=false);
#else
FORCE_INLINE
static void report(const bool forReplay=false) { UNUSED(forReplay); }
static void report(const bool=false) {}
#endif
private:

View File

@ -279,12 +279,12 @@ void homeaxis(const AxisEnum axis);
#else
#define NATIVE_TO_LOGICAL(POS, AXIS) (POS)
#define LOGICAL_TO_NATIVE(POS, AXIS) (POS)
FORCE_INLINE void toLogical(xy_pos_t &raw) { UNUSED(raw); }
FORCE_INLINE void toLogical(xyz_pos_t &raw) { UNUSED(raw); }
FORCE_INLINE void toLogical(xyze_pos_t &raw) { UNUSED(raw); }
FORCE_INLINE void toNative(xy_pos_t &raw) { UNUSED(raw); }
FORCE_INLINE void toNative(xyz_pos_t &raw) { UNUSED(raw); }
FORCE_INLINE void toNative(xyze_pos_t &raw) { UNUSED(raw); }
FORCE_INLINE void toLogical(xy_pos_t&) {}
FORCE_INLINE void toLogical(xyz_pos_t&) {}
FORCE_INLINE void toLogical(xyze_pos_t&) {}
FORCE_INLINE void toNative(xy_pos_t&) {}
FORCE_INLINE void toNative(xyz_pos_t&) {}
FORCE_INLINE void toNative(xyze_pos_t&) {}
#endif
#define LOGICAL_X_POSITION(POS) NATIVE_TO_LOGICAL(POS, X_AXIS)
#define LOGICAL_Y_POSITION(POS) NATIVE_TO_LOGICAL(POS, Y_AXIS)

View File

@ -431,12 +431,9 @@ class Planner {
#else
FORCE_INLINE static float fade_scaling_factor_for_z(const float &rz) {
UNUSED(rz);
return 1;
}
FORCE_INLINE static float fade_scaling_factor_for_z(const float&) { return 1; }
FORCE_INLINE static bool leveling_active_at_z(const float &rz) { UNUSED(rz); return true; }
FORCE_INLINE static bool leveling_active_at_z(const float&) { return true; }
#endif

View File

@ -813,13 +813,7 @@ void Temperature::min_temp_error(const heater_ind_t heater) {
#if HOTENDS
float Temperature::get_pid_output_hotend(const uint8_t e) {
#if HOTENDS == 1
#define _HOTEND_TEST true
#else
#define _HOTEND_TEST (e == active_extruder)
#endif
E_UNUSED();
float Temperature::get_pid_output_hotend(const uint8_t E_NAME) {
const uint8_t ee = HOTEND_INDEX;
#if ENABLED(PIDTEMP)
#if DISABLED(PID_OPENLOOP)
@ -860,8 +854,13 @@ void Temperature::min_temp_error(const heater_ind_t heater) {
pid_output = work_pid[ee].Kp + work_pid[ee].Ki + work_pid[ee].Kd + float(MIN_POWER);
#if ENABLED(PID_EXTRUSION_SCALING)
#if HOTENDS == 1
constexpr bool this_hotend = true;
#else
const bool this_hotend = (e == active_extruder);
#endif
work_pid[ee].Kc = 0;
if (_HOTEND_TEST) {
if (this_hotend) {
const long e_position = stepper.position(E_AXIS);
if (e_position > last_e_position) {
lpq[lpq_ptr] = e_position - last_e_position;
@ -895,6 +894,7 @@ void Temperature::min_temp_error(const heater_ind_t heater) {
MSG_PID_DEBUG_OUTPUT, pid_output
);
#if DISABLED(PID_OPENLOOP)
{
SERIAL_ECHOPAIR(
MSG_PID_DEBUG_PTERM, work_pid[ee].Kp,
MSG_PID_DEBUG_ITERM, work_pid[ee].Ki,
@ -903,6 +903,7 @@ void Temperature::min_temp_error(const heater_ind_t heater) {
, MSG_PID_DEBUG_CTERM, work_pid[ee].Kc
#endif
);
}
#endif
SERIAL_EOL();
}
@ -911,12 +912,11 @@ void Temperature::min_temp_error(const heater_ind_t heater) {
#else // No PID enabled
#if HEATER_IDLE_HANDLER
#define _TIMED_OUT_TEST hotend_idle[ee].timed_out
const bool is_idling = hotend_idle[ee].timed_out;
#else
#define _TIMED_OUT_TEST false
constexpr bool is_idling = false;
#endif
const float pid_output = (!_TIMED_OUT_TEST && temp_hotend[ee].celsius < temp_hotend[ee].target) ? BANG_MAX : 0;
#undef _TIMED_OUT_TEST
const float pid_output = (!is_idling && temp_hotend[ee].celsius < temp_hotend[ee].target) ? BANG_MAX : 0;
#endif
@ -971,6 +971,7 @@ void Temperature::min_temp_error(const heater_ind_t heater) {
#endif // PID_OPENLOOP
#if ENABLED(PID_BED_DEBUG)
{
SERIAL_ECHO_START();
SERIAL_ECHOLNPAIR(
" PID_BED_DEBUG : Input ", temp_bed.celsius, " Output ", pid_output,
@ -980,6 +981,7 @@ void Temperature::min_temp_error(const heater_ind_t heater) {
MSG_PID_DEBUG_DTERM, work_pid.Kd,
#endif
);
}
#endif
return pid_output;
@ -1811,8 +1813,7 @@ void Temperature::init() {
* their target temperature by a configurable margin.
* This is called when the temperature is set. (M104, M109)
*/
void Temperature::start_watching_hotend(const uint8_t e) {
E_UNUSED();
void Temperature::start_watching_hotend(const uint8_t E_NAME) {
const uint8_t ee = HOTEND_INDEX;
if (degTargetHotend(ee) && degHotend(ee) < degTargetHotend(ee) - (WATCH_TEMP_INCREASE + TEMP_HYSTERESIS + 1)) {
watch_hotend[ee].target = degHotend(ee) + WATCH_TEMP_INCREASE;

View File

@ -39,10 +39,10 @@
#if HOTENDS <= 1
#define HOTEND_INDEX 0
#define E_UNUSED() UNUSED(e)
#define E_NAME
#else
#define HOTEND_INDEX e
#define E_UNUSED()
#define E_NAME e
#endif
// Identifiers for other heaters
@ -304,17 +304,15 @@ class Temperature {
static bool allow_cold_extrude;
static int16_t extrude_min_temp;
FORCE_INLINE static bool tooCold(const int16_t temp) { return allow_cold_extrude ? false : temp < extrude_min_temp; }
FORCE_INLINE static bool tooColdToExtrude(const uint8_t e) {
E_UNUSED();
FORCE_INLINE static bool tooColdToExtrude(const uint8_t E_NAME) {
return tooCold(degHotend(HOTEND_INDEX));
}
FORCE_INLINE static bool targetTooColdToExtrude(const uint8_t e) {
E_UNUSED();
FORCE_INLINE static bool targetTooColdToExtrude(const uint8_t E_NAME) {
return tooCold(degTargetHotend(HOTEND_INDEX));
}
#else
FORCE_INLINE static bool tooColdToExtrude(const uint8_t e) { UNUSED(e); return false; }
FORCE_INLINE static bool targetTooColdToExtrude(const uint8_t e) { UNUSED(e); return false; }
FORCE_INLINE static bool tooColdToExtrude(const uint8_t) { return false; }
FORCE_INLINE static bool targetTooColdToExtrude(const uint8_t) { return false; }
#endif
FORCE_INLINE static bool hotEnoughToExtrude(const uint8_t e) { return !tooColdToExtrude(e); }
@ -546,16 +544,13 @@ class Temperature {
* Preheating hotends
*/
#ifdef MILLISECONDS_PREHEAT_TIME
static bool is_preheating(const uint8_t e) {
E_UNUSED();
static bool is_preheating(const uint8_t E_NAME) {
return preheat_end_time[HOTEND_INDEX] && PENDING(millis(), preheat_end_time[HOTEND_INDEX]);
}
static void start_preheat_time(const uint8_t e) {
E_UNUSED();
static void start_preheat_time(const uint8_t E_NAME) {
preheat_end_time[HOTEND_INDEX] = millis() + MILLISECONDS_PREHEAT_TIME;
}
static void reset_preheat_time(const uint8_t e) {
E_UNUSED();
static void reset_preheat_time(const uint8_t E_NAME) {
preheat_end_time[HOTEND_INDEX] = 0;
}
#else
@ -566,39 +561,36 @@ class Temperature {
//inline so that there is no performance decrease.
//deg=degreeCelsius
FORCE_INLINE static float degHotend(const uint8_t e) {
E_UNUSED();
FORCE_INLINE static float degHotend(const uint8_t E_NAME) {
return (0
#if HOTENDS
return temp_hotend[HOTEND_INDEX].celsius;
#else
return 0;
+ temp_hotend[HOTEND_INDEX].celsius
#endif
);
}
#if ENABLED(SHOW_TEMP_ADC_VALUES)
FORCE_INLINE static int16_t rawHotendTemp(const uint8_t e) {
E_UNUSED();
FORCE_INLINE static int16_t rawHotendTemp(const uint8_t E_NAME) {
return (0
#if HOTENDS
return temp_hotend[HOTEND_INDEX].raw;
#else
return 0;
+ temp_hotend[HOTEND_INDEX].raw
#endif
);
}
#endif
FORCE_INLINE static int16_t degTargetHotend(const uint8_t e) {
E_UNUSED();
FORCE_INLINE static int16_t degTargetHotend(const uint8_t E_NAME) {
return (0
#if HOTENDS
return temp_hotend[HOTEND_INDEX].target;
#else
return 0;
+ temp_hotend[HOTEND_INDEX].target
#endif
);
}
#if WATCH_HOTENDS
static void start_watching_hotend(const uint8_t e=0);
#else
static inline void start_watching_hotend(const uint8_t e=0) { UNUSED(e); }
static inline void start_watching_hotend(const uint8_t=0) {}
#endif
#if HOTENDS
@ -612,8 +604,7 @@ class Temperature {
static inline void start_watching_E5() { start_watching_hotend(5); }
#endif
static void setTargetHotend(const int16_t celsius, const uint8_t e) {
E_UNUSED();
static void setTargetHotend(const int16_t celsius, const uint8_t E_NAME) {
const uint8_t ee = HOTEND_INDEX;
#ifdef MILLISECONDS_PREHEAT_TIME
if (celsius == 0)
@ -628,13 +619,11 @@ class Temperature {
start_watching_hotend(ee);
}
FORCE_INLINE static bool isHeatingHotend(const uint8_t e) {
E_UNUSED();
FORCE_INLINE static bool isHeatingHotend(const uint8_t E_NAME) {
return temp_hotend[HOTEND_INDEX].target > temp_hotend[HOTEND_INDEX].celsius;
}
FORCE_INLINE static bool isCoolingHotend(const uint8_t e) {
E_UNUSED();
FORCE_INLINE static bool isCoolingHotend(const uint8_t E_NAME) {
return temp_hotend[HOTEND_INDEX].target < temp_hotend[HOTEND_INDEX].celsius;
}
@ -765,8 +754,7 @@ class Temperature {
#if HEATER_IDLE_HANDLER
static void reset_heater_idle_timer(const uint8_t e) {
E_UNUSED();
static void reset_heater_idle_timer(const uint8_t E_NAME) {
hotend_idle[HOTEND_INDEX].reset();
start_watching_hotend(HOTEND_INDEX);
}

View File

@ -61,7 +61,7 @@ class Sd2Card {
inline bool readData(uint8_t* dst) { return readBlock(pos++, dst); }
inline bool readStop() const { return true; }
inline bool writeStart(const uint32_t block, const uint32_t eraseCount) { UNUSED(eraseCount); pos = block; return ready(); }
inline bool writeStart(const uint32_t block, const uint32_t) { pos = block; return ready(); }
inline bool writeData(uint8_t* src) { return writeBlock(pos++, src); }
inline bool writeStop() const { return true; }