🚨 Fix some compiler warnings

This commit is contained in:
Scott Lahteine 2022-01-01 17:49:54 -06:00 committed by Scott Lahteine
parent f7bea2846f
commit 494a2fc80c
10 changed files with 41 additions and 25 deletions

View File

@ -19,6 +19,10 @@
*/ */
#pragma once #pragma once
/**
* HAL for Arduino AVR
*/
#include "../shared/Marduino.h" #include "../shared/Marduino.h"
#include "../shared/HAL_SPI.h" #include "../shared/HAL_SPI.h"
#include "fastio.h" #include "fastio.h"

View File

@ -43,7 +43,9 @@ public:
} }
constexpr SerialMask(const uint8_t mask) : mask(mask) {} constexpr SerialMask(const uint8_t mask) : mask(mask) {}
constexpr SerialMask(const SerialMask & other) : mask(other.mask) {} // Can't use = default here since not all framework support this constexpr SerialMask(const SerialMask &rs) : mask(rs.mask) {} // Can't use = default here since not all frameworks support this
SerialMask& operator=(const SerialMask &rs) { mask = rs.mask; return *this; }
static constexpr uint8_t All = 0xFF; static constexpr uint8_t All = 0xFF;
}; };

View File

@ -92,8 +92,8 @@ struct Flags {
void clear(const int n) { b &= ~(bits_t)_BV(n); } void clear(const int n) { b &= ~(bits_t)_BV(n); }
bool test(const int n) const { return TEST(b, n); } bool test(const int n) const { return TEST(b, n); }
bool operator[](const int n) { return test(n); } bool operator[](const int n) { return test(n); }
const bool operator[](const int n) const { return test(n); } bool operator[](const int n) const { return test(n); }
const int size() const { return sizeof(b); } int size() const { return sizeof(b); }
}; };
// Specialization for a single bool flag // Specialization for a single bool flag
@ -106,8 +106,8 @@ struct Flags<1> {
void clear(const int) { b = false; } void clear(const int) { b = false; }
bool test(const int) const { return b; } bool test(const int) const { return b; }
bool operator[](const int) { return b; } bool operator[](const int) { return b; }
const bool operator[](const int) const { return b; } bool operator[](const int) const { return b; }
const int size() const { return sizeof(b); } int size() const { return sizeof(b); }
}; };
typedef Flags<8> flags_8_t; typedef Flags<8> flags_8_t;
@ -125,8 +125,8 @@ typedef struct AxisFlags {
void clear(const int n) { flags.clear(n); } void clear(const int n) { flags.clear(n); }
bool test(const int n) const { return flags.test(n); } bool test(const int n) const { return flags.test(n); }
bool operator[](const int n) { return flags[n]; } bool operator[](const int n) { return flags[n]; }
const bool operator[](const int n) const { return flags[n]; } bool operator[](const int n) const { return flags[n]; }
const int size() const { return sizeof(flags); } int size() const { return sizeof(flags); }
} axis_flags_t; } axis_flags_t;
// //

View File

@ -135,8 +135,8 @@ void GcodeSuite::M201() {
LOOP_LOGICAL_AXES(i) { LOOP_LOGICAL_AXES(i) {
if (parser.seenval(AXIS_CHAR(i))) { if (parser.seenval(AXIS_CHAR(i))) {
const uint8_t a = TERN(HAS_EXTRUDERS, (i == E_AXIS ? uint8_t(E_AXIS_N(target_extruder)) : i), i); const AxisEnum a = TERN(HAS_EXTRUDERS, (i == E_AXIS ? E_AXIS_N(target_extruder) : (AxisEnum)i), (AxisEnum)i);
planner.set_max_acceleration(a, parser.value_axis_units((AxisEnum)a)); planner.set_max_acceleration(a, parser.value_axis_units(a));
} }
} }
} }
@ -184,8 +184,8 @@ void GcodeSuite::M203() {
LOOP_LOGICAL_AXES(i) LOOP_LOGICAL_AXES(i)
if (parser.seenval(AXIS_CHAR(i))) { if (parser.seenval(AXIS_CHAR(i))) {
const uint8_t a = TERN(HAS_EXTRUDERS, (i == E_AXIS ? uint8_t(E_AXIS_N(target_extruder)) : i), i); const AxisEnum a = TERN(HAS_EXTRUDERS, (i == E_AXIS ? E_AXIS_N(target_extruder) : (AxisEnum)i), (AxisEnum)i);
planner.set_max_feedrate(a, parser.value_axis_units((AxisEnum)a)); planner.set_max_feedrate(a, parser.value_axis_units(a));
} }
} }

View File

@ -656,7 +656,7 @@ namespace ExtUI {
} }
void setAxisMaxFeedrate_mm_s(const feedRate_t value, const axis_t axis) { void setAxisMaxFeedrate_mm_s(const feedRate_t value, const axis_t axis) {
planner.set_max_feedrate(axis, value); planner.set_max_feedrate((AxisEnum)axis, value);
} }
void setAxisMaxFeedrate_mm_s(const feedRate_t value, const extruder_t extruder) { void setAxisMaxFeedrate_mm_s(const feedRate_t value, const extruder_t extruder) {
@ -674,7 +674,7 @@ namespace ExtUI {
} }
void setAxisMaxAcceleration_mm_s2(const_float_t value, const axis_t axis) { void setAxisMaxAcceleration_mm_s2(const_float_t value, const axis_t axis) {
planner.set_max_acceleration(axis, value); planner.set_max_acceleration((AxisEnum)axis, value);
} }
void setAxisMaxAcceleration_mm_s2(const_float_t value, const extruder_t extruder) { void setAxisMaxAcceleration_mm_s2(const_float_t value, const extruder_t extruder) {

View File

@ -1399,7 +1399,7 @@ void prepare_line_to_destination() {
bool homing_needed_error(linear_axis_bits_t axis_bits/*=linear_bits*/) { bool homing_needed_error(linear_axis_bits_t axis_bits/*=linear_bits*/) {
if ((axis_bits = axes_should_home(axis_bits))) { if ((axis_bits = axes_should_home(axis_bits))) {
PGM_P home_first = GET_TEXT(MSG_HOME_FIRST); PGM_P home_first = GET_TEXT(MSG_HOME_FIRST);
char msg[strlen_P(home_first)+1]; char msg[30];
sprintf_P(msg, home_first, sprintf_P(msg, home_first,
NUM_AXIS_LIST( NUM_AXIS_LIST(
TEST(axis_bits, X_AXIS) ? STR_A : "", TEST(axis_bits, X_AXIS) ? STR_A : "",

View File

@ -3292,7 +3292,7 @@ void Planner::refresh_positioning() {
} }
// Apply limits to a variable and give a warning if the value was out of range // Apply limits to a variable and give a warning if the value was out of range
inline void limit_and_warn(float &val, const uint8_t axis, PGM_P const setting_name, const xyze_float_t &max_limit) { inline void limit_and_warn(float &val, const AxisEnum axis, PGM_P const setting_name, const xyze_float_t &max_limit) {
const uint8_t lim_axis = TERN_(HAS_EXTRUDERS, axis > E_AXIS ? E_AXIS :) axis; const uint8_t lim_axis = TERN_(HAS_EXTRUDERS, axis > E_AXIS ? E_AXIS :) axis;
const float before = val; const float before = val;
LIMIT(val, 0.1, max_limit[lim_axis]); LIMIT(val, 0.1, max_limit[lim_axis]);
@ -3311,7 +3311,7 @@ inline void limit_and_warn(float &val, const uint8_t axis, PGM_P const setting_n
* *
* This hard limit is applied as a block is being added to the planner queue. * This hard limit is applied as a block is being added to the planner queue.
*/ */
void Planner::set_max_acceleration(const uint8_t axis, float inMaxAccelMMS2) { void Planner::set_max_acceleration(const AxisEnum axis, float inMaxAccelMMS2) {
#if ENABLED(LIMITED_MAX_ACCEL_EDITING) #if ENABLED(LIMITED_MAX_ACCEL_EDITING)
#ifdef MAX_ACCEL_EDIT_VALUES #ifdef MAX_ACCEL_EDIT_VALUES
constexpr xyze_float_t max_accel_edit = MAX_ACCEL_EDIT_VALUES; constexpr xyze_float_t max_accel_edit = MAX_ACCEL_EDIT_VALUES;
@ -3334,7 +3334,7 @@ void Planner::set_max_acceleration(const uint8_t axis, float inMaxAccelMMS2) {
* *
* This hard limit is applied as a block is being added to the planner queue. * This hard limit is applied as a block is being added to the planner queue.
*/ */
void Planner::set_max_feedrate(const uint8_t axis, float inMaxFeedrateMMS) { void Planner::set_max_feedrate(const AxisEnum axis, float inMaxFeedrateMMS) {
#if ENABLED(LIMITED_MAX_FR_EDITING) #if ENABLED(LIMITED_MAX_FR_EDITING)
#ifdef MAX_FEEDRATE_EDIT_VALUES #ifdef MAX_FEEDRATE_EDIT_VALUES
constexpr xyze_float_t max_fr_edit = MAX_FEEDRATE_EDIT_VALUES; constexpr xyze_float_t max_fr_edit = MAX_FEEDRATE_EDIT_VALUES;

View File

@ -501,10 +501,10 @@ class Planner {
static void refresh_positioning(); static void refresh_positioning();
// For an axis set the Maximum Acceleration in mm/s^2 // For an axis set the Maximum Acceleration in mm/s^2
static void set_max_acceleration(const uint8_t axis, float inMaxAccelMMS2); static void set_max_acceleration(const AxisEnum axis, float inMaxAccelMMS2);
// For an axis set the Maximum Feedrate in mm/s // For an axis set the Maximum Feedrate in mm/s
static void set_max_feedrate(const uint8_t axis, float inMaxFeedrateMMS); static void set_max_feedrate(const AxisEnum axis, float inMaxFeedrateMMS);
// For an axis set the Maximum Jerk (instant change) in mm/s // For an axis set the Maximum Jerk (instant change) in mm/s
#if HAS_CLASSIC_JERK #if HAS_CLASSIC_JERK

View File

@ -751,7 +751,7 @@ volatile bool Temperature::raw_temps_ready = false;
// Report heater states every 2 seconds // Report heater states every 2 seconds
if (ELAPSED(ms, next_temp_ms)) { if (ELAPSED(ms, next_temp_ms)) {
#if HAS_TEMP_SENSOR #if HAS_TEMP_SENSOR
print_heater_states(ischamber ? active_extruder : (isbed ? active_extruder : heater_id)); print_heater_states(heater_id < 0 ? active_extruder : (int8_t)heater_id);
SERIAL_EOL(); SERIAL_EOL();
#endif #endif
next_temp_ms = ms + 2000UL; next_temp_ms = ms + 2000UL;
@ -2817,6 +2817,9 @@ void Temperature::init() {
#if HAS_THERMAL_PROTECTION #if HAS_THERMAL_PROTECTION
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wimplicit-fallthrough"
Temperature::tr_state_machine_t Temperature::tr_state_machine[NR_HEATER_RUNAWAY]; // = { { TRInactive, 0 } }; Temperature::tr_state_machine_t Temperature::tr_state_machine[NR_HEATER_RUNAWAY]; // = { { TRInactive, 0 } };
/** /**
@ -2946,6 +2949,8 @@ void Temperature::init() {
} }
} }
#pragma GCC diagnostic pop
#endif // HAS_THERMAL_PROTECTION #endif // HAS_THERMAL_PROTECTION
void Temperature::disable_all_heaters() { void Temperature::disable_all_heaters() {
@ -3669,6 +3674,9 @@ void Temperature::isr() {
switch (adc_sensor_state) { switch (adc_sensor_state) {
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wimplicit-fallthrough"
case SensorsReady: { case SensorsReady: {
// All sensors have been read. Stay in this state for a few // All sensors have been read. Stay in this state for a few
// ISRs to save on calls to temp update/checking code below. // ISRs to save on calls to temp update/checking code below.
@ -3686,6 +3694,8 @@ void Temperature::isr() {
} }
} }
#pragma GCC diagnostic pop
case StartSampling: // Start of sampling loops. Do updates/checks. case StartSampling: // Start of sampling loops. Do updates/checks.
if (++temp_count >= OVERSAMPLENR) { // 10 * 16 * 1/(16000000/64/256) = 164ms. if (++temp_count >= OVERSAMPLENR) { // 10 * 16 * 1/(16000000/64/256) = 164ms.
temp_count = 0; temp_count = 0;
@ -3917,7 +3927,7 @@ void Temperature::isr() {
delay(2); delay(2);
} }
void Temperature::print_heater_states(const uint8_t target_extruder void Temperature::print_heater_states(const int8_t target_extruder
OPTARG(HAS_TEMP_REDUNDANT, const bool include_r/*=false*/) OPTARG(HAS_TEMP_REDUNDANT, const bool include_r/*=false*/)
) { ) {
#if HAS_TEMP_HOTEND #if HAS_TEMP_HOTEND

View File

@ -995,7 +995,7 @@ class Temperature {
#endif // HEATER_IDLE_HANDLER #endif // HEATER_IDLE_HANDLER
#if HAS_TEMP_SENSOR #if HAS_TEMP_SENSOR
static void print_heater_states(const uint8_t target_extruder static void print_heater_states(const int8_t target_extruder
OPTARG(HAS_TEMP_REDUNDANT, const bool include_r=false) OPTARG(HAS_TEMP_REDUNDANT, const bool include_r=false)
); );
#if ENABLED(AUTO_REPORT_TEMPERATURES) #if ENABLED(AUTO_REPORT_TEMPERATURES)