mirror of
https://github.com/MarlinFirmware/Marlin.git
synced 2024-11-23 12:04:19 +00:00
Add COUNT macro and apply
This commit is contained in:
parent
d85861d296
commit
278aa15301
@ -3047,7 +3047,7 @@ inline void gcode_M42() {
|
||||
if (code_seen('P') && pin_status >= 0 && pin_status <= 255)
|
||||
pin_number = code_value_short();
|
||||
|
||||
for (int8_t i = 0; i < (int8_t)(sizeof(sensitive_pins) / sizeof(*sensitive_pins)); i++) {
|
||||
for (int8_t i = 0; i < COUNT(sensitive_pins); i++) {
|
||||
if (sensitive_pins[i] == pin_number) {
|
||||
pin_number = -1;
|
||||
break;
|
||||
@ -4192,7 +4192,7 @@ inline void gcode_M226() {
|
||||
|
||||
if (pin_state >= -1 && pin_state <= 1) {
|
||||
|
||||
for (int8_t i = 0; i < (int8_t)(sizeof(sensitive_pins)/sizeof(*sensitive_pins)); i++) {
|
||||
for (int8_t i = 0; i < COUNT(sensitive_pins); i++) {
|
||||
if (sensitive_pins[i] == pin_number) {
|
||||
pin_number = -1;
|
||||
break;
|
||||
|
@ -19,6 +19,8 @@
|
||||
*/
|
||||
// Warning this file was generated by a program.
|
||||
#include "Marlin.h"
|
||||
#include "macros.h"
|
||||
|
||||
#ifdef SDSUPPORT
|
||||
|
||||
#ifndef Sd2PinMap_h
|
||||
@ -385,7 +387,7 @@ static const pin_map_t digitalPinMap[] = {
|
||||
#error unknown chip
|
||||
#endif // defined(__AVR_ATmega1280__)
|
||||
//------------------------------------------------------------------------------
|
||||
static const uint8_t digitalPinCount = sizeof(digitalPinMap)/sizeof(pin_map_t);
|
||||
static const uint8_t digitalPinCount = COUNT(digitalPinMap);
|
||||
|
||||
uint8_t badPinNumber(void)
|
||||
__attribute__((error("Pin number is too large or not a constant")));
|
||||
|
@ -475,7 +475,7 @@ void Config_ResetDefault() {
|
||||
max_feedrate[i] = tmp2[i];
|
||||
max_acceleration_units_per_sq_second[i] = tmp3[i];
|
||||
#ifdef SCARA
|
||||
if (i < sizeof(axis_scaling) / sizeof(*axis_scaling))
|
||||
if (i < COUNT(axis_scaling))
|
||||
axis_scaling[i] = 1;
|
||||
#endif
|
||||
}
|
||||
|
@ -50,7 +50,7 @@ void digipot_i2c_init() {
|
||||
const float digipot_motor_current[] = DIGIPOT_I2C_MOTOR_CURRENTS;
|
||||
Wire.begin();
|
||||
// setup initial currents as defined in Configuration_adv.h
|
||||
for(int i = 0; i <= sizeof(digipot_motor_current) / sizeof(float); i++) {
|
||||
for(int i = 0; i < COUNT(digipot_motor_current); i++) {
|
||||
digipot_i2c_set_current(i, digipot_motor_current[i]);
|
||||
}
|
||||
}
|
||||
|
@ -22,4 +22,6 @@
|
||||
#define ENABLED(b) _CAT(SWITCH_ENABLED_, b)
|
||||
#define DISABLED(b) (!_CAT(SWITCH_ENABLED_, b))
|
||||
|
||||
#define COUNT(a) (sizeof(a)/sizeof(*a))
|
||||
|
||||
#endif //__MACROS_H
|
||||
|
@ -1249,7 +1249,7 @@ void microstep_init() {
|
||||
pinMode(E0_MS1_PIN,OUTPUT);
|
||||
pinMode(E0_MS2_PIN,OUTPUT);
|
||||
const uint8_t microstep_modes[] = MICROSTEP_MODES;
|
||||
for (uint16_t i = 0; i < sizeof(microstep_modes) / sizeof(microstep_modes[0]); i++)
|
||||
for (uint16_t i = 0; i < COUNT(microstep_modes); i++)
|
||||
microstep_mode(i, microstep_modes[i]);
|
||||
#endif
|
||||
}
|
||||
|
@ -2,6 +2,7 @@
|
||||
#define THERMISTORTABLES_H_
|
||||
|
||||
#include "Marlin.h"
|
||||
#include "macros.h"
|
||||
|
||||
#define OVERSAMPLENR 16
|
||||
|
||||
@ -1123,7 +1124,7 @@ const short temptable_1047[][2] PROGMEM = {
|
||||
|
||||
#ifdef THERMISTORHEATER_0
|
||||
# define HEATER_0_TEMPTABLE TT_NAME(THERMISTORHEATER_0)
|
||||
# define HEATER_0_TEMPTABLE_LEN (sizeof(HEATER_0_TEMPTABLE)/sizeof(*HEATER_0_TEMPTABLE))
|
||||
# define HEATER_0_TEMPTABLE_LEN COUNT(HEATER_0_TEMPTABLE)
|
||||
#else
|
||||
# ifdef HEATER_0_USES_THERMISTOR
|
||||
# error No heater 0 thermistor table specified
|
||||
@ -1146,7 +1147,7 @@ const short temptable_1047[][2] PROGMEM = {
|
||||
|
||||
#ifdef THERMISTORHEATER_1
|
||||
# define HEATER_1_TEMPTABLE TT_NAME(THERMISTORHEATER_1)
|
||||
# define HEATER_1_TEMPTABLE_LEN (sizeof(HEATER_1_TEMPTABLE)/sizeof(*HEATER_1_TEMPTABLE))
|
||||
# define HEATER_1_TEMPTABLE_LEN COUNT(HEATER_1_TEMPTABLE)
|
||||
#else
|
||||
# ifdef HEATER_1_USES_THERMISTOR
|
||||
# error No heater 1 thermistor table specified
|
||||
@ -1169,7 +1170,7 @@ const short temptable_1047[][2] PROGMEM = {
|
||||
|
||||
#ifdef THERMISTORHEATER_2
|
||||
# define HEATER_2_TEMPTABLE TT_NAME(THERMISTORHEATER_2)
|
||||
# define HEATER_2_TEMPTABLE_LEN (sizeof(HEATER_2_TEMPTABLE)/sizeof(*HEATER_2_TEMPTABLE))
|
||||
# define HEATER_2_TEMPTABLE_LEN COUNT(HEATER_2_TEMPTABLE)
|
||||
#else
|
||||
# ifdef HEATER_2_USES_THERMISTOR
|
||||
# error No heater 2 thermistor table specified
|
||||
@ -1192,7 +1193,7 @@ const short temptable_1047[][2] PROGMEM = {
|
||||
|
||||
#ifdef THERMISTORHEATER_3
|
||||
# define HEATER_3_TEMPTABLE TT_NAME(THERMISTORHEATER_3)
|
||||
# define HEATER_3_TEMPTABLE_LEN (sizeof(HEATER_3_TEMPTABLE)/sizeof(*HEATER_3_TEMPTABLE))
|
||||
# define HEATER_3_TEMPTABLE_LEN COUNT(HEATER_3_TEMPTABLE)
|
||||
#else
|
||||
# ifdef HEATER_3_USES_THERMISTOR
|
||||
# error No heater 3 thermistor table specified
|
||||
@ -1215,7 +1216,7 @@ const short temptable_1047[][2] PROGMEM = {
|
||||
|
||||
#ifdef THERMISTORBED
|
||||
# define BEDTEMPTABLE TT_NAME(THERMISTORBED)
|
||||
# define BEDTEMPTABLE_LEN (sizeof(BEDTEMPTABLE)/sizeof(*BEDTEMPTABLE))
|
||||
# define BEDTEMPTABLE_LEN COUNT(BEDTEMPTABLE)
|
||||
#else
|
||||
# ifdef BED_USES_THERMISTOR
|
||||
# error No bed thermistor table specified
|
||||
|
Loading…
Reference in New Issue
Block a user