Commit fc4ef25c authored by MagoKimbra's avatar MagoKimbra

Fix

parent 4a191428
...@@ -1397,9 +1397,9 @@ ...@@ -1397,9 +1397,9 @@
************************** Motor's current **************************** ************************** Motor's current ****************************
***********************************************************************/ ***********************************************************************/
// Motor Current setting (Only functional on ALLIGATOR BOARD) // Motor Current setting (Only functional on ALLIGATOR BOARD)
#define MOTOR_CURRENT {1, 1, 1, 1, 1, 1, 1} // X Y Z E0 E1 E2 E3 - Values 0 - 2.5 A #define MOTOR_CURRENT {1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0} // X Y Z E0 E1 E2 E3 - Values 0 - 2.5 A
// Motor Current setting (Only functional when motor driver current ref pins are connected to a digital trimpot on supported boards) // Motor Current setting (Only functional when motor driver current ref pins are connected to a digital trimpot on supported boards)
#define DIGIPOT_MOTOR_CURRENT {135,135,135,135,135} // Values 0-255 (RAMBO 135 = ~0.75A, 185 = ~1A) #define DIGIPOT_MOTOR_CURRENT {135, 135, 135, 135, 135} // Values 0-255 (RAMBO 135 = ~0.75A, 185 = ~1A)
/***********************************************************************/ /***********************************************************************/
......
...@@ -450,21 +450,15 @@ void Config_ResetDefault() { ...@@ -450,21 +450,15 @@ void Config_ResetDefault() {
float tmp3[] = DEFAULT_MAX_ACCELERATION; float tmp3[] = DEFAULT_MAX_ACCELERATION;
float tmp4[] = DEFAULT_RETRACT_ACCELERATION; float tmp4[] = DEFAULT_RETRACT_ACCELERATION;
float tmp5[] = DEFAULT_EJERK; float tmp5[] = DEFAULT_EJERK;
#if ENABLED(PIDTEMP) float tmp6[] = DEFAULT_Kp;
float tmp6[] = DEFAULT_Kp; float tmp7[] = DEFAULT_Ki;
float tmp7[] = DEFAULT_Ki; float tmp8[] = DEFAULT_Kd;
float tmp8[] = DEFAULT_Kd; float tmp9[] = DEFAULT_Kc;
float tmp9[] = DEFAULT_Kc;
#endif // PIDTEMP
#if ENABLED(HOTEND_OFFSET_X) && ENABLED(HOTEND_OFFSET_Y) && ENABLED(HOTEND_OFFSET_Z) #if ENABLED(HOTEND_OFFSET_X) && ENABLED(HOTEND_OFFSET_Y) && ENABLED(HOTEND_OFFSET_Z)
float tmp10[] = HOTEND_OFFSET_X; float tmp10[] = HOTEND_OFFSET_X;
float tmp11[] = HOTEND_OFFSET_Y; float tmp11[] = HOTEND_OFFSET_Y;
float tmp12[] = HOTEND_OFFSET_Z; float tmp12[] = HOTEND_OFFSET_Z;
#else
float tmp10[] = {0};
float tmp11[] = {0};
float tmp12[] = {0};
#endif #endif
#if MB(ALLIGATOR) #if MB(ALLIGATOR)
...@@ -472,55 +466,30 @@ void Config_ResetDefault() { ...@@ -472,55 +466,30 @@ void Config_ResetDefault() {
#endif #endif
for (int8_t i = 0; i < 3 + EXTRUDERS; i++) { for (int8_t i = 0; i < 3 + EXTRUDERS; i++) {
short max_i; axis_steps_per_unit[i] = tmp1[i];
max_i = sizeof(tmp1) / sizeof(*tmp1); max_feedrate[i] = tmp2[i];
if(i < max_i) max_acceleration_units_per_sq_second[i] = tmp3[i];
axis_steps_per_unit[i] = tmp1[i]; }
else
axis_steps_per_unit[i] = tmp1[max_i - 1]; for (int8_t i = 0; i < EXTRUDERS; i++) {
max_i = sizeof(tmp2) / sizeof(*tmp2); retract_acceleration[i] = tmp4[i];
if(i < max_i) max_e_jerk[i] = tmp5[i];
max_feedrate[i] = tmp2[i]; }
else
max_feedrate[i] = tmp2[max_i - 1]; #if MB(ALLIGATOR)
max_i = sizeof(tmp3) / sizeof(*tmp3); for (int8_t i = 0; i < 3 + DRIVER_EXTRUDERS; i++)
if(i < max_i) motor_current[i] = tmp13[i];
max_acceleration_units_per_sq_second[i] = tmp3[i]; #endif
else
max_acceleration_units_per_sq_second[i] = tmp3[max_i - 1]; for (int8_t i = 0; i < HOTENDS; i++) {
if(i < EXTRUDERS) { #if ENABLED(HOTEND_OFFSET_X) && ENABLED(HOTEND_OFFSET_Y) && ENABLED(HOTEND_OFFSET_Z)
max_i = sizeof(tmp4) / sizeof(*tmp4); hotend_offset[X_AXIS][i] = tmp10[i];
if(i < max_i) hotend_offset[Y_AXIS][i] = tmp11[i];
retract_acceleration[i] = tmp4[i]; hotend_offset[Z_AXIS][i] = tmp12[i];
else #else
retract_acceleration[i] = tmp4[max_i - 1]; hotend_offset[X_AXIS][i] = 0;
max_i = sizeof(tmp5) / sizeof(*tmp5); hotend_offset[Y_AXIS][i] = 0;
if(i < max_i) hotend_offset[Z_AXIS][i] = 0;
max_e_jerk[i] = tmp5[i];
else
max_e_jerk[i] = tmp5[max_i - 1];
max_i = sizeof(tmp10) / sizeof(*tmp10);
if(i < max_i)
hotend_offset[X_AXIS][i] = tmp10[i];
else
hotend_offset[X_AXIS][i] = 0;
max_i = sizeof(tmp11) / sizeof(*tmp11);
if(i < max_i)
hotend_offset[Y_AXIS][i] = tmp11[i];
else
hotend_offset[Y_AXIS][i] = 0;
max_i = sizeof(tmp12) / sizeof(*tmp12);
if(i < max_i)
hotend_offset[Z_AXIS][i] = tmp12[i];
else
hotend_offset[Z_AXIS][i] = 0;
}
#if MB(ALLIGATOR)
max_i = sizeof(tmp13) / sizeof(*tmp13);
if(i < max_i)
motor_current[i] = tmp13[i];
else
motor_current[i] = tmp13[max_i - 1];
#endif #endif
} }
......
...@@ -12,11 +12,11 @@ ...@@ -12,11 +12,11 @@
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
* *
*/ */
......
...@@ -261,7 +261,7 @@ double printer_usage_filament; ...@@ -261,7 +261,7 @@ double printer_usage_filament;
#endif #endif
#if MB(ALLIGATOR) #if MB(ALLIGATOR)
float motor_current[DRIVER_EXTRUDERS + 3]; float motor_current[3 + DRIVER_EXTRUDERS];
#endif #endif
#if ENABLED(COLOR_MIXING_EXTRUDER) #if ENABLED(COLOR_MIXING_EXTRUDER)
...@@ -665,7 +665,7 @@ bool enqueue_and_echo_command(const char* cmd, bool say_ok/*=false*/) { ...@@ -665,7 +665,7 @@ bool enqueue_and_echo_command(const char* cmd, bool say_ok/*=false*/) {
*/ */
void setup() { void setup() {
#if MB(ALLIGATOR) #if MB(ALLIGATOR)
setup_alligator_board();// Initialize Alligator Board setup_alligator_board(); // Initialize Alligator Board
#endif #endif
#if HAS(KILL) #if HAS(KILL)
setup_killpin(); setup_killpin();
...@@ -1068,7 +1068,7 @@ bool code_seen(char code) { ...@@ -1068,7 +1068,7 @@ bool code_seen(char code) {
* *
* Returns TRUE if the target is invalid * Returns TRUE if the target is invalid
*/ */
bool setTargetedExtruder(int code) { bool get_target_extruder_from_command(int code) {
if (code_seen('T')) { if (code_seen('T')) {
short t = code_value_short(); short t = code_value_short();
if (t >= EXTRUDERS) { if (t >= EXTRUDERS) {
...@@ -1089,7 +1089,7 @@ bool setTargetedExtruder(int code) { ...@@ -1089,7 +1089,7 @@ bool setTargetedExtruder(int code) {
* *
* Returns TRUE if the target is invalid * Returns TRUE if the target is invalid
*/ */
bool setTargetedHotend(int code) { bool get_target_hotend_from_command(int code) {
if (code_seen('H')) { if (code_seen('H')) {
short h = code_value_short(); short h = code_value_short();
if (h >= HOTENDS) { if (h >= HOTENDS) {
...@@ -5146,7 +5146,7 @@ inline void gcode_M85() { ...@@ -5146,7 +5146,7 @@ inline void gcode_M85() {
* M92: Set axis_steps_per_unit * M92: Set axis_steps_per_unit
*/ */
inline void gcode_M92() { inline void gcode_M92() {
if (setTargetedExtruder(92)) return; if (get_target_extruder_from_command(92)) return;
for(uint8_t i = 0; i < NUM_AXIS; i++) { for(uint8_t i = 0; i < NUM_AXIS; i++) {
if (code_seen(axis_codes[i])) { if (code_seen(axis_codes[i])) {
...@@ -5387,7 +5387,7 @@ inline void gcode_M92() { ...@@ -5387,7 +5387,7 @@ inline void gcode_M92() {
* M104: Set hotend temperature * M104: Set hotend temperature
*/ */
inline void gcode_M104() { inline void gcode_M104() {
if (setTargetedExtruder(104)) return; if (get_target_extruder_from_command(104)) return;
if (DEBUGGING(DRYRUN)) return; if (DEBUGGING(DRYRUN)) return;
#if HOTENDS == 1 #if HOTENDS == 1
...@@ -5426,7 +5426,7 @@ inline void gcode_M104() { ...@@ -5426,7 +5426,7 @@ inline void gcode_M104() {
* M105: Read hot end and bed temperature * M105: Read hot end and bed temperature
*/ */
inline void gcode_M105() { inline void gcode_M105() {
if (setTargetedExtruder(105)) return; if (get_target_extruder_from_command(105)) return;
#if HAS(TEMP_0) || HAS(TEMP_BED) || ENABLED(HEATER_0_USES_MAX6675) #if HAS(TEMP_0) || HAS(TEMP_BED) || ENABLED(HEATER_0_USES_MAX6675)
ECHO_S(OK); ECHO_S(OK);
...@@ -5456,7 +5456,7 @@ inline void gcode_M105() { ...@@ -5456,7 +5456,7 @@ inline void gcode_M105() {
* Rxxx Wait for extruder(s) to reach temperature. Waits when heating and cooling. * Rxxx Wait for extruder(s) to reach temperature. Waits when heating and cooling.
*/ */
inline void gcode_M109() { inline void gcode_M109() {
if (setTargetedExtruder(109)) return; if (get_target_extruder_from_command(109)) return;
if (DEBUGGING(DRYRUN)) return; if (DEBUGGING(DRYRUN)) return;
#if HOTENDS == 1 #if HOTENDS == 1
...@@ -5801,7 +5801,7 @@ inline void gcode_M140() { ...@@ -5801,7 +5801,7 @@ inline void gcode_M140() {
*/ */
inline void gcode_M200() { inline void gcode_M200() {
if (setTargetedExtruder(200)) return; if (get_target_extruder_from_command(200)) return;
if (code_seen('D')) { if (code_seen('D')) {
float diameter = code_value(); float diameter = code_value();
...@@ -5861,7 +5861,7 @@ inline void gcode_M201() { ...@@ -5861,7 +5861,7 @@ inline void gcode_M201() {
* *
*/ */
inline void gcode_M203() { inline void gcode_M203() {
if (setTargetedExtruder(203)) return; if (get_target_extruder_from_command(203)) return;
for(uint8_t i = 0; i < NUM_AXIS; i++) { for(uint8_t i = 0; i < NUM_AXIS; i++) {
if (code_seen(axis_codes[i])) { if (code_seen(axis_codes[i])) {
...@@ -5883,7 +5883,7 @@ inline void gcode_M203() { ...@@ -5883,7 +5883,7 @@ inline void gcode_M203() {
* Also sets minimum segment time in ms (B20000) to prevent buffer under-runs and M20 minimum feedrate * Also sets minimum segment time in ms (B20000) to prevent buffer under-runs and M20 minimum feedrate
*/ */
inline void gcode_M204() { inline void gcode_M204() {
if (setTargetedExtruder(204)) return; if (get_target_extruder_from_command(204)) return;
if (code_seen('S')) { // Kept for legacy compatibility. Should NOT BE USED for new developments. if (code_seen('S')) { // Kept for legacy compatibility. Should NOT BE USED for new developments.
acceleration = code_value(); acceleration = code_value();
...@@ -5915,7 +5915,7 @@ inline void gcode_M204() { ...@@ -5915,7 +5915,7 @@ inline void gcode_M204() {
* E = Max E Jerk (mm/s/s) * E = Max E Jerk (mm/s/s)
*/ */
inline void gcode_M205() { inline void gcode_M205() {
if (setTargetedExtruder(205)) return; if (get_target_extruder_from_command(205)) return;
if (code_seen('S')) minimumfeedrate = code_value(); if (code_seen('S')) minimumfeedrate = code_value();
if (code_seen('V')) mintravelfeedrate = code_value(); if (code_seen('V')) mintravelfeedrate = code_value();
...@@ -6003,7 +6003,7 @@ inline void gcode_M206() { ...@@ -6003,7 +6003,7 @@ inline void gcode_M206() {
* M218 - set hotend offset (in mm), H<hotend_number> X<offset_on_X> Y<offset_on_Y> Z<offset_on_Z> * M218 - set hotend offset (in mm), H<hotend_number> X<offset_on_X> Y<offset_on_Y> Z<offset_on_Z>
*/ */
inline void gcode_M218() { inline void gcode_M218() {
if (setTargetedHotend(218)) return; if (get_target_hotend_from_command(218)) return;
if (code_seen('X')) hotend_offset[X_AXIS][target_extruder] = code_value(); if (code_seen('X')) hotend_offset[X_AXIS][target_extruder] = code_value();
if (code_seen('Y')) hotend_offset[Y_AXIS][target_extruder] = code_value(); if (code_seen('Y')) hotend_offset[Y_AXIS][target_extruder] = code_value();
...@@ -6029,7 +6029,7 @@ inline void gcode_M220() { ...@@ -6029,7 +6029,7 @@ inline void gcode_M220() {
* M221: Set extrusion percentage (M221 T0 S95) * M221: Set extrusion percentage (M221 T0 S95)
*/ */
inline void gcode_M221() { inline void gcode_M221() {
if (setTargetedExtruder(221)) return; if (get_target_extruder_from_command(221)) return;
if (code_seen('S')) extruder_multiplier[target_extruder] = code_value(); if (code_seen('S')) extruder_multiplier[target_extruder] = code_value();
} }
...@@ -6038,7 +6038,7 @@ inline void gcode_M221() { ...@@ -6038,7 +6038,7 @@ inline void gcode_M221() {
* M222: Set density extrusion percentage (M222 T0 S95) * M222: Set density extrusion percentage (M222 T0 S95)
*/ */
inline void gcode_M222() { inline void gcode_M222() {
if (setTargetedExtruder(222)) return; if (get_target_extruder_from_command(222)) return;
if (code_seen('S')) { if (code_seen('S')) {
density_multiplier[target_extruder] = code_value(); density_multiplier[target_extruder] = code_value();
...@@ -6862,7 +6862,7 @@ inline void gcode_M503() { ...@@ -6862,7 +6862,7 @@ inline void gcode_M503() {
* M522: Read or Write on card. M522 T<extruders> R<read> or W<write> L<list> * M522: Read or Write on card. M522 T<extruders> R<read> or W<write> L<list>
*/ */
inline void gcode_M522() { inline void gcode_M522() {
if (setTargetedExtruder(522)) return; if (get_target_extruder_from_command(522)) return;
if (!RFID_ON) return; if (!RFID_ON) return;
if (code_seen('R')) { if (code_seen('R')) {
...@@ -6898,7 +6898,7 @@ inline void gcode_M503() { ...@@ -6898,7 +6898,7 @@ inline void gcode_M503() {
* M595 - set Hotend AD595 offset & Gain H<hotend_number> O<offset> S<gain> * M595 - set Hotend AD595 offset & Gain H<hotend_number> O<offset> S<gain>
*/ */
inline void gcode_M595() { inline void gcode_M595() {
if (setTargetedHotend(595)) return; if (get_target_hotend_from_command(595)) return;
if (code_seen('O')) ad595_offset[target_extruder] = code_value(); if (code_seen('O')) ad595_offset[target_extruder] = code_value();
if (code_seen('S')) ad595_gain[target_extruder] = code_value(); if (code_seen('S')) ad595_gain[target_extruder] = code_value();
...@@ -7272,8 +7272,8 @@ inline void gcode_M503() { ...@@ -7272,8 +7272,8 @@ inline void gcode_M503() {
* M906: Set motor currents * M906: Set motor currents
*/ */
inline void gcode_M906() { inline void gcode_M906() {
if (setTargetedExtruder(906)) return; if (get_target_extruder_from_command(906)) return;
for (uint8_t i = 0; i < 3 + DRIVER_EXTRUDERS; i++) { for (uint8_t i = 0; i < NUM_AXIS; i++) {
if (code_seen(axis_codes[i])) { if (code_seen(axis_codes[i])) {
if (i == E_AXIS) if (i == E_AXIS)
motor_current[i + target_extruder] = code_value(); motor_current[i + target_extruder] = code_value();
...@@ -7281,6 +7281,7 @@ inline void gcode_M503() { ...@@ -7281,6 +7281,7 @@ inline void gcode_M503() {
motor_current[i] = code_value(); motor_current[i] = code_value();
} }
} }
set_driver_current();
} }
#endif // ALLIGATOR #endif // ALLIGATOR
...@@ -7340,11 +7341,21 @@ inline void gcode_M907() { ...@@ -7340,11 +7341,21 @@ inline void gcode_M907() {
/** /**
* M999: Restart after being stopped * M999: Restart after being stopped
*
* Default behaviour is to flush the serial buffer and request
* a resend to the host starting on the last N line received.
*
* Sending "M999 S1" will resume printing without flushing the
* existing command buffer.
*
*/ */
inline void gcode_M999() { inline void gcode_M999() {
Running = true; Running = true;
Printing = false; Printing = false;
lcd_reset_alert_level(); lcd_reset_alert_level();
if (code_seen('S') && code_value_short() == 1) return;
FlushSerialRequestResend(); FlushSerialRequestResend();
} }
...@@ -8293,7 +8304,7 @@ static void report_current_position() { ...@@ -8293,7 +8304,7 @@ static void report_current_position() {
float difference[NUM_AXIS]; float difference[NUM_AXIS];
float addDistance[NUM_AXIS]; float addDistance[NUM_AXIS];
float fractions[NUM_AXIS]; float fractions[NUM_AXIS];
float frfm = feedrate / 60 * feedrate_multiplier / 100.0; float _feedrate = feedrate * feedrate_multiplier / 6000.0;
for (uint8_t i = 0; i < NUM_AXIS; i++) difference[i] = target[i] - current_position[i]; for (uint8_t i = 0; i < NUM_AXIS; i++) difference[i] = target[i] - current_position[i];
...@@ -8302,8 +8313,9 @@ static void report_current_position() { ...@@ -8302,8 +8313,9 @@ static void report_current_position() {
if (cartesian_mm < 0.000001) return false; if (cartesian_mm < 0.000001) return false;
#if ENABLED(DELTA_SEGMENTS_PER_SECOND) #if ENABLED(DELTA_SEGMENTS_PER_SECOND)
float seconds = 6000 * cartesian_mm / feedrate / feedrate_multiplier; float seconds = cartesian_mm / _feedrate;
int steps = max(1, int(DELTA_SEGMENTS_PER_SECOND * seconds)); int steps = max(1, int(DELTA_SEGMENTS_PER_SECOND * seconds));
float inv_steps = 1.0 / steps;
if (DEBUGGING(DEBUG)) { if (DEBUGGING(DEBUG)) {
ECHO_SMV(DEB, "mm=", cartesian_mm); ECHO_SMV(DEB, "mm=", cartesian_mm);
...@@ -8332,7 +8344,7 @@ static void report_current_position() { ...@@ -8332,7 +8344,7 @@ static void report_current_position() {
for (int s = 1; s <= steps; s++) { for (int s = 1; s <= steps; s++) {
#if ENABLED(DELTA_SEGMENTS_PER_SECOND) #if ENABLED(DELTA_SEGMENTS_PER_SECOND)
float fraction = float(s) / float(steps); float fraction = float(s) * inv_steps;
for (uint8_t i = 0; i < NUM_AXIS; i++) for (uint8_t i = 0; i < NUM_AXIS; i++)
target[i] = current_position[i] + difference[i] * fraction; target[i] = current_position[i] + difference[i] * fraction;
#else #else
...@@ -8351,7 +8363,7 @@ static void report_current_position() { ...@@ -8351,7 +8363,7 @@ static void report_current_position() {
DEBUG_POS("prepare_move_delta", delta); DEBUG_POS("prepare_move_delta", delta);
} }
plan_buffer_line(delta[TOWER_1], delta[TOWER_2], delta[TOWER_3], target[E_AXIS], frfm, active_extruder, active_driver); plan_buffer_line(delta[TOWER_1], delta[TOWER_2], delta[TOWER_3], target[E_AXIS], _feedrate, active_extruder, active_driver);
} }
return true; return true;
} }
...@@ -8835,7 +8847,7 @@ void manage_inactivity(bool ignore_stepper_queue/*=false*/) { ...@@ -8835,7 +8847,7 @@ void manage_inactivity(bool ignore_stepper_queue/*=false*/) {
#endif #endif
#if ENABLED(EXTRUDER_RUNOUT_PREVENT) #if ENABLED(EXTRUDER_RUNOUT_PREVENT)
if (ELAPSED(ms, previous_cmd_ms + (EXTRUDER_RUNOUT_SECONDS) * 1000UL)) if (ELAPSED(ms, previous_cmd_ms + (EXTRUDER_RUNOUT_SECONDS) * 1000UL)) {
if (degHotend(active_extruder) > EXTRUDER_RUNOUT_MINTEMP) { if (degHotend(active_extruder) > EXTRUDER_RUNOUT_MINTEMP) {
bool oldstatus; bool oldstatus;
switch(active_extruder) { switch(active_extruder) {
......
...@@ -138,6 +138,12 @@ extern bool axis_known_position[3]; ...@@ -138,6 +138,12 @@ extern bool axis_known_position[3];
extern bool axis_homed[3]; extern bool axis_homed[3];
extern float zprobe_zoffset; extern float zprobe_zoffset;
// GCode support for external objects
bool code_seen(char);
float code_value();
long code_value_long();
int16_t code_value_short();
#if ENABLED(ADVANCE_LPC) #if ENABLED(ADVANCE_LPC)
extern int extruder_advance_k; extern int extruder_advance_k;
#endif #endif
...@@ -253,7 +259,7 @@ extern uint8_t previous_extruder; ...@@ -253,7 +259,7 @@ extern uint8_t previous_extruder;
extern uint8_t active_driver; extern uint8_t active_driver;
#if MB(ALLIGATOR) #if MB(ALLIGATOR)
extern float motor_current[DRIVER_EXTRUDERS + 3]; extern float motor_current[3 + DRIVER_EXTRUDERS];
#endif #endif
#if ENABLED(DIGIPOT_I2C) #if ENABLED(DIGIPOT_I2C)
...@@ -273,19 +279,12 @@ extern uint8_t active_driver; ...@@ -273,19 +279,12 @@ extern uint8_t active_driver;
extern float mixing_factor[DRIVER_EXTRUDERS]; extern float mixing_factor[DRIVER_EXTRUDERS];
#endif #endif
extern void calculate_volumetric_multipliers(); void calculate_volumetric_multipliers();
#if ENABLED(M100_FREE_MEMORY_WATCHER) #if ENABLED(M100_FREE_MEMORY_WATCHER)
extern void *__brkval; extern void *__brkval;
extern size_t __heap_start, __heap_end, __flp; extern size_t __heap_start, __heap_end, __flp;
//
// Declare all the functions we need from Marlin_Main.cpp to do the work!
//
float code_value();
long code_value_long();
bool code_seen(char );
// //
// Utility functions used by M100 to get its work done. // Utility functions used by M100 to get its work done.
// //
......
...@@ -12,11 +12,11 @@ ...@@ -12,11 +12,11 @@
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
* *
*/ */
......
...@@ -12,11 +12,11 @@ ...@@ -12,11 +12,11 @@
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
* *
*/ */
...@@ -39,7 +39,8 @@ ...@@ -39,7 +39,8 @@
#define DOGM_LCD_IMPLEMENTATION_H #define DOGM_LCD_IMPLEMENTATION_H
/** /**
* Implementation of the LCD display routines for a DOGM128 graphic display. These are common LCD 128x64 pixel graphic displays. * Implementation of the LCD display routines for a DOGM128 graphic display.
* These are common LCD 128x64 pixel graphic displays.
*/ */
#if ENABLED(ULTIPANEL) #if ENABLED(ULTIPANEL)
...@@ -140,6 +141,7 @@ ...@@ -140,6 +141,7 @@
// LCD selection // LCD selection
#if ENABLED(U8GLIB_ST7920) #if ENABLED(U8GLIB_ST7920)
//U8GLIB_ST7920_128X64_RRD u8g(0,0,0);
U8GLIB_ST7920_128X64_RRD u8g(0); U8GLIB_ST7920_128X64_RRD u8g(0);
#elif ENABLED(MAKRPANEL) #elif ENABLED(MAKRPANEL)
// The MaKrPanel display, ST7565 controller as well // The MaKrPanel display, ST7565 controller as well
...@@ -171,7 +173,6 @@ ...@@ -171,7 +173,6 @@
#include "utf_mapper.h" #include "utf_mapper.h"
int lcd_contrast; int lcd_contrast;
static unsigned char blink = 0; // Variable for visualization of fan rotation in GLCD
static char currentfont = 0; static char currentfont = 0;
static void lcd_setFont(char font_nr) { static void lcd_setFont(char font_nr) {
...@@ -367,8 +368,16 @@ FORCE_INLINE void _draw_axis_label(AxisEnum axis, const char *pstr, bool blink) ...@@ -367,8 +368,16 @@ FORCE_INLINE void _draw_axis_label(AxisEnum axis, const char *pstr, bool blink)
static void lcd_implementation_status_screen() { static void lcd_implementation_status_screen() {
u8g.setColorIndex(1); // black on white u8g.setColorIndex(1); // black on white
bool blink = lcd_blink();
// Symbols menu graphics, animated fan // Symbols menu graphics, animated fan
u8g.drawBitmapP(9, 1, STATUS_SCREENBYTEWIDTH, STATUS_SCREENHEIGHT, (blink % 2) && fanSpeed ? status_screen0_bmp : status_screen1_bmp); u8g.drawBitmapP(9, 1, STATUS_SCREENBYTEWIDTH, STATUS_SCREENHEIGHT,
#if HAS(FAN)
blink && fanSpeed ? status_screen0_bmp : status_screen1_bmp
#else
status_screen0_bmp
#endif
);
// Status Menu Font for SD info, Heater status, Fan, XYZ // Status Menu Font for SD info, Heater status, Fan, XYZ
lcd_setFont(FONT_STATUSMENU); lcd_setFont(FONT_STATUSMENU);
...@@ -510,7 +519,7 @@ static void lcd_implementation_status_screen() { ...@@ -510,7 +519,7 @@ static void lcd_implementation_status_screen() {
lcd_print(lcd_status_message); lcd_print(lcd_status_message);
#if HAS(LCD_POWER_SENSOR) #if HAS(LCD_POWER_SENSOR)
#if HAS(LCD_FILAMENT_SENSOR) #if HAS(LCD_FILAMENT_SENSOR)
else if (millis() < previous_lcd_status_ms + 10000) else if (PENDING(millis(), previous_lcd_status_ms + 10000UL))
#else #else
else else
#endif #endif
...@@ -605,7 +614,7 @@ static void _drawmenu_setting_edit_generic(bool isSelected, uint8_t row, const c ...@@ -605,7 +614,7 @@ static void _drawmenu_setting_edit_generic(bool isSelected, uint8_t row, const c
#define lcd_implementation_drawmenu_setting_edit_callback_long5(sel, row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, ftostr5(*(data))) #define lcd_implementation_drawmenu_setting_edit_callback_long5(sel, row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, ftostr5(*(data)))
#define lcd_implementation_drawmenu_setting_edit_callback_bool(sel, row, pstr, pstr2, data, callback) lcd_implementation_drawmenu_setting_edit_generic_P(sel, row, pstr, (*(data))?PSTR(MSG_ON):PSTR(MSG_OFF)) #define lcd_implementation_drawmenu_setting_edit_callback_bool(sel, row, pstr, pstr2, data, callback) lcd_implementation_drawmenu_setting_edit_generic_P(sel, row, pstr, (*(data))?PSTR(MSG_ON):PSTR(MSG_OFF))
void lcd_implementation_drawedit(const char* pstr, char* value) { void lcd_implementation_drawedit(const char* pstr, const char* value=NULL) {
uint8_t rows = 1; uint8_t rows = 1;
uint8_t lcd_width = LCD_WIDTH, char_width = DOG_CHAR_WIDTH; uint8_t lcd_width = LCD_WIDTH, char_width = DOG_CHAR_WIDTH;
uint8_t vallen = lcd_strlen(value); uint8_t vallen = lcd_strlen(value);
......
...@@ -78,7 +78,7 @@ int gumPreheatFanSpeed; ...@@ -78,7 +78,7 @@ int gumPreheatFanSpeed;
typedef void (*menuFunc_t)(); typedef void (*menuFunc_t)();
uint8_t lcd_status_message_level; uint8_t lcd_status_message_level;
char lcd_status_message[3 * LCD_WIDTH + 1] = WELCOME_MSG; // worst case is kana with up to 3*LCD_WIDTH+1 char lcd_status_message[3 * (LCD_WIDTH) + 1] = WELCOME_MSG; // worst case is kana with up to 3*LCD_WIDTH+1
#if ENABLED(DOGLCD) #if ENABLED(DOGLCD)
#include "dogm_lcd_implementation.h" #include "dogm_lcd_implementation.h"
...@@ -120,7 +120,7 @@ static void lcd_status_screen(); ...@@ -120,7 +120,7 @@ static void lcd_status_screen();
static void lcd_filament_change_resume_message(); static void lcd_filament_change_resume_message();
#endif #endif
#if HAS(LCD_CONTRAST) #if ENABLED(HAS_LCD_CONTRAST)
static void lcd_set_contrast(); static void lcd_set_contrast();
#endif #endif
...@@ -316,7 +316,7 @@ typedef struct { ...@@ -316,7 +316,7 @@ typedef struct {
#endif #endif
} menuPosition; } menuPosition;
menuFunc_t currentMenu = lcd_status_screen; /* function pointer to the currently active menu */ menuFunc_t currentMenu = lcd_status_screen; // pointer to the currently active menu handler
menuPosition menu_history[10]; menuPosition menu_history[10];
uint8_t menu_history_depth = 0; uint8_t menu_history_depth = 0;
...@@ -337,11 +337,11 @@ enum LCDViewAction { ...@@ -337,11 +337,11 @@ enum LCDViewAction {
uint8_t lcdDrawUpdate = LCDVIEW_CLEAR_CALL_REDRAW; // Set when the LCD needs to draw, decrements after every draw. Set to 2 in LCD routines so the LCD gets at least 1 full redraw (first redraw is partial) uint8_t lcdDrawUpdate = LCDVIEW_CLEAR_CALL_REDRAW; // Set when the LCD needs to draw, decrements after every draw. Set to 2 in LCD routines so the LCD gets at least 1 full redraw (first redraw is partial)
//Variables used when editing values. // Variables used when editing values.
const char* editLabel; const char* editLabel;
void* editValue; void* editValue;
int32_t minEditValue, maxEditValue; int32_t minEditValue, maxEditValue;
menuFunc_t callbackFunc; menuFunc_t callbackFunc; // call this after editing
// place-holders for Ki and Kd edits // place-holders for Ki and Kd edits
float raw_Ki, raw_Kd; float raw_Ki, raw_Kd;
...@@ -363,7 +363,7 @@ static void lcd_goto_menu(menuFunc_t menu, const bool feedback = false, const ui ...@@ -363,7 +363,7 @@ static void lcd_goto_menu(menuFunc_t menu, const bool feedback = false, const ui
menu_history_depth = 0; menu_history_depth = 0;
} }
#if ENABLED(LCD_PROGRESS_BAR) #if ENABLED(LCD_PROGRESS_BAR)
// For LCD_PROGRESS_BAR re-initialize the custom characters // For LCD_PROGRESS_BAR re-initialize custom characters
lcd_set_custom_characters(menu == lcd_status_screen); lcd_set_custom_characters(menu == lcd_status_screen);
#endif #endif
} }
...@@ -419,7 +419,7 @@ static void lcd_status_screen() { ...@@ -419,7 +419,7 @@ static void lcd_status_screen() {
if (card.isFileOpen()) { if (card.isFileOpen()) {
// Expire the message when printing is active // Expire the message when printing is active
if (IS_SD_PRINTING) { if (IS_SD_PRINTING) {
if (ms >= expire_status_ms) { if (ELAPSED(ms, expire_status_ms)) {
lcd_status_message[0] = '\0'; lcd_status_message[0] = '\0';
expire_status_ms = 0; expire_status_ms = 0;
} }
...@@ -441,14 +441,14 @@ static void lcd_status_screen() { ...@@ -441,14 +441,14 @@ static void lcd_status_screen() {
lcd_implementation_status_screen(); lcd_implementation_status_screen();
#if HAS(LCD_POWER_SENSOR) #if HAS(LCD_POWER_SENSOR)
if (millis() > print_millis + 2000) print_millis = millis(); if (ELAPSED(millis(), print_millis + 2000UL)) print_millis = millis();
#endif #endif
#if HAS(LCD_FILAMENT_SENSOR) || HAS(LCD_POWER_SENSOR) #if HAS(LCD_FILAMENT_SENSOR) || HAS(LCD_POWER_SENSOR)
#if HAS(LCD_FILAMENT_SENSOR) && HAS(LCD_POWER_SENSOR) #if HAS(LCD_FILAMENT_SENSOR) && HAS(LCD_POWER_SENSOR)
if (millis() > previous_lcd_status_ms + 15000) if (ELAPSED(millis(), previous_lcd_status_ms + 15000UL))
#else #else
if (millis() > previous_lcd_status_ms + 10000) if (ELAPSED(millis(), previous_lcd_status_ms + 10000UL))
#endif #endif
{ {
previous_lcd_status_ms = millis(); previous_lcd_status_ms = millis();
...@@ -600,7 +600,7 @@ static void lcd_main_menu() { ...@@ -600,7 +600,7 @@ static void lcd_main_menu() {
* "Tune" submenu items * "Tune" submenu items
* *
*/ */
/** /**
* Set the home offset based on the current_position * Set the home offset based on the current_position
*/ */
...@@ -614,7 +614,7 @@ void lcd_set_home_offsets() { ...@@ -614,7 +614,7 @@ void lcd_set_home_offsets() {
int babysteps_done = 0; int babysteps_done = 0;
static void _lcd_babystep(const int axis, const char* msg) { static void _lcd_babystep(const AxisEnum axis, const char* msg) {
ENCODER_DIRECTION_NORMAL(); ENCODER_DIRECTION_NORMAL();
if (encoderPosition) { if (encoderPosition) {
int distance = (int32_t)encoderPosition * BABYSTEP_MULTIPLICATOR; int distance = (int32_t)encoderPosition * BABYSTEP_MULTIPLICATOR;
...@@ -1691,7 +1691,7 @@ static void lcd_control_volumetric_menu() { ...@@ -1691,7 +1691,7 @@ static void lcd_control_volumetric_menu() {
lcd_contrast &= 0x3F; lcd_contrast &= 0x3F;
#endif #endif
encoderPosition = 0; encoderPosition = 0;
lcdDrawUpdate = 1; lcdDrawUpdate = LCDVIEW_REDRAW_NOW;
u8g.setContrast(lcd_contrast); u8g.setContrast(lcd_contrast);
} }
if (lcdDrawUpdate) { if (lcdDrawUpdate) {
...@@ -1793,8 +1793,6 @@ static void lcd_control_volumetric_menu() { ...@@ -1793,8 +1793,6 @@ static void lcd_control_volumetric_menu() {
static void lcd_filament_change_resume_print() { static void lcd_filament_change_resume_print() {
filament_change_menu_response = FILAMENT_CHANGE_RESPONSE_RESUME_PRINT; filament_change_menu_response = FILAMENT_CHANGE_RESPONSE_RESUME_PRINT;
lcdDrawUpdate = 2;
lcd_goto_menu(lcd_status_screen);
} }
static void lcd_filament_change_extrude_more() { static void lcd_filament_change_extrude_more() {
...@@ -1867,6 +1865,7 @@ static void lcd_control_volumetric_menu() { ...@@ -1867,6 +1865,7 @@ static void lcd_control_volumetric_menu() {
switch (message) { switch (message) {
case FILAMENT_CHANGE_MESSAGE_INIT: case FILAMENT_CHANGE_MESSAGE_INIT:
defer_return_to_status = true; defer_return_to_status = true;
lcdDrawUpdate = LCDVIEW_CLEAR_CALL_REDRAW;
lcd_goto_menu(lcd_filament_change_init_message); lcd_goto_menu(lcd_filament_change_init_message);
break; break;
case FILAMENT_CHANGE_MESSAGE_UNLOAD: case FILAMENT_CHANGE_MESSAGE_UNLOAD:
...@@ -1890,6 +1889,7 @@ static void lcd_control_volumetric_menu() { ...@@ -1890,6 +1889,7 @@ static void lcd_control_volumetric_menu() {
lcd_goto_menu(lcd_filament_change_resume_message); lcd_goto_menu(lcd_filament_change_resume_message);
break; break;
case FILAMENT_CHANGE_MESSAGE_STATUS: case FILAMENT_CHANGE_MESSAGE_STATUS:
lcd_implementation_clear();
lcd_return_to_status(); lcd_return_to_status();
break; break;
} }
...@@ -2023,7 +2023,7 @@ menu_edit_type(unsigned long, long5, ftostr5, 0.01) ...@@ -2023,7 +2023,7 @@ menu_edit_type(unsigned long, long5, ftostr5, 0.01)
#endif #endif
void lcd_quick_feedback() { void lcd_quick_feedback() {
lcdDrawUpdate = 2; lcdDrawUpdate = LCDVIEW_CLEAR_CALL_REDRAW;
next_button_update_ms = millis() + 500; next_button_update_ms = millis() + 500;
#if ENABLED(LCD_USE_I2C_BUZZER) #if ENABLED(LCD_USE_I2C_BUZZER)
...@@ -2193,11 +2193,30 @@ bool lcd_blink() { ...@@ -2193,11 +2193,30 @@ bool lcd_blink() {
* - Act on RepRap World keypad input * - Act on RepRap World keypad input
* - Update the encoder position * - Update the encoder position
* - Apply acceleration to the encoder position * - Apply acceleration to the encoder position
* - Set lcdDrawUpdate = LCDVIEW_CALL_REDRAW_NOW on controller events
* - Reset the Info Screen timeout if there's any input * - Reset the Info Screen timeout if there's any input
* - Update status indicators, if any * - Update status indicators, if any
* - Clear the LCD if lcdDrawUpdate == 2
* *
* Warning: This function is called from interrupt context! * Run the current LCD menu handler callback function:
* - Call the handler only if lcdDrawUpdate != LCDVIEW_NONE
* - Before calling the handler, LCDVIEW_CALL_NO_REDRAW => LCDVIEW_NONE
* - Call the menu handler. Menu handlers should do the following:
* - If a value changes, set lcdDrawUpdate to LCDVIEW_REDRAW_NOW and draw the value
* (Encoder events automatically set lcdDrawUpdate for you.)
* - if (lcdDrawUpdate) { redraw }
* - Before exiting the handler set lcdDrawUpdate to:
* - LCDVIEW_CLEAR_CALL_REDRAW to clear screen and set LCDVIEW_CALL_REDRAW_NEXT.
* - LCDVIEW_REDRAW_NOW or LCDVIEW_NONE to keep drawingm but only in this loop.
* - LCDVIEW_REDRAW_NEXT to keep drawing and draw on the next loop also.
* - LCDVIEW_CALL_NO_REDRAW to keep drawing (or start drawing) with no redraw on the next loop.
* - NOTE: For graphical displays menu handlers may be called 2 or more times per loop,
* so don't change lcdDrawUpdate without considering this.
*
* After the menu handler callback runs (or not):
* - Clear the LCD if lcdDrawUpdate == LCDVIEW_CLEAR_CALL_REDRAW
* - Update lcdDrawUpdate for the next loop (i.e., move one state down, usually)
*
* No worries. This function is only called from the main thread.
*/ */
void lcd_update() { void lcd_update() {
#if ENABLED(ULTIPANEL) #if ENABLED(ULTIPANEL)
......
...@@ -12,11 +12,11 @@ ...@@ -12,11 +12,11 @@
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
* *
*/ */
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
#define BUTTON_EXISTS(BN) (defined(BTN_## BN) && BTN_## BN >= 0) #define BUTTON_EXISTS(BN) (defined(BTN_## BN) && BTN_## BN >= 0)
#define BUTTON_PRESSED(BN) !READ(BTN_## BN) #define BUTTON_PRESSED(BN) !READ(BTN_## BN)
int lcd_strlen(const char* s); int lcd_strlen(const char* s);
int lcd_strlen_P(const char* s); int lcd_strlen_P(const char* s);
void lcd_update(); void lcd_update();
...@@ -106,6 +106,7 @@ ...@@ -106,6 +106,7 @@
bool lcd_blink(); bool lcd_blink();
#if ENABLED(ULTIPANEL) && ENABLED(REPRAPWORLD_KEYPAD) #if ENABLED(ULTIPANEL) && ENABLED(REPRAPWORLD_KEYPAD)
#define REPRAPWORLD_BTN_OFFSET 0 // bit offset into buttons for shift register values #define REPRAPWORLD_BTN_OFFSET 0 // bit offset into buttons for shift register values
#define BLEN_REPRAPWORLD_KEYPAD_F3 0 #define BLEN_REPRAPWORLD_KEYPAD_F3 0
...@@ -133,6 +134,7 @@ ...@@ -133,6 +134,7 @@
#define REPRAPWORLD_KEYPAD_MOVE_HOME (buttons_reprapworld_keypad & EN_REPRAPWORLD_KEYPAD_MIDDLE) #define REPRAPWORLD_KEYPAD_MOVE_HOME (buttons_reprapworld_keypad & EN_REPRAPWORLD_KEYPAD_MIDDLE)
#define REPRAPWORLD_KEYPAD_MOVE_Y_UP (buttons_reprapworld_keypad & EN_REPRAPWORLD_KEYPAD_UP) #define REPRAPWORLD_KEYPAD_MOVE_Y_UP (buttons_reprapworld_keypad & EN_REPRAPWORLD_KEYPAD_UP)
#define REPRAPWORLD_KEYPAD_MOVE_X_LEFT (buttons_reprapworld_keypad & EN_REPRAPWORLD_KEYPAD_LEFT) #define REPRAPWORLD_KEYPAD_MOVE_X_LEFT (buttons_reprapworld_keypad & EN_REPRAPWORLD_KEYPAD_LEFT)
#endif // ULTIPANEL && REPRAPWORLD_KEYPAD #endif // ULTIPANEL && REPRAPWORLD_KEYPAD
#if ENABLED(NEWPANEL) #if ENABLED(NEWPANEL)
......
...@@ -12,11 +12,11 @@ ...@@ -12,11 +12,11 @@
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
* *
*/ */
...@@ -25,14 +25,9 @@ ...@@ -25,14 +25,9 @@
/** /**
* Implementation of the LCD display routines for a Hitachi HD44780 display. These are common LCD character displays. * Implementation of the LCD display routines for a Hitachi HD44780 display. These are common LCD character displays.
* When selecting the Russian language, a slightly different LCD implementation is used to handle UTF8 characters.
**/ **/
//#if DISABLED(REPRAPWORLD_KEYPAD) extern volatile uint8_t buttons; //an extended version of the last checked buttons in a bit array.
// extern volatile uint8_t buttons; //the last checked buttons in a bit array.
//#else
extern volatile uint8_t buttons; //an extended version of the last checked buttons in a bit array.
//#endif
//////////////////////////////////// ////////////////////////////////////
// Setup button and encode mappings for each panel (into 'buttons' variable // Setup button and encode mappings for each panel (into 'buttons' variable
...@@ -49,13 +44,13 @@ ...@@ -49,13 +44,13 @@
#define EN_B (_BV(BLEN_B)) // The two encoder pins are connected through BTN_EN1 and BTN_EN2 #define EN_B (_BV(BLEN_B)) // The two encoder pins are connected through BTN_EN1 and BTN_EN2
#define EN_A (_BV(BLEN_A)) #define EN_A (_BV(BLEN_A))
#if defined(BTN_ENC) && BTN_ENC > -1 #if BUTTON_EXISTS(ENC)
// encoder click is directly connected // encoder click is directly connected
#define BLEN_C 2 #define BLEN_C 2
#define EN_C (_BV(BLEN_C)) #define EN_C (_BV(BLEN_C))
#endif #endif
#if ENABLED(BTN_BACK) && BTN_BACK > 0 #if BUTTON_EXISTS(BTN_BACK)
#define BLEN_D 3 #define BLEN_D 3
#define EN_D (_BV(BLEN_D)) #define EN_D (_BV(BLEN_D))
#endif #endif
...@@ -73,16 +68,17 @@ ...@@ -73,16 +68,17 @@
#define B_DW (BUTTON_DOWN<<B_I2C_BTN_OFFSET) #define B_DW (BUTTON_DOWN<<B_I2C_BTN_OFFSET)
#define B_RI (BUTTON_RIGHT<<B_I2C_BTN_OFFSET) #define B_RI (BUTTON_RIGHT<<B_I2C_BTN_OFFSET)
#if ENABLED(BTN_ENC) && BTN_ENC > -1 #if BUTTON_EXISTS(ENC)
// the pause/stop/restart button is connected to BTN_ENC when used // the pause/stop/restart button is connected to BTN_ENC when used
#define B_ST (EN_C) // Map the pause/stop/resume button into its normalized functional name #define B_ST (EN_C) // Map the pause/stop/resume button into its normalized functional name
#undef LCD_CLICKED
#if ENABLED(INVERT_CLICK_BUTTON) #if ENABLED(INVERT_CLICK_BUTTON)
#define LCD_CLICKED !(buttons&(B_MI|B_RI|B_ST)) // pause/stop button also acts as click until we implement proper pause/stop. #define LCD_CLICKED !(buttons&(B_MI|B_RI|B_ST)) // pause/stop button also acts as click until we implement proper pause/stop.
#else #else
#define LCD_CLICKED (buttons&(B_MI|B_RI|B_ST)) // pause/stop button also acts as click until we implement proper pause/stop. #define LCD_CLICKED (buttons&(B_MI|B_RI|B_ST)) // pause/stop button also acts as click until we implement proper pause/stop.
#endif #endif
#else #else
#undef LCD_CLICKED
#if ENABLED(INVERT_CLICK_BUTTON) #if ENABLED(INVERT_CLICK_BUTTON)
#define LCD_CLICKED !(buttons&(B_MI|B_RI)) #define LCD_CLICKED !(buttons&(B_MI|B_RI))
#else #else
...@@ -94,12 +90,23 @@ ...@@ -94,12 +90,23 @@
#define LCD_HAS_SLOW_BUTTONS #define LCD_HAS_SLOW_BUTTONS
#elif ENABLED(LCD_I2C_PANELOLU2) #elif ENABLED(LCD_I2C_PANELOLU2)
// encoder click can be read through I2C if not directly connected
#if BTN_ENC <= 0 #if BUTTON_EXISTS(ENC)
#undef LCD_CLICKED
#if ENABLED(INVERT_CLICK_BUTTON)
#define LCD_CLICKED !(buttons&EN_C)
#else
#define LCD_CLICKED (buttons&EN_C)
#endif
#else // Read through I2C if not directly connected to a pin
#define B_I2C_BTN_OFFSET 3 // (the first three bit positions reserved for EN_A, EN_B, EN_C) #define B_I2C_BTN_OFFSET 3 // (the first three bit positions reserved for EN_A, EN_B, EN_C)
#define B_MI (PANELOLU2_ENCODER_C<<B_I2C_BTN_OFFSET) // requires LiquidTWI2 library v1.2.3 or later #define B_MI (PANELOLU2_ENCODER_C<<B_I2C_BTN_OFFSET) // requires LiquidTWI2 library v1.2.3 or later
#undef LCD_CLICKED
#if ENABLED(INVERT_CLICK_BUTTON) #if ENABLED(INVERT_CLICK_BUTTON)
#define LCD_CLICKED !(buttons&B_MI) #define LCD_CLICKED !(buttons&B_MI)
#else #else
...@@ -108,46 +115,12 @@ ...@@ -108,46 +115,12 @@
// I2C buttons take too long to read inside an interrupt context and so we read them during lcd_update // I2C buttons take too long to read inside an interrupt context and so we read them during lcd_update
#define LCD_HAS_SLOW_BUTTONS #define LCD_HAS_SLOW_BUTTONS
#else
#if ENABLED(INVERT_CLICK_BUTTON)
#define LCD_CLICKED !(buttons&EN_C)
#else
#define LCD_CLICKED (buttons&EN_C)
#endif
#endif #endif
#elif ENABLED(REPRAPWORLD_KEYPAD) #elif ENABLED(REPRAPWORLD_KEYPAD)
// define register bit values, don't change it
#define BLEN_REPRAPWORLD_KEYPAD_F3 0 // REPRAPWORLD_KEYPAD defined in ultralcd.h
#define BLEN_REPRAPWORLD_KEYPAD_F2 1
#define BLEN_REPRAPWORLD_KEYPAD_F1 2
#define BLEN_REPRAPWORLD_KEYPAD_UP 6
#define BLEN_REPRAPWORLD_KEYPAD_RIGHT 4
#define BLEN_REPRAPWORLD_KEYPAD_MIDDLE 5
#define BLEN_REPRAPWORLD_KEYPAD_DOWN 3
#define BLEN_REPRAPWORLD_KEYPAD_LEFT 7
#define REPRAPWORLD_BTN_OFFSET 0 // bit offset into buttons for shift register values
#define EN_REPRAPWORLD_KEYPAD_F3 (_BV(BLEN_REPRAPWORLD_KEYPAD_F3+REPRAPWORLD_BTN_OFFSET))
#define EN_REPRAPWORLD_KEYPAD_F2 (_BV(BLEN_REPRAPWORLD_KEYPAD_F2+REPRAPWORLD_BTN_OFFSET))
#define EN_REPRAPWORLD_KEYPAD_F1 (_BV(BLEN_REPRAPWORLD_KEYPAD_F1+REPRAPWORLD_BTN_OFFSET))
#define EN_REPRAPWORLD_KEYPAD_UP (_BV(BLEN_REPRAPWORLD_KEYPAD_UP+REPRAPWORLD_BTN_OFFSET))
#define EN_REPRAPWORLD_KEYPAD_RIGHT (_BV(BLEN_REPRAPWORLD_KEYPAD_RIGHT+REPRAPWORLD_BTN_OFFSET))
#define EN_REPRAPWORLD_KEYPAD_MIDDLE (_BV(BLEN_REPRAPWORLD_KEYPAD_MIDDLE+REPRAPWORLD_BTN_OFFSET))
#define EN_REPRAPWORLD_KEYPAD_DOWN (_BV(BLEN_REPRAPWORLD_KEYPAD_DOWN+REPRAPWORLD_BTN_OFFSET))
#define EN_REPRAPWORLD_KEYPAD_LEFT (_BV(BLEN_REPRAPWORLD_KEYPAD_LEFT+REPRAPWORLD_BTN_OFFSET))
/*
#if ENABLED(INVERT_CLICK_BUTTON)
#define LCD_CLICKED !((buttons&EN_C) || (buttons&EN_REPRAPWORLD_KEYPAD_F1))
#else
#define LCD_CLICKED ((buttons&EN_C) || (buttons&EN_REPRAPWORLD_KEYPAD_F1))
#endif
*/
//#define REPRAPWORLD_KEYPAD_MOVE_Y_DOWN (buttons&EN_REPRAPWORLD_KEYPAD_DOWN)
//#define REPRAPWORLD_KEYPAD_MOVE_Y_UP (buttons&EN_REPRAPWORLD_KEYPAD_UP)
//#define REPRAPWORLD_KEYPAD_MOVE_HOME (buttons&EN_REPRAPWORLD_KEYPAD_MIDDLE)
#elif ENABLED(NEWPANEL) #elif ENABLED(NEWPANEL)
#if ENABLED(INVERT_CLICK_BUTTON) #if ENABLED(INVERT_CLICK_BUTTON)
...@@ -249,6 +222,12 @@ ...@@ -249,6 +222,12 @@
#include <LiquidCrystal_SR.h> #include <LiquidCrystal_SR.h>
#define LCD_CLASS LiquidCrystal_SR #define LCD_CLASS LiquidCrystal_SR
LCD_CLASS lcd(SR_DATA_PIN, SR_CLK_PIN); LCD_CLASS lcd(SR_DATA_PIN, SR_CLK_PIN);
#elif ENABLED(LCM1602)
#include <Wire.h>
#include <LCD.h>
#include <LiquidCrystal_I2C.h>
#define LCD_CLASS LiquidCrystal_I2C
LCD_CLASS lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);
#else #else
// Standard directly connected LCD implementations // Standard directly connected LCD implementations
#include <LiquidCrystal.h> #include <LiquidCrystal.h>
...@@ -271,6 +250,10 @@ ...@@ -271,6 +250,10 @@
#define LCD_STR_PROGRESS "\x03\x04\x05" #define LCD_STR_PROGRESS "\x03\x04\x05"
#endif #endif
#if ENABLED(LCD_HAS_STATUS_INDICATORS)
static void lcd_implementation_update_indicators();
#endif
static void lcd_set_custom_characters( static void lcd_set_custom_characters(
#if ENABLED(LCD_PROGRESS_BAR) #if ENABLED(LCD_PROGRESS_BAR)
bool progress_bar_set = true bool progress_bar_set = true
...@@ -484,6 +467,7 @@ char lcd_print(const char* str) { ...@@ -484,6 +467,7 @@ char lcd_print(const char* str) {
unsigned lcd_print(char c) { return charset_mapper(c); } unsigned lcd_print(char c) { return charset_mapper(c); }
#if ENABLED(SHOW_BOOTSCREEN) #if ENABLED(SHOW_BOOTSCREEN)
void lcd_erase_line(int line) { void lcd_erase_line(int line) {
lcd.setCursor(0, line); lcd.setCursor(0, line);
for (int i = 0; i < LCD_WIDTH; i++) for (int i = 0; i < LCD_WIDTH; i++)
...@@ -502,6 +486,13 @@ unsigned lcd_print(char c) { return charset_mapper(c); } ...@@ -502,6 +486,13 @@ unsigned lcd_print(char c) { return charset_mapper(c); }
} }
} }
static void logo_lines(const char *extra) {
int indent = (LCD_WIDTH - 8 - lcd_strlen_P(extra)) / 2;
lcd.setCursor(indent, 0); lcd.print('\x00'); lcd_printPGM(PSTR( "------------" )); lcd.print('\x01');
lcd.setCursor(indent, 1); lcd_printPGM(PSTR("|MarlinKimbra|")); lcd_printPGM(extra);
lcd.setCursor(indent, 2); lcd.print('\x02'); lcd_printPGM(PSTR( "------------" )); lcd.print('\x03');
}
static void bootscreen() { static void bootscreen() {
show_bootscreen = false; show_bootscreen = false;
byte top_left[8] = { byte top_left[8] = {
...@@ -551,28 +542,72 @@ unsigned lcd_print(char c) { return charset_mapper(c); } ...@@ -551,28 +542,72 @@ unsigned lcd_print(char c) { return charset_mapper(c); }
lcd.clear(); lcd.clear();
#define TEXT_SCREEN_LOGO_SHIFT ((LCD_WIDTH/2) - 7) #define LCD_EXTRA_SPACE (LCD_WIDTH-8)
lcd.setCursor(TEXT_SCREEN_LOGO_SHIFT, 0); lcd.print('\x00'); lcd_printPGM(PSTR( "------------" )); lcd.print('\x01');
lcd.setCursor(TEXT_SCREEN_LOGO_SHIFT, 1); lcd_printPGM(PSTR("|MarlinKimbra|")); #define CENTER_OR_SCROLL(STRING,DELAY) \
lcd.setCursor(TEXT_SCREEN_LOGO_SHIFT, 2); lcd.print('\x02'); lcd_printPGM(PSTR( "------------" )); lcd.print('\x03'); lcd_erase_line(3); \
if (strlen(STRING) <= LCD_WIDTH) { \
delay(1000); lcd.setCursor((LCD_WIDTH - lcd_strlen_P(PSTR(STRING))) / 2, 3); \
lcd_printPGM(PSTR(STRING)); \
#ifdef STRING_SPLASH_LINE1 HAL::delayMilliseconds(DELAY); \
lcd_erase_line(3); } \
lcd_scroll(0, 3, PSTR(STRING_SPLASH_LINE1), LCD_WIDTH, 3000); else { \
#endif lcd_scroll(0, 3, PSTR(STRING), LCD_WIDTH, DELAY); \
}
#ifdef STRING_SPLASH_LINE2 #if ENABLED(STRING_SPLASH_LINE1)
lcd_erase_line(3); //
lcd_scroll(0, 3, PSTR(STRING_SPLASH_LINE2), LCD_WIDTH, 3000); // Show the MarlinKimbra logo with splash line 1
//
if (LCD_EXTRA_SPACE >= strlen(STRING_SPLASH_LINE1) + 1) {
//
// Show the Marlin logo, splash line1, and splash line 2
//
logo_lines(PSTR(STRING_SPLASH_LINE1));
#if ENABLED(STRING_SPLASH_LINE2)
CENTER_OR_SCROLL(STRING_SPLASH_LINE2, 2000);
#else
HAL::delayMilliseconds(2000);
#endif
}
else {
//
// Show the MarlinKimbra logo with splash line 1
// After a delay show splash line 2, if it exists
//
#if ENABLED(STRING_SPLASH_LINE2)
#define _SPLASH_WAIT_1 1500
#else
#define _SPLASH_WAIT_1 2000
#endif
logo_lines(PSTR(""));
CENTER_OR_SCROLL(STRING_SPLASH_LINE1, _SPLASH_WAIT_1);
#if ENABLED(STRING_SPLASH_LINE2)
CENTER_OR_SCROLL(STRING_SPLASH_LINE2, 1500);
#endif
}
#elif ENABLED(STRING_SPLASH_LINE2)
//
// Show splash line 2 only, alongside the logo if possible
//
if (LCD_EXTRA_SPACE >= strlen(STRING_SPLASH_LINE2) + 1) {
logo_lines(PSTR(" " STRING_SPLASH_LINE2));
HAL::delayMilliseconds(2000);
}
else {
logo_lines(PSTR(""));
CENTER_OR_SCROLL(STRING_SPLASH_LINE2, 2000);
}
#else
//
// Show only the MarlinKimbra logo
//
logo_lines(PSTR(""));
HAL::delayMilliseconds(2000);
#endif #endif
#ifdef FIRMWARE_URL
lcd_erase_line(3);
lcd_scroll(0, 3, PSTR(FIRMWARE_URL), LCD_WIDTH, 5000);
#endif
} }
#endif // SHOW_BOOTSCREEN #endif // SHOW_BOOTSCREEN
FORCE_INLINE void _draw_axis_label(AxisEnum axis, const char *pstr, bool blink) { FORCE_INLINE void _draw_axis_label(AxisEnum axis, const char *pstr, bool blink) {
...@@ -590,7 +625,7 @@ FORCE_INLINE void _draw_axis_label(AxisEnum axis, const char *pstr, bool blink) ...@@ -590,7 +625,7 @@ FORCE_INLINE void _draw_axis_label(AxisEnum axis, const char *pstr, bool blink)
} }
} }
/* /**
Possible status screens: Possible status screens:
16x2 |000/000 B000/000| 16x2 |000/000 B000/000|
|0123456789012345| |0123456789012345|
...@@ -793,8 +828,8 @@ static void lcd_implementation_status_screen() { ...@@ -793,8 +828,8 @@ static void lcd_implementation_status_screen() {
if (card.isFileOpen()) { if (card.isFileOpen()) {
// Draw the progress bar if the message has shown long enough // Draw the progress bar if the message has shown long enough
// or if there is no message set. // or if there is no message set.
if (millis() >= progress_bar_ms + PROGRESS_BAR_MSG_TIME || !lcd_status_message[0]) { if (ELAPSED(millis(), progress_bar_ms + PROGRESS_BAR_MSG_TIME) || !lcd_status_message[0]) {
int tix = (int)(card.percentDone() * LCD_WIDTH * 3) / 100, int tix = (int)(card.percentDone() * (LCD_WIDTH) * 3) / 100,
cel = tix / 3, rem = tix % 3, i = LCD_WIDTH; cel = tix / 3, rem = tix % 3, i = LCD_WIDTH;
char msg[LCD_WIDTH + 1], b = ' '; char msg[LCD_WIDTH + 1], b = ' ';
msg[i] = '\0'; msg[i] = '\0';
...@@ -814,7 +849,7 @@ static void lcd_implementation_status_screen() { ...@@ -814,7 +849,7 @@ static void lcd_implementation_status_screen() {
//Display both Status message line and Filament display on the last line //Display both Status message line and Filament display on the last line
#if HAS(LCD_FILAMENT_SENSOR) || HAS(LCD_POWER_SENSOR) #if HAS(LCD_FILAMENT_SENSOR) || HAS(LCD_POWER_SENSOR)
if (millis() >= previous_lcd_status_ms + 5000UL) { if (ELAPSED(millis(), previous_lcd_status_ms + 5000UL)) {
lcd_print(lcd_status_message); lcd_print(lcd_status_message);
} }
#if HAS(LCD_POWER_SENSOR) #if HAS(LCD_POWER_SENSOR)
...@@ -951,21 +986,25 @@ void lcd_implementation_drawedit(const char* pstr, const char* value = NULL) { ...@@ -951,21 +986,25 @@ void lcd_implementation_drawedit(const char* pstr, const char* value = NULL) {
#if ENABLED(LCD_HAS_STATUS_INDICATORS) #if ENABLED(LCD_HAS_STATUS_INDICATORS)
static void lcd_implementation_update_indicators() { static void lcd_implementation_update_indicators() {
#if ENABLED(LCD_I2C_PANELOLU2) || ENABLED(LCD_I2C_VIKI) // Set the LEDS - referred to as backlights by the LiquidTWI2 library
// Set the LEDS - referred to as backlights by the LiquidTWI2 library static uint8_t ledsprev = 0;
static uint8_t ledsprev = 0; uint8_t leds = 0;
uint8_t leds = 0;
if (target_temperature_bed > 0) leds |= LED_A; if (target_temperature_bed > 0) leds |= LED_A;
if (target_temperature[0] > 0) leds |= LED_B;
if (fanSpeed) leds |= LED_C; if (target_temperature[0] > 0) leds |= LED_B;
#if HOTENDS > 1
if (target_temperature[1] > 0) leds |= LED_C; if (fanSpeed) leds |= LED_C;
#endif
if (leds != ledsprev) { #if HOTENDS > 1
lcd.setBacklight(leds); if (target_temperature[1] > 0) leds |= LED_C;
ledsprev = leds;
}
#endif #endif
if (leds != ledsprev) {
lcd.setBacklight(leds);
ledsprev = leds;
}
} }
#endif // LCD_HAS_STATUS_INDICATORS #endif // LCD_HAS_STATUS_INDICATORS
...@@ -976,16 +1015,15 @@ void lcd_implementation_drawedit(const char* pstr, const char* value = NULL) { ...@@ -976,16 +1015,15 @@ void lcd_implementation_drawedit(const char* pstr, const char* value = NULL) {
static uint8_t lcd_implementation_read_slow_buttons() { static uint8_t lcd_implementation_read_slow_buttons() {
#if ENABLED(LCD_I2C_TYPE_MCP23017) #if ENABLED(LCD_I2C_TYPE_MCP23017)
uint8_t slow_buttons;
// Reading these buttons this is likely to be too slow to call inside interrupt context // Reading these buttons this is likely to be too slow to call inside interrupt context
// so they are called during normal lcd_update // so they are called during normal lcd_update
slow_buttons = lcd.readButtons() << B_I2C_BTN_OFFSET; uint8_t slow_bits = lcd.readButtons() << B_I2C_BTN_OFFSET;
#if ENABLED(LCD_I2C_VIKI) #if ENABLED(LCD_I2C_VIKI)
if ((slow_buttons & (B_MI | B_RI)) && millis() < next_button_update_ms) // LCD clicked if ((slow_bits & (B_MI | B_RI)) && PENDING(millis(), next_button_update_ms)) // LCD clicked
slow_buttons &= ~(B_MI | B_RI); // Disable LCD clicked buttons if screen is updated slow_bits &= ~(B_MI | B_RI); // Disable LCD clicked buttons if screen is updated
#endif #endif // LCD_I2C_VIKI
return slow_buttons; return slow_bits;
#endif #endif // LCD_I2C_TYPE_MCP23017
} }
#endif // LCD_HAS_SLOW_BUTTONS #endif // LCD_HAS_SLOW_BUTTONS
......
...@@ -1245,13 +1245,19 @@ void digipot_init() { ...@@ -1245,13 +1245,19 @@ void digipot_init() {
#endif #endif
#if MB(ALLIGATOR) #if MB(ALLIGATOR)
unsigned int digipot_motor = 0; set_driver_current();
#endif // MB(ALLIGATOR)
}
#if MB(ALLIGATOR)
void set_driver_current() {
uint8_t digipot_motor = 0;
for (uint8_t i = 0; i < 3 + DRIVER_EXTRUDERS; i++) { for (uint8_t i = 0; i < 3 + DRIVER_EXTRUDERS; i++) {
digipot_motor = 255 * motor_current[i] / 3.3; digipot_motor = 255 * motor_current[i] / 3.3;
ExternalDac::setValue(i, digipot_motor); ExternalDac::setValue(i, digipot_motor);
} }
#endif//MB(ALLIGATOR) }
} #endif
void digipot_current(uint8_t driver, int current) { void digipot_current(uint8_t driver, int current) {
#if HAS(DIGIPOTSS) #if HAS(DIGIPOTSS)
......
...@@ -12,11 +12,11 @@ ...@@ -12,11 +12,11 @@
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
* *
*/ */
...@@ -120,4 +120,8 @@ ...@@ -120,4 +120,8 @@
void colorstep(long csteps, const bool direction); void colorstep(long csteps, const bool direction);
#endif #endif
#if MB(ALLIGATOR)
extern void set_driver_current();
#endif
#endif // STEPPER_H #endif // STEPPER_H
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