Apply maths macros and type changes ahead of HAL
This commit is contained in:
@ -49,7 +49,7 @@
|
||||
bool ubl_lcd_map_control = false;
|
||||
#endif
|
||||
|
||||
int lcd_preheat_hotend_temp[2], lcd_preheat_bed_temp[2], lcd_preheat_fan_speed[2];
|
||||
int16_t lcd_preheat_hotend_temp[2], lcd_preheat_bed_temp[2], lcd_preheat_fan_speed[2];
|
||||
|
||||
#if ENABLED(FILAMENT_LCD_DISPLAY) && ENABLED(SDSUPPORT)
|
||||
millis_t previous_lcd_status_ms = 0;
|
||||
@ -184,7 +184,7 @@ uint16_t max_display_update_time = 0;
|
||||
void menu_action_setting_edit_callback_ ## _name(const char * const pstr, _type * const ptr, const _type minValue, const _type maxValue, const screenFunc_t callback, const bool live=false); \
|
||||
typedef void _name##_void
|
||||
|
||||
DECLARE_MENU_EDIT_TYPE(int, int3);
|
||||
DECLARE_MENU_EDIT_TYPE(int16_t, int3);
|
||||
DECLARE_MENU_EDIT_TYPE(uint8_t, int8);
|
||||
DECLARE_MENU_EDIT_TYPE(float, float3);
|
||||
DECLARE_MENU_EDIT_TYPE(float, float32);
|
||||
@ -193,7 +193,7 @@ uint16_t max_display_update_time = 0;
|
||||
DECLARE_MENU_EDIT_TYPE(float, float51);
|
||||
DECLARE_MENU_EDIT_TYPE(float, float52);
|
||||
DECLARE_MENU_EDIT_TYPE(float, float62);
|
||||
DECLARE_MENU_EDIT_TYPE(unsigned long, long5);
|
||||
DECLARE_MENU_EDIT_TYPE(uint32_t, long5);
|
||||
|
||||
void menu_action_setting_edit_bool(const char* pstr, bool* ptr);
|
||||
void menu_action_setting_edit_callback_bool(const char* pstr, bool* ptr, screenFunc_t callbackFunc);
|
||||
@ -602,7 +602,7 @@ void lcd_status_screen() {
|
||||
}
|
||||
|
||||
#if ENABLED(ULTIPANEL_FEEDMULTIPLY)
|
||||
const int new_frm = feedrate_percentage + (int32_t)encoderPosition;
|
||||
const int16_t new_frm = feedrate_percentage + (int32_t)encoderPosition;
|
||||
// Dead zone at 100% feedrate
|
||||
if ((feedrate_percentage < 100 && new_frm > 100) || (feedrate_percentage > 100 && new_frm < 100)) {
|
||||
feedrate_percentage = 100;
|
||||
@ -966,7 +966,7 @@ void kill_screen(const char* lcd_msg) {
|
||||
if (lcd_clicked) { defer_return_to_status = false; return lcd_goto_previous_menu(); }
|
||||
ENCODER_DIRECTION_NORMAL();
|
||||
if (encoderPosition) {
|
||||
const int babystep_increment = (int32_t)encoderPosition * (BABYSTEP_MULTIPLICATOR);
|
||||
const int16_t babystep_increment = (int32_t)encoderPosition * (BABYSTEP_MULTIPLICATOR);
|
||||
encoderPosition = 0;
|
||||
lcdDrawUpdate = LCDVIEW_REDRAW_NOW;
|
||||
thermalManager.babystep_axis(axis, babystep_increment);
|
||||
@ -990,7 +990,7 @@ void kill_screen(const char* lcd_msg) {
|
||||
defer_return_to_status = true;
|
||||
ENCODER_DIRECTION_NORMAL();
|
||||
if (encoderPosition) {
|
||||
const int babystep_increment = (int32_t)encoderPosition * (BABYSTEP_MULTIPLICATOR);
|
||||
const int16_t babystep_increment = (int32_t)encoderPosition * (BABYSTEP_MULTIPLICATOR);
|
||||
encoderPosition = 0;
|
||||
|
||||
const float new_zoffset = zprobe_zoffset + planner.steps_to_mm[Z_AXIS] * babystep_increment;
|
||||
@ -1021,7 +1021,7 @@ void kill_screen(const char* lcd_msg) {
|
||||
|
||||
float mesh_edit_value, mesh_edit_accumulator; // We round mesh_edit_value to 2.5 decimal places. So we keep a
|
||||
// separate value that doesn't lose precision.
|
||||
static int ubl_encoderPosition = 0;
|
||||
static int16_t ubl_encoderPosition = 0;
|
||||
|
||||
static void _lcd_mesh_fine_tune(const char* msg) {
|
||||
defer_return_to_status = true;
|
||||
@ -1275,7 +1275,7 @@ void kill_screen(const char* lcd_msg) {
|
||||
* "Prepare" submenu items
|
||||
*
|
||||
*/
|
||||
void _lcd_preheat(const int endnum, const int16_t temph, const int16_t tempb, const int16_t fan) {
|
||||
void _lcd_preheat(const int16_t endnum, const int16_t temph, const int16_t tempb, const int16_t fan) {
|
||||
if (temph > 0) thermalManager.setTargetHotend(min(heater_maxtemp[endnum], temph), endnum);
|
||||
#if TEMP_SENSOR_BED != 0
|
||||
if (tempb >= 0) thermalManager.setTargetBed(tempb);
|
||||
@ -1806,7 +1806,7 @@ void kill_screen(const char* lcd_msg) {
|
||||
|
||||
void _lcd_ubl_level_bed();
|
||||
|
||||
static int ubl_storage_slot = 0,
|
||||
static int16_t ubl_storage_slot = 0,
|
||||
custom_bed_temp = 50,
|
||||
custom_hotend_temp = 190,
|
||||
side_points = 3,
|
||||
@ -2624,7 +2624,7 @@ void kill_screen(const char* lcd_msg) {
|
||||
// This assumes the center is 0,0
|
||||
#if ENABLED(DELTA)
|
||||
if (axis != Z_AXIS) {
|
||||
max = sqrt(sq((float)(DELTA_PRINTABLE_RADIUS)) - sq(current_position[Y_AXIS - axis]));
|
||||
max = SQRT(sq((float)(DELTA_PRINTABLE_RADIUS)) - sq(current_position[Y_AXIS - axis]));
|
||||
min = -max;
|
||||
}
|
||||
#endif
|
||||
@ -2872,14 +2872,14 @@ void kill_screen(const char* lcd_msg) {
|
||||
#if ENABLED(PID_AUTOTUNE_MENU)
|
||||
|
||||
#if ENABLED(PIDTEMP)
|
||||
int autotune_temp[HOTENDS] = ARRAY_BY_HOTENDS1(150);
|
||||
int16_t autotune_temp[HOTENDS] = ARRAY_BY_HOTENDS1(150);
|
||||
#endif
|
||||
|
||||
#if ENABLED(PIDTEMPBED)
|
||||
int autotune_temp_bed = 70;
|
||||
int16_t autotune_temp_bed = 70;
|
||||
#endif
|
||||
|
||||
void _lcd_autotune(int e) {
|
||||
void _lcd_autotune(int16_t e) {
|
||||
char cmd[30];
|
||||
sprintf_P(cmd, PSTR("M303 U1 E%i S%i"), e,
|
||||
#if HAS_PID_FOR_BOTH
|
||||
@ -2899,14 +2899,14 @@ void kill_screen(const char* lcd_msg) {
|
||||
|
||||
// Helpers for editing PID Ki & Kd values
|
||||
// grab the PID value out of the temp variable; scale it; then update the PID driver
|
||||
void copy_and_scalePID_i(int e) {
|
||||
void copy_and_scalePID_i(int16_t e) {
|
||||
#if DISABLED(PID_PARAMS_PER_HOTEND) || HOTENDS == 1
|
||||
UNUSED(e);
|
||||
#endif
|
||||
PID_PARAM(Ki, e) = scalePID_i(raw_Ki);
|
||||
thermalManager.updatePID();
|
||||
}
|
||||
void copy_and_scalePID_d(int e) {
|
||||
void copy_and_scalePID_d(int16_t e) {
|
||||
#if DISABLED(PID_PARAMS_PER_HOTEND) || HOTENDS == 1
|
||||
UNUSED(e);
|
||||
#endif
|
||||
@ -3475,7 +3475,7 @@ void kill_screen(const char* lcd_msg) {
|
||||
STATIC_ITEM(MSG_INFO_PRINT_LONGEST ": ", false, false); // Longest job time:
|
||||
STATIC_ITEM("", false, false, buffer); // 99y 364d 23h 59m 59s
|
||||
|
||||
sprintf_P(buffer, PSTR("%ld.%im"), long(stats.filamentUsed / 1000), int(stats.filamentUsed / 100) % 10);
|
||||
sprintf_P(buffer, PSTR("%ld.%im"), long(stats.filamentUsed / 1000), int16_t(stats.filamentUsed / 100) % 10);
|
||||
STATIC_ITEM(MSG_INFO_PRINT_FILAMENT ": ", false, false); // Extruded total:
|
||||
STATIC_ITEM("", false, false, buffer); // 125m
|
||||
END_SCREEN();
|
||||
@ -3878,14 +3878,14 @@ void kill_screen(const char* lcd_msg) {
|
||||
*
|
||||
* The "DEFINE_MENU_EDIT_TYPE" macro generates the functions needed to edit a numerical value.
|
||||
*
|
||||
* For example, DEFINE_MENU_EDIT_TYPE(int, int3, itostr3, 1) expands into these functions:
|
||||
* For example, DEFINE_MENU_EDIT_TYPE(int16_t, int3, itostr3, 1) expands into these functions:
|
||||
*
|
||||
* bool _menu_edit_int3();
|
||||
* void menu_edit_int3(); // edit int (interactively)
|
||||
* void menu_edit_callback_int3(); // edit int (interactively) with callback on completion
|
||||
* void _menu_action_setting_edit_int3(const char * const pstr, int * const ptr, const int minValue, const int maxValue);
|
||||
* void menu_action_setting_edit_int3(const char * const pstr, int * const ptr, const int minValue, const int maxValue);
|
||||
* void menu_action_setting_edit_callback_int3(const char * const pstr, int * const ptr, const int minValue, const int maxValue, const screenFunc_t callback, const bool live); // edit int with callback
|
||||
* void menu_edit_int3(); // edit int16_t (interactively)
|
||||
* void menu_edit_callback_int3(); // edit int16_t (interactively) with callback on completion
|
||||
* void _menu_action_setting_edit_int3(const char * const pstr, int16_t * const ptr, const int16_t minValue, const int16_t maxValue);
|
||||
* void menu_action_setting_edit_int3(const char * const pstr, int16_t * const ptr, const int16_t minValue, const int16_t maxValue);
|
||||
* void menu_action_setting_edit_callback_int3(const char * const pstr, int16_t * const ptr, const int16_t minValue, const int16_t maxValue, const screenFunc_t callback, const bool live); // edit int16_t with callback
|
||||
*
|
||||
* You can then use one of the menu macros to present the edit interface:
|
||||
* MENU_ITEM_EDIT(int3, MSG_SPEED, &feedrate_percentage, 10, 999)
|
||||
@ -3936,7 +3936,7 @@ void kill_screen(const char* lcd_msg) {
|
||||
} \
|
||||
typedef void _name
|
||||
|
||||
DEFINE_MENU_EDIT_TYPE(int, int3, itostr3, 1);
|
||||
DEFINE_MENU_EDIT_TYPE(int16_t, int3, itostr3, 1);
|
||||
DEFINE_MENU_EDIT_TYPE(uint8_t, int8, i8tostr3, 1);
|
||||
DEFINE_MENU_EDIT_TYPE(float, float3, ftostr3, 1.0);
|
||||
DEFINE_MENU_EDIT_TYPE(float, float32, ftostr32, 100.0);
|
||||
@ -3945,7 +3945,7 @@ void kill_screen(const char* lcd_msg) {
|
||||
DEFINE_MENU_EDIT_TYPE(float, float51, ftostr51sign, 10.0);
|
||||
DEFINE_MENU_EDIT_TYPE(float, float52, ftostr52sign, 100.0);
|
||||
DEFINE_MENU_EDIT_TYPE(float, float62, ftostr62rj, 100.0);
|
||||
DEFINE_MENU_EDIT_TYPE(unsigned long, long5, ftostr5rj, 0.01);
|
||||
DEFINE_MENU_EDIT_TYPE(uint32_t, long5, ftostr5rj, 0.01);
|
||||
|
||||
/**
|
||||
*
|
||||
@ -3953,7 +3953,7 @@ void kill_screen(const char* lcd_msg) {
|
||||
*
|
||||
*/
|
||||
#if ENABLED(REPRAPWORLD_KEYPAD)
|
||||
void _reprapworld_keypad_move(AxisEnum axis, int dir) {
|
||||
void _reprapworld_keypad_move(AxisEnum axis, int16_t dir) {
|
||||
move_menu_scale = REPRAPWORLD_KEYPAD_MOVE_STEP;
|
||||
encoderPosition = dir;
|
||||
switch (axis) {
|
||||
@ -4112,8 +4112,8 @@ void lcd_init() {
|
||||
#endif
|
||||
}
|
||||
|
||||
int lcd_strlen(const char* s) {
|
||||
int i = 0, j = 0;
|
||||
int16_t lcd_strlen(const char* s) {
|
||||
int16_t i = 0, j = 0;
|
||||
while (s[i]) {
|
||||
if (PRINTABLE(s[i])) j++;
|
||||
i++;
|
||||
@ -4121,8 +4121,8 @@ int lcd_strlen(const char* s) {
|
||||
return j;
|
||||
}
|
||||
|
||||
int lcd_strlen_P(const char* s) {
|
||||
int j = 0;
|
||||
int16_t lcd_strlen_P(const char* s) {
|
||||
int16_t j = 0;
|
||||
while (pgm_read_byte(s)) {
|
||||
if (PRINTABLE(pgm_read_byte(s))) j++;
|
||||
s++;
|
||||
|
Reference in New Issue
Block a user