Spacing, const, comments

This commit is contained in:
Scott Lahteine 2017-06-05 17:41:38 -05:00
parent 7f0945d2b1
commit efc198f952
7 changed files with 73 additions and 104 deletions

View file

@ -243,7 +243,7 @@
/* Custom characters defined in the first 8 characters of the LCD */
#define LCD_BEDTEMP_CHAR 0x00 // Print only as a char. This will have 'unexpected' results when used in a string!
#define LCD_DEGREE_CHAR 0x01
#define LCD_STR_THERMOMETER "\x02" // Too many places use preprocessor string concatination to change this to a char right now.
#define LCD_STR_THERMOMETER "\x02" // Still used with string concatenation
#define LCD_UPLEVEL_CHAR 0x03
#define LCD_REFRESH_CHAR 0x04
#define LCD_STR_FOLDER "\x05"

View file

@ -225,13 +225,11 @@
*/
//#define CASE_LIGHT_ENABLE
#if ENABLED(CASE_LIGHT_ENABLE)
#define CASE_LIGHT_PIN 4 // can be defined here or in the pins_XXX.h file for your board
// pins_XXX.h file overrides this one
#define INVERT_CASE_LIGHT false // set to true if case light is ON when pin is at 0
#define CASE_LIGHT_DEFAULT_ON true // set default power up state to on or off
#define CASE_LIGHT_DEFAULT_BRIGHTNESS 105 // set power up brightness 0-255 ( only used if on PWM
// and if CASE_LIGHT_DEFAULT is set to on
//#define MENU_ITEM_CASE_LIGHT // Uncomment to have a Case Light entry in main menu
//#define CASE_LIGHT_PIN 4 // Override the default pin if needed
#define INVERT_CASE_LIGHT false // Set true if Case Light is ON when pin is LOW
#define CASE_LIGHT_DEFAULT_ON true // Set default power-up state on
#define CASE_LIGHT_DEFAULT_BRIGHTNESS 105 // Set default power-up brightness (0-255, requires PWM pin)
//#define MENU_ITEM_CASE_LIGHT // Add a Case Light option to the LCD main menu
#endif
//===========================================================================

View file

@ -458,7 +458,7 @@ volatile bool wait_for_heatup = true;
volatile bool wait_for_user = false;
#endif
const char axis_codes[XYZE] = {'X', 'Y', 'Z', 'E'};
const char axis_codes[XYZE] = { 'X', 'Y', 'Z', 'E' };
// Number of characters read in the current line of serial input
static int serial_count = 0;
@ -1394,7 +1394,7 @@ bool get_target_extruder_from_command(int code) {
*
* Callers must sync the planner position after calling this!
*/
static void set_axis_is_at_home(AxisEnum axis) {
static void set_axis_is_at_home(const AxisEnum axis) {
#if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) {
SERIAL_ECHOPAIR(">>> set_axis_is_at_home(", axis_codes[axis]);
@ -1496,7 +1496,7 @@ static void set_axis_is_at_home(AxisEnum axis) {
/**
* Some planner shorthand inline functions
*/
inline float get_homing_bump_feedrate(AxisEnum axis) {
inline float get_homing_bump_feedrate(const AxisEnum axis) {
int constexpr homing_bump_divisor[] = HOMING_BUMP_DIVISOR;
int hbd = homing_bump_divisor[axis];
if (hbd < 1) {
@ -1507,20 +1507,19 @@ inline float get_homing_bump_feedrate(AxisEnum axis) {
return homing_feedrate_mm_s[axis] / hbd;
}
//
// line_to_current_position
// Move the planner to the current position from wherever it last moved
// (or from wherever it has been told it is located).
//
/**
* Move the planner to the current position from wherever it last moved
* (or from wherever it has been told it is located).
*/
inline void line_to_current_position() {
planner.buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], feedrate_mm_s, active_extruder);
}
//
// line_to_destination
// Move the planner, not necessarily synced with current_position
//
inline void line_to_destination(float fr_mm_s) {
/**
* Move the planner to the position stored in the destination array, which is
* used by G0/G1/G2/G3/G5 and many other functions to set a destination.
*/
inline void line_to_destination(const float fr_mm_s) {
planner.buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], fr_mm_s, active_extruder);
}
inline void line_to_destination() { line_to_destination(feedrate_mm_s); }
@ -2751,7 +2750,7 @@ static void clean_up_after_endstop_or_probe_move() {
/**
* Home an individual linear axis
*/
static void do_homing_move(const AxisEnum axis, float distance, float fr_mm_s=0.0) {
static void do_homing_move(const AxisEnum axis, const float distance, const float fr_mm_s=0.0) {
#if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) {
@ -4907,7 +4906,7 @@ void home_all_axes() { gcode_G28(true); }
if ( NEAR(current_position[X_AXIS], xProbe - (X_PROBE_OFFSET_FROM_EXTRUDER))
&& NEAR(current_position[Y_AXIS], yProbe - (Y_PROBE_OFFSET_FROM_EXTRUDER))
) {
float simple_z = current_position[Z_AXIS] - measured_z;
const float simple_z = current_position[Z_AXIS] - measured_z;
#if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) {
SERIAL_ECHOPAIR("Z from Probe:", simple_z);
@ -7667,45 +7666,32 @@ void report_current_position() {
#ifdef M114_DETAIL
static const char axis_char[XYZE] = {'X','Y','Z','E'};
void report_xyze(const float pos[XYZE], uint8_t n = 4, uint8_t precision = 3) {
void report_xyze(const float pos[XYZE], const uint8_t n = 4, const uint8_t precision = 3) {
char str[12];
for(uint8_t i=0; i<n; i++) {
for (uint8_t i = 0; i < n; i++) {
SERIAL_CHAR(' ');
SERIAL_CHAR(axis_char[i]);
SERIAL_CHAR(axis_codes[i]);
SERIAL_CHAR(':');
SERIAL_PROTOCOL(dtostrf(pos[i],8,precision,str));
SERIAL_PROTOCOL(dtostrf(pos[i], 8, precision, str));
}
SERIAL_EOL;
}
inline void report_xyz(const float pos[XYZ]) {
report_xyze(pos,3);
}
inline void report_xyz(const float pos[XYZ]) { report_xyze(pos, 3); }
void report_current_position_detail() {
stepper.synchronize();
SERIAL_EOL;
SERIAL_PROTOCOLPGM("Logical:");
SERIAL_PROTOCOLPGM("\nLogical:");
report_xyze(current_position);
SERIAL_PROTOCOLPGM("Raw: ");
const float raw[XYZ] = {
RAW_X_POSITION(current_position[X_AXIS]),
RAW_Y_POSITION(current_position[Y_AXIS]),
RAW_Z_POSITION(current_position[Z_AXIS])
};
const float raw[XYZ] = { RAW_X_POSITION(current_position[X_AXIS]), RAW_Y_POSITION(current_position[Y_AXIS]), RAW_Z_POSITION(current_position[Z_AXIS]) };
report_xyz(raw);
SERIAL_PROTOCOLPGM("Leveled:");
float leveled[XYZ] = {
current_position[X_AXIS],
current_position[Y_AXIS],
current_position[Z_AXIS]
};
float leveled[XYZ] = { current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS] };
planner.apply_leveling(leveled);
report_xyz(leveled);
@ -7725,13 +7711,8 @@ void report_current_position() {
#endif
SERIAL_PROTOCOLPGM("Stepper:");
const float step_count[XYZE] = {
(float)stepper.position(X_AXIS),
(float)stepper.position(Y_AXIS),
(float)stepper.position(Z_AXIS),
(float)stepper.position(E_AXIS)
};
report_xyze(step_count,4,0);
const float step_count[XYZE] = { stepper.position(X_AXIS), stepper.position(Y_AXIS), stepper.position(Z_AXIS), stepper.position(E_AXIS) };
report_xyze(step_count, 4, 0);
#if IS_SCARA
const float deg[XYZ] = {
@ -7739,17 +7720,12 @@ void report_current_position() {
stepper.get_axis_position_degrees(B_AXIS)
};
SERIAL_PROTOCOLPGM("Degrees:");
report_xyze(deg,2);
report_xyze(deg, 2);
#endif
SERIAL_PROTOCOLPGM("FromStp:");
get_cartesian_from_steppers(); // writes cartes[XYZ] (with forward kinematics)
const float from_steppers[XYZE] = {
cartes[X_AXIS],
cartes[Y_AXIS],
cartes[Z_AXIS],
stepper.get_axis_position_mm(E_AXIS)
};
const float from_steppers[XYZE] = { cartes[X_AXIS], cartes[Y_AXIS], cartes[Z_AXIS], stepper.get_axis_position_mm(E_AXIS) };
report_xyze(from_steppers);
const float diff[XYZE] = {
@ -7764,12 +7740,12 @@ void report_current_position() {
#endif // M114_DETAIL
/**
* M114: Output current position to serial port
* M114: Report current position to host
*/
inline void gcode_M114() {
#ifdef M114_DETAIL
if ( parser.seen('D') ) {
if (parser.seen('D')) {
report_current_position_detail();
return;
}
@ -7777,7 +7753,7 @@ inline void gcode_M114() {
stepper.synchronize();
report_current_position();
}
}
/**
* M115: Capabilities string
@ -7859,9 +7835,7 @@ inline void gcode_M115() {
/**
* M117: Set LCD Status Message
*/
inline void gcode_M117() {
lcd_setstatus(parser.string_arg);
}
inline void gcode_M117() { lcd_setstatus(parser.string_arg); }
/**
* M119: Output endstop states to serial output
@ -12749,7 +12723,7 @@ void setup() {
#if ENABLED(ENDSTOP_INTERRUPTS_FEATURE)
setup_endstop_interrupts();
#endif
#if ENABLED(SWITCHING_EXTRUDER)
move_extruder_servo(0); // Initialize extruder servo
#endif

View file

@ -104,7 +104,7 @@ class Buzzer {
* @param duration Duration of the tone in milliseconds
* @param frequency Frequency of the tone in hertz
*/
void tone(uint16_t const &duration, uint16_t const &frequency = 0) {
void tone(const uint16_t &duration, const uint16_t &frequency = 0) {
while (buffer.isFull()) {
this->tick();
thermalManager.manage_heater();

View file

@ -457,10 +457,10 @@ void MarlinSettings::postprocess() {
#endif
#if DISABLED(ULTIPANEL)
const int lcd_preheat_hotend_temp[2] = { PREHEAT_1_TEMP_HOTEND, PREHEAT_2_TEMP_HOTEND },
lcd_preheat_bed_temp[2] = { PREHEAT_1_TEMP_BED, PREHEAT_2_TEMP_BED },
lcd_preheat_fan_speed[2] = { PREHEAT_1_FAN_SPEED, PREHEAT_2_FAN_SPEED };
#endif // !ULTIPANEL
constexpr int lcd_preheat_hotend_temp[2] = { PREHEAT_1_TEMP_HOTEND, PREHEAT_2_TEMP_HOTEND },
lcd_preheat_bed_temp[2] = { PREHEAT_1_TEMP_BED, PREHEAT_2_TEMP_BED },
lcd_preheat_fan_speed[2] = { PREHEAT_1_FAN_SPEED, PREHEAT_2_FAN_SPEED };
#endif
EEPROM_WRITE(lcd_preheat_hotend_temp);
EEPROM_WRITE(lcd_preheat_bed_temp);

View file

@ -52,7 +52,7 @@
#endif
#if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT)
static void* heater_ttbl_map[2] = {(void*)HEATER_0_TEMPTABLE, (void*)HEATER_1_TEMPTABLE };
static void* heater_ttbl_map[2] = { (void*)HEATER_0_TEMPTABLE, (void*)HEATER_1_TEMPTABLE };
static uint8_t heater_ttbllen_map[2] = { HEATER_0_TEMPTABLE_LEN, HEATER_1_TEMPTABLE_LEN };
#else
static void* heater_ttbl_map[HOTENDS] = ARRAY_BY_HOTENDS((void*)HEATER_0_TEMPTABLE, (void*)HEATER_1_TEMPTABLE, (void*)HEATER_2_TEMPTABLE, (void*)HEATER_3_TEMPTABLE, (void*)HEATER_4_TEMPTABLE);

View file

@ -193,18 +193,19 @@ extern volatile uint8_t buttons; //an extended version of the last checked butt
static void lcd_implementation_update_indicators();
#endif
static void createChar_P(char c, PROGMEM byte *ptr) {
static void createChar_P(const char c, const byte * const ptr) {
byte temp[8];
int8_t i;
for(i=0; i<8; i++) {
for (uint8_t i = 0; i < 8; i++)
temp[i] = pgm_read_byte(&ptr[i]);
}
lcd.createChar(c, temp);
}
const static PROGMEM byte bedTemp[8] = {
static void lcd_set_custom_characters(
#if ENABLED(LCD_PROGRESS_BAR)
const bool info_screen_charset = true
#endif
) {
const static PROGMEM byte bedTemp[8] = {
B00000,
B11111,
B10101,
@ -213,9 +214,9 @@ const static PROGMEM byte bedTemp[8] = {
B11111,
B00000,
B00000
};
};
const static PROGMEM byte degree[8] = {
const static PROGMEM byte degree[8] = {
B01100,
B10010,
B10010,
@ -226,7 +227,7 @@ const static PROGMEM byte degree[8] = {
B00000
};
const static PROGMEM byte thermometer[8] = {
const static PROGMEM byte thermometer[8] = {
B00100,
B01010,
B01010,
@ -237,7 +238,7 @@ const static PROGMEM byte thermometer[8] = {
B01110
};
const static PROGMEM byte uplevel[8] = {
const static PROGMEM byte uplevel[8] = {
B00100,
B01110,
B11111,
@ -246,9 +247,9 @@ const static PROGMEM byte uplevel[8] = {
B00000,
B00000,
B00000
};
};
const static PROGMEM byte feedrate[8] = {
const static PROGMEM byte feedrate[8] = {
B11100,
B10000,
B11000,
@ -257,9 +258,9 @@ const static PROGMEM byte feedrate[8] = {
B00110,
B00101,
B00000
};
};
const static PROGMEM byte clock[8] = {
const static PROGMEM byte clock[8] = {
B00000,
B01110,
B10011,
@ -268,10 +269,10 @@ const static PROGMEM byte clock[8] = {
B01110,
B00000,
B00000
};
};
#if ENABLED(SDSUPPORT)
const static PROGMEM byte refresh[8] = {
#if ENABLED(SDSUPPORT)
const static PROGMEM byte refresh[8] = {
B00000,
B00110,
B11001,
@ -280,8 +281,8 @@ const static PROGMEM byte clock[8] = {
B10011,
B01100,
B00000,
};
const static PROGMEM byte folder[8] = {
};
const static PROGMEM byte folder[8] = {
B00000,
B11100,
B11111,
@ -290,10 +291,10 @@ const static PROGMEM byte clock[8] = {
B11111,
B00000,
B00000
};
};
#if ENABLED(LCD_PROGRESS_BAR)
const static PROGMEM byte progress[3][8] = { {
#if ENABLED(LCD_PROGRESS_BAR)
const static PROGMEM byte progress[3][8] = { {
B00000,
B10000,
B10000,
@ -321,14 +322,8 @@ const static PROGMEM byte clock[8] = {
B10101,
B00000
} };
#endif
#endif
#endif
static void lcd_set_custom_characters(
#if ENABLED(LCD_PROGRESS_BAR)
const bool info_screen_charset = true
#endif
) {
createChar_P(LCD_BEDTEMP_CHAR, bedTemp);
createChar_P(LCD_DEGREE_CHAR, degree);
@ -638,10 +633,12 @@ FORCE_INLINE void _draw_heater_status(const int8_t heater, const char prefix, co
#if ENABLED(LCD_PROGRESS_BAR)
inline void lcd_draw_progress_bar(const uint8_t percent) {
int tix = (int)(percent * (LCD_WIDTH) * 3) / 100,
cel = tix / 3, rem = tix % 3, i = LCD_WIDTH;
const int tix = (int)(percent * (LCD_WIDTH) * 3) / 100,
cel = tix / 3,
rem = tix % 3;
uint8_t i = LCD_WIDTH;
char msg[LCD_WIDTH + 1], b = ' ';
msg[i] = '\0';
msg[LCD_WIDTH] = '\0';
while (i--) {
if (i == cel - 1)
b = LCD_STR_PROGRESS[2];