Commit 74dd3e2d authored by MagoKimbra's avatar MagoKimbra

Same fix

parent a33bb7f8
......@@ -62,28 +62,31 @@
// why double up on these macros? see http://gcc.gnu.org/onlinedocs/cpp/Stringification.html
/// Read a pin wrapper
#define READ(IO) _READ(IO)
#define READ(IO) _READ(IO)
/// Write to a pin wrapper
#define WRITE(IO, v) _WRITE(IO, v)
#define WRITE(IO, v) _WRITE(IO, v)
/// toggle a pin wrapper
#define TOGGLE(IO) _TOGGLE(IO)
#define TOGGLE(IO) _TOGGLE(IO)
/// set pin as input wrapper
#define SET_INPUT(IO) _SET_INPUT(IO)
#define SET_INPUT(IO) _SET_INPUT(IO)
/// set pin as output wrapper
#define SET_OUTPUT(IO) _SET_OUTPUT(IO)
#define SET_OUTPUT(IO) _SET_OUTPUT(IO)
/// check if pin is an input wrapper
#define GET_INPUT(IO) _GET_INPUT(IO)
#define GET_INPUT(IO) _GET_INPUT(IO)
/// check if pin is an output wrapper
#define GET_OUTPUT(IO) _GET_OUTPUT(IO)
#define GET_OUTPUT(IO) _GET_OUTPUT(IO)
/// check if pin is an timer wrapper
#define GET_TIMER(IO) _GET_TIMER(IO)
#define GET_TIMER(IO) _GET_TIMER(IO)
// Shorthand
#define OUT_WRITE(IO, v) { SET_OUTPUT(IO); WRITE(IO, v); }
#define OUT_WRITE(IO, v) { SET_OUTPUT(IO); WRITE(IO, v); }
// Pullup
#define PULLUP(IO, v) WRITE(IO, v)
/*
ports and functions
......
......@@ -60,7 +60,7 @@
#define MSG_MOVE_01MM "Muovi di 0.1mm"
#define MSG_MOVE_1MM "Muovi di 1mm"
#define MSG_MOVE_10MM "Muovi di 10mm"
#define MSG_SPEED "Velocità"
#define MSG_SPEED "Velocita"
#define MSG_NOZZLE "Ugello"
#define MSG_BED "Piatto"
#define MSG_FAN_SPEED "Ventola"
......@@ -104,7 +104,7 @@
#define MSG_TEMPERATURE "Temperatura"
#define MSG_MOTION "Movimento"
#define MSG_FILAMENT "Filamento"
#define MSG_VOLUMETRIC_ENABLED "E in mm³"
#define MSG_VOLUMETRIC_ENABLED "E in mm"
#define MSG_FILAMENT_SIZE_EXTRUDER "Diam. filo"
#define MSG_CONTRAST "Contrasto LCD"
#define MSG_STORE_EPROM "Salva in EEPROM"
......
......@@ -2337,23 +2337,49 @@
#if ENABLED(ULTRA_LCD)
// RADDS LCD panel
#if ENABLED(NEWPANEL)
#define LCD_PINS_RS 42
#if ENABLED(RADDS_DISPLAY)
#define LCD_PINS_RS 42
#define LCD_PINS_ENABLE 43
#define LCD_PINS_D4 44
#define LCD_PINS_D5 45
#define LCD_PINS_D6 46
#define LCD_PINS_D7 47
#if ENABLED(REPRAP_DISCOUNT_SMART_CONTROLLER)
#define BEEPER_PIN 41
#define BTN_EN1 52
#define BTN_EN2 50
#define BTN_ENC 48
#define SD_DETECT_PIN 14
#endif
#endif
#endif //ULTRA_LCD
#define LCD_PINS_D4 44
#define LCD_PINS_D5 45
#define LCD_PINS_D6 46
#define LCD_PINS_D7 47
#define BEEPER 41
#define BTN_EN1 50
#define BTN_EN2 52
#define BTN_ENC 48
#define BTN_BACK 71
#undef SDSS
#define SDSS 10
#define SDCARDDETECT 14
#elif ENABLED(SSD1306_OLED_I2C_CONTROLLER)
#define BTN_EN1 50
#define BTN_EN2 52
#define BTN_ENC 48
#define BEEPER 41
#define LCD_SDSS 10
#define SDCARDDETECT 14
#define KILL_PIN -1
#elif defined(SPARK_FULL_GRAPHICS)
#define LCD_PINS_D4 29
#define LCD_PINS_ENABLE 27
#define LCD_PINS_RS 25
#define BTN_EN1 35
#define BTN_EN2 33
#define BTN_ENC 37
#define KILL_PIN -1
#undef BEEPER
#define BEEPER -1
#endif // SPARK_FULL_GRAPHICS
#endif // ULTRA_LCD
// SPI for Max6675 Thermocouple
......
......@@ -995,70 +995,70 @@ void st_init() {
#if HAS(X_MIN)
SET_INPUT(X_MIN_PIN);
#if ENABLED(ENDSTOPPULLUP_XMIN)
WRITE(X_MIN_PIN, HIGH);
PULLUP(X_MIN_PIN, HIGH);
#endif
#endif
#if HAS(Y_MIN)
SET_INPUT(Y_MIN_PIN);
#if ENABLED(ENDSTOPPULLUP_YMIN)
WRITE(Y_MIN_PIN, HIGH);
PULLUP(Y_MIN_PIN, HIGH);
#endif
#endif
#if HAS(Z_MIN)
SET_INPUT(Z_MIN_PIN);
#if ENABLED(ENDSTOPPULLUP_ZMIN)
WRITE(Z_MIN_PIN, HIGH);
PULLUP(Z_MIN_PIN, HIGH);
#endif
#endif
#if HAS(Z2_MIN)
SET_INPUT(Z2_MIN_PIN);
#if ENABLED(ENDSTOPPULLUP_Z2MIN)
WRITE(Z2_MIN_PIN, HIGH);
PULLUP(Z2_MIN_PIN, HIGH);
#endif
#endif
#if HAS(E_MIN)
SET_INPUT(E_MIN_PIN);
#if ENABLED(ENDSTOPPULLUP_EMIN)
WRITE(E_MIN_PIN, HIGH);
PULLUP(E_MIN_PIN, HIGH);
#endif
#endif
#if HAS(X_MAX)
SET_INPUT(X_MAX_PIN);
#if ENABLED(ENDSTOPPULLUP_XMAX)
WRITE(X_MAX_PIN, HIGH);
PULLUP(X_MAX_PIN, HIGH);
#endif
#endif
#if HAS(Y_MAX)
SET_INPUT(Y_MAX_PIN);
#if ENABLED(ENDSTOPPULLUP_YMAX)
WRITE(Y_MAX_PIN, HIGH);
PULLUP(Y_MAX_PIN, HIGH);
#endif
#endif
#if HAS(Z_MAX)
SET_INPUT(Z_MAX_PIN);
#if ENABLED(ENDSTOPPULLUP_ZMAX)
WRITE(Z_MAX_PIN, HIGH);
PULLUP(Z_MAX_PIN, HIGH);
#endif
#endif
#if HAS(Z2_MAX)
SET_INPUT(Z2_MAX_PIN);
#if ENABLED(ENDSTOPPULLUP_Z2MAX)
WRITE(Z2_MAX_PIN, HIGH);
PULLUP(Z2_MAX_PIN, HIGH);
#endif
#endif
#if HAS(Z_PROBE) // Check for Z_PROBE_ENDSTOP so we don't pull a pin high unless it's to be used.
SET_INPUT(Z_PROBE_PIN);
#if ENABLED(ENDSTOPPULLUP_ZPROBE)
WRITE(Z_PROBE_PIN, HIGH);
PULLUP(Z_PROBE_PIN, HIGH);
#endif
#endif
......
......@@ -401,7 +401,7 @@ void autotempShutdown() {
void updatePID() {
#if ENABLED(PIDTEMP)
for (int h = 0; h < HOTENDS; h++) {
temp_iState_max[h] = PID_INTEGRAL_DRIVE_MAX / PID_PARAM(Ki,h);
temp_iState_max[h] = PID_INTEGRAL_DRIVE_MAX / PID_PARAM(Ki, h);
}
#if ENABLED(PID_ADD_EXTRUSION_RATE)
for (int e = 0; e < EXTRUDERS; e++) last_position[e] = 0;
......@@ -545,10 +545,10 @@ float get_pid_output(int h) {
temp_iState[h] = 0.0;
pid_reset[h] = false;
}
pTerm[h] = PID_PARAM(Kp,h) * pid_error[h];
pTerm[h] = PID_PARAM(Kp, h) * pid_error[h];
temp_iState[h] += pid_error[h];
temp_iState[h] = constrain(temp_iState[h], temp_iState_min[h], temp_iState_max[h]);
iTerm[h] = PID_PARAM(Ki,h) * temp_iState[h];
iTerm[h] = PID_PARAM(Ki, h) * temp_iState[h];
pid_output = pTerm[h] + iTerm[h] - dTerm[h];
......@@ -564,7 +564,7 @@ float get_pid_output(int h) {
lpq[lpq_ptr++] = 0;
}
if (lpq_ptr >= lpq_len) lpq_ptr = 0;
cTerm[0] = (lpq[lpq_ptr] / axis_steps_per_unit[E_AXIS + active_extruder]) * Kc[0];
cTerm[0] = (lpq[lpq_ptr] / axis_steps_per_unit[E_AXIS + active_extruder]) * PID_PARAM(Kc, 0);
pid_output += cTerm[0] / 100.0;
#else
if (h == active_extruder) {
......@@ -572,11 +572,12 @@ float get_pid_output(int h) {
if (e_position > last_position[h]) {
lpq[lpq_ptr++] = e_position - last_position[h];
last_position[h] = e_position;
} else {
}
else {
lpq[lpq_ptr++] = 0;
}
if (lpq_ptr >= lpq_len) lpq_ptr = 0;
cTerm[h] = (lpq[lpq_ptr] / axis_steps_per_unit[E_AXIS + active_extruder]) * Kc[h];
cTerm[h] = (lpq[lpq_ptr] / axis_steps_per_unit[E_AXIS + active_extruder]) * PID_PARAM(Kc, h);
pid_output += cTerm[h] / 100.0;
}
#endif // SINGLENOZZLE
......@@ -971,7 +972,7 @@ void tp_init() {
maxttemp[h] = maxttemp[0];
#if ENABLED(PIDTEMP)
temp_iState_min[h] = 0.0;
temp_iState_max[h] = PID_INTEGRAL_DRIVE_MAX / PID_PARAM(Ki,h);
temp_iState_max[h] = PID_INTEGRAL_DRIVE_MAX / PID_PARAM(Ki, h);
#endif //PIDTEMP
#if ENABLED(PIDTEMPBED)
temp_iState_min_bed = 0.0;
......
......@@ -515,7 +515,7 @@ void lcd_set_home_offsets() {
#if ENABLED(BABYSTEPPING)
static void _lcd_babystep(menuFunc_t menu, int axis, const char* msg) {
static void _lcd_babystep(int axis, const char* msg) {
if (encoderPosition != 0) {
babystepsTodo[axis] += BABYSTEP_MULTIPLICATOR * (int)encoderPosition;
encoderPosition = 0;
......@@ -524,9 +524,9 @@ void lcd_set_home_offsets() {
if (lcdDrawUpdate) lcd_implementation_drawedit(msg, "");
if (LCD_CLICKED) lcd_goto_menu(lcd_tune_menu);
}
static void lcd_babystep_x() { _lcd_babystep(lcd_tune_menu, X_AXIS, PSTR(MSG_BABYSTEPPING_X)); }
static void lcd_babystep_y() { _lcd_babystep(lcd_tune_menu, Y_AXIS, PSTR(MSG_BABYSTEPPING_Y)); }
static void lcd_babystep_z() { _lcd_babystep(lcd_tune_menu, Z_AXIS, PSTR(MSG_BABYSTEPPING_Z)); }
static void lcd_babystep_x() { _lcd_babystep(X_AXIS, PSTR(MSG_BABYSTEPPING_X)); }
static void lcd_babystep_y() { _lcd_babystep(Y_AXIS, PSTR(MSG_BABYSTEPPING_Y)); }
static void lcd_babystep_z() { _lcd_babystep(Z_AXIS, PSTR(MSG_BABYSTEPPING_Z)); }
#endif // BABYSTEPPING
......@@ -547,35 +547,48 @@ static void lcd_tune_fixstep() {
#endif
#if HOTENDS > 1 && TEMP_SENSOR_1 != 0
void watch_temp_callback_E1() { start_watching_heater(1); }
#if HOTENDS > 2 && TEMP_SENSOR_2 != 0
void watch_temp_callback_E2() { start_watching_heater(2); }
#if HOTENDS > 3 && TEMP_SENSOR_3 != 0
void watch_temp_callback_E3() { start_watching_heater(3); }
#endif // HOTENDS > 3
#endif // HOTENDS > 2
#endif // HOTENDS > 1
#endif
#if HOTENDS > 2 && TEMP_SENSOR_2 != 0
void watch_temp_callback_E2() { start_watching_heater(2); }
#endif
#if HOTENDS > 3 && TEMP_SENSOR_3 != 0
void watch_temp_callback_E3() { start_watching_heater(3); }
#endif
#else
#if TEMP_SENSOR_0 != 0
void watch_temp_callback_E0() {}
#endif
#if HOTENDS > 1 && TEMP_SENSOR_1 != 0
void watch_temp_callback_E1() {}
#if HOTENDS > 2 && TEMP_SENSOR_2 != 0
void watch_temp_callback_E2() {}
#if HOTENDS > 3 && TEMP_SENSOR_3 != 0
void watch_temp_callback_E3() {}
#endif // HOTENDS > 3
#endif // HOTENDS > 2
#endif // HOTENDS > 1
#endif
#if HOTENDS > 2 && TEMP_SENSOR_2 != 0
void watch_temp_callback_E2() {}
#endif
#if HOTENDS > 3 && TEMP_SENSOR_3 != 0
void watch_temp_callback_E3() {}
#endif
#endif // !THERMAL_PROTECTION_HOTENDS
/**
* Items shared between Tune and Temperature menus
*
* "Tune" submenu
*
*/
static void nozzle_bed_fan_menu_items(uint8_t &encoderLine, uint8_t &_lineNr, uint8_t &_drawLineNr, uint8_t &_menuItemNr, bool &wasClicked, bool &itemSelected) {
static void lcd_tune_menu() {
START_MENU(lcd_main_menu);
//
// ^ Main
//
MENU_ITEM(back, MSG_MAIN, lcd_main_menu);
//
// Speed:
//
MENU_ITEM_EDIT(int3, MSG_SPEED, &feedrate_multiplier, 10, 999);
//
// Nozzle:
// Nozzle [1-4]:
//
#if HOTENDS == 1
#if TEMP_SENSOR_0 != 0
......@@ -592,7 +605,7 @@ static void nozzle_bed_fan_menu_items(uint8_t &encoderLine, uint8_t &_lineNr, ui
#if TEMP_SENSOR_2 != 0
MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(int3, MSG_NOZZLE " 2", &target_temperature[2], 0, HEATER_2_MAXTEMP - 15, watch_temp_callback_E2);
#endif
#if EXTRUDERS > 3
#if HOTENDS > 3
#if TEMP_SENSOR_3 != 0
MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(int3, MSG_NOZZLE " 3", &target_temperature[3], 0, HEATER_3_MAXTEMP - 15, watch_temp_callback_E3);
#endif
......@@ -611,30 +624,7 @@ static void nozzle_bed_fan_menu_items(uint8_t &encoderLine, uint8_t &_lineNr, ui
// Fan Speed:
//
MENU_MULTIPLIER_ITEM_EDIT(int3, MSG_FAN_SPEED, &fanSpeed, 0, 255);
}
/**
*
* "Tune" submenu
*
*/
static void lcd_tune_menu() {
START_MENU(lcd_main_menu);
//
// ^ Main
//
MENU_ITEM(back, MSG_MAIN, lcd_main_menu);
//
// Speed:
//
MENU_ITEM_EDIT(int3, MSG_SPEED, &feedrate_multiplier, 10, 999);
// Nozzle, Bed, and Fan Control
nozzle_bed_fan_menu_items(encoderLine, _lineNr, _drawLineNr, _menuItemNr, wasClicked, itemSelected);
//
// Flow:
// Flow 1:
......@@ -846,7 +836,7 @@ void lcd_cooldown() {
static void lcd_prepare_menu() {
START_MENU(lcd_main_menu);
//
// ^ Main
//
......@@ -1208,8 +1198,43 @@ static void lcd_control_temperature_menu() {
//
MENU_ITEM(back, MSG_CONTROL, lcd_control_menu);
// Nozzle, Bed, and Fan Control
nozzle_bed_fan_menu_items(encoderLine, _lineNr, _drawLineNr, _menuItemNr, wasClicked, itemSelected);
//
// Nozzle:
//
#if HOTENDS == 1
#if TEMP_SENSOR_0 != 0
MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(int3, MSG_NOZZLE, &target_temperature[0], 0, HEATER_0_MAXTEMP - 15, watch_temp_callback_E0);
#endif
#else // HOTENDS > 1
#if TEMP_SENSOR_0 != 0
MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(int3, MSG_NOZZLE " 0", &target_temperature[0], 0, HEATER_0_MAXTEMP - 15, watch_temp_callback_E0);
#endif
#if TEMP_SENSOR_1 != 0
MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(int3, MSG_NOZZLE " 1", &target_temperature[1], 0, HEATER_1_MAXTEMP - 15, watch_temp_callback_E1);
#endif
#if HOTENDS > 2
#if TEMP_SENSOR_2 != 0
MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(int3, MSG_NOZZLE " 2", &target_temperature[2], 0, HEATER_2_MAXTEMP - 15, watch_temp_callback_E2);
#endif
#if HOTENDS > 3
#if TEMP_SENSOR_3 != 0
MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(int3, MSG_NOZZLE " 3", &target_temperature[3], 0, HEATER_3_MAXTEMP - 15, watch_temp_callback_E3);
#endif
#endif // HOTENDS > 3
#endif // HOTENDS > 2
#endif // HOTENDS > 1
//
// Bed:
//
#if TEMP_SENSOR_BED != 0
MENU_MULTIPLIER_ITEM_EDIT(int3, MSG_BED, &target_temperature_bed, 0, BED_MAXTEMP - 15);
#endif
//
// Fan Speed:
//
MENU_MULTIPLIER_ITEM_EDIT(int3, MSG_FAN_SPEED, &fanSpeed, 0, 255);
//
// Autotemp, Min, Max, Fact
......@@ -1217,7 +1242,7 @@ static void lcd_control_temperature_menu() {
#if ENABLED(AUTOTEMP) && (TEMP_SENSOR_0 != 0)
MENU_ITEM_EDIT(bool, MSG_AUTOTEMP, &autotemp_enabled);
MENU_ITEM_EDIT(float3, MSG_MIN, &autotemp_min, 0, HEATER_0_MAXTEMP - 15);
MENU_ITEM_EDIT(float3, MSG_MAX, &autotemp_max, 0, HEATER_0_MAXTEMP -15 );
MENU_ITEM_EDIT(float3, MSG_MAX, &autotemp_max, 0, HEATER_0_MAXTEMP - 15);
MENU_ITEM_EDIT(float32, MSG_FACTOR, &autotemp_factor, 0.0, 1.0);
#endif
......@@ -1732,19 +1757,19 @@ void lcd_init() {
SET_INPUT(BTN_EN1);
SET_INPUT(BTN_EN2);
WRITE(BTN_EN1, HIGH);
WRITE(BTN_EN2, HIGH);
PULLUP(BTN_EN1, HIGH);
PULLUP(BTN_EN2, HIGH);
#if BTN_ENC > 0
SET_INPUT(BTN_ENC);
WRITE(BTN_ENC, HIGH);
PULLUP(BTN_ENC, HIGH);
#endif
#if ENABLED(REPRAPWORLD_KEYPAD)
pinMode(SHIFT_CLK, OUTPUT);
pinMode(SHIFT_LD, OUTPUT);
pinMode(SHIFT_OUT, INPUT);
WRITE(SHIFT_OUT, HIGH);
PULLUP(SHIFT_OUT, HIGH);
WRITE(SHIFT_LD, HIGH);
#endif
......@@ -1758,7 +1783,7 @@ void lcd_init() {
pinMode(SHIFT_LD, OUTPUT);
pinMode(SHIFT_EN, OUTPUT);
pinMode(SHIFT_OUT, INPUT);
WRITE(SHIFT_OUT, HIGH);
PULLUP(SHIFT_OUT, HIGH);
WRITE(SHIFT_LD, HIGH);
WRITE(SHIFT_EN, LOW);
#endif // SR_LCD_2W_NL
......@@ -1767,7 +1792,7 @@ void lcd_init() {
#if ENABLED(SDSUPPORT) && PIN_EXISTS(SD_DETECT)
pinMode(SD_DETECT_PIN, INPUT);
WRITE(SD_DETECT_PIN, HIGH);
PULLUP(SD_DETECT_PIN, HIGH);
lcd_sd_status = 2; // UNKNOWN
#endif
......
......@@ -27,13 +27,13 @@
#define EN_B BIT(BLEN_B) // The two encoder pins are connected through BTN_EN1 and BTN_EN2
#define EN_A BIT(BLEN_A)
#if ENABLED(BTN_ENC) && BTN_ENC > -1
#if ENABLED(BTN_ENC) && BTN_ENC > 0
// encoder click is directly connected
#define BLEN_C 2
#define EN_C BIT(BLEN_C)
#endif
#if HAS(BTN_BACK)
#if ENABLED(BTN_BACK) && BTN_BACK > 0
#define BLEN_D 3
#define EN_D BIT(BLEN_D)
#endif
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment