Commit 5ee63302 authored by MagoKimbra's avatar MagoKimbra

Same fix

parent 78a42efa
......@@ -7,7 +7,7 @@
* @date 2015/8/13
*
* @copyright
* Copyright (C) 2014-2015 ITEAD Intelligent Systems Co., Ltd. \n
* Copyright (C) 2014-2015 ITEAD Intelligent Systems Co., Ltd.
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
......
/**
* @file NexDualStateButton.cpp
*
* The implementation of class NexDSButton.
*
* @author huang xianming (email:<xianming.huang@itead.cc>)
* @date 2015/11/11
* @copyright
* Copyright (C) 2014-2015 ITEAD Intelligent Systems Co., Ltd.
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*/
#include "NexDualStateButton.h"
NexDSButton::NexDSButton(uint8_t pid, uint8_t cid, const char *name)
:NexTouch(pid, cid, name)
{
}
bool NexDSButton::getValue(uint32_t *number)
{
String cmd = String("get ");
cmd += getObjName();
cmd += ".val";
sendCommand(cmd.c_str());
return recvRetNumber(number);
}
bool NexDSButton::setValue(uint32_t number)
{
char buf[10] = {0};
String cmd;
utoa(number, buf, 10);
cmd += getObjName();
cmd += ".val=";
cmd += buf;
sendCommand(cmd.c_str());
return recvRetCommandFinished();
}
/**
* @file NexDualStateButton.h
*
* The definition of class NexDSButton.
*
* @author huang xianming (email:<xianming.huang@itead.cc>)
* @date 2015/11/11
*
*
* @copyright
* Copyright (C) 2014-2015 ITEAD Intelligent Systems Co., Ltd.
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*/
#ifndef __NEXDSBUTTON_H__
#define __NEXDSBUTTON_H__
#include "NexTouch.h"
#include "NexHardware.h"
/**
* @addtogroup Component
* @{
*/
/**
* NexDSButton component.
*
* Commonly, you want to do something after push and pop it. It is recommanded that only
* call @ref NexTouch::attachPop to satisfy your purpose.
*
* @warning Please do not call @ref NexTouch::attachPush on this component, even though you can.
*/
class NexDSButton: public NexTouch
{
public: /* methods */
/**
* @copydoc NexObject::NexObject(uint8_t pid, uint8_t cid, const char *name);
*/
NexDSButton(uint8_t pid, uint8_t cid, const char *name);
/**
* Get number attribute of component.
*
* @param buffer - buffer storing text returned.
* @param len - length of buffer.
* @return The real length of text returned.
*/
bool getValue(uint32_t *number);
/**
* Set number attribute of component.
*
* @param buffer - number buffer.
* @return true if success, false for failure.
*/
bool setValue(uint32_t number);
};
/**
* @}
*/
#endif /* #ifndef __NEXDSBUTTON_H__ */
......@@ -25,7 +25,7 @@
*/
/**
* NexTNumber component.
* NexNumber component.
*/
class NexNumber: public NexTouch
{
......
......@@ -35,6 +35,7 @@
#include "NexTimer.h"
#include "NexNumber.h"
#include "NexVar.h"
#include "NexDualStateButton.h"
#endif /* #ifndef __NEXTION_H__ */
......@@ -286,6 +286,9 @@
#define Z_RAISE_BETWEEN_PROBINGS 5 //How much the extruder will be raised when travelling from between next probing points
#define Z_RAISE_AFTER_PROBING 5 //How much the extruder will be raised after the last probing point.
//#define Z_PROBE_END_SCRIPT "G1 Z10 F8000\nG1 X10 Y10\nG1 Z0.5" // These commands will be executed in the end of G29 routine.
// Useful to retract a deployable Z probe.
//#define Z_PROBE_SLED // turn on if you have a z-probe mounted on a sled like those designed by Charles Bell
//#define SLED_DOCKING_OFFSET 5 // the extra distance the X axis must travel to pick up the sled. 0 should be fine but you can push it further if you'd like.
/*****************************************************************************************/
......
......@@ -308,6 +308,9 @@
#define Z_RAISE_BETWEEN_PROBINGS 5 //How much the extruder will be raised when travelling from between next probing points
#define Z_RAISE_AFTER_PROBING 5 //How much the extruder will be raised after the last probing point.
//#define Z_PROBE_END_SCRIPT "G1 Z10 F8000\nG1 X10 Y10\nG1 Z0.5" // These commands will be executed in the end of G29 routine.
// Useful to retract a deployable Z probe.
//#define Z_PROBE_SLED // turn on if you have a z-probe mounted on a sled like those designed by Charles Bell
//#define SLED_DOCKING_OFFSET 5 // the extra distance the X axis must travel to pick up the sled. 0 should be fine but you can push it further if you'd like.
/*****************************************************************************************/
......
......@@ -406,7 +406,7 @@
* *
***********************************************************************/
//#define NPR2
#define COLOR_STEP {120,25,-65,-155} // CARTER ANGLE
#define COLOR_STEP {0, 10, 20, 30} // CARTER ANGLE
#define COLOR_SLOWRATE 170 // MICROSECOND delay for carter motor routine (Carter Motor Feedrate: upper value-slow feedrate)
#define COLOR_HOMERATE 4 // FEEDRATE for carter home
#define MOTOR_ANGLE 1.8 // Nema angle for single step
......@@ -674,10 +674,10 @@
* *
**************************************************************************/
//#define BABYSTEPPING
//#define BABYSTEP_XY // not only z, but also XY in the menu. more clutter, more functions
#define BABYSTEP_XY // not only z, but also XY in the menu. more clutter, more functions
// not implemented for CoreXY and deltabots!
#define BABYSTEP_INVERT_Z false // true for inverse movements in Z
#define BABYSTEP_Z_MULTIPLICATOR 2 // faster z movements
#define BABYSTEP_MULTIPLICATOR 2 // faster z movements
/**************************************************************************/
......@@ -1074,13 +1074,13 @@
// The Panucatt Devices Viki 2.0 and mini Viki with Graphic LCD
// http://panucatt.com
// ==> REMEMBER TO INSTALL U8glib to your ARDUINO library folder: http://code.google.com/p/u8glib/wiki/u8glib
// ==> REMEMBER TO INSTALL U8glib to your ARDUINO library folder: https://github.com/olikraus/U8glib_Arduino
//#define VIKI2
//#define miniVIKI
// This is a new controller currently under development. https://github.com/eboston/Adafruit-ST7565-Full-Graphic-Controller/
//
// ==> REMEMBER TO INSTALL U8glib to your ARDUINO library folder: http://code.google.com/p/u8glib/wiki/u8glib
// ==> REMEMBER TO INSTALL U8glib to your ARDUINO library folder: https://github.com/olikraus/U8glib_Arduino
//#define ELB_FULL_GRAPHIC_CONTROLLER
//#define SD_DETECT_INVERTED
......@@ -1095,7 +1095,7 @@
// The RepRapDiscount FULL GRAPHIC Smart Controller (quadratic white PCB)
// http://reprap.org/wiki/RepRapDiscount_Full_Graphic_Smart_Controller
//
// ==> REMEMBER TO INSTALL U8glib to your ARDUINO library folder: http://code.google.com/p/u8glib/wiki/u8glib
// ==> REMEMBER TO INSTALL U8glib to your ARDUINO library folder: https://github.com/olikraus/U8glib_Arduino
//#define REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER
// The RepRapWorld REPRAPWORLD_KEYPAD v1.1
......@@ -1113,7 +1113,7 @@
// #define MINIPANEL
// Nextion HMI panel
// REMEMBER TO INSTALL Nextion library in your ARDUINO library folder. You can find it in Arduino\libraries\
// ==> REMEMBER TO INSTALL Nextion library in your ARDUINO library folder. You can find it in Arduino\libraries\
//#define NEXTION
// I2C Panels
......@@ -1132,7 +1132,7 @@
//#define LCD_I2C_VIKI
// SSD1306 OLED generic display support
// ==> REMEMBER TO INSTALL U8glib to your ARDUINO library folder: http://code.google.com/p/u8glib/wiki/u8glib
// ==> REMEMBER TO INSTALL U8glib to your ARDUINO library folder: https://github.com/olikraus/U8glib_Arduino
//#define U8GLIB_SSD1306
// Shift register panels
......
......@@ -118,7 +118,6 @@
* M3 - Put S<value> in laser beam control
* M4 - Turn on laser beam
* M5 - Turn off laser beam
* M11 - Start printer for pause mode
* M17 - Enable/Power all stepper motors
* M18 - Disable all stepper motors; same as M84
* M20 - List SD card
......@@ -434,7 +433,7 @@ unsigned long printer_usage_seconds;
#if HAS(FILRUNOUT)
static bool filrunoutEnqueued = false;
bool printing = false;
bool filrunoutActive = false;
#endif
#if ENABLED(SDSUPPORT)
......@@ -3663,9 +3662,10 @@ inline void gcode_G28() {
int abl2 = auto_bed_leveling_grid_points * auto_bed_leveling_grid_points;
double eqnAMatrix[abl2 * 3], // "A" matrix of the linear system of equations
eqnBVector[abl2]; // "B" vector of Z points
eqnBVector[abl2], // "B" vector of Z points
mean = 0.0;
int8_t indexIntoAB[auto_bed_leveling_grid_points][auto_bed_leveling_grid_points];
int probePointCounter = 0;
bool zig = (auto_bed_leveling_grid_points & 1) ? true : false; //always end at [RIGHT_PROBE_BED_POSITION, BACK_PROBE_BED_POSITION]
......@@ -3693,14 +3693,13 @@ inline void gcode_G28() {
float measured_z,
z_before = probePointCounter ? Z_RAISE_BETWEEN_PROBINGS + current_position[Z_AXIS] : Z_RAISE_BEFORE_PROBING;
if (probePointCounter) {
if (debugLevel & DEBUG_INFO) ECHO_LMV(DB, "z_before = (between) ", (float)(Z_RAISE_BETWEEN_PROBINGS + current_position[Z_AXIS]));
}
else {
if (debugLevel & DEBUG_INFO) ECHO_LMV(DB, "z_before = (before) ", (float)Z_RAISE_BEFORE_PROBING);
if (debugLevel & DEBUG_INFO) {
if (probePointCounter)
ECHO_LMV(DB, "z_before = (between) ", (float)(Z_RAISE_BETWEEN_PROBINGS + current_position[Z_AXIS]));
else
ECHO_LMV(DB, "z_before = (before) ", (float)Z_RAISE_BEFORE_PROBING);
}
// Enhanced G29 - Do not retract servo between probes
ProbeAction act;
if (deploy_probe_for_each_reading) // G29 E - Stow between probes
act = ProbeDeployAndStow;
......@@ -3712,6 +3711,7 @@ inline void gcode_G28() {
act = ProbeStay;
measured_z = probe_pt(xProbe, yProbe, z_before, act, verbose_level);
mean += measured_z;
eqnBVector[probePointCounter] = measured_z;
eqnAMatrix[probePointCounter + 0 * abl2] = xProbe;
......@@ -3737,83 +3737,43 @@ inline void gcode_G28() {
double plane_equation_coefficients[3];
qr_solve(plane_equation_coefficients, abl2, 3, eqnAMatrix, eqnBVector);
mean /= abl2;
if (verbose_level) {
ECHO_SMV(DB, "Eqn coefficients: a: ", plane_equation_coefficients[0], 8);
ECHO_MV(" b: ", plane_equation_coefficients[1], 8);
ECHO_EMV(" d: ", plane_equation_coefficients[2], 8);
if (verbose_level > 2)
ECHO_LMV(DB, "Mean of sampled points: ", mean, 8);
}
if (!dryrun) set_bed_level_equation_lsq(plane_equation_coefficients);
matrix_3x3 inverse_bed_level_matrix = matrix_3x3::transpose(plan_bed_level_matrix); // inverse bed level matrix
// In the special case of an rotation matrix "the inverse" = "the transposed" matrix.
// search minimum and maximum point on bed in rotated coordinates
float rot_min_diff = Z_MAX_POS,
rot_max_diff = -Z_MAX_POS,
min_diff = Z_MAX_POS;
for (int8_t i = 0; i < abl2; i++) {
vector_3 probe_point = vector_3(eqnAMatrix[i + 0 * abl2], eqnAMatrix[i + 1 * abl2], eqnBVector[i]);
probe_point.apply_rotation(inverse_bed_level_matrix);
rot_min_diff = min(rot_min_diff, probe_point.z);
rot_max_diff = max(rot_max_diff, probe_point.z);
min_diff = min(min_diff, eqnBVector[i]);
}
// Show the Topography map if enabled
if (do_topography_map) {
// search minimum measured Z
ECHO_LM(DB, "Bed Height Topography:");
ECHO_LM(DB, "+-----------+");
ECHO_LM(DB, "|...Back....|");
ECHO_LM(DB, "|Left..Right|");
ECHO_LM(DB, "|...Front...|");
ECHO_LM(DB, "+-----------+");
ECHO_LM(DB, "Measured Bed Topography:");
for (int8_t yy = auto_bed_leveling_grid_points - 1; yy >= 0; yy--) {
ECHO_S(DB);
for (int8_t xx = 0; xx < auto_bed_leveling_grid_points; xx++) {
int8_t ind = indexIntoAB[xx][yy];
float diff = eqnBVector[ind];
if (diff >= 0.0)
ECHO_M(" +"); // Include + for column alignment
else
ECHO_M(" ");
ECHO_V(diff, 5);
} // xx
ECHO_E;
} // yy
ECHO_E;
float min_diff = 999;
ECHO_LM(DB, "Corrected Bed Topography:");
for (int8_t yy = auto_bed_leveling_grid_points - 1; yy >= 0; yy--) {
for (int yy = auto_bed_leveling_grid_points - 1; yy >= 0; yy--) {
ECHO_S(DB);
for (int8_t xx = 0; xx < auto_bed_leveling_grid_points; xx++) {
int8_t ind = indexIntoAB[xx][yy];
for (int xx = 0; xx < auto_bed_leveling_grid_points; xx++) {
int ind = indexIntoAB[xx][yy];
float diff = eqnBVector[ind] - mean;
float diff = eqnBVector[ind] - min_diff;
if (diff >= 0.0)
ECHO_M(" +"); // Include + for column alignment
else
ECHO_M(" ");
ECHO_V(diff, 5);
} // xx
ECHO_E;
} // yy
ECHO_E;
float x_tmp = eqnAMatrix[ind + 0 * abl2],
y_tmp = eqnAMatrix[ind + 1 * abl2],
z_tmp = 0;
ECHO_LM(DB, "Corrected Bed Topography in new coordinates:");
for (int8_t yy = auto_bed_leveling_grid_points - 1; yy >= 0; yy--) {
ECHO_S(DB);
for (int8_t xx = 0; xx < auto_bed_leveling_grid_points; xx++) {
int8_t ind = indexIntoAB[xx][yy];
apply_rotation_xyz(plan_bed_level_matrix, x_tmp, y_tmp, z_tmp);
vector_3 probe_point = vector_3(eqnAMatrix[ind + 0 * abl2], eqnAMatrix[ind + 1 * abl2], eqnBVector[ind]);
probe_point.apply_rotation(inverse_bed_level_matrix);
float diff = probe_point.z - rot_min_diff;
if (eqnBVector[ind] - z_tmp < min_diff)
min_diff = eqnBVector[ind] - z_tmp;
if (diff >= 0.0)
ECHO_M(" +"); // Include + for column alignment
......@@ -3824,17 +3784,19 @@ inline void gcode_G28() {
ECHO_E;
} // yy
ECHO_E;
if (verbose_level > 3) {
ECHO_LM(DB, "Corrected Bed Height vs. Bed Topology:");
ECHO_LM(DB, "Height from Bed to Nozzle");
ECHO_LM(DB, "(+) above, or (-) below surface :");
for (int8_t yy = auto_bed_leveling_grid_points - 1; yy >= 0; yy--) {
for (int yy = auto_bed_leveling_grid_points - 1; yy >= 0; yy--) {
ECHO_S(DB);
for (int8_t xx = 0; xx < auto_bed_leveling_grid_points; xx++) {
int8_t ind = indexIntoAB[xx][yy];
for (int xx = 0; xx < auto_bed_leveling_grid_points; xx++) {
int ind = indexIntoAB[xx][yy];
float x_tmp = eqnAMatrix[ind + 0 * abl2],
y_tmp = eqnAMatrix[ind + 1 * abl2],
z_tmp = 0;
vector_3 probe_point = vector_3(eqnAMatrix[ind + 0 * abl2], eqnAMatrix[ind + 1 * abl2], eqnBVector[ind]);
probe_point.apply_rotation(inverse_bed_level_matrix);
float diff = -(probe_point.z - rot_max_diff);
apply_rotation_xyz(plan_bed_level_matrix, x_tmp, y_tmp, z_tmp);
float diff = eqnBVector[ind] - min_diff;
if (diff >= 0.0)
ECHO_M(" +"); // Include + for column alignment
......@@ -3845,6 +3807,7 @@ inline void gcode_G28() {
ECHO_E;
} // yy
ECHO_E;
}
} //do_topography_map
#else // !AUTO_BED_LEVELING_GRID
......@@ -3871,23 +3834,66 @@ inline void gcode_G28() {
plan_bed_level_matrix.debug(" Bed Level Correction Matrix:");
if (!dryrun) {
uint8_t ind = abl2-1; // last point probe = current point
vector_3 probe_point = vector_3(eqnAMatrix[ind + 0 * abl2], eqnAMatrix[ind + 1 * abl2], eqnBVector[ind]);
probe_point.apply_rotation(inverse_bed_level_matrix);
current_position[Z_AXIS] = -zprobe_zoffset + (probe_point.z - rot_max_diff)
#if HAS(SERVO_ENDSTOPS) || HAS(Z_PROBE_SLED)
// Correct the Z height difference from Z probe position and nozzle tip position.
// The Z height on homing is measured by Z probe, but the Z probe is quite far from the nozzle.
// When the bed is uneven, this height must be corrected.
float x_tmp = current_position[X_AXIS] + X_PROBE_OFFSET_FROM_EXTRUDER,
y_tmp = current_position[Y_AXIS] + Y_PROBE_OFFSET_FROM_EXTRUDER,
z_tmp = current_position[Z_AXIS],
real_z = st_get_position_mm(Z_AXIS); //get the real Z (since plan_get_position is now correcting the plane)
if (debugLevel & DEBUG_INFO) {
ECHO_LMV(DB, "> BEFORE apply_rotation_xyz > z_tmp = ", z_tmp);
ECHO_LMV(DB, "> BEFORE apply_rotation_xyz > real_z = ", real_z);
}
apply_rotation_xyz(plan_bed_level_matrix, x_tmp, y_tmp, z_tmp); // Apply the correction sending the Z probe offset
// Get the current Z position and send it to the planner.
//
// >> (z_tmp - real_z) : The rotated current Z minus the uncorrected Z (most recent plan_set_position/sync_plan_position)
//
// >> zprobe_zoffset : Z distance from nozzle to Z probe (set by default, M851, EEPROM, or Menu)
//
// >> Z_RAISE_AFTER_PROBING : The distance the Z probe will have lifted after the last probe
//
// >> Should home_offset[Z_AXIS] be included?
//
// Discussion: home_offset[Z_AXIS] was applied in G28 to set the starting Z.
// If Z is not tweaked in G29 -and- the Z probe in G29 is not actually "homing" Z...
// then perhaps it should not be included here. The purpose of home_offset[] is to
// adjust for inaccurate endstops, not for reasonably accurate probes. If it were
// added here, it could be seen as a compensating factor for the Z probe.
//
if (debugLevel & DEBUG_INFO)
ECHO_LMV(DB, "> AFTER apply_rotation_xyz > z_tmp = ", z_tmp);
current_position[Z_AXIS] = -zprobe_zoffset + (z_tmp - real_z)
#if HAS(SERVO_ENDSTOPS) || ENABLED(Z_PROBE_SLED)
+ Z_RAISE_AFTER_PROBING
#endif
;
// current_position[Z_AXIS] += home_offset[Z_AXIS]; // The Z probe determines Z=0, not "Z home"
sync_plan_position();
if (debugLevel & DEBUG_INFO) ECHO_LMV(DB, "> AFTER apply_rotation_xyz > current_position[Z_AXIS]= ", current_position[Z_AXIS], 5);
if (debugLevel & DEBUG_INFO)
print_xyz("> corrected Z in G29", current_position);
}
// Sled assembly for Cartesian bots
#if HAS(Z_PROBE_SLED)
dock_sled(true); // dock the probe
#endif
#if ENABLED(Z_PROBE_END_SCRIPT)
if (debugLevel & DEBUG_INFO) {
ECHO_SM(DB, "Z Probe End Script: ");
ECHO_EM(Z_PROBE_END_SCRIPT);
}
enqueuecommands_P(PSTR(Z_PROBE_END_SCRIPT));
st_synchronize();
#endif
if (debugLevel & DEBUG_INFO) ECHO_LM(DB, "<<< gcode_G29");
}
......@@ -4330,22 +4336,6 @@ inline void gcode_G92() {
}
#endif //LASERBEAM
#if HAS(FILRUNOUT)
/**
* M11: Start printing
*/
inline void gcode_M11() {
printing = true;
filrunoutEnqueued = false;
ECHO_LM(DB, "Start Printing, pause pin active.");
ECHO_S(RESUME);
ECHO_E;
#if HAS(POWER_CONSUMPTION_SENSOR)
startpower = power_consumption_hour;
#endif
}
#endif
/**
* M17: Enable power on all stepper motors
*/
......@@ -6336,6 +6326,7 @@ inline void gcode_M503() {
* X[position] - Move to this X position, with Y
* Y[position] - Move to this Y position, with X
* L[distance] - Retract distance for removal (manual reload)
* S[0-1] - Deactivate Filament runout - Active Filament runout
*
* Default values are used for omitted arguments.
*
......@@ -6347,6 +6338,26 @@ inline void gcode_M503() {
return;
}
#if HAS(FILRUNOUT)
if (code_seen('S')) {
if (code_value() == 1) {
filrunoutActive = true;
filrunoutEnqueued = false;
ECHO_LM(DB, "Filament runout activated.");
ECHO_S(RESUME);
ECHO_E;
#if HAS(POWER_CONSUMPTION_SENSOR)
startpower = power_consumption_hour;
#endif
} else {
filrunoutActive = false;
filrunoutEnqueued = false;
ECHO_LM(DB, "Filament runout deactivated.");
}
return;
}
#endif
float lastpos[NUM_AXIS], fr60 = feedrate / 60;
filament_changing = true;
......@@ -6936,16 +6947,14 @@ inline void gcode_T(uint8_t tmp_extruder) {
ECHO_LMV(DB, MSG_ACTIVE_EXTRUDER, active_extruder);
#elif ENABLED(NPR2)
st_synchronize(); // Finish all movement
if (old_color == 99)
{
if (old_color == 99) {
csteps = (color_position[target_extruder]) * color_step_moltiplicator;
}
else
{
else {
csteps = (color_position[target_extruder] - color_position[old_color]) * color_step_moltiplicator;
}
if (csteps < 0) colorstep(-csteps,false);
if (csteps > 0) colorstep(csteps,true);
if (csteps < 0) colorstep(-csteps, false);
if (csteps > 0) colorstep(csteps, true);
old_color = active_extruder = target_extruder;
active_driver = 0;
ECHO_LMV(DB, MSG_ACTIVE_COLOR, (int)active_extruder);
......@@ -7114,11 +7123,6 @@ void process_next_command() {
gcode_M5(); break;
#endif //LASERBEAM
#if HAS(FILRUNOUT)
case 11: //M11 - Start printing
gcode_M11(); break;
#endif
case 17: //M17 - Enable/Power all stepper motors
gcode_M17(); break;
......@@ -7974,7 +7978,7 @@ void idle(bool ignore_stepper_queue/*=false*/) {
void manage_inactivity(bool ignore_stepper_queue/*=false*/) {
#if HAS(FILRUNOUT)
if ((printing || IS_SD_PRINTING ) && (READ(FILRUNOUT_PIN) ^ FILRUNOUT_PIN_INVERTING))
if ((filrunoutActive || IS_SD_PRINTING) && (READ(FILRUNOUT_PIN) ^ FILRUNOUT_PIN_INVERTING))
filrunout();
#endif
......
#include "base.h"
#if HAS(BUZZER)
#include "buzzer.h"
#include "ultralcd.h"
#include "buzzer.h"
#include "ultralcd.h"
void buzz(long duration, uint16_t freq) {
void buzz(long duration, uint16_t freq) {
if (freq > 0) {
#if ENABLED(LCD_USE_I2C_BUZZER)
#if ENABLED(LCD_USE_I2C_BUZZER)
lcd_buzz(duration, freq);
#elif PIN_EXISTS(BEEPER) // on-board buzzers have no further condition
#elif PIN_EXISTS(BEEPER) // on-board buzzers have no further condition
SET_OUTPUT(BEEPER_PIN);
#if ENABLED(SPEAKER) // a speaker needs a AC ore a pulsed DC
#if ENABLED(SPEAKER) // a speaker needs a AC ore a pulsed DC
//tone(BEEPER_PIN, freq, duration); // needs a PWMable pin
unsigned int delay = 1000000 / freq / 2;
int i = duration * freq / 1000;
......@@ -19,15 +19,17 @@ void buzz(long duration, uint16_t freq) {
WRITE(BEEPER_PIN, LOW);
delayMicroseconds(delay);
}
#else // buzzer has its own resonator - needs a DC
#else // buzzer has its own resonator - needs a DC
WRITE(BEEPER_PIN, HIGH);
delay(duration);
WRITE(BEEPER_PIN, LOW);
#endif
#else
#endif
#else
delay(duration);
#endif
} else
#endif
}
else {
delay(duration);
}
}
}
#endif
#ifndef BUZZER_H
#define BUZZER_H
#define BUZZER_H
void buzz(long duration, uint16_t freq);
#if HAS(BUZZER)
void buzz(long duration, uint16_t freq);
#endif
#endif
#endif // BUZZER_H
......@@ -24,12 +24,15 @@ CardReader::CardReader() {
workDirDepth = 0;
file_subcall_ctr = 0;
memset(workDirParents, 0, sizeof(workDirParents));
autostart_stilltocheck = true; //the SD start is delayed, because otherwise the serial cannot answer fast enough to make contact with the host software.
autostart_index = 0;
//power to SD reader
#if SDPOWER > -1
#if SDPOWER > -1
OUT_WRITE(SDPOWER, HIGH);
#endif //SDPOWER
#endif // SDPOWER
next_autostart_ms = millis() + SPLASH_SCREEN_DURATION;
}
......@@ -53,24 +56,31 @@ char* createFilename(char* buffer, const dir_t& p) { //buffer > 12characters
void CardReader::lsDive(const char* prepend, SdFile parent, const char* const match/*=NULL*/) {
dir_t p;
uint8_t cnt = 0;
// Read the next entry from a directory
while (parent.readDir(p, longFilename) > 0) {
// If the entry is a directory and the action is LS_SerialPrint
if (DIR_IS_SUBDIR(&p) && lsAction != LS_Count && lsAction != LS_GetFilename) {
// Get the short name for the item, which we know is a folder
char lfilename[FILENAME_LENGTH];
createFilename(lfilename, p);
// Allocate enough stack space for the full path to a folder, trailing slash, and nul
boolean prepend_is_empty = (prepend[0] == '\0');
int len = (prepend_is_empty ? 1 : strlen(prepend)) + strlen(lfilename) + 1 + 1;
char path[len];
// Append the FOLDERNAME12/ to the passed string.
// It contains the full path to the "parent" argument.
// We now have the full path to the item in this folder.
strcpy(path, prepend_is_empty ? "/" : prepend); // root slash if prepend is empty
strcat(path, lfilename); // FILENAME_LENGTH-1 characters maximum
strcat(path, "/"); // 1 character
// Serial.print(path);
// Get a new directory object using the full path
// and dive recursively into it.
SdFile dir;
......@@ -81,14 +91,19 @@ void CardReader::lsDive(const char* prepend, SdFile parent, const char* const ma
}
lsDive(path, dir);
// close() is done automatically by destructor of SdFile
} else {
}
else {
char pn0 = p.name[0];
if (pn0 == DIR_NAME_FREE) break;
if (pn0 == DIR_NAME_DELETED || pn0 == '.') continue;
if (longFilename[0] == '.') continue;
if (!DIR_IS_FILE_OR_SUBDIR(&p)) continue;
filenameIsDir = DIR_IS_SUBDIR(&p);
if (!filenameIsDir && (p.name[8] != 'G' || p.name[9] == '~')) continue;
switch (lsAction) {
case LS_Count:
nrFiles++;
......@@ -102,7 +117,8 @@ void CardReader::lsDive(const char* prepend, SdFile parent, const char* const ma
createFilename(filename, p);
if (match != NULL) {
if (strcasecmp(match, filename) == 0) return;
} else if (cnt == nrFiles) return;
}
else if (cnt == nrFiles) return;
cnt++;
break;
}
......@@ -118,27 +134,38 @@ void CardReader::ls() {
#if ENABLED(LONG_FILENAME_HOST_SUPPORT)
/**
/**
* Get a long pretty path based on a DOS 8.3 path
*/
void CardReader::printLongPath(char* path) {
void CardReader::printLongPath(char* path) {
lsAction = LS_GetFilename;
int i, pathLen = strlen(path);
// ECHO_M("Full Path: "); ECHO_EV(path);
// Zero out slashes to make segments
for (i = 0; i < pathLen; i++) if (path[i] == '/') path[i] = '\0';
SdFile diveDir = root; // start from the root for segment 1
for (i = 0; i < pathLen;) {
if (path[i] == '\0') i++; // move past a single nul
char* segment = &path[i]; // The segment after most slashes
// If a segment is empty (extra-slash) then exit
if (!*segment) break;
// Go to the next segment
while (path[++i]) { }
// ECHO_M("Looking for segment: "); ECHO_EV(segment);
// Find the item, setting the long filename
diveDir.rewind();
lsDive("", diveDir, segment);
// Print /LongNamePart to serial output
ECHO_C('/');
ECHO_V(longFilename[0] ? longFilename : "???");
......@@ -152,35 +179,43 @@ void CardReader::printLongPath(char* path) {
ECHO_SMV(DB, MSG_SD_CANT_OPEN_SUBDIR, segment);
break;
}
diveDir.close();
diveDir = dir;
} // while i<pathLen
ECHO_E;
}
}
#endif // LONG_FILENAME_HOST_SUPPORT
void CardReader::initsd() {
cardOK = false;
if (root.isOpen()) root.close();
#if ENABLED(SDEXTRASLOW)
#if ENABLED(SDEXTRASLOW)
#define SPI_SPEED SPI_QUARTER_SPEED
#elif ENABLED(SDSLOW)
#elif ENABLED(SDSLOW)
#define SPI_SPEED SPI_HALF_SPEED
#else
#else
#define SPI_SPEED SPI_FULL_SPEED
#endif
#endif
if (!card.init(SPI_SPEED, SDSS)
#if defined(LCD_SDSS) && (LCD_SDSS != SDSS)
#if defined(LCD_SDSS) && (LCD_SDSS != SDSS)
&& !card.init(SPI_SPEED, LCD_SDSS)
#endif
#endif
) {
ECHO_LM(DB, MSG_SD_INIT_FAIL);
} else if (!volume.init(&card)) {
}
else if (!volume.init(&card)) {
ECHO_LM(ER, MSG_SD_VOL_INIT_FAIL);
} else if (!root.openRoot(&volume)) {
}
else if (!root.openRoot(&volume)) {
ECHO_LM(ER, MSG_SD_OPENROOT_FAIL);
} else {
}
else {
cardOK = true;
ECHO_LM(DB, MSG_SD_CARD_OK);
}
......
......@@ -29,9 +29,11 @@ void digipot_i2c_set_current(int channel, float current) {
addr = 0x2E; // channel 4-7
channel -= 4;
}
// Initial setup
i2c_send(addr, 0x40, 0xff);
i2c_send(addr, 0xA0, 0xff);
// Set actual wiper value
byte addresses[4] = { 0x00, 0x10, 0x60, 0x70 };
i2c_send(addr, addresses[channel], current_to_wiper(current));
......
......@@ -4,31 +4,31 @@
#define START_BMPHIGH
#if ENABLED(SHOW_BOOTSCREEN)
#if ENABLED(START_BMPHIGH)
#define START_BMPWIDTH 112
#define START_BMPHEIGHT 38
#define START_BMPBYTEWIDTH 14
#define START_BMPBYTES 532 // START_BMPWIDTH * START_BMPHEIGHT / 8
#if ENABLED(START_BMPHIGH)
#define START_BMPWIDTH 112
#define START_BMPHEIGHT 38
#define START_BMPBYTEWIDTH 14
#define START_BMPBYTES 532 // START_BMPWIDTH * START_BMPHEIGHT / 8
const unsigned char start_bmp[START_BMPBYTES] PROGMEM = {
const unsigned char start_bmp[START_BMPBYTES] PROGMEM = {
0x3,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xc0,0xf,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xf0,0x1e,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x78,0x38,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1c,0x70,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xe,0x60,0x0,0x0,0x0,0x0,0x30,0x0,0x0,0x0,0x0,0x1,0x0,0x0,0x6,0xe0,0x1f,0x7c,0x0,0x0,0x33,0x0,0x0,0x0,0x0,0x1,0x80,0x3,0x87,0xc0,0x3f,0xfe,0x0,0x0,0x33,0x0,0x0,0x0,0x0,0x1,0xc0,0x2,0x83,
0xc0,0x73,0xce,0x0,0x0,0x30,0x0,0x0,0x0,0x0,0x3,0xc0,0x3,0x83,0xc0,0xf3,0xce,0x3c,0xf,0x33,0xf,0x0,0x0,0x0,0x3,0xc0,0x2,0x83,0xc0,0xe3,0x8e,0x7e,0x1f,0xb3,0x1f,0x80,0x0,0x0,0x1f,0xe0,0x0,0x3,0xc0,0xe3,0x8e,0xe7,0x39,0xb3,0x39,0xc0,0x0,0x0,0xff,0xfc,0x3,0x83,0xc0,0xe3,0x8e,0xc3,0x31,0xb3,0x38,0xc0,0x0,0x0,0x3f,0xff,0x2,0x3,0xc0,0xe3,0x8e,0xc3,0x30,0x33,0x38,0xc0,0x0,0x0,0x7,0xf0,0x2,0x3,0xc0,0xe3,0x8e,0xe3,0x30,0x33,0x38,0xc0,0x0,0x1,0x7,0xf0,0x3,0x83,0xc0,0xe3,0x8e,0xfb,0xf0,0x3f,0xf8,0xc0,0x0,0x3,0x83,0xf0,0x0,0x3,
0xc0,0x63,0x8e,0x7b,0xf0,0x1f,0xf8,0xc0,0x0,0x7,0xc1,0xf8,0x0,0x3,0xc0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x3,0x9f,0xfe,0x0,0x3,0xc0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xff,0xff,0x80,0x43,0xe0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x7f,0xff,0xf8,0xc3,0xf0,0x0,0x0,0x0,0x0,0x0,0x3,0x0,0x0,0x0,0x33,0xff,0xff,0xc3,0xf8,0x0,0x0,0x30,0xf0,0x0,0x3,0x0,0x0,0x0,0x19,0xff,0xff,0x83,0xfc,0x0,0x0,0x71,0xe6,0x0,0x3,0x0,0x0,0x0,0xc,0x7f,0xff,0x3,0xfe,0x0,0x0,0x73,0xc6,0x0,0x3,0x0,0x0,0x0,0x6,0x7f,0xff,0x3,
0xff,0x0,0x0,0x77,0x80,0x0,0x3,0x0,0x0,0x0,0x3,0x3f,0xfe,0x3,0xff,0x80,0x0,0x7f,0x6,0x7f,0xe3,0xf0,0xf0,0xf0,0x1,0x9f,0xfc,0x3,0xff,0xc0,0x0,0x7e,0x6,0xff,0xf3,0xf9,0xf9,0xf8,0x0,0xcf,0xf8,0x3,0xff,0xe0,0x0,0x7c,0x6,0xe7,0x33,0x9b,0x9b,0x9c,0x0,0x67,0xf0,0x3,0xff,0xf0,0x0,0x7e,0x6,0xe3,0x1b,0x1b,0x1b,0xc,0x0,0x33,0xc0,0x3,0xff,0xf8,0x0,0x7f,0x6,0xe3,0x1b,0x1b,0x3,0xc,0x0,0x19,0x0,0x3,0xff,0xfc,0x0,0x73,0x86,0xe3,0x1b,0x3b,0x3,0x8c,0x0,0xc,0x0,0x3,0xff,0xfe,0x0,0x71,0xc6,0xe3,0x1b,0xf3,0x3,0xef,0x0,0x6,0x0,0x7,
0xff,0xff,0x0,0x30,0xe6,0x63,0x19,0xe3,0x1,0xef,0x0,0x2,0x0,0x6,0xff,0xff,0x80,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xe,0xff,0xff,0xc0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1c,0xff,0xff,0xe0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x78,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xc0
};
#else
#define START_BMPWIDTH 56
#define START_BMPHEIGHT 19
#define START_BMPBYTEWIDTH 7
#define START_BMPBYTES 133 // START_BMPWIDTH * START_BMPHEIGHT / 8
};
#else
#define START_BMPWIDTH 56
#define START_BMPHEIGHT 19
#define START_BMPBYTEWIDTH 7
#define START_BMPBYTES 133 // START_BMPWIDTH * START_BMPHEIGHT / 8
const unsigned char start_bmp[START_BMPBYTES] PROGMEM = {
const unsigned char start_bmp[START_BMPBYTES] PROGMEM = {
0x1f,0xff,0xff,0xff,0xff,0xff,0xfc,0x30,0x0,0x0,0x0,0x0,0x0,0x6,0x60,0x0,0x0,0x0,0x0,0x0,0x3,0xc3,0x60,0x5,0x0,0x0,0x8,0x1,0x84,0x90,0x4,0x0,0x0,0x18,0x1,0x84,0x97,0x75,0x70,0x0,0x3c,0x1,0x84,0x95,0x45,0x50,0x0,0x7f,0x1,0x84,0x95,0x45,0x50,0x0,0x1c,0x1,
0x84,0x97,0xc5,0x50,0x1,0x8e,0x1,0x80,0x0,0x0,0x0,0x0,0xff,0x81,0xc0,0x0,0x0,0x10,0x0,0x5f,0xf9,0xe0,0x2,0xd0,0x10,0x0,0x27,0xf1,0xf0,0x3,0x80,0x10,0x0,0x17,0xf1,0xf8,0x3,0x17,0xde,0xee,0xb,0xe1,0xfc,0x3,0x15,0x52,0x8a,0x5,0x81,0xfe,0x3,0x95,0x52,0x8a,0x2,0x1,
0xff,0x2,0xd5,0x5e,0x8f,0x1,0x1,0xff,0x80,0x0,0x0,0x0,0x0,0x3,0xff,0xff,0xff,0xff,0xff,0xff,0xfe
};
#endif
};
#endif
#endif
// Here comes a compile-time operation to match the extruder symbols
......@@ -38,10 +38,10 @@ const unsigned char start_bmp[START_BMPBYTES] PROGMEM = {
// be displayed.
#if HOTENDS == 1
#define STATUS_SCREENWIDTH 115 //Width in pixels
#define STATUS_SCREENHEIGHT 19 //Height in pixels
#define STATUS_SCREENBYTEWIDTH 15 //Width in bytes
const unsigned char status_screen0_bmp[] PROGMEM = { //AVR-GCC, WinAVR
#define STATUS_SCREENWIDTH 115 //Width in pixels
#define STATUS_SCREENHEIGHT 19 //Height in pixels
#define STATUS_SCREENBYTEWIDTH 15 //Width in bytes
const unsigned char status_screen0_bmp[] PROGMEM = { //AVR-GCC, WinAVR
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0xFF, 0xE0,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x00, 0xE0,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x63, 0x0C, 0x60,
......@@ -61,12 +61,12 @@ const unsigned char status_screen0_bmp[] PROGMEM = { //AVR-GCC, WinAVR
0x3F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x00, 0xE0,
0x1E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xFF, 0xFF, 0x80, 0x7F, 0xFF, 0xE0,
0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xFF, 0xFF, 0x80, 0x00, 0x00, 0x00
};
};
#define STATUS_SCREENWIDTH 115 //Width in pixels
#define STATUS_SCREENHEIGHT 19 //Height in pixels
#define STATUS_SCREENBYTEWIDTH 15 //Width in bytes
const unsigned char status_screen1_bmp[] PROGMEM = { //AVR-GCC, WinAVR
#define STATUS_SCREENWIDTH 115 //Width in pixels
#define STATUS_SCREENHEIGHT 19 //Height in pixels
#define STATUS_SCREENBYTEWIDTH 15 //Width in bytes
const unsigned char status_screen1_bmp[] PROGMEM = { //AVR-GCC, WinAVR
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0xFF, 0xE0,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x00, 0xE0,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x61, 0xF8, 0x60,
......@@ -86,12 +86,12 @@ const unsigned char status_screen1_bmp[] PROGMEM = { //AVR-GCC, WinAVR
0x3F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x00, 0xE0,
0x1E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xFF, 0xFF, 0x80, 0x7F, 0xFF, 0xE0,
0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xFF, 0xFF, 0x80, 0x00, 0x00, 0x00
};
};
#elif HOTENDS == 2
#define STATUS_SCREENWIDTH 115 //Width in pixels
#define STATUS_SCREENHEIGHT 19 //Height in pixels
#define STATUS_SCREENBYTEWIDTH 15 //Width in bytes
const unsigned char status_screen0_bmp[] PROGMEM = { //AVR-GCC, WinAVR
#define STATUS_SCREENWIDTH 115 //Width in pixels
#define STATUS_SCREENHEIGHT 19 //Height in pixels
#define STATUS_SCREENBYTEWIDTH 15 //Width in bytes
const unsigned char status_screen0_bmp[] PROGMEM = { //AVR-GCC, WinAVR
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0xFF, 0xE0,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x00, 0xE0,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x63, 0x0C, 0x60,
......@@ -111,12 +111,12 @@ const unsigned char status_screen0_bmp[] PROGMEM = { //AVR-GCC, WinAVR
0x3F, 0x00, 0x00, 0x1F, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x00, 0xE0,
0x1E, 0x00, 0x00, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x01, 0xFF, 0xFF, 0x80, 0x7F, 0xFF, 0xE0,
0x0C, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x01, 0xFF, 0xFF, 0x80, 0x00, 0x00, 0x00
};
};
#define STATUS_SCREENWIDTH 115 //Width in pixels
#define STATUS_SCREENHEIGHT 19 //Height in pixels
#define STATUS_SCREENBYTEWIDTH 15 //Width in bytes
const unsigned char status_screen1_bmp[] PROGMEM = { //AVR-GCC, WinAVR
#define STATUS_SCREENWIDTH 115 //Width in pixels
#define STATUS_SCREENHEIGHT 19 //Height in pixels
#define STATUS_SCREENBYTEWIDTH 15 //Width in bytes
const unsigned char status_screen1_bmp[] PROGMEM = { //AVR-GCC, WinAVR
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0xFF, 0xE0,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x00, 0xE0,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x61, 0xF8, 0x60,
......@@ -136,12 +136,12 @@ const unsigned char status_screen1_bmp[] PROGMEM = { //AVR-GCC, WinAVR
0x3F, 0x00, 0x00, 0x1F, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x00, 0xE0,
0x1E, 0x00, 0x00, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x01, 0xFF, 0xFF, 0x80, 0x7F, 0xFF, 0xE0,
0x0C, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x01, 0xFF, 0xFF, 0x80, 0x00, 0x00, 0x00
};
};
#else
#define STATUS_SCREENWIDTH 115 //Width in pixels
#define STATUS_SCREENHEIGHT 19 //Height in pixels
#define STATUS_SCREENBYTEWIDTH 15 //Width in bytes
const unsigned char status_screen0_bmp[] PROGMEM = { //AVR-GCC, WinAVR
#define STATUS_SCREENWIDTH 115 //Width in pixels
#define STATUS_SCREENHEIGHT 19 //Height in pixels
#define STATUS_SCREENBYTEWIDTH 15 //Width in bytes
const unsigned char status_screen0_bmp[] PROGMEM = { //AVR-GCC, WinAVR
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0xFF, 0xE0,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x00, 0xE0,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x63, 0x0C, 0x60,
......@@ -161,12 +161,12 @@ const unsigned char status_screen0_bmp[] PROGMEM = { //AVR-GCC, WinAVR
0x3F, 0x00, 0x00, 0x1F, 0x80, 0x00, 0x1F, 0x80, 0x00, 0x00, 0x00, 0x00, 0x70, 0x00, 0xE0,
0x1E, 0x00, 0x00, 0x0F, 0x00, 0x00, 0x0F, 0x00, 0x01, 0xFF, 0xFF, 0x80, 0x7F, 0xFF, 0xE0,
0x0C, 0x00, 0x00, 0x06, 0x00, 0x00, 0x06, 0x00, 0x01, 0xFF, 0xFF, 0x80, 0x00, 0x00, 0x00
};
};
#define STATUS_SCREENWIDTH 115 //Width in pixels
#define STATUS_SCREENHEIGHT 19 //Height in pixels
#define STATUS_SCREENBYTEWIDTH 15 //Width in bytes
const unsigned char status_screen1_bmp[] PROGMEM = { //AVR-GCC, WinAVR
#define STATUS_SCREENWIDTH 115 //Width in pixels
#define STATUS_SCREENHEIGHT 19 //Height in pixels
#define STATUS_SCREENBYTEWIDTH 15 //Width in bytes
const unsigned char status_screen1_bmp[] PROGMEM = { //AVR-GCC, WinAVR
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0xFF, 0xE0,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x00, 0xE0,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x61, 0xF8, 0x60,
......@@ -186,5 +186,5 @@ const unsigned char status_screen1_bmp[] PROGMEM = { //AVR-GCC, WinAVR
0x3F, 0x00, 0x00, 0x1F, 0x80, 0x00, 0x1F, 0x80, 0x00, 0x00, 0x00, 0x00, 0x70, 0x00, 0xE0,
0x1E, 0x00, 0x00, 0x0F, 0x00, 0x00, 0x0F, 0x00, 0x01, 0xFF, 0xFF, 0x80, 0x7F, 0xFF, 0xE0,
0x0C, 0x00, 0x00, 0x06, 0x00, 0x00, 0x06, 0x00, 0x01, 0xFF, 0xFF, 0x80, 0x00, 0x00, 0x00
};
#endif // Extruders
};
#endif // Hotends
......@@ -165,7 +165,8 @@ char lcd_print(char c) {
u8g.print(c);
lcd_setFont(currentfont);
return 1;
} else
}
else
return charset_mapper(c);
}
......@@ -173,8 +174,9 @@ char lcd_print(char* str) {
char c;
int i = 0;
char n = 0;
while ((c = str[i++]))
while ((c = str[i++])) {
n += lcd_print(c);
}
return n;
}
......@@ -182,8 +184,9 @@ char lcd_print(char* str) {
char lcd_printPGM(const char* str) {
char c;
char n = 0;
while ((c = pgm_read_byte(str++)))
while ((c = pgm_read_byte(str++))) {
n += lcd_print(c);
}
return n;
}
......@@ -193,55 +196,64 @@ char lcd_printPGM(const char* str) {
/* Warning: This function is called from interrupt context */
static void lcd_implementation_init() {
#if ENABLED(LCD_PIN_BL) // Enable LCD backlight
#if ENABLED(LCD_PIN_BL) && LCD_PIN_BL > -1 // Enable LCD backlight
pinMode(LCD_PIN_BL, OUTPUT);
digitalWrite(LCD_PIN_BL, HIGH);
#endif
#if ENABLED(LCD_PIN_RESET)
#endif
#if ENABLED(LCD_PIN_RESET) && LCD_PIN_RESET > -1
pinMode(LCD_PIN_RESET, OUTPUT);
digitalWrite(LCD_PIN_RESET, HIGH);
#endif
#if DISABLED(MINIPANEL) // setContrast not working for Mini Panel
#endif
#if DISABLED(MINIPANEL) // setContrast not working for Mini Panel
u8g.setContrast(lcd_contrast);
#endif
#endif
// FIXME: remove this workaround
// Uncomment this if you have the first generation (V1.10) of STBs board
// pinMode(17, OUTPUT); // Enable LCD backlight
// digitalWrite(17, HIGH);
#if ENABLED(LCD_SCREEN_ROT_90)
#if ENABLED(LCD_SCREEN_ROT_90)
u8g.setRot90(); // Rotate screen by 90°
#elif ENABLED(LCD_SCREEN_ROT_180)
#elif ENABLED(LCD_SCREEN_ROT_180)
u8g.setRot180(); // Rotate screen by 180°
#elif ENABLED(LCD_SCREEN_ROT_270)
#elif ENABLED(LCD_SCREEN_ROT_270)
u8g.setRot270(); // Rotate screen by 270°
#endif
#if ENABLED(SHOW_BOOTSCREEN)
#endif
#if ENABLED(SHOW_BOOTSCREEN)
int offx = (u8g.getWidth() - START_BMPWIDTH) / 2;
#if ENABLED(START_BMPHIGH)
#if ENABLED(START_BMPHIGH)
int offy = 0;
#else
#else
int offy = DOG_CHAR_HEIGHT;
#endif
#endif
int txt1X = (u8g.getWidth() - (sizeof(STRING_SPLASH_LINE1) - 1) * DOG_CHAR_WIDTH) / 2;
u8g.firstPage();
do {
if (show_bootscreen) {
u8g.drawBitmapP(offx, offy, START_BMPBYTEWIDTH, START_BMPHEIGHT, start_bmp);
lcd_setFont(FONT_MENU);
#if DISABLED(STRING_SPLASH_LINE2)
#if DISABLED(STRING_SPLASH_LINE2)
u8g.drawStr(txt1X, u8g.getHeight() - DOG_CHAR_HEIGHT, STRING_SPLASH_LINE1);
#else
#else
int txt2X = (u8g.getWidth() - (sizeof(STRING_SPLASH_LINE2) - 1) * DOG_CHAR_WIDTH) / 2;
u8g.drawStr(txt1X, u8g.getHeight() - DOG_CHAR_HEIGHT * 3 / 2, STRING_SPLASH_LINE1);
u8g.drawStr(txt2X, u8g.getHeight() - DOG_CHAR_HEIGHT * 1 / 2, STRING_SPLASH_LINE2);
#endif
#endif
}
} while (u8g.nextPage());
if (show_bootscreen) {
delay(SPLASH_SCREEN_DURATION);
show_bootscreen = false;
}
#endif
#endif
}
static void lcd_implementation_clear() { } // Automatically cleared by Picture Loop
......@@ -249,15 +261,18 @@ static void lcd_implementation_clear() { } // Automatically cleared by Picture L
static void _draw_heater_status(int x, int heater) {
bool isBed = heater < 0;
int y = 17 + (isBed ? 1 : 0);
lcd_setFont(FONT_STATUSMENU);
u8g.setPrintPos(x, 7);
lcd_print(itostr3(int((heater >= 0 ? degTargetHotend(heater) : degTargetBed()) + 0.5)));
lcd_printPGM(PSTR(LCD_STR_DEGREE " "));
u8g.setPrintPos(x, 28);
lcd_print(itostr3(int(heater >= 0 ? degHotend(heater) : degBed()) + 0.5));
lcd_printPGM(PSTR(LCD_STR_DEGREE " "));
if (!isHeatingHotend(0))
if (!isHeatingHotend(0)) {
u8g.drawBox(x + 7, y, 2, 2);
}
else {
u8g.setColorIndex(0); // white on black
u8g.drawBox(x + 7, y, 2, 2);
......@@ -267,68 +282,83 @@ static void _draw_heater_status(int x, int heater) {
static void lcd_implementation_status_screen() {
u8g.setColorIndex(1); // black on white
// Symbols menu graphics, animated fan
u8g.drawBitmapP(9, 1, STATUS_SCREENBYTEWIDTH, STATUS_SCREENHEIGHT, (blink % 2) && fanSpeed ? status_screen0_bmp : status_screen1_bmp);
#if ENABLED(SDSUPPORT)
#if ENABLED(SDSUPPORT)
// SD Card Symbol
u8g.drawBox(42, 42 - TALL_FONT_CORRECTION, 8, 7);
u8g.drawBox(50, 44 - TALL_FONT_CORRECTION, 2, 5);
u8g.drawFrame(42, 49 - TALL_FONT_CORRECTION, 10, 4);
u8g.drawPixel(50, 43 - TALL_FONT_CORRECTION);
// Progress bar frame
u8g.drawFrame(54, 49, 73, 4 - TALL_FONT_CORRECTION);
// SD Card Progress bar and clock
lcd_setFont(FONT_STATUSMENU);
if (IS_SD_PRINTING) {
// Progress bar solid part
u8g.drawBox(55, 50, (unsigned int)(71.f * card.percentDone() / 100.f), 2 - TALL_FONT_CORRECTION);
}
u8g.setPrintPos(80, 48);
if (print_job_start_ms != 0) {
#if HAS(LCD_POWER_SENSOR)
#if HAS(LCD_POWER_SENSOR)
if (millis() < print_millis + 1000) {
uint16_t time = (millis() - print_job_start_ms) / 60000;
lcd_print(itostr2(time/60));
lcd_print(':');
lcd_print(itostr2(time%60));
} else {
}
else {
lcd_print(itostr4(power_consumption_hour-startpower));
lcd_print("Wh");
}
#else
#else
uint16_t time = (millis() - print_job_start_ms) / 60000;
lcd_print(itostr2(time / 60));
lcd_print(':');
lcd_print(itostr2(time % 60));
#endif
} else
#endif
}
else {
lcd_printPGM(PSTR("--:--"));
#endif
}
#endif
// Hotends
for (int i = 0; i < HOTENDS; i++) _draw_heater_status(6 + i * 25, i);
// Heatbed
if (HOTENDS < 4) _draw_heater_status(81, -1);
// Fan
lcd_setFont(FONT_STATUSMENU);
u8g.setPrintPos(104, 27);
#if HAS(FAN)
#if HAS(FAN)
int per = ((fanSpeed + 1) * 100) / 256;
if (per) {
lcd_print(itostr3(per));
lcd_print('%');
} else
#endif
}
else
#endif
{
lcd_printPGM(PSTR("---"));
}
// X, Y, Z-Coordinates
#define XYZ_BASELINE 38
#define XYZ_BASELINE 38
lcd_setFont(FONT_STATUSMENU);
#if ENABLED(USE_SMALL_INFOFONT)
#if ENABLED(USE_SMALL_INFOFONT)
u8g.drawBox(0, 30, LCD_PIXEL_WIDTH, 10);
#else
#else
u8g.drawBox(0, 30, LCD_PIXEL_WIDTH, 9);
#endif
#endif
u8g.setColorIndex(0); // white on black
u8g.setPrintPos(2, XYZ_BASELINE);
lcd_print('X');
......@@ -358,6 +388,7 @@ static void lcd_implementation_status_screen() {
else
lcd_printPGM(PSTR("---.--"));
u8g.setColorIndex(1); // black on white
// Feedrate
lcd_setFont(FONT_MENU);
u8g.setPrintPos(3, 49);
......@@ -366,23 +397,23 @@ static void lcd_implementation_status_screen() {
u8g.setPrintPos(12, 49);
lcd_print(itostr3(feedrate_multiplier));
lcd_print('%');
// Status line
lcd_setFont(FONT_STATUSMENU);
#if ENABLED(USE_SMALL_INFOFONT)
#if ENABLED(USE_SMALL_INFOFONT)
u8g.setPrintPos(0, 62);
#else
#else
u8g.setPrintPos(0, 63);
#endif
#if HAS(LCD_FILAMENT_SENSOR) || HAS(LCD_POWER_SENSOR)
#endif
#if HAS(LCD_FILAMENT_SENSOR) || HAS(LCD_POWER_SENSOR)
if (millis() < previous_lcd_status_ms + 5000) //Display both Status message line and Filament display on the last line
lcd_print(lcd_status_message);
}
#if HAS(LCD_POWER_SENSOR)
#if HAS(LCD_FILAMENT_SENSOR)
#if HAS(LCD_POWER_SENSOR)
#if HAS(LCD_FILAMENT_SENSOR)
else if (millis() < previous_lcd_status_ms + 10000)
#else
#else
else
#endif
#endif
{
lcd_printPGM(PSTR("P:"));
lcd_print(ftostr31(power_consumption_meas));
......@@ -390,8 +421,8 @@ static void lcd_implementation_status_screen() {
lcd_print(ltostr7(power_consumption_hour));
lcd_printPGM(PSTR("Wh"));
}
#endif
#if HAS(LCD_FILAMENT_SENSOR)
#endif
#if HAS(LCD_FILAMENT_SENSOR)
else {
lcd_printPGM(PSTR("dia:"));
lcd_print(ftostr12ns(filament_width_meas));
......@@ -399,10 +430,10 @@ static void lcd_implementation_status_screen() {
lcd_print(itostr3(100.0 * volumetric_multiplier[FILAMENT_SENSOR_EXTRUDER_NUM]));
lcd_print('%');
}
#endif
#else
#endif
#else
lcd_print(lcd_status_message);
#endif
#endif
}
static void lcd_implementation_mark_as_selected(uint8_t row, bool isSelected) {
......@@ -410,7 +441,8 @@ static void lcd_implementation_mark_as_selected(uint8_t row, bool isSelected) {
u8g.setColorIndex(1); // black on white
u8g.drawBox(0, row * DOG_CHAR_HEIGHT + 3 - TALL_FONT_CORRECTION, LCD_PIXEL_WIDTH, DOG_CHAR_HEIGHT);
u8g.setColorIndex(0); // following text must be white on black
} else {
}
else {
u8g.setColorIndex(1); // unmarked text is black on white
}
u8g.setPrintPos(START_ROW * DOG_CHAR_WIDTH, (row + 1) * DOG_CHAR_HEIGHT);
......@@ -419,7 +451,9 @@ static void lcd_implementation_mark_as_selected(uint8_t row, bool isSelected) {
static void lcd_implementation_drawmenu_generic(bool isSelected, uint8_t row, const char* pstr, char pre_char, char post_char) {
char c;
uint8_t n = LCD_WIDTH - 2;
lcd_implementation_mark_as_selected(row, isSelected);
while (c = pgm_read_byte(pstr)) {
n -= lcd_print(c);
pstr++;
......@@ -434,7 +468,9 @@ static void _drawmenu_setting_edit_generic(bool isSelected, uint8_t row, const c
char c;
uint8_t vallen = (pgm ? lcd_strlen_P(data) : (lcd_strlen((char*)data)));
uint8_t n = LCD_WIDTH - 2 - vallen;
lcd_implementation_mark_as_selected(row, isSelected);
while (c = pgm_read_byte(pstr)) {
n -= lcd_print(c);
pstr++;
......@@ -473,18 +509,24 @@ void lcd_implementation_drawedit(const char* pstr, char* value) {
uint8_t rows = 1;
uint8_t lcd_width = LCD_WIDTH, char_width = DOG_CHAR_WIDTH;
uint8_t vallen = lcd_strlen(value);
#if ENABLED(USE_BIG_EDIT_FONT)
#if ENABLED(USE_BIG_EDIT_FONT)
if (lcd_strlen_P(pstr) <= LCD_WIDTH_EDIT - 1) {
lcd_setFont(FONT_MENU_EDIT);
lcd_width = LCD_WIDTH_EDIT + 1;
char_width = DOG_CHAR_WIDTH_EDIT;
if (lcd_strlen_P(pstr) >= LCD_WIDTH_EDIT - vallen) rows = 2;
} else
}
else {
lcd_setFont(FONT_MENU);
#endif
}
#endif
if (lcd_strlen_P(pstr) > LCD_WIDTH - 2 - vallen) rows = 2;
const float kHalfChar = DOG_CHAR_HEIGHT_EDIT / 2;
float rowHeight = u8g.getHeight() / (rows + 1); // 1/(rows+1) = 1/2 or 1/3
u8g.setPrintPos(0, rowHeight + kHalfChar);
lcd_printPGM(pstr);
lcd_print(':');
......@@ -494,24 +536,27 @@ void lcd_implementation_drawedit(const char* pstr, char* value) {
#if ENABLED(SDSUPPORT)
static void _drawmenu_sd(bool isSelected, uint8_t row, const char* pstr, const char* filename, char* const longFilename, bool isDir) {
static void _drawmenu_sd(bool isSelected, uint8_t row, const char* pstr, const char* filename, char* const longFilename, bool isDir) {
char c;
uint8_t n = LCD_WIDTH - 1;
if (longFilename[0]) {
filename = longFilename;
longFilename[n] = '\0';
}
lcd_implementation_mark_as_selected(row, isSelected);
if (isDir) lcd_print(LCD_STR_FOLDER[0]);
while ((c = *filename)) {
n -= lcd_print(c);
filename++;
}
while (n--) lcd_print(' ');
}
}
#define lcd_implementation_drawmenu_sdfile(sel, row, pstr, filename, longFilename) _drawmenu_sd(sel, row, pstr, filename, longFilename, false)
#define lcd_implementation_drawmenu_sddirectory(sel, row, pstr, filename, longFilename) _drawmenu_sd(sel, row, pstr, filename, longFilename, true)
#define lcd_implementation_drawmenu_sdfile(sel, row, pstr, filename, longFilename) _drawmenu_sd(sel, row, pstr, filename, longFilename, false)
#define lcd_implementation_drawmenu_sddirectory(sel, row, pstr, filename, longFilename) _drawmenu_sd(sel, row, pstr, filename, longFilename, true)
#endif //SDSUPPORT
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -32,7 +32,7 @@ void FirmwareTest() {
ECHO_EM(" ");
ECHO_EM("***** ENDSTOP X *****");
#if PIN_EXISTS(X_MIN_PIN) && (X_HOME_DIR == -1)
#if PIN_EXISTS(X_MIN) && (X_HOME_DIR == -1)
if (!READ(X_MIN_PIN)^X_MIN_ENDSTOP_INVERTING) {
ECHO_M("MIN ENDSTOP X: ");
ECHO_EV(MSG_ENDSTOP_OPEN);
......@@ -72,7 +72,7 @@ void FirmwareTest() {
ECHO_EV(MSG_FWTEST_ENDSTOP_ERR);
return;
}
#elif PIN_EXISTS(X_MAX_PIN) && X_HOME_DIR == 1
#elif PIN_EXISTS(X_MAX) && X_HOME_DIR == 1
if (!READ(X_MAX_PIN)^X_MAX_ENDSTOP_INVERTING) {
ECHO_M("MAX ENDSTOP X: ");
ECHO_EV(MSG_ENDSTOP_OPEN);
......@@ -126,7 +126,7 @@ void FirmwareTest() {
ECHO_EM(" ");
ECHO_EM("***** ENDSTOP Y *****");
#if PIN_EXISTS(Y_MIN_PIN) && Y_HOME_DIR == -1
#if PIN_EXISTS(Y_MIN) && Y_HOME_DIR == -1
if (!READ(Y_MIN_PIN)^Y_MIN_ENDSTOP_INVERTING) {
ECHO_M("MIN ENDSTOP Y: ");
ECHO_EV(MSG_ENDSTOP_OPEN);
......@@ -166,7 +166,7 @@ void FirmwareTest() {
ECHO_EV(MSG_FWTEST_ENDSTOP_ERR);
return;
}
#elif PIN_EXISTS(Y_MAX_PIN) && Y_HOME_DIR == 1
#elif PIN_EXISTS(Y_MAX) && Y_HOME_DIR == 1
if (!READ(Y_MAX_PIN)^Y_MAX_ENDSTOP_INVERTING) {
ECHO_M("MAX ENDSTOP Y: ");
ECHO_EV(MSG_ENDSTOP_OPEN);
......@@ -220,7 +220,7 @@ void FirmwareTest() {
ECHO_EM(" ");
ECHO_EM("***** ENDSTOP Z *****");
#if PIN_EXISTS(Z_MIN_PIN) && Z_HOME_DIR == -1
#if PIN_EXISTS(Z_MIN) && Z_HOME_DIR == -1
if (!READ(Z_MIN_PIN)^Z_MIN_ENDSTOP_INVERTING) {
ECHO_M("MIN ENDSTOP Z: ");
ECHO_EV(MSG_ENDSTOP_OPEN);
......@@ -260,7 +260,7 @@ void FirmwareTest() {
ECHO_EV(MSG_FWTEST_ENDSTOP_ERR);
return;
}
#elif PIN_EXISTS(Z_MAX_PIN) && Z_HOME_DIR == 1
#elif PIN_EXISTS(Z_MAX) && Z_HOME_DIR == 1
if (!READ(Z_MAX_PIN)^Z_MAX_ENDSTOP_INVERTING) {
ECHO_M("MAX ENDSTOP Z: ");
ECHO_EV(MSG_ENDSTOP_OPEN);
......
......@@ -104,7 +104,7 @@
#define MSG_TEMPERATURE "Temperatura"
#define MSG_MOTION "Movimento"
#define MSG_FILAMENT "Filamento"
#define MSG_VOLUMETRIC_ENABLED "E in mm3"
#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"
......
......@@ -110,7 +110,7 @@ long position[NUM_AXIS]; // Rescaled from extern when axis_steps_p
static float previous_speed[NUM_AXIS]; // Speed of previous path line segment
static float previous_nominal_speed; // Nominal speed of previous path line segment
unsigned char g_uc_extruder_last_move[4] = {0,0,0,0};
uint8_t g_uc_extruder_last_move[EXTRUDERS] = { 0 };
#if ENABLED(XY_FREQUENCY_LIMIT)
// Used for the frequency limit
......@@ -118,13 +118,17 @@ unsigned char g_uc_extruder_last_move[4] = {0,0,0,0};
// Old direction bits. Used for speed calculations
static unsigned char old_direction_bits = 0;
// Segment times (in µs). Used for speed calculations
static long axis_segment_time[2][3] = { {MAX_FREQ_TIME+1,0,0}, {MAX_FREQ_TIME+1,0,0} };
static long axis_segment_time[2][3] = { {MAX_FREQ_TIME + 1, 0, 0}, {MAX_FREQ_TIME + 1, 0, 0} };
#endif
#if ENABLED(FILAMENT_SENSOR)
static char meas_sample; //temporary variable to hold filament measurement sample
#endif
#if ENABLED(DUAL_X_CARRIAGE)
extern bool extruder_duplication_enabled;
#endif
//===========================================================================
//================================ functions ================================
//===========================================================================
......@@ -153,7 +157,7 @@ FORCE_INLINE float intersection_distance(float initial_rate, float final_rate, f
// Calculates trapezoid parameters so that the entry- and exit-speed is compensated by the provided factors.
void calculate_trapezoid_for_block(block_t *block, float entry_factor, float exit_factor) {
void calculate_trapezoid_for_block(block_t* block, float entry_factor, float exit_factor) {
unsigned long initial_rate = ceil(block->nominal_rate * entry_factor); // (step/min)
unsigned long final_rate = ceil(block->nominal_rate * exit_factor); // (step/min)
......@@ -178,17 +182,17 @@ void calculate_trapezoid_for_block(block_t *block, float entry_factor, float exi
plateau_steps = 0;
}
#if ENABLED(ADVANCE)
#if ENABLED(ADVANCE)
volatile long initial_advance = block->advance * entry_factor * entry_factor;
volatile long final_advance = block->advance * exit_factor * exit_factor;
#endif // ADVANCE
#endif // ADVANCE
// block->accelerate_until = accelerate_steps;
// block->decelerate_after = accelerate_steps+plateau_steps;
CRITICAL_SECTION_START; // Fill variables used by the stepper in a critical section
if (!block->busy) { // Don't update variables if block is busy.
block->accelerate_until = accelerate_steps;
block->decelerate_after = accelerate_steps+plateau_steps;
block->decelerate_after = accelerate_steps + plateau_steps;
block->initial_rate = initial_rate;
block->final_rate = final_rate;
#if ENABLED(ADVANCE)
......@@ -215,23 +219,25 @@ FORCE_INLINE float max_allowable_speed(float acceleration, float target_velocity
// The kernel called by planner_recalculate() when scanning the plan from last to first entry.
void planner_reverse_pass_kernel(block_t *previous, block_t *current, block_t *next) {
void planner_reverse_pass_kernel(block_t* previous, block_t* current, block_t* next) {
if (!current) return;
UNUSED(previous);
if (next) {
// If entry speed is already at the maximum entry speed, no need to recheck. Block is cruising.
// If not, block in state of acceleration or deceleration. Reset entry speed to maximum and
// check for maximum allowable speed reductions to ensure maximum possible planned speed.
if (current->entry_speed != current->max_entry_speed) {
float max_entry_speed = current->max_entry_speed;
if (current->entry_speed != max_entry_speed) {
// If nominal length true, max junction speed is guaranteed to be reached. Only compute
// for max allowable speed if block is decelerating and nominal length is false.
if (!current->nominal_length_flag && current->max_entry_speed > next->entry_speed) {
current->entry_speed = min(current->max_entry_speed,
if (!current->nominal_length_flag && max_entry_speed > next->entry_speed) {
current->entry_speed = min(max_entry_speed,
max_allowable_speed(-current->acceleration, next->entry_speed, current->millimeters));
}
else {
current->entry_speed = current->max_entry_speed;
current->entry_speed = max_entry_speed;
}
current->recalculate_flag = true;
......@@ -251,11 +257,11 @@ void planner_reverse_pass() {
if (BLOCK_MOD(block_buffer_head - tail + BLOCK_BUFFER_SIZE) > 3) { // moves queued
block_index = BLOCK_MOD(block_buffer_head - 3);
block_t *block[3] = { NULL, NULL, NULL };
block_t* block[3] = { NULL, NULL, NULL };
while (block_index != tail) {
block_index = prev_block_index(block_index);
block[2]= block[1];
block[1]= block[0];
block[2] = block[1];
block[1] = block[0];
block[0] = &block_buffer[block_index];
planner_reverse_pass_kernel(block[0], block[1], block[2]);
}
......@@ -263,8 +269,9 @@ void planner_reverse_pass() {
}
// The kernel called by planner_recalculate() when scanning the plan from first to last entry.
void planner_forward_pass_kernel(block_t *previous, block_t *current, block_t *next) {
void planner_forward_pass_kernel(block_t* previous, block_t* current, block_t* next) {
if (!previous) return;
UNUSED(next);
// If the previous block is an acceleration block, but it is not long enough to complete the
// full speed change within the block, we need to adjust the entry speed accordingly. Entry
......@@ -274,7 +281,6 @@ void planner_forward_pass_kernel(block_t *previous, block_t *current, block_t *n
if (previous->entry_speed < current->entry_speed) {
double entry_speed = min(current->entry_speed,
max_allowable_speed(-previous->acceleration, previous->entry_speed, previous->millimeters));
// Check for junction speed change
if (current->entry_speed != entry_speed) {
current->entry_speed = entry_speed;
......@@ -288,7 +294,7 @@ void planner_forward_pass_kernel(block_t *previous, block_t *current, block_t *n
// implements the forward pass.
void planner_forward_pass() {
uint8_t block_index = block_buffer_tail;
block_t *block[3] = { NULL, NULL, NULL };
block_t* block[3] = { NULL, NULL, NULL };
while (block_index != block_buffer_head) {
block[0] = block[1];
......@@ -305,8 +311,8 @@ void planner_forward_pass() {
// updating the blocks.
void planner_recalculate_trapezoids() {
int8_t block_index = block_buffer_tail;
block_t *current;
block_t *next = NULL;
block_t* current;
block_t* next = NULL;
while (block_index != block_buffer_head) {
current = next;
......@@ -320,7 +326,7 @@ void planner_recalculate_trapezoids() {
current->recalculate_flag = false; // Reset current only to ensure next trapezoid is computed
}
}
block_index = next_block_index( block_index );
block_index = next_block_index(block_index);
}
// Last/newest block in buffer. Exit speed is set with MINIMUM_PLANNER_SPEED. Always recalculated.
if (next) {
......@@ -356,7 +362,7 @@ void planner_recalculate() {
void plan_init() {
block_buffer_head = block_buffer_tail = 0;
memset(position, 0, sizeof(position)); // clear position
for (int i=0; i<NUM_AXIS; i++) previous_speed[i] = 0.0;
for (int i = 0; i < NUM_AXIS; i++) previous_speed[i] = 0.0;
previous_nominal_speed = 0.0;
}
......@@ -372,7 +378,7 @@ void plan_init() {
uint8_t block_index = block_buffer_tail;
while (block_index != block_buffer_head) {
block_t *block = &block_buffer[block_index];
block_t* block = &block_buffer[block_index];
if (block->steps[X_AXIS] || block->steps[Y_AXIS] || block->steps[Z_AXIS]) {
float se = (float)block->steps[E_AXIS] / block->step_event_count * block->nominal_speed; // mm/sec;
if (se > high) high = se;
......@@ -389,7 +395,7 @@ void plan_init() {
oldt = t;
setTargetHotend0(t);
}
#endif
#endif //AUTOTEMP
void check_axes_activity() {
unsigned char axis_active[NUM_AXIS] = { 0 },
......@@ -401,7 +407,7 @@ void check_axes_activity() {
#if ENABLED(LASERBEAM)
unsigned char tail_laser_ttl_modulation = laser_ttl_modulation;
#endif
block_t *block;
block_t* block;
if (blocks_queued()) {
uint8_t block_index = block_buffer_tail;
......@@ -417,7 +423,7 @@ void check_axes_activity() {
while (block_index != block_buffer_head) {
block = &block_buffer[block_index];
for (int i=0; i<NUM_AXIS; i++) if (block->steps[i]) axis_active[i]++;
for (int i = 0; i < NUM_AXIS; i++) if (block->steps[i]) axis_active[i]++;
block_index = next_block_index(block_index);
}
}
......@@ -440,10 +446,12 @@ void check_axes_activity() {
// Just starting up fan - run at full power.
fan_kick_end = ms + FAN_KICKSTART_TIME;
tail_fan_speed = 255;
} else if (fan_kick_end > ms)
}
else if (fan_kick_end > ms)
// Fan still spinning up.
tail_fan_speed = 255;
} else {
}
else {
fan_kick_end = 0;
}
#endif //FAN_KICKSTART_TIME
......@@ -465,10 +473,10 @@ void check_axes_activity() {
#if ENABLED(BARICUDA)
#if HAS(HEATER_1)
analogWrite(HEATER_1_PIN,tail_valve_pressure);
analogWrite(HEATER_1_PIN, tail_valve_pressure);
#endif
#if HAS(HEATER_2)
analogWrite(HEATER_2_PIN,tail_e_to_p_pressure);
analogWrite(HEATER_2_PIN, tail_e_to_p_pressure);
#endif
#endif
......@@ -484,9 +492,9 @@ float junction_deviation = 0.1;
// mm. Microseconds specify how many microseconds the move should take to perform. To aid acceleration
// calculation the caller must also provide the physical length of the line in millimeters.
#if ENABLED(AUTO_BED_LEVELING_FEATURE)
void plan_buffer_line(float x, float y, float z, const float &e, float feed_rate, const uint8_t &extruder, const uint8_t &driver)
void plan_buffer_line(float x, float y, float z, const float& e, float feed_rate, const uint8_t extruder, const uint8_t driver)
#else
void plan_buffer_line(const float &x, const float &y, const float &z, const float &e, float feed_rate, const uint8_t &extruder, const uint8_t &driver)
void plan_buffer_line(const float& x, const float& y, const float& z, const float& e, float feed_rate, const uint8_t extruder, const uint8_t driver)
#endif // AUTO_BED_LEVELING_FEATURE
{
// Calculate the buffer head after we push this byte
......@@ -563,7 +571,7 @@ float junction_deviation = 0.1;
#endif // PREVENT_DANGEROUS_EXTRUDE
// Prepare to set up new block
block_t *block = &block_buffer[block_buffer_head];
block_t* block = &block_buffer[block_buffer_head];
// Mark block as not busy (Not executed by the stepper interrupt)
block->busy = false;
......@@ -933,9 +941,9 @@ float junction_deviation = 0.1;
// Compute path unit vector
double unit_vec[3];
unit_vec[X_AXIS] = delta_mm[X_AXIS]*inverse_millimeters;
unit_vec[Y_AXIS] = delta_mm[Y_AXIS]*inverse_millimeters;
unit_vec[Z_AXIS] = delta_mm[Z_AXIS]*inverse_millimeters;
unit_vec[X_AXIS] = delta_mm[X_AXIS] * inverse_millimeters;
unit_vec[Y_AXIS] = delta_mm[Y_AXIS] * inverse_millimeters;
unit_vec[Z_AXIS] = delta_mm[Z_AXIS] * inverse_millimeters;
// Compute maximum allowable entry speed at junction by centripetal acceleration approximation.
// Let a circle be tangent to both previous and current path line segments, where the junction
......@@ -955,16 +963,15 @@ float junction_deviation = 0.1;
double cos_theta = - previous_unit_vec[X_AXIS] * unit_vec[X_AXIS]
- previous_unit_vec[Y_AXIS] * unit_vec[Y_AXIS]
- previous_unit_vec[Z_AXIS] * unit_vec[Z_AXIS] ;
// Skip and use default max junction speed for 0 degree acute junction.
if (cos_theta < 0.95) {
vmax_junction = min(previous_nominal_speed,block->nominal_speed);
vmax_junction = min(previous_nominal_speed, block->nominal_speed);
// Skip and avoid divide by zero for straight junctions at 180 degrees. Limit to min() of nominal speeds.
if (cos_theta > -0.95) {
// Compute maximum junction velocity based on maximum acceleration and junction deviation
double sin_theta_d2 = sqrt(0.5*(1.0-cos_theta)); // Trig half angle identity. Always positive.
double sin_theta_d2 = sqrt(0.5 * (1.0 - cos_theta)); // Trig half angle identity. Always positive.
vmax_junction = min(vmax_junction,
sqrt(block->acceleration * junction_deviation * sin_theta_d2/(1.0-sin_theta_d2)) );
sqrt(block->acceleration * junction_deviation * sin_theta_d2 / (1.0 - sin_theta_d2)));
}
}
}
......@@ -1065,9 +1072,9 @@ float junction_deviation = 0.1;
#endif // AUTO_BED_LEVELING_FEATURE
#if ENABLED(AUTO_BED_LEVELING_FEATURE)
void plan_set_position(float x, float y, float z, const float &e)
void plan_set_position(float x, float y, float z, const float& e)
#else
void plan_set_position(const float &x, const float &y, const float &z, const float &e)
void plan_set_position(const float& x, const float& y, const float& z, const float& e)
#endif // AUTO_BED_LEVELING_FEATURE
{
#if ENABLED(AUTO_BED_LEVELING_FEATURE)
......@@ -1085,7 +1092,7 @@ float junction_deviation = 0.1;
for (int i = 0; i < NUM_AXIS; i++) previous_speed[i] = 0.0;
}
void plan_set_e_position(const float &e) {
void plan_set_e_position(const float& e) {
position[E_AXIS] = lround(e * axis_steps_per_unit[E_AXIS + active_extruder]);
last_extruder = active_extruder;
st_set_e_position(position[E_AXIS]);
......
......@@ -26,7 +26,7 @@
// This struct is used when buffering the setup for each linear movement "nominal" values are as specified in
// the source g-code and may never actually be reached if acceleration management is active.
struct beffering{
typedef struct {
// Fields used by the bresenham algorithm for tracing the line
long steps[NUM_AXIS]; // Step count along each axis
unsigned long step_event_count; // The number of step events required to complete this block
......@@ -66,8 +66,8 @@ struct beffering{
unsigned long laser_ttlmodulation;
#endif
volatile char busy;
};
typedef struct beffering block_t;
} block_t;
#define BLOCK_MOD(n) ((n)&(BLOCK_BUFFER_SIZE-1))
// Initialize the motion plan subsystem
......@@ -96,37 +96,39 @@ FORCE_INLINE uint8_t movesplanned() { return BLOCK_MOD(block_buffer_head - block
* Add a new linear movement to the buffer. x, y, z are the signed, absolute target position in
* millimeters. Feed rate specifies the (target) speed of the motion.
*/
void plan_buffer_line(float x, float y, float z, const float &e, float feed_rate, const uint8_t &extruder, const uint8_t &driver);
void plan_buffer_line(float x, float y, float z, const float& e, float feed_rate, const uint8_t extruder, const uint8_t driver);
/**
* Set the planner positions. Used for G92 instructions.
* Multiplies by axis_steps_per_unit[] to set stepper positions.
* Clears previous speed values.
*/
void plan_set_position(float x, float y, float z, const float &e);
void plan_set_position(float x, float y, float z, const float& e);
#else
void plan_buffer_line(const float &x, const float &y, const float &z, const float &e, float feed_rate, const uint8_t &extruder, const uint8_t &driver);
void plan_set_position(const float &x, const float &y, const float &z, const float &e);
void plan_buffer_line(const float& x, const float& y, const float& z, const float& e, float feed_rate, const uint8_t extruder, const uint8_t driver);
void plan_set_position(const float& x, const float& y, const float& z, const float& e);
#endif // AUTO_BED_LEVELING_FEATURE
void plan_set_e_position(const float &e);
void plan_set_e_position(const float& e);
//===========================================================================
//============================= public variables ============================
//===========================================================================
extern millis_t minsegmenttime;
extern float max_feedrate[3 + EXTRUDERS]; // set the max speeds
extern float max_feedrate[3 + EXTRUDERS]; // Max speeds in mm per minute
extern float axis_steps_per_unit[3 + EXTRUDERS];
extern unsigned long max_acceleration_units_per_sq_second[3 + EXTRUDERS]; // Use M201 to override by software
extern float minimumfeedrate;
extern float acceleration; // Normal acceleration mm/s^2 THIS IS THE DEFAULT ACCELERATION for all moves. M204 SXXXX
extern float retract_acceleration[EXTRUDERS]; // mm/s^2 filament pull-pack and push-forward while standing still in the other axis M204 TXXXX
extern float travel_acceleration; // Travel acceleration mm/s^2 THIS IS THE DEFAULT ACCELERATION for all NON printing moves. M204 MXXXX
extern float max_xy_jerk; //speed than can be stopped at once, if i understand correctly.
extern float acceleration; // Normal acceleration mm/s^2 DEFAULT ACCELERATION for all moves. M204 SXXXX
extern float retract_acceleration[EXTRUDERS]; // Retract acceleration mm/s^2 filament pull-back and push-forward while standing still in the other axis M204 TXXXX
extern float travel_acceleration; // Travel acceleration mm/s^2 DEFAULT ACCELERATION for all NON printing moves. M204 MXXXX
extern float max_xy_jerk; // The largest speed change requiring no acceleration
extern float max_z_jerk;
extern float max_e_jerk[EXTRUDERS]; // mm/s - initial speed for extruder retract moves
extern float max_e_jerk[EXTRUDERS];
extern float mintravelfeedrate;
extern unsigned long axis_steps_per_sqr_second[3 + EXTRUDERS];
......@@ -152,9 +154,9 @@ FORCE_INLINE void plan_discard_current_block() {
}
// Gets the current block. Returns NULL if buffer empty
FORCE_INLINE block_t *plan_get_current_block() {
FORCE_INLINE block_t* plan_get_current_block() {
if (blocks_queued()) {
block_t *block = &block_buffer[block_buffer_tail];
block_t* block = &block_buffer[block_buffer_tail];
block->busy = true;
return block;
}
......
......@@ -80,20 +80,20 @@ volatile static unsigned long step_events_completed; // The number of step event
static long acceleration_time, deceleration_time;
//static unsigned long accelerate_until, decelerate_after, acceleration_rate, initial_rate, final_rate, nominal_rate;
static unsigned short acc_step_rate; // needed for deceleration start point
static char step_loops;
static uint8_t step_loops;
static uint8_t step_loops_nominal;
static unsigned short OCR1A_nominal;
static unsigned short step_loops_nominal;
volatile long endstops_trigsteps[3] = { 0 };
volatile long endstops_stepsTotal, endstops_stepsDone;
static volatile char endstop_hit_bits = 0; // use X_MIN, Y_MIN, Z_MIN and Z_PROBE as BIT value
#if DISABLED(Z_DUAL_ENDSTOPS)
static byte
#else
#if ENABLED(Z_DUAL_ENDSTOPS) || ENABLED(NPR2)
static uint16_t
#else
static byte
#endif
old_endstop_bits = 0; // use X_MIN, X_MAX... Z_MAX, Z_PROBE, Z2_MIN, Z2_MAX
old_endstop_bits = 0; // use X_MIN, X_MAX... Z_MAX, Z_PROBE, Z2_MIN, Z2_MAX, E_MIN
#if ENABLED(ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED)
bool abort_on_endstop_hit = false;
......@@ -315,7 +315,7 @@ void enable_endstops(bool check) {
// Check endstops
inline void update_endstops() {
#if ENABLED(Z_DUAL_ENDSTOPS)
#if ENABLED(Z_DUAL_ENDSTOPS) || ENABLED(NPR2)
uint16_t
#else
byte
......@@ -478,6 +478,9 @@ inline void update_endstops() {
#if MECH(COREXZ)
}
#endif
#if ENABLED(NPR2)
UPDATE_ENDSTOP(E, MIN);
#endif
old_endstop_bits = current_endstop_bits;
}
......@@ -504,7 +507,8 @@ void st_wake_up() {
FORCE_INLINE unsigned short calc_timer(unsigned short step_rate) {
unsigned short timer;
if (step_rate > MAX_STEP_FREQUENCY) step_rate = MAX_STEP_FREQUENCY;
NOMORE(step_rate, MAX_STEP_FREQUENCY);
if(step_rate > (2 * DOUBLE_STEP_FREQUENCY)) { // If steprate > 2*DOUBLE_STEP_FREQUENCY >> step 4 times
step_rate = (step_rate >> 2) & 0x3fff;
......@@ -518,8 +522,8 @@ FORCE_INLINE unsigned short calc_timer(unsigned short step_rate) {
step_loops = 1;
}
if (step_rate < (F_CPU / 500000)) step_rate = (F_CPU / 500000);
step_rate -= (F_CPU / 500000); // Correct for minimal speed
NOLESS(step_rate, F_CPU / 500000);
step_rate -= F_CPU / 500000; // Correct for minimal speed
if (step_rate >= (8 * 256)) { // higher step rate
unsigned short table_address = (unsigned short)&speed_lookuptable_fast[(unsigned char)(step_rate >> 8)][0];
unsigned char tmp_step_rate = (step_rate & 0x00ff);
......@@ -738,8 +742,7 @@ ISR(TIMER1_COMPA_vect) {
acc_step_rate += current_block->initial_rate;
// upper limit
if (acc_step_rate > current_block->nominal_rate)
acc_step_rate = current_block->nominal_rate;
NOMORE(acc_step_rate, current_block->nominal_rate);
// step_rate to timer interval
timer = calc_timer(acc_step_rate);
......@@ -748,10 +751,9 @@ ISR(TIMER1_COMPA_vect) {
#if ENABLED(ADVANCE)
for (int8_t i = 0; i < step_loops; i++) {
advance += advance_rate;
}
// if (advance > current_block->advance) advance = current_block->advance;
advance += advance_rate * step_loops;
//NOLESS(advance, current_block->advance);
// Do E steps + advance steps
e_steps[current_block->active_driver] += ((advance >> 8) - old_advance);
old_advance = advance >> 8;
......@@ -761,29 +763,26 @@ ISR(TIMER1_COMPA_vect) {
else if (step_events_completed > (unsigned long)current_block->decelerate_after) {
MultiU24X32toH16(step_rate, deceleration_time, current_block->acceleration_rate);
if (step_rate > acc_step_rate) { // Check step_rate stays positive
step_rate = current_block->final_rate;
}
else {
step_rate = acc_step_rate - step_rate; // Decelerate from acceleration end point.
if (step_rate <= acc_step_rate) { // Still decelerating?
step_rate = acc_step_rate - step_rate;
NOLESS(step_rate, current_block->final_rate);
}
// lower limit
if (step_rate < current_block->final_rate)
else
step_rate = current_block->final_rate;
// step_rate to timer interval
timer = calc_timer(step_rate);
OCR1A = timer;
deceleration_time += timer;
#if ENABLED(ADVANCE)
for (int8_t i = 0; i < step_loops; i++) {
advance -= advance_rate;
}
if (advance < final_advance) advance = final_advance;
advance -= advance_rate * step_loops;
NOLESS(advance, final_advance);
// Do E steps + advance steps
e_steps[current_block->active_driver] += ((advance >> 8) - old_advance);
old_advance = advance >> 8;
uint32_t advance_whole = advance >> 8;
e_steps[current_block->active_driver] += advance_whole - old_advance;
old_advance = advance_whole;
#endif //ADVANCE
}
else {
......@@ -996,28 +995,28 @@ void st_init() {
#if HAS(X_MIN)
SET_INPUT(X_MIN_PIN);
#if ENABLED(ENDSTOPPULLUP_XMIN)
WRITE(X_MIN_PIN,HIGH);
WRITE(X_MIN_PIN, HIGH);
#endif
#endif
#if HAS(Y_MIN)
SET_INPUT(Y_MIN_PIN);
#if ENABLED(ENDSTOPPULLUP_YMIN)
WRITE(Y_MIN_PIN,HIGH);
WRITE(Y_MIN_PIN, HIGH);
#endif
#endif
#if HAS(Z_MIN)
SET_INPUT(Z_MIN_PIN);
#if ENABLED(ENDSTOPPULLUP_ZMIN)
WRITE(Z_MIN_PIN,HIGH);
WRITE(Z_MIN_PIN, HIGH);
#endif
#endif
#if HAS(Z2_MIN)
SET_INPUT(Z2_MIN_PIN);
#if ENABLED(ENDSTOPPULLUP_Z2MIN)
WRITE(Z2_MIN_PIN,HIGH);
WRITE(Z2_MIN_PIN, HIGH);
#endif
#endif
......@@ -1031,35 +1030,35 @@ void st_init() {
#if HAS(X_MAX)
SET_INPUT(X_MAX_PIN);
#if ENABLED(ENDSTOPPULLUP_XMAX)
WRITE(X_MAX_PIN,HIGH);
WRITE(X_MAX_PIN, HIGH);
#endif
#endif
#if HAS(Y_MAX)
SET_INPUT(Y_MAX_PIN);
#if ENABLED(ENDSTOPPULLUP_YMAX)
WRITE(Y_MAX_PIN,HIGH);
WRITE(Y_MAX_PIN, HIGH);
#endif
#endif
#if HAS(Z_MAX)
SET_INPUT(Z_MAX_PIN);
#if ENABLED(ENDSTOPPULLUP_ZMAX)
WRITE(Z_MAX_PIN,HIGH);
WRITE(Z_MAX_PIN, HIGH);
#endif
#endif
#if HAS(Z2_MAX)
SET_INPUT(Z2_MAX_PIN);
#if ENABLED(ENDSTOPPULLUP_Z2MAX)
WRITE(Z2_MAX_PIN,HIGH);
WRITE(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);
WRITE(Z_PROBE_PIN, HIGH);
#endif
#endif
......
......@@ -32,7 +32,7 @@
*/
enum AxisEnum {X_AXIS=0, A_AXIS=0, Y_AXIS=1, B_AXIS=1, Z_AXIS=2, C_AXIS=2, E_AXIS=3, X_HEAD=4, Y_HEAD=5, Z_HEAD=5};
enum EndstopEnum {X_MIN=0, Y_MIN=1, Z_MIN=2, Z_PROBE=3, X_MAX=4, Y_MAX=5, Z_MAX=6, Z2_MIN=7, Z2_MAX=8};
enum EndstopEnum {X_MIN=0, Y_MIN=1, Z_MIN=2, Z_PROBE=3, X_MAX=4, Y_MAX=5, Z_MAX=6, Z2_MIN=7, Z2_MAX=8, E_MIN=9};
#if DRIVER_EXTRUDERS > 3
#define E_STEP_WRITE(v) { if(current_block->active_driver == 3) { E3_STEP_WRITE(v); } else { if(current_block->active_driver == 2) { E2_STEP_WRITE(v); } else { if(current_block->active_driver == 1) { E1_STEP_WRITE(v); } else { E0_STEP_WRITE(v); }}}}
......@@ -116,11 +116,11 @@ void microstep_readings();
#endif
#if ENABLED(BABYSTEPPING)
void babystep(const uint8_t axis,const bool direction); // perform a short step with a single stepper motor, outside of any convention
void babystep(const uint8_t axis, const bool direction); // perform a short step with a single stepper motor, outside of any convention
#endif
#if ENABLED(NPR2) // Multiextruder
void colorstep(long csteps,const bool direction);
void colorstep(long csteps, const bool direction);
#endif
#endif // STEPPER_H
......@@ -71,11 +71,11 @@ const short temptable_1[][2] PROGMEM = {
#endif
#if (THERMISTORHEATER_0 == 2) || (THERMISTORHEATER_1 == 2) || (THERMISTORHEATER_2 == 2) || (THERMISTORHEATER_3 == 2) || (THERMISTORBED == 2) //200k bed thermistor
const short temptable_2[][2] PROGMEM = {
//200k ATC Semitec 204GT-2
//Verified by linagee. Source: http://shop.arcol.hu/static/datasheets/thermistors.pdf
// Calculated using 4.7kohm pullup, voltage divider math, and manufacturer provided temp/resistance
//200k ATC Semitec 204GT-2
//Verified by linagee. Source: http://shop.arcol.hu/static/datasheets/thermistors.pdf
// Calculated using 4.7kohm pullup, voltage divider math, and manufacturer provided temp/resistance
{1 * OVERSAMPLENR, 848},
{30 * OVERSAMPLENR, 300}, // top rating 300C
{30 * OVERSAMPLENR, 300}, //top rating 300C
{34 * OVERSAMPLENR, 290},
{39 * OVERSAMPLENR, 280},
{46 * OVERSAMPLENR, 270},
......@@ -105,7 +105,7 @@ const short temptable_2[][2] PROGMEM = {
{993 * OVERSAMPLENR, 30},
{1004 * OVERSAMPLENR, 20},
{1012 * OVERSAMPLENR, 10},
{1016 * OVERSAMPLENR, 0}
{1016 * OVERSAMPLENR, 0},
};
#endif
......@@ -166,14 +166,13 @@ const short temptable_4[][2] PROGMEM = {
{1008 * OVERSAMPLENR, -35}
};
#endif
#if (THERMISTORHEATER_0 == 5) || (THERMISTORHEATER_1 == 5) || (THERMISTORHEATER_2 == 5) || (THERMISTORHEATER_3 == 5) || (THERMISTORBED == 5) //100k ParCan thermistor (104GT-2)
const short temptable_5[][2] PROGMEM = {
// ATC Semitec 104GT-2 (Used in ParCan)
// Verified by linagee. Source: http://shop.arcol.hu/static/datasheets/thermistors.pdf
// Calculated using 4.7kohm pullup,voltage divider math,and manufacturer provided temp/resistance
// ATC Semitec 104GT-2 (Used in ParCan)
// Verified by linagee. Source: http://shop.arcol.hu/static/datasheets/thermistors.pdf
// Calculated using 4.7kohm pullup, voltage divider math, and manufacturer provided temp/resistance
{1 * OVERSAMPLENR, 713},
{17 * OVERSAMPLENR, 300},//top rating 300C
{17 * OVERSAMPLENR, 300}, //top rating 300C
{20 * OVERSAMPLENR, 290},
{23 * OVERSAMPLENR, 280},
{27 * OVERSAMPLENR, 270},
......@@ -206,11 +205,10 @@ const short temptable_5[][2] PROGMEM = {
{1010 * OVERSAMPLENR, 0}
};
#endif
#if (THERMISTORHEATER_0 == 6) || (THERMISTORHEATER_1 == 6) || (THERMISTORHEATER_2 == 6) || (THERMISTORHEATER_3 == 6) || (THERMISTORBED == 6) // 100k Epcos thermistor
const short temptable_6[][2] PROGMEM = {
{1 * OVERSAMPLENR, 350},
{28 * OVERSAMPLENR, 250},//top rating 250C
{28 * OVERSAMPLENR, 250}, //top rating 250C
{31 * OVERSAMPLENR, 245},
{35 * OVERSAMPLENR, 240},
{39 * OVERSAMPLENR, 235},
......@@ -219,8 +217,8 @@ const short temptable_6[][2] PROGMEM = {
{49 * OVERSAMPLENR, 220},
{53 * OVERSAMPLENR, 215},
{62 * OVERSAMPLENR, 210},
{71 * OVERSAMPLENR, 205},//fitted graphically
{78 * OVERSAMPLENR, 200},//fitted graphically
{71 * OVERSAMPLENR, 205}, //fitted graphically
{78 * OVERSAMPLENR, 200}, //fitted graphically
{94 * OVERSAMPLENR, 190},
{102 * OVERSAMPLENR, 185},
{116 * OVERSAMPLENR, 170},
......@@ -249,12 +247,11 @@ const short temptable_6[][2] PROGMEM = {
{1023 * OVERSAMPLENR, 0} //to allow internal 0 degrees C
};
#endif
#if (THERMISTORHEATER_0 == 7) || (THERMISTORHEATER_1 == 7) || (THERMISTORHEATER_2 == 7) || (THERMISTORHEATER_3 == 7) || (THERMISTORBED == 7) // 100k Honeywell 135-104LAG-J01
const short temptable_7[][2] PROGMEM = {
{1 * OVERSAMPLENR, 941},
{19 * OVERSAMPLENR, 362},
{37 * OVERSAMPLENR, 299},//top rating 300C
{37 * OVERSAMPLENR, 299}, //top rating 300C
{55 * OVERSAMPLENR, 266},
{73 * OVERSAMPLENR, 245},
{91 * OVERSAMPLENR, 229},
......@@ -312,7 +309,6 @@ const short temptable_7[][2] PROGMEM = {
{1023 * OVERSAMPLENR, 0} //to allow internal 0 degrees C
};
#endif
#if (THERMISTORHEATER_0 == 71) || (THERMISTORHEATER_1 == 71) || (THERMISTORHEATER_2 == 71) || (THERMISTORHEATER_3 == 71) || (THERMISTORBED == 71) // 100k Honeywell 135-104LAF-J01
// R0 = 100000 Ohm
// T0 = 25 °C
......@@ -460,10 +456,9 @@ const short temptable_71[][2] PROGMEM = {
{995 * OVERSAMPLENR, 15},
{1001 * OVERSAMPLENR, 10},
{1006 * OVERSAMPLENR, 5},
{1010 * OVERSAMPLENR, 0}
{1010 * OVERSAMPLENR, 0},
};
#endif
#if (THERMISTORHEATER_0 == 8) || (THERMISTORHEATER_1 == 8) || (THERMISTORHEATER_2 == 8) || (THERMISTORHEATER_3 == 8) || (THERMISTORBED == 8)
// 100k 0603 SMD Vishay NTCS0603E3104FXT (4.7k pullup)
const short temptable_8[][2] PROGMEM = {
......@@ -561,7 +556,6 @@ const short temptable_10[][2] PROGMEM = {
{1016 * OVERSAMPLENR, 0}
};
#endif
#if (THERMISTORHEATER_0 == 11) || (THERMISTORHEATER_1 == 11) || (THERMISTORHEATER_2 == 11) || (THERMISTORHEATER_3 == 11) || (THERMISTORBED == 11)
// QU-BD silicone bed QWG-104F-3950 thermistor
......@@ -618,37 +612,36 @@ const short temptable_11[][2] PROGMEM = {
{1021 * OVERSAMPLENR, -27}
};
#endif
#if (THERMISTORHEATER_0 == 13) || (THERMISTORHEATER_1 == 13) || (THERMISTORHEATER_2 == 13) || (THERMISTORHEATER_3 == 13) || (THERMISTORBED == 13)
// Hisens thermistor B25/50 =3950 +/-1%
const short temptable_13[][2] PROGMEM = {
{20.04*OVERSAMPLENR, 300 },
{23.19*OVERSAMPLENR, 290 },
{26.71*OVERSAMPLENR, 280 },
{31.23*OVERSAMPLENR, 270 },
{36.52*OVERSAMPLENR, 260 },
{42.75*OVERSAMPLENR, 250 },
{50.68*OVERSAMPLENR, 240 },
{60.22*OVERSAMPLENR, 230 },
{72.03*OVERSAMPLENR, 220 },
{86.84*OVERSAMPLENR, 210 },
{102.79*OVERSAMPLENR, 200 },
{124.46*OVERSAMPLENR, 190 },
{151.02*OVERSAMPLENR, 180 },
{182.86*OVERSAMPLENR, 170 },
{220.72*OVERSAMPLENR, 160 },
{316.96*OVERSAMPLENR, 140 },
{447.17*OVERSAMPLENR, 120 },
{590.61*OVERSAMPLENR, 100 },
{737.31*OVERSAMPLENR, 80 },
{857.77*OVERSAMPLENR, 60 },
{939.52*OVERSAMPLENR, 40 },
{986.03*OVERSAMPLENR, 20 },
{1008.7*OVERSAMPLENR, 0}
{ 20.04 * OVERSAMPLENR, 300 },
{ 23.19 * OVERSAMPLENR, 290 },
{ 26.71 * OVERSAMPLENR, 280 },
{ 31.23 * OVERSAMPLENR, 270 },
{ 36.52 * OVERSAMPLENR, 260 },
{ 42.75 * OVERSAMPLENR, 250 },
{ 50.68 * OVERSAMPLENR, 240 },
{ 60.22 * OVERSAMPLENR, 230 },
{ 72.03 * OVERSAMPLENR, 220 },
{ 86.84 * OVERSAMPLENR, 210 },
{ 102.79 * OVERSAMPLENR, 200 },
{ 124.46 * OVERSAMPLENR, 190 },
{ 151.02 * OVERSAMPLENR, 180 },
{ 182.86 * OVERSAMPLENR, 170 },
{ 220.72 * OVERSAMPLENR, 160 },
{ 316.96 * OVERSAMPLENR, 140 },
{ 447.17 * OVERSAMPLENR, 120 },
{ 590.61 * OVERSAMPLENR, 100 },
{ 737.31 * OVERSAMPLENR, 80 },
{ 857.77 * OVERSAMPLENR, 60 },
{ 939.52 * OVERSAMPLENR, 40 },
{ 986.03 * OVERSAMPLENR, 20 },
{ 1008.7 * OVERSAMPLENR, 0}
};
#endif
#if (THERMISTORHEATER_0 == 20) || (THERMISTORHEATER_1 == 20) || (THERMISTORHEATER_2 == 20) || (THERMISTORBED == 20) // PT100 with INA826 amp on Ultimaker v2.0 electronics
/* The PT100 in the Ultimaker v2.0 electronics has a high sample value for a high temperature.
This does not match the normal thermistor behaviour so we need to set the following defines */
......@@ -673,66 +666,65 @@ This does not match the normal thermistor behaviour so we need to set the follow
#define HEATER_BED_RAW_LO_TEMP 0
#endif
const short temptable_20[][2] PROGMEM = {
{0 * OVERSAMPLENR, 0},
{227 * OVERSAMPLENR, 1},
{236 * OVERSAMPLENR, 10},
{245 * OVERSAMPLENR, 20},
{253 * OVERSAMPLENR, 30},
{262 * OVERSAMPLENR, 40},
{270 * OVERSAMPLENR, 50},
{279 * OVERSAMPLENR, 60},
{287 * OVERSAMPLENR, 70},
{295 * OVERSAMPLENR, 80},
{304 * OVERSAMPLENR, 90},
{312 * OVERSAMPLENR, 100},
{320 * OVERSAMPLENR, 110},
{329 * OVERSAMPLENR, 120},
{337 * OVERSAMPLENR, 130},
{345 * OVERSAMPLENR, 140},
{353 * OVERSAMPLENR, 150},
{361 * OVERSAMPLENR, 160},
{369 * OVERSAMPLENR, 170},
{377 * OVERSAMPLENR, 180},
{385 * OVERSAMPLENR, 190},
{393 * OVERSAMPLENR, 200},
{401 * OVERSAMPLENR, 210},
{409 * OVERSAMPLENR, 220},
{417 * OVERSAMPLENR, 230},
{424 * OVERSAMPLENR, 240},
{432 * OVERSAMPLENR, 250},
{440 * OVERSAMPLENR, 260},
{447 * OVERSAMPLENR, 270},
{455 * OVERSAMPLENR, 280},
{463 * OVERSAMPLENR, 290},
{470 * OVERSAMPLENR, 300},
{478 * OVERSAMPLENR, 310},
{485 * OVERSAMPLENR, 320},
{493 * OVERSAMPLENR, 330},
{500 * OVERSAMPLENR, 340},
{507 * OVERSAMPLENR, 350},
{515 * OVERSAMPLENR, 360},
{522 * OVERSAMPLENR, 370},
{529 * OVERSAMPLENR, 380},
{537 * OVERSAMPLENR, 390},
{544 * OVERSAMPLENR, 400},
{614 * OVERSAMPLENR, 500},
{681 * OVERSAMPLENR, 600},
{744 * OVERSAMPLENR, 700},
{805 * OVERSAMPLENR, 800},
{862 * OVERSAMPLENR, 900},
{917 * OVERSAMPLENR, 1000},
{968 * OVERSAMPLENR, 1100}
{ 0 * OVERSAMPLENR , 0 },
{ 227 * OVERSAMPLENR , 1 },
{ 236 * OVERSAMPLENR , 10 },
{ 245 * OVERSAMPLENR , 20 },
{ 253 * OVERSAMPLENR , 30 },
{ 262 * OVERSAMPLENR , 40 },
{ 270 * OVERSAMPLENR , 50 },
{ 279 * OVERSAMPLENR , 60 },
{ 287 * OVERSAMPLENR , 70 },
{ 295 * OVERSAMPLENR , 80 },
{ 304 * OVERSAMPLENR , 90 },
{ 312 * OVERSAMPLENR , 100 },
{ 320 * OVERSAMPLENR , 110 },
{ 329 * OVERSAMPLENR , 120 },
{ 337 * OVERSAMPLENR , 130 },
{ 345 * OVERSAMPLENR , 140 },
{ 353 * OVERSAMPLENR , 150 },
{ 361 * OVERSAMPLENR , 160 },
{ 369 * OVERSAMPLENR , 170 },
{ 377 * OVERSAMPLENR , 180 },
{ 385 * OVERSAMPLENR , 190 },
{ 393 * OVERSAMPLENR , 200 },
{ 401 * OVERSAMPLENR , 210 },
{ 409 * OVERSAMPLENR , 220 },
{ 417 * OVERSAMPLENR , 230 },
{ 424 * OVERSAMPLENR , 240 },
{ 432 * OVERSAMPLENR , 250 },
{ 440 * OVERSAMPLENR , 260 },
{ 447 * OVERSAMPLENR , 270 },
{ 455 * OVERSAMPLENR , 280 },
{ 463 * OVERSAMPLENR , 290 },
{ 470 * OVERSAMPLENR , 300 },
{ 478 * OVERSAMPLENR , 310 },
{ 485 * OVERSAMPLENR , 320 },
{ 493 * OVERSAMPLENR , 330 },
{ 500 * OVERSAMPLENR , 340 },
{ 507 * OVERSAMPLENR , 350 },
{ 515 * OVERSAMPLENR , 360 },
{ 522 * OVERSAMPLENR , 370 },
{ 529 * OVERSAMPLENR , 380 },
{ 537 * OVERSAMPLENR , 390 },
{ 544 * OVERSAMPLENR , 400 },
{ 614 * OVERSAMPLENR , 500 },
{ 681 * OVERSAMPLENR , 600 },
{ 744 * OVERSAMPLENR , 700 },
{ 805 * OVERSAMPLENR , 800 },
{ 862 * OVERSAMPLENR , 900 },
{ 917 * OVERSAMPLENR , 1000 },
{ 968 * OVERSAMPLENR , 1100 }
};
#endif
#if (THERMISTORHEATER_0 == 51) || (THERMISTORHEATER_1 == 51) || (THERMISTORHEATER_2 == 51) || (THERMISTORHEATER_3 == 51) || (THERMISTORBED == 51)
// 100k EPCOS (WITH 1kohm RESISTOR FOR PULLUP,R9 ON SANGUINOLOLU! NOT FOR 4.7kohm PULLUP! THIS IS NOT NORMAL!)
// 100k EPCOS (WITH 1kohm RESISTOR FOR PULLUP, R9 ON SANGUINOLOLU! NOT FOR 4.7kohm PULLUP! THIS IS NOT NORMAL!)
// Verified by linagee.
// Calculated using 1kohm pullup,voltage divider math,and manufacturer provided temp/resistance
// Calculated using 1kohm pullup, voltage divider math, and manufacturer provided temp/resistance
// Advantage: Twice the resolution and better linearity from 150C to 200C
const short temptable_51[][2] PROGMEM = {
{1 * OVERSAMPLENR, 350},
{190 * OVERSAMPLENR, 250},//top rating 250C
{190 * OVERSAMPLENR, 250}, //top rating 250C
{203 * OVERSAMPLENR, 245},
{217 * OVERSAMPLENR, 240},
{232 * OVERSAMPLENR, 235},
......@@ -788,13 +780,13 @@ const short temptable_51[][2] PROGMEM = {
#endif
#if (THERMISTORHEATER_0 == 52) || (THERMISTORHEATER_1 == 52) || (THERMISTORHEATER_2 == 52) || (THERMISTORHEATER_3 == 52) || (THERMISTORBED == 52)
// 200k ATC Semitec 204GT-2 (WITH 1kohm RESISTOR FOR PULLUP,R9 ON SANGUINOLOLU! NOT FOR 4.7kohm PULLUP! THIS IS NOT NORMAL!)
// 200k ATC Semitec 204GT-2 (WITH 1kohm RESISTOR FOR PULLUP, R9 ON SANGUINOLOLU! NOT FOR 4.7kohm PULLUP! THIS IS NOT NORMAL!)
// Verified by linagee. Source: http://shop.arcol.hu/static/datasheets/thermistors.pdf
// Calculated using 1kohm pullup,voltage divider math,and manufacturer provided temp/resistance
// Calculated using 1kohm pullup, voltage divider math, and manufacturer provided temp/resistance
// Advantage: More resolution and better linearity from 150C to 200C
const short temptable_52[][2] PROGMEM = {
{1 * OVERSAMPLENR, 500},
{125 * OVERSAMPLENR, 300},//top rating 300C
{125 * OVERSAMPLENR, 300}, //top rating 300C
{142 * OVERSAMPLENR, 290},
{162 * OVERSAMPLENR, 280},
{185 * OVERSAMPLENR, 270},
......@@ -829,9 +821,9 @@ const short temptable_52[][2] PROGMEM = {
#endif
#if (THERMISTORHEATER_0 == 55) || (THERMISTORHEATER_1 == 55) || (THERMISTORHEATER_2 == 55) || (THERMISTORHEATER_3 == 55) || (THERMISTORBED == 55)
// 100k ATC Semitec 104GT-2 (Used on ParCan) (WITH 1kohm RESISTOR FOR PULLUP,R9 ON SANGUINOLOLU! NOT FOR 4.7kohm PULLUP! THIS IS NOT NORMAL!)
// 100k ATC Semitec 104GT-2 (Used on ParCan) (WITH 1kohm RESISTOR FOR PULLUP, R9 ON SANGUINOLOLU! NOT FOR 4.7kohm PULLUP! THIS IS NOT NORMAL!)
// Verified by linagee. Source: http://shop.arcol.hu/static/datasheets/thermistors.pdf
// Calculated using 1kohm pullup,voltage divider math,and manufacturer provided temp/resistance
// Calculated using 1kohm pullup, voltage divider math, and manufacturer provided temp/resistance
// Advantage: More resolution and better linearity from 150C to 200C
const short temptable_55[][2] PROGMEM = {
{1 * OVERSAMPLENR, 500},
......@@ -950,13 +942,13 @@ const short temptable_60[][2] PROGMEM = {
{981 * OVERSAMPLENR, 23},
{991 * OVERSAMPLENR, 17},
{1001 * OVERSAMPLENR, 9},
{1008 * OVERSAMPLENR, 0}
{1008 * OVERSAMPLENR, 0},
};
#endif
#if (THERMISTORBED == 12)
#if (THERMISTORHEATER_0 == 12) || (THERMISTORHEATER_1 == 12) || (THERMISTORHEATER_2 == 12) || (THERMISTORHEATER_3 == 12) || (THERMISTORBED == 12)
//100k 0603 SMD Vishay NTCS0603E3104FXT (4.7k pullup) (calibrated for Makibox hot bed)
const short temptable_12[][2] PROGMEM = {
{35 * OVERSAMPLENR, 180},//top rating 180C
{35 * OVERSAMPLENR, 180}, //top rating 180C
{211 * OVERSAMPLENR, 140},
{233 * OVERSAMPLENR, 135},
{261 * OVERSAMPLENR, 130},
......@@ -985,106 +977,106 @@ const short temptable_12[][2] PROGMEM = {
{995 * OVERSAMPLENR, 15},
{1001 * OVERSAMPLENR, 10},
{1010 * OVERSAMPLENR, 0},
{1023 * OVERSAMPLENR, -40}
{1023 * OVERSAMPLENR, -40},
};
#endif
// Pt1000 and Pt100 handling
//
// Rt=R0*(1+a*T+b*T*T) [for T>0]
// a=3.9083E-3,b=-5.775E-7
// a=3.9083E-3, b=-5.775E-7
#define PtA 3.9083E-3
#define PtB -5.775E-7
#define PtRt(T,R0) ((R0)*(1.0+(PtA)*(T)+(PtB)*(T)*(T)))
#define PtAdVal(T,R0,Rup) (short)(1024/(Rup/PtRt(T,R0)+1))
#define PtLine(T,R0,Rup) { PtAdVal(T,R0,Rup) * OVERSAMPLENR, T},
#define PtLine(T,R0,Rup) { PtAdVal(T,R0,Rup)*OVERSAMPLENR, T },
#if (THERMISTORHEATER_0 == 110) || (THERMISTORHEATER_1 == 110) || (THERMISTORHEATER_2 == 110) || (THERMISTORHEATER_3 == 110) || (THERMISTORBED == 110) // Pt100 with 1k0 pullup
const short temptable_110[][2] PROGMEM = {
// only few values are needed as the curve is very flat
PtLine(0,100,1000)
PtLine(50,100,1000)
PtLine(100,100,1000)
PtLine(150,100,1000)
PtLine(200,100,1000)
PtLine(250,100,1000)
PtLine(300,100,1000)
// only few values are needed as the curve is very flat
PtLine(0, 100, 1000)
PtLine(50, 100, 1000)
PtLine(100, 100, 1000)
PtLine(150, 100, 1000)
PtLine(200, 100, 1000)
PtLine(250, 100, 1000)
PtLine(300, 100, 1000)
};
#endif
#if (THERMISTORHEATER_0 == 147) || (THERMISTORHEATER_1 == 147) || (THERMISTORHEATER_2 == 147) || (THERMISTORHEATER_3 == 147) || (THERMISTORBED == 147) // Pt100 with 4k7 pullup
const short temptable_147[][2] PROGMEM = {
// only few values are needed as the curve is very flat
PtLine(0,100,4700)
PtLine(50,100,4700)
PtLine(100,100,4700)
PtLine(150,100,4700)
PtLine(200,100,4700)
PtLine(250,100,4700)
PtLine(300,100,4700)
// only few values are needed as the curve is very flat
PtLine(0, 100, 4700)
PtLine(50, 100, 4700)
PtLine(100, 100, 4700)
PtLine(150, 100, 4700)
PtLine(200, 100, 4700)
PtLine(250, 100, 4700)
PtLine(300, 100, 4700)
};
#endif
#if (THERMISTORHEATER_0 == 1010) || (THERMISTORHEATER_1 == 1010) || (THERMISTORHEATER_2 == 1010) || (THERMISTORHEATER_3 == 1010) || (THERMISTORBED == 1010) // Pt1000 with 1k0 pullup
const short temptable_1010[][2] PROGMEM = {
PtLine(0,1000,1000)
PtLine(25,1000,1000)
PtLine(50,1000,1000)
PtLine(75,1000,1000)
PtLine(100,1000,1000)
PtLine(125,1000,1000)
PtLine(150,1000,1000)
PtLine(175,1000,1000)
PtLine(200,1000,1000)
PtLine(225,1000,1000)
PtLine(250,1000,1000)
PtLine(275,1000,1000)
PtLine(300,1000,1000)
PtLine(0, 1000, 1000)
PtLine(25, 1000, 1000)
PtLine(50, 1000, 1000)
PtLine(75, 1000, 1000)
PtLine(100, 1000, 1000)
PtLine(125, 1000, 1000)
PtLine(150, 1000, 1000)
PtLine(175, 1000, 1000)
PtLine(200, 1000, 1000)
PtLine(225, 1000, 1000)
PtLine(250, 1000, 1000)
PtLine(275, 1000, 1000)
PtLine(300, 1000, 1000)
};
#endif
#if (THERMISTORHEATER_0 == 1047) || (THERMISTORHEATER_1 == 1047) || (THERMISTORHEATER_2 == 1047) || (THERMISTORHEATER_3 == 1047) || (THERMISTORBED == 1047) // Pt1000 with 4k7 pullup
const short temptable_1047[][2] PROGMEM = {
// only few values are needed as the curve is very flat
PtLine(0,1000,4700)
PtLine(50,1000,4700)
PtLine(100,1000,4700)
PtLine(150,1000,4700)
PtLine(200,1000,4700)
PtLine(250,1000,4700)
PtLine(300,1000,4700)
// only few values are needed as the curve is very flat
PtLine(0, 1000, 4700)
PtLine(50, 1000, 4700)
PtLine(100, 1000, 4700)
PtLine(150, 1000, 4700)
PtLine(200, 1000, 4700)
PtLine(250, 1000, 4700)
PtLine(300, 1000, 4700)
};
#endif
#if (THERMISTORHEATER_0 == 999) || (THERMISTORHEATER_1 == 999) || (THERMISTORHEATER_2 == 999) || (THERMISTORHEATER_3 == 999) || (THERMISTORBED == 999) //User defined table
// Dummy Thermistor table.. It will ALWAYS read a fixed value.
#if DISABLED(DUMMY_THERMISTOR_999_VALUE)
#ifndef DUMMY_THERMISTOR_999_VALUE
#define DUMMY_THERMISTOR_999_VALUE 25
#endif
const short temptable_999[][2] PROGMEM = {
{1 * OVERSAMPLENR, DUMMY_THERMISTOR_999_VALUE},
{1023 * OVERSAMPLENR, DUMMY_THERMISTOR_999_VALUE}
};
};
#endif
#if (THERMISTORHEATER_0 == 998) || (THERMISTORHEATER_1 == 998) || (THERMISTORHEATER_2 == 998) || (THERMISTORHEATER_3 == 998) || (THERMISTORBED == 998) //User defined table
// Dummy Thermistor table.. It will ALWAYS read a fixed value.
#if DISABLED(DUMMY_THERMISTOR_998_VALUE)
#ifndef DUMMY_THERMISTOR_998_VALUE
#define DUMMY_THERMISTOR_998_VALUE 25
#endif
const short temptable_998[][2] PROGMEM = {
{1 * OVERSAMPLENR, DUMMY_THERMISTOR_998_VALUE},
{1023 * OVERSAMPLENR, DUMMY_THERMISTOR_998_VALUE}
};
};
#endif
#define _TT_NAME(_N) temptable_ ## _N
#define TT_NAME(_N) _TT_NAME(_N)
#if ENABLED(THERMISTORHEATER_0)
#ifdef THERMISTORHEATER_0
#define HEATER_0_TEMPTABLE TT_NAME(THERMISTORHEATER_0)
#define HEATER_0_TEMPTABLE_LEN COUNT(HEATER_0_TEMPTABLE)
#else
#if ENABLED(HEATER_0_USES_THERMISTOR)
#ifdef HEATER_0_USES_THERMISTOR
#error No heater 0 thermistor table specified
#else // HEATER_0_USES_THERMISTOR
#define HEATER_0_TEMPTABLE NULL
......@@ -1092,9 +1084,9 @@ const short temptable_1047[][2] PROGMEM = {
#endif // HEATER_0_USES_THERMISTOR
#endif
//Set the high and low raw values for the heater,this indicates which raw value is a high or low temperature
#if DISABLED(HEATER_0_RAW_HI_TEMP)
#if ENABLED(HEATER_0_USES_THERMISTOR) //In case of a thermistor the highest temperature results in the lowest ADC value
//Set the high and low raw values for the heater, this indicates which raw value is a high or low temperature
#ifndef HEATER_0_RAW_HI_TEMP
#ifdef HEATER_0_USES_THERMISTOR //In case of a thermistor the highest temperature results in the lowest ADC value
#define HEATER_0_RAW_HI_TEMP 0
#define HEATER_0_RAW_LO_TEMP 16383
#else //In case of an thermocouple the highest temperature results in the highest ADC value
......@@ -1103,11 +1095,11 @@ const short temptable_1047[][2] PROGMEM = {
#endif
#endif
#if ENABLED(THERMISTORHEATER_1)
#ifdef THERMISTORHEATER_1
#define HEATER_1_TEMPTABLE TT_NAME(THERMISTORHEATER_1)
#define HEATER_1_TEMPTABLE_LEN COUNT(HEATER_1_TEMPTABLE)
#else
#if ENABLED(HEATER_1_USES_THERMISTOR)
#ifdef HEATER_1_USES_THERMISTOR
#error No heater 1 thermistor table specified
#else // HEATER_1_USES_THERMISTOR
#define HEATER_1_TEMPTABLE NULL
......@@ -1115,9 +1107,9 @@ const short temptable_1047[][2] PROGMEM = {
#endif // HEATER_1_USES_THERMISTOR
#endif
//Set the high and low raw values for the heater,this indicates which raw value is a high or low temperature
#if DISABLED(HEATER_1_RAW_HI_TEMP)
#if ENABLED(HEATER_1_USES_THERMISTOR) //In case of a thermistor the highest temperature results in the lowest ADC value
//Set the high and low raw values for the heater, this indicates which raw value is a high or low temperature
#ifndef HEATER_1_RAW_HI_TEMP
#ifdef HEATER_1_USES_THERMISTOR //In case of a thermistor the highest temperature results in the lowest ADC value
#define HEATER_1_RAW_HI_TEMP 0
#define HEATER_1_RAW_LO_TEMP 16383
#else //In case of an thermocouple the highest temperature results in the highest ADC value
......@@ -1126,11 +1118,11 @@ const short temptable_1047[][2] PROGMEM = {
#endif
#endif
#if ENABLED(THERMISTORHEATER_2)
#ifdef THERMISTORHEATER_2
#define HEATER_2_TEMPTABLE TT_NAME(THERMISTORHEATER_2)
#define HEATER_2_TEMPTABLE_LEN COUNT(HEATER_2_TEMPTABLE)
#else
#if ENABLED(HEATER_2_USES_THERMISTOR)
#ifdef HEATER_2_USES_THERMISTOR
#error No heater 2 thermistor table specified
#else // HEATER_2_USES_THERMISTOR
#define HEATER_2_TEMPTABLE NULL
......@@ -1138,9 +1130,9 @@ const short temptable_1047[][2] PROGMEM = {
#endif // HEATER_2_USES_THERMISTOR
#endif
//Set the high and low raw values for the heater,this indicates which raw value is a high or low temperature
#if DISABLED(HEATER_2_RAW_HI_TEMP)
#if ENABLED(HEATER_2_USES_THERMISTOR) //In case of a thermistor the highest temperature results in the lowest ADC value
//Set the high and low raw values for the heater, this indicates which raw value is a high or low temperature
#ifndef HEATER_2_RAW_HI_TEMP
#ifdef HEATER_2_USES_THERMISTOR //In case of a thermistor the highest temperature results in the lowest ADC value
#define HEATER_2_RAW_HI_TEMP 0
#define HEATER_2_RAW_LO_TEMP 16383
#else //In case of an thermocouple the highest temperature results in the highest ADC value
......@@ -1149,11 +1141,11 @@ const short temptable_1047[][2] PROGMEM = {
#endif
#endif
#if ENABLED(THERMISTORHEATER_3)
#ifdef THERMISTORHEATER_3
#define HEATER_3_TEMPTABLE TT_NAME(THERMISTORHEATER_3)
#define HEATER_3_TEMPTABLE_LEN COUNT(HEATER_3_TEMPTABLE)
#else
#if ENABLED(HEATER_3_USES_THERMISTOR)
#ifdef HEATER_3_USES_THERMISTOR
#error No heater 3 thermistor table specified
#else // HEATER_3_USES_THERMISTOR
#define HEATER_3_TEMPTABLE NULL
......@@ -1161,9 +1153,9 @@ const short temptable_1047[][2] PROGMEM = {
#endif // HEATER_3_USES_THERMISTOR
#endif
//Set the high and low raw values for the heater,this indicates which raw value is a high or low temperature
#if DISABLED(HEATER_3_RAW_HI_TEMP)
#if ENABLED(HEATER_3_USES_THERMISTOR) //In case of a thermistor the highest temperature results in the lowest ADC value
//Set the high and low raw values for the heater, this indicates which raw value is a high or low temperature
#ifndef HEATER_3_RAW_HI_TEMP
#ifdef HEATER_3_USES_THERMISTOR //In case of a thermistor the highest temperature results in the lowest ADC value
#define HEATER_3_RAW_HI_TEMP 0
#define HEATER_3_RAW_LO_TEMP 16383
#else //In case of an thermocouple the highest temperature results in the highest ADC value
......@@ -1172,18 +1164,18 @@ const short temptable_1047[][2] PROGMEM = {
#endif
#endif
#if ENABLED(THERMISTORBED)
#ifdef THERMISTORBED
#define BEDTEMPTABLE TT_NAME(THERMISTORBED)
#define BEDTEMPTABLE_LEN COUNT(BEDTEMPTABLE)
#else
#if ENABLED(BED_USES_THERMISTOR)
#ifdef BED_USES_THERMISTOR
#error No bed thermistor table specified
#endif // BED_USES_THERMISTOR
#endif
//Set the high and low raw values for the heater,this indicates which raw value is a high or low temperature
#if DISABLED(HEATER_BED_RAW_HI_TEMP)
#if ENABLED(BED_USES_THERMISTOR) //In case of a thermistor the highest temperature results in the lowest ADC value
//Set the high and low raw values for the heater, this indicates which raw value is a high or low temperature
#ifndef HEATER_BED_RAW_HI_TEMP
#ifdef BED_USES_THERMISTOR //In case of a thermistor the highest temperature results in the lowest ADC value
#define HEATER_BED_RAW_HI_TEMP 0
#define HEATER_BED_RAW_LO_TEMP 16383
#else //In case of an thermocouple the highest temperature results in the highest ADC value
......
......@@ -459,13 +459,14 @@ static void lcd_return_to_status() { lcd_goto_menu(lcd_status_screen); }
static void lcd_main_menu() {
START_MENU(lcd_status_screen);
MENU_ITEM(back, MSG_WATCH, lcd_status_screen);
if (movesplanned() || IS_SD_PRINTING)
if (movesplanned() || IS_SD_PRINTING) {
MENU_ITEM(submenu, MSG_TUNE, lcd_tune_menu);
}
else {
MENU_ITEM(submenu, MSG_PREPARE, lcd_prepare_menu);
#if MECH(DELTA)
MENU_ITEM(submenu, MSG_DELTA_CALIBRATE, lcd_delta_calibrate_menu);
#endif // DELTA
#endif
}
MENU_ITEM(submenu, MSG_CONTROL, lcd_control_menu);
MENU_ITEM(submenu, MSG_STATS, lcd_stats_menu);
......@@ -518,31 +519,17 @@ void lcd_set_home_offsets() {
static void _lcd_babystep(menuFunc_t menu, int axis, const char* msg) {
if (encoderPosition != 0) {
babystepsTodo[axis] += (int)encoderPosition;
babystepsTodo[axis] += BABYSTEP_MULTIPLICATOR * (int)encoderPosition;
encoderPosition = 0;
lcdDrawUpdate = 1;
}
if (lcdDrawUpdate) lcd_implementation_drawedit(msg, "");
if (LCD_CLICKED) lcd_goto_menu(menu);
if (LCD_CLICKED) lcd_goto_menu(lcd_tune_menu);
}
static void lcd_prepare_motion_babystep();
static void lcd_tune_babystep_x() { _lcd_babystep(lcd_tune_menu, X_AXIS, PSTR(MSG_BABYSTEPPING_X)); }
static void lcd_tune_babystep_y() { _lcd_babystep(lcd_tune_menu, Y_AXIS, PSTR(MSG_BABYSTEPPING_Y)); }
static void lcd_tune_babystep_z() { _lcd_babystep(lcd_tune_menu, Z_AXIS, PSTR(MSG_BABYSTEPPING_Z)); }
static void lcd_prepare_babystep_x() { _lcd_babystep(lcd_prepare_motion_babystep, X_AXIS, PSTR(MSG_BABYSTEPPING_X)); }
static void lcd_prepare_babystep_y() { _lcd_babystep(lcd_prepare_motion_babystep, Y_AXIS, PSTR(MSG_BABYSTEPPING_Y)); }
static void lcd_prepare_babystep_z() { _lcd_babystep(lcd_prepare_motion_babystep, Z_AXIS, PSTR(MSG_BABYSTEPPING_Z)); }
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_prepare_motion_babystep() {
START_MENU(lcd_main_menu);
MENU_ITEM(back, MSG_MOTION, lcd_prepare_motion_menu);
#if ENABLED(BABYSTEP_XY)
MENU_ITEM(submenu, MSG_BABYSTEP_X, lcd_prepare_babystep_x);
MENU_ITEM(submenu, MSG_BABYSTEP_Y, lcd_prepare_babystep_y);
#endif //BABYSTEP_XY
MENU_ITEM(submenu, MSG_BABYSTEP_Z, lcd_prepare_babystep_z);
END_MENU();
}
#endif // BABYSTEPPING
static void lcd_tune_fixstep() {
......@@ -553,56 +540,147 @@ static void lcd_tune_fixstep() {
#endif
}
/**
*
* "Tune" submenu
*
#if ENABLED(THERMAL_PROTECTION_HOTENDS)
/**
* Watch temperature callbacks
*/
#if TEMP_SENSOR_0 != 0
void watch_temp_callback_E0() { start_watching_heater(0); }
#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
#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 // !THERMAL_PROTECTION_HOTENDS
static void lcd_tune_menu() {
START_MENU(lcd_main_menu);
MENU_ITEM(back, MSG_MAIN, lcd_main_menu);
MENU_ITEM_EDIT(int3, MSG_SPEED, &feedrate_multiplier, 10, 999);
/**
* Items shared between Tune and Temperature menus
*/
static void nozzle_bed_fan_menu_items(uint8_t &encoderLine, uint8_t &_lineNr, uint8_t &_drawLineNr, uint8_t &_menuItemNr, bool &wasClicked, bool &itemSelected) {
//
// Nozzle:
// Nozzle [1-4]:
//
#if HOTENDS == 1
#if TEMP_SENSOR_0 != 0
MENU_MULTIPLIER_ITEM_EDIT(int3, MSG_NOZZLE " 0", &target_temperature[0], 0, HEATER_0_MAXTEMP);
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(int3, MSG_NOZZLE " 1", &target_temperature[1], 0, HEATER_1_MAXTEMP);
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(int3, MSG_NOZZLE " 2", &target_temperature[2], 0, HEATER_2_MAXTEMP);
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 TEMP_SENSOR_3 != 0
MENU_MULTIPLIER_ITEM_EDIT(int3, MSG_NOZZLE " 3", &target_temperature[3], 0, HEATER_3_MAXTEMP);
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);
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);
}
/**
*
* "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:
// Flow 2:
// Flow 3:
// Flow 4:
//
#if EXTRUDERS == 1
MENU_ITEM_EDIT(int3, MSG_FLOW, &extruder_multiplier[0], 10, 999);
#else // EXTRUDERS > 1
MENU_ITEM_EDIT(int3, MSG_FLOW, &extruder_multiplier[active_extruder], 10, 999);
MENU_ITEM_EDIT(int3, MSG_FLOW " 0", &extruder_multiplier[0], 10, 999);
#if TEMP_SENSOR_1 != 0
MENU_ITEM_EDIT(int3, MSG_FLOW " 1", &extruder_multiplier[1], 10, 999);
#endif
#if TEMP_SENSOR_2 != 0
#if EXTRUDERS > 2
MENU_ITEM_EDIT(int3, MSG_FLOW " 2", &extruder_multiplier[2], 10, 999);
#endif
#if TEMP_SENSOR_3 != 0
#if EXTRUDERS > 3
MENU_ITEM_EDIT(int3, MSG_FLOW " 3", &extruder_multiplier[3], 10, 999);
#endif
#endif //EXTRUDERS > 3
#endif //EXTRUDERS > 2
#endif //EXTRUDERS > 1
//
// Babystep X:
// Babystep Y:
// Babystep Z:
//
#if ENABLED(BABYSTEPPING)
#if ENABLED(BABYSTEP_XY)
MENU_ITEM(submenu, MSG_BABYSTEP_X, lcd_tune_babystep_x);
MENU_ITEM(submenu, MSG_BABYSTEP_Y, lcd_tune_babystep_y);
MENU_ITEM(submenu, MSG_BABYSTEP_X, lcd_babystep_x);
MENU_ITEM(submenu, MSG_BABYSTEP_Y, lcd_babystep_y);
#endif //BABYSTEP_XY
MENU_ITEM(submenu, MSG_BABYSTEP_Z, lcd_tune_babystep_z);
MENU_ITEM(submenu, MSG_BABYSTEP_Z, lcd_babystep_z);
#endif
MENU_ITEM(function, MSG_FIX_LOSE_STEPS, lcd_tune_fixstep);
//
// Change filament
//
#if ENABLED(FILAMENTCHANGEENABLE)
MENU_ITEM(gcode, MSG_FILAMENTCHANGE, PSTR("M600"));
#endif
END_MENU();
}
......@@ -638,9 +716,12 @@ void _lcd_preheat(int endnum, const float temph, const float tempb, const int fa
fanSpeed = fan;
lcd_return_to_status();
}
void lcd_preheat_pla0() { _lcd_preheat(0, plaPreheatHotendTemp, plaPreheatHPBTemp, plaPreheatFanSpeed); }
void lcd_preheat_abs0() { _lcd_preheat(0, absPreheatHotendTemp, absPreheatHPBTemp, absPreheatFanSpeed); }
void lcd_preheat_gum0() { _lcd_preheat(0, gumPreheatHotendTemp, gumPreheatHPBTemp, gumPreheatFanSpeed); }
#if TEMP_SENSOR_0 != 0
void lcd_preheat_pla0() { _lcd_preheat(0, plaPreheatHotendTemp, plaPreheatHPBTemp, plaPreheatFanSpeed); }
void lcd_preheat_abs0() { _lcd_preheat(0, absPreheatHotendTemp, absPreheatHPBTemp, absPreheatFanSpeed); }
void lcd_preheat_gum0() { _lcd_preheat(0, gumPreheatHotendTemp, gumPreheatHPBTemp, gumPreheatFanSpeed); }
#endif
#if HOTENDS > 1
void lcd_preheat_pla1() { _lcd_preheat(1, plaPreheatHotendTemp, plaPreheatHPBTemp, plaPreheatFanSpeed); }
......@@ -683,11 +764,16 @@ void lcd_preheat_gum0() { _lcd_preheat(0, gumPreheatHotendTemp, gumPreheatHPBTem
void lcd_preheat_abs_bedonly() { _lcd_preheat(0, 0, absPreheatHPBTemp, absPreheatFanSpeed); }
void lcd_preheat_gum_bedonly() { _lcd_preheat(0, 0, gumPreheatHPBTemp, gumPreheatFanSpeed); }
#endif
static void lcd_preheat_pla_menu() {
START_MENU(lcd_prepare_temperature_menu);
MENU_ITEM(back, MSG_TEMPERATURE, lcd_prepare_temperature_menu);
#if TEMP_SENSOR_0 != 0 && (TEMP_SENSOR_1 != 0 || TEMP_SENSOR_2 != 0 || TEMP_SENSOR_3 != 0 || TEMP_SENSOR_BED != 0)
static void lcd_preheat_pla_menu() {
START_MENU(lcd_prepare_menu);
MENU_ITEM(back, MSG_PREPARE, lcd_prepare_menu);
#if HOTENDS == 1
MENU_ITEM(function, MSG_PREHEAT_PLA, lcd_preheat_pla0);
#else
MENU_ITEM(function, MSG_PREHEAT_PLA " 0", lcd_preheat_pla0);
#if HOTENDS > 1
MENU_ITEM(function, MSG_PREHEAT_PLA " 1", lcd_preheat_pla1);
#if HOTENDS > 2
MENU_ITEM(function, MSG_PREHEAT_PLA " 2", lcd_preheat_pla2);
......@@ -701,13 +787,15 @@ static void lcd_preheat_pla_menu() {
MENU_ITEM(function, MSG_PREHEAT_PLA_BEDONLY, lcd_preheat_pla_bedonly);
#endif
END_MENU();
}
}
static void lcd_preheat_abs_menu() {
START_MENU(lcd_prepare_temperature_menu);
MENU_ITEM(back, MSG_TEMPERATURE, lcd_prepare_temperature_menu);
static void lcd_preheat_abs_menu() {
START_MENU(lcd_prepare_menu);
MENU_ITEM(back, MSG_TEMPERATURE, lcd_prepare_menu);
#if HOTENDS == 1
MENU_ITEM(function, MSG_PREHEAT_ABS, lcd_preheat_abs0);
#else
MENU_ITEM(function, MSG_PREHEAT_ABS " 0", lcd_preheat_abs0);
#if HOTENDS > 1
MENU_ITEM(function, MSG_PREHEAT_ABS " 1", lcd_preheat_abs1);
#if HOTENDS > 2
MENU_ITEM(function, MSG_PREHEAT_ABS " 2", lcd_preheat_abs2);
......@@ -721,13 +809,15 @@ static void lcd_preheat_abs_menu() {
MENU_ITEM(function, MSG_PREHEAT_ABS_BEDONLY, lcd_preheat_abs_bedonly);
#endif
END_MENU();
}
}
static void lcd_preheat_gum_menu() {
START_MENU(lcd_prepare_temperature_menu);
MENU_ITEM(back, MSG_TEMPERATURE, lcd_prepare_temperature_menu);
static void lcd_preheat_gum_menu() {
START_MENU(lcd_prepare_menu);
MENU_ITEM(back, MSG_TEMPERATURE, lcd_prepare_menu);
#if HOTENDS == 1
MENU_ITEM(function, MSG_PREHEAT_GUM, lcd_preheat_gum0);
#else
MENU_ITEM(function, MSG_PREHEAT_GUM " 0", lcd_preheat_gum0);
#if HOTENDS > 1
MENU_ITEM(function, MSG_PREHEAT_GUM " 1", lcd_preheat_gum1);
#if HOTENDS > 2
MENU_ITEM(function, MSG_PREHEAT_GUM " 2", lcd_preheat_gum2);
......@@ -741,7 +831,9 @@ static void lcd_preheat_gum_menu() {
MENU_ITEM(function, MSG_PREHEAT_GUM_BEDONLY, lcd_preheat_gum_bedonly);
#endif
END_MENU();
}
}
#endif // TEMP_SENSOR_0 && (TEMP_SENSOR_1 || TEMP_SENSOR_2 || TEMP_SENSOR_3 || TEMP_SENSOR_BED)
void lcd_cooldown() {
disable_all_heaters();
......@@ -763,28 +855,16 @@ static void lcd_prepare_menu() {
//
MENU_ITEM(back, MSG_MAIN, lcd_main_menu);
MENU_ITEM(submenu, MSG_MOTION, lcd_prepare_motion_menu);
MENU_ITEM(submenu, MSG_TEMPERATURE, lcd_prepare_temperature_menu);
END_MENU();
}
/**
*
* "Prepare > Motion" submenu
*
*/
static void lcd_prepare_motion_menu() {
START_MENU(lcd_prepare_menu);
//
// ^ Prepare
// Auto Home
//
MENU_ITEM(back, MSG_PREPARE, lcd_prepare_menu);
MENU_ITEM(gcode, MSG_AUTO_HOME, PSTR("G28"));
//
// Auto Home
// Set Home Offsets
//
MENU_ITEM(gcode, MSG_AUTO_HOME, PSTR("G28"));
MENU_ITEM(function, MSG_SET_HOME_OFFSETS, lcd_set_home_offsets);
//MENU_ITEM(gcode, MSG_SET_ORIGIN, PSTR("G92 X0 Y0 Z0"));
//
// Level Bed
......@@ -796,94 +876,16 @@ static void lcd_prepare_motion_menu() {
MENU_ITEM(submenu, MSG_MBL_SETTING, config_lcd_level_bed);
#endif
//
// Set Home Offsets
//
MENU_ITEM(function, MSG_SET_HOME_OFFSETS, lcd_set_home_offsets);
//Add Preset menu for LASER setting '14. 7. 22
#if ENABLED(LASERBEAM)
MENU_ITEM_EDIT(int3, MSG_LASER, &laser_ttl_modulation, 0, 255);
if(laser_ttl_modulation == 0) {
WRITE(LASER_PWR_PIN, LOW);
}
else {
WRITE(LASER_PWR_PIN, HIGH);
}
#endif
//
// Move Axis
//
MENU_ITEM(submenu, MSG_MOVE_AXIS, lcd_move_menu);
//
// Easy Load
//
#if ENABLED(EASY_LOAD)
MENU_ITEM(function, MSG_E_BOWDEN_LENGTH, lcd_easy_load);
MENU_ITEM(function, MSG_R_BOWDEN_LENGTH, lcd_easy_unload);
MENU_ITEM(function, MSG_PURGE_XMM, lcd_purge);
MENU_ITEM(function, MSG_RETRACT_XMM, lcd_retract);
#endif // EASY_LOAD
//
// Babystepping
//
#if ENABLED(BABYSTEPPING)
MENU_ITEM(submenu, MSG_BABYSTEP, lcd_prepare_motion_babystep);
#endif
MENU_ITEM(function, MSG_FIX_LOSE_STEPS, lcd_tune_fixstep);
//
// Disable Steppers
//
MENU_ITEM(gcode, MSG_DISABLE_STEPPERS, PSTR("M84"));
END_MENU();
}
/**
*
* "Prepare > Temperature" submenu
*
*/
static void lcd_prepare_temperature_menu() {
START_MENU(lcd_prepare_menu);
//
// ^ Prepare
//
MENU_ITEM(back, MSG_PREPARE, lcd_prepare_menu);
//
// Nozzle, Nozzle 2, Nozzle 3, Nozzle 4
//
#if TEMP_SENSOR_0 != 0
MENU_MULTIPLIER_ITEM_EDIT(int3, MSG_NOZZLE " 0", &target_temperature[0], 0, HEATER_0_MAXTEMP);
#endif
#if HOTENDS > 1 && TEMP_SENSOR_1 != 0
MENU_MULTIPLIER_ITEM_EDIT(int3, MSG_NOZZLE " 1", &target_temperature[1], 0, HEATER_1_MAXTEMP);
#if HOTENDS > 2 && TEMP_SENSOR_2 != 0
MENU_MULTIPLIER_ITEM_EDIT(int3, MSG_NOZZLE " 2", &target_temperature[2], 0, HEATER_2_MAXTEMP);
#if HOTENDS > 3 && TEMP_SENSOR_3 != 0
MENU_MULTIPLIER_ITEM_EDIT(int3, MSG_NOZZLE " 3", &target_temperature[3], 0, HEATER_3_MAXTEMP);
#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);
#endif
//
// Fan Speed
//
MENU_MULTIPLIER_ITEM_EDIT(int3, MSG_FAN_SPEED, &fanSpeed, 0, 255);
//
// Preheat PLA
// Preheat ABS
......@@ -901,11 +903,51 @@ static void lcd_prepare_temperature_menu() {
#endif
#endif
//
// Easy Load
//
#if ENABLED(EASY_LOAD)
MENU_ITEM(function, MSG_E_BOWDEN_LENGTH, lcd_easy_load);
MENU_ITEM(function, MSG_R_BOWDEN_LENGTH, lcd_easy_unload);
MENU_ITEM(function, MSG_PURGE_XMM, lcd_purge);
MENU_ITEM(function, MSG_RETRACT_XMM, lcd_retract);
#endif // EASY_LOAD
//
// LASER BEAM
//
#if ENABLED(LASERBEAM)
MENU_ITEM_EDIT(int3, MSG_LASER, &laser_ttl_modulation, 0, 255);
if(laser_ttl_modulation == 0) {
WRITE(LASER_PWR_PIN, LOW);
}
else {
WRITE(LASER_PWR_PIN, HIGH);
}
#endif
//
// Cooldown
//
MENU_ITEM(function, MSG_COOLDOWN, lcd_cooldown);
//
// Switch power on/off
//
#if HAS(POWER_SWITCH)
if (powersupply)
MENU_ITEM(gcode, MSG_SWITCH_PS_OFF, PSTR("M81"));
else
MENU_ITEM(gcode, MSG_SWITCH_PS_ON, PSTR("M80"));
#endif
//
// Autostart
//
#if ENABLED(SDSUPPORT) && ENABLED(MENU_ADDAUTOSTART)
MENU_ITEM(function, MSG_AUTOSTART, lcd_autostart_sd);
#endif
END_MENU();
}
......@@ -942,7 +984,7 @@ inline void line_to_current(float feedrate) {
float move_menu_scale;
static void lcd_move_menu_axis();
static void _lcd_move(const char *name, AxisEnum axis, int min, int max) {
static void _lcd_move(const char* name, AxisEnum axis, int min, int max) {
if (encoderPosition != 0) {
refresh_cmd_timeout();
current_position[axis] += float((int)encoderPosition) * move_menu_scale;
......@@ -958,7 +1000,15 @@ static void _lcd_move(const char *name, AxisEnum axis, int min, int max) {
static void lcd_move_x() { _lcd_move(PSTR(MSG_MOVE_X), X_AXIS, X_MIN_POS, X_MAX_POS); }
static void lcd_move_y() { _lcd_move(PSTR(MSG_MOVE_Y), Y_AXIS, Y_MIN_POS, Y_MAX_POS); }
static void lcd_move_z() { _lcd_move(PSTR(MSG_MOVE_Z), Z_AXIS, Z_MIN_POS, Z_MAX_POS); }
static void lcd_move_e() {
static void lcd_move_e(
#if EXTRUDERS > 1
uint8_t e
#endif
) {
#if EXTRUDERS > 1
unsigned short original_active_extruder = active_extruder;
active_extruder = e;
#endif
if (encoderPosition != 0) {
#if ENABLED(IDLE_OOZING_PREVENT)
IDLE_OOZING_retract(false);
......@@ -968,10 +1018,41 @@ static void lcd_move_e() {
line_to_current(manual_feedrate[E_AXIS]);
lcdDrawUpdate = 1;
}
if (lcdDrawUpdate) lcd_implementation_drawedit(PSTR(MSG_MOVE_E), ftostr31(current_position[E_AXIS]));
if (lcdDrawUpdate) {
PGM_P pos_label;
#if EXTRUDERS == 1
pos_label = PSTR(MSG_MOVE_E);
#else
switch (e) {
case 0: pos_label = PSTR(MSG_MOVE_E MSG_MOVE_E1); break;
case 1: pos_label = PSTR(MSG_MOVE_E MSG_MOVE_E2); break;
#if EXTRUDERS > 2
case 2: pos_label = PSTR(MSG_MOVE_E MSG_MOVE_E3); break;
#if EXTRUDERS > 3
case 3: pos_label = PSTR(MSG_MOVE_E MSG_MOVE_E4); break;
#endif //EXTRUDERS > 3
#endif //EXTRUDERS > 2
}
#endif //EXTRUDERS > 1
lcd_implementation_drawedit(pos_label, ftostr31(current_position[E_AXIS]));
}
if (LCD_CLICKED) lcd_goto_menu(lcd_move_menu_axis);
#if EXTRUDERS > 1
active_extruder = original_active_extruder;
#endif
}
#if EXTRUDERS > 1
static void lcd_move_e0() { lcd_move_e(0); }
static void lcd_move_e1() { lcd_move_e(1); }
#if EXTRUDERS > 2
static void lcd_move_e2() { lcd_move_e(2); }
#if EXTRUDERS > 3
static void lcd_move_e3() { lcd_move_e(3); }
#endif
#endif
#endif // EXTRUDERS > 1
/**
*
* "Prepare" > "Move Xmm" > "Move XYZ" submenu
......@@ -985,7 +1066,18 @@ static void lcd_move_menu_axis() {
MENU_ITEM(submenu, MSG_MOVE_Y, lcd_move_y);
MENU_ITEM(submenu, MSG_MOVE_Z, lcd_move_z);
if (move_menu_scale < 10.0) {
#if EXTRUDERS == 1
MENU_ITEM(submenu, MSG_MOVE_E, lcd_move_e);
#else
MENU_ITEM(submenu, MSG_MOVE_E MSG_MOVE_E1, lcd_move_e0);
MENU_ITEM(submenu, MSG_MOVE_E MSG_MOVE_E2, lcd_move_e1);
#if EXTRUDERS > 2
MENU_ITEM(submenu, MSG_MOVE_E MSG_MOVE_E3, lcd_move_e2);
#if EXTRUDERS > 3
MENU_ITEM(submenu, MSG_MOVE_E MSG_MOVE_E4, lcd_move_e3);
#endif
#endif
#endif // EXTRUDERS > 1
}
END_MENU();
}
......@@ -1010,8 +1102,8 @@ static void lcd_move_menu_01mm() {
*/
static void lcd_move_menu() {
START_MENU(lcd_prepare_motion_menu);
MENU_ITEM(back, MSG_MOTION, lcd_prepare_motion_menu);
START_MENU(lcd_prepare_menu);
MENU_ITEM(back, MSG_MOTION, lcd_prepare_menu);
MENU_ITEM(submenu, MSG_MOVE_10MM, lcd_move_menu_10mm);
MENU_ITEM(submenu, MSG_MOVE_1MM, lcd_move_menu_1mm);
MENU_ITEM(submenu, MSG_MOVE_01MM, lcd_move_menu_01mm);
......@@ -1039,24 +1131,6 @@ static void lcd_control_menu() {
#if ENABLED(FWRETRACT)
MENU_ITEM(submenu, MSG_RETRACT, lcd_control_retract_menu);
#endif
//
// Switch power on/off
//
#if HAS(POWER_SWITCH)
if (powersupply)
MENU_ITEM(gcode, MSG_SWITCH_PS_OFF, PSTR("M81"));
else
MENU_ITEM(gcode, MSG_SWITCH_PS_ON, PSTR("M80"));
#endif
//
// Autostart
//
#if ENABLED(SDSUPPORT) && ENABLED(MENU_ADDAUTOSTART)
MENU_ITEM(function, MSG_AUTOSTART, lcd_autostart_sd);
#endif
#if ENABLED(EEPROM_SETTINGS)
MENU_ITEM(function, MSG_STORE_EPROM, Config_StoreSettings);
MENU_ITEM(function, MSG_LOAD_EPROM, Config_RetrieveSettings);
......@@ -1093,25 +1167,24 @@ static void lcd_stats_menu() {
// 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) {
PID_PARAM(Ki, e) = scalePID_i(raw_Ki);
void copy_and_scalePID_i(int h) {
PID_PARAM(Ki, h) = scalePID_i(raw_Ki);
updatePID();
}
void copy_and_scalePID_d(int e) {
PID_PARAM(Kd, e) = scalePID_d(raw_Kd);
void copy_and_scalePID_d(int h) {
PID_PARAM(Kd, h) = scalePID_d(raw_Kd);
updatePID();
}
void copy_and_scalePID_i_H0() { copy_and_scalePID_i(0); }
void copy_and_scalePID_d_H0() { copy_and_scalePID_d(0); }
#define COPY_AND_SCALE(hindex) \
void copy_and_scalePID_i_H ## hindex() { copy_and_scalePID_i(hindex); } \
void copy_and_scalePID_d_H ## hindex() { copy_and_scalePID_d(hindex); }
COPY_AND_SCALE(0);
#if HOTENDS > 1
void copy_and_scalePID_i_H1() { copy_and_scalePID_i(1); }
void copy_and_scalePID_d_H1() { copy_and_scalePID_d(1); }
COPY_AND_SCALE(1);
#if HOTENDS > 2
void copy_and_scalePID_i_H2() { copy_and_scalePID_i(2); }
void copy_and_scalePID_d_H2() { copy_and_scalePID_d(2); }
COPY_AND_SCALE(2);
#if HOTENDS > 3
void copy_and_scalePID_i_H3() { copy_and_scalePID_i(3); }
void copy_and_scalePID_d_H3() { copy_and_scalePID_d(3); }
COPY_AND_SCALE(3);
#endif //HOTENDS > 3
#endif //HOTENDS > 2
#endif //HOTENDS > 1
......@@ -1131,13 +1204,16 @@ 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);
//
// Autotemp, Min, Max, Fact
//
#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);
MENU_ITEM_EDIT(float3, MSG_MAX, &autotemp_max, 0, HEATER_0_MAXTEMP);
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(float32, MSG_FACTOR, &autotemp_factor, 0.0, 1.0);
#endif
......@@ -1215,10 +1291,10 @@ static void lcd_control_temperature_preheat_pla_settings_menu() {
MENU_ITEM(back, MSG_TEMPERATURE, lcd_control_temperature_menu);
MENU_ITEM_EDIT(int3, MSG_FAN_SPEED, &plaPreheatFanSpeed, 0, 255);
#if TEMP_SENSOR_0 != 0
MENU_ITEM_EDIT(int3, MSG_NOZZLE, &plaPreheatHotendTemp, HEATER_0_MINTEMP, HEATER_0_MAXTEMP);
MENU_ITEM_EDIT(int3, MSG_NOZZLE, &plaPreheatHotendTemp, HEATER_0_MINTEMP, HEATER_0_MAXTEMP - 15);
#endif
#if TEMP_SENSOR_BED != 0
MENU_ITEM_EDIT(int3, MSG_BED, &plaPreheatHPBTemp, BED_MINTEMP, BED_MAXTEMP);
MENU_ITEM_EDIT(int3, MSG_BED, &plaPreheatHPBTemp, BED_MINTEMP, BED_MAXTEMP - 15);
#endif
#if ENABLED(EEPROM_SETTINGS)
MENU_ITEM(function, MSG_STORE_EPROM, Config_StoreSettings);
......@@ -1236,10 +1312,10 @@ static void lcd_control_temperature_preheat_abs_settings_menu() {
MENU_ITEM(back, MSG_TEMPERATURE, lcd_control_temperature_menu);
MENU_ITEM_EDIT(int3, MSG_FAN_SPEED, &absPreheatFanSpeed, 0, 255);
#if TEMP_SENSOR_0 != 0
MENU_ITEM_EDIT(int3, MSG_NOZZLE, &absPreheatHotendTemp, HEATER_0_MINTEMP, HEATER_0_MAXTEMP);
MENU_ITEM_EDIT(int3, MSG_NOZZLE, &absPreheatHotendTemp, HEATER_0_MINTEMP, HEATER_0_MAXTEMP - 15);
#endif
#if TEMP_SENSOR_BED != 0
MENU_ITEM_EDIT(int3, MSG_BED, &absPreheatHPBTemp, BED_MINTEMP, BED_MAXTEMP);
MENU_ITEM_EDIT(int3, MSG_BED, &absPreheatHPBTemp, BED_MINTEMP, BED_MAXTEMP - 15);
#endif
#if ENABLED(EEPROM_SETTINGS)
MENU_ITEM(function, MSG_STORE_EPROM, Config_StoreSettings);
......@@ -1257,10 +1333,10 @@ static void lcd_control_temperature_preheat_gum_settings_menu() {
MENU_ITEM(back, MSG_TEMPERATURE, lcd_control_temperature_menu);
MENU_ITEM_EDIT(int3, MSG_FAN_SPEED, &gumPreheatFanSpeed, 0, 255);
#if TEMP_SENSOR_0 != 0
MENU_ITEM_EDIT(int3, MSG_NOZZLE, &gumPreheatHotendTemp, HEATER_0_MINTEMP, HEATER_0_MAXTEMP);
MENU_ITEM_EDIT(int3, MSG_NOZZLE, &gumPreheatHotendTemp, HEATER_0_MINTEMP, HEATER_0_MAXTEMP - 15);
#endif
#if TEMP_SENSOR_BED != 0
MENU_ITEM_EDIT(int3, MSG_BED, &gumPreheatHPBTemp, BED_MINTEMP, BED_MAXTEMP);
MENU_ITEM_EDIT(int3, MSG_BED, &gumPreheatHPBTemp, BED_MINTEMP, BED_MAXTEMP - 15);
#endif
#if ENABLED(EEPROM_SETTINGS)
MENU_ITEM(function, MSG_STORE_EPROM, Config_StoreSettings);
......@@ -1327,8 +1403,8 @@ static void lcd_control_motion_menu() {
MENU_ITEM_EDIT(bool, MSG_ENDSTOP_ABORT, &abort_on_endstop_hit);
#endif
#if MECH(SCARA)
MENU_ITEM_EDIT(float74, MSG_XSCALE, &axis_scaling[X_AXIS],0.5,2);
MENU_ITEM_EDIT(float74, MSG_YSCALE, &axis_scaling[Y_AXIS],0.5,2);
MENU_ITEM_EDIT(float74, MSG_XSCALE, &axis_scaling[X_AXIS], 0.5, 2);
MENU_ITEM_EDIT(float74, MSG_YSCALE, &axis_scaling[Y_AXIS], 0.5, 2);
#endif
END_MENU();
}
......@@ -1345,8 +1421,10 @@ static void lcd_control_volumetric_menu() {
MENU_ITEM_EDIT_CALLBACK(bool, MSG_VOLUMETRIC_ENABLED, &volumetric_enabled, calculate_volumetric_multipliers);
if (volumetric_enabled) {
MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float43, MSG_FILAMENT_SIZE_EXTRUDER " 0", &filament_size[0], DEFAULT_NOMINAL_FILAMENT_DIA - .5, DEFAULT_NOMINAL_FILAMENT_DIA + .5, calculate_volumetric_multipliers);
#if EXTRUDERS > 1
#if EXTRUDERS == 1
MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float43, MSG_FILAMENT_SIZE_EXTRUDER, &filament_size[0], DEFAULT_NOMINAL_FILAMENT_DIA - .5, DEFAULT_NOMINAL_FILAMENT_DIA + .5, calculate_volumetric_multipliers);
#else // EXTRUDERS > 1
MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float43, MSG_FILAMENT_SIZE_EXTRUDER " 0 ", &filament_size[0], DEFAULT_NOMINAL_FILAMENT_DIA - .5, DEFAULT_NOMINAL_FILAMENT_DIA + .5, calculate_volumetric_multipliers);
MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float43, MSG_FILAMENT_SIZE_EXTRUDER " 1", &filament_size[1], DEFAULT_NOMINAL_FILAMENT_DIA - .5, DEFAULT_NOMINAL_FILAMENT_DIA + .5, calculate_volumetric_multipliers);
#if EXTRUDERS > 2
MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float43, MSG_FILAMENT_SIZE_EXTRUDER " 2", &filament_size[2], DEFAULT_NOMINAL_FILAMENT_DIA - .5, DEFAULT_NOMINAL_FILAMENT_DIA + .5, calculate_volumetric_multipliers);
......@@ -1587,7 +1665,6 @@ void lcd_quick_feedback() {
#if DISABLED(LCD_FEEDBACK_FREQUENCY_DURATION_MS)
#define LCD_FEEDBACK_FREQUENCY_DURATION_MS (1000/6)
#endif
lcd.buzz(LCD_FEEDBACK_FREQUENCY_DURATION_MS, LCD_FEEDBACK_FREQUENCY_HZ);
#elif HAS(BUZZER)
#if DISABLED(LCD_FEEDBACK_FREQUENCY_HZ)
......@@ -1614,24 +1691,25 @@ static void menu_action_back(menuFunc_t func) { lcd_goto_menu(func); }
static void menu_action_submenu(menuFunc_t func) { lcd_goto_menu(func); }
static void menu_action_gcode(const char* pgcode) { enqueuecommands_P(pgcode); }
static void menu_action_function(menuFunc_t func) { (*func)(); }
static void menu_action_sdfile(const char* filename, char* longFilename) {
#if ENABLED(SDSUPPORT)
static void menu_action_sdfile(const char* filename, char* longFilename) {
char cmd[30];
char* c;
sprintf_P(cmd, PSTR("M23 %s"), filename);
for(c = &cmd[4]; *c; c++) *c = tolower(*c);
for (c = &cmd[4]; *c; c++) *c = tolower(*c);
enqueuecommand(cmd);
enqueuecommands_P(PSTR("M24"));
lcd_return_to_status();
}
#if ENABLED(SDSUPPORT)
}
static void menu_action_sddirectory(const char* filename, char* longFilename) {
card.chdir(filename);
encoderPosition = 0;
}
#endif
#endif // SDSUPPORT
static void menu_action_setting_edit_bool(const char* pstr, bool* ptr) { *ptr = !(*ptr); }
static void menu_action_setting_edit_callback_bool(const char* pstr, bool* ptr, menuFunc_t callback) {
......@@ -1639,42 +1717,48 @@ static void menu_action_setting_edit_callback_bool(const char* pstr, bool* ptr,
(*callback)();
}
#endif //ULTIPANEL
#endif // ULTIPANEL
/** LCD API **/
void lcd_init() {
lcd_implementation_init();
#if ENABLED(NEWPANEL)
SET_INPUT(BTN_EN1);
SET_INPUT(BTN_EN2);
WRITE(BTN_EN1,HIGH);
WRITE(BTN_EN2,HIGH);
WRITE(BTN_EN1, HIGH);
WRITE(BTN_EN2, HIGH);
#if BTN_ENC > 0
SET_INPUT(BTN_ENC);
WRITE(BTN_ENC,HIGH);
WRITE(BTN_ENC, HIGH);
#endif
#if ENABLED(REPRAPWORLD_KEYPAD)
pinMode(SHIFT_CLK,OUTPUT);
pinMode(SHIFT_LD,OUTPUT);
pinMode(SHIFT_OUT,INPUT);
WRITE(SHIFT_OUT,HIGH);
WRITE(SHIFT_LD,HIGH);
pinMode(SHIFT_CLK, OUTPUT);
pinMode(SHIFT_LD, OUTPUT);
pinMode(SHIFT_OUT, INPUT);
WRITE(SHIFT_OUT, HIGH);
WRITE(SHIFT_LD, HIGH);
#endif
#else // Not NEWPANEL
#if ENABLED(SR_LCD_2W_NL) // Non latching 2 wire shift register
pinMode (SR_DATA_PIN, OUTPUT);
pinMode (SR_CLK_PIN, OUTPUT);
pinMode(SR_DATA_PIN, OUTPUT);
pinMode(SR_CLK_PIN, OUTPUT);
#elif ENABLED(SHIFT_CLK)
pinMode(SHIFT_CLK,OUTPUT);
pinMode(SHIFT_LD,OUTPUT);
pinMode(SHIFT_EN,OUTPUT);
pinMode(SHIFT_OUT,INPUT);
WRITE(SHIFT_OUT,HIGH);
WRITE(SHIFT_LD,HIGH);
WRITE(SHIFT_EN,LOW);
pinMode(SHIFT_CLK, OUTPUT);
pinMode(SHIFT_LD, OUTPUT);
pinMode(SHIFT_EN, OUTPUT);
pinMode(SHIFT_OUT, INPUT);
WRITE(SHIFT_OUT, HIGH);
WRITE(SHIFT_LD, HIGH);
WRITE(SHIFT_EN, LOW);
#endif // SR_LCD_2W_NL
#endif//!NEWPANEL
#if ENABLED(SDSUPPORT) && PIN_EXISTS(SD_DETECT)
......@@ -1694,7 +1778,7 @@ void lcd_init() {
#endif
}
int lcd_strlen(char *s) {
int lcd_strlen(char* s) {
int i = 0, j = 0;
while (s[i]) {
if ((s[i] & 0xc0) != 0x80) j++;
......@@ -1703,7 +1787,7 @@ int lcd_strlen(char *s) {
return j;
}
int lcd_strlen_P(const char *s) {
int lcd_strlen_P(const char* s) {
int j = 0;
while (pgm_read_byte(s)) {
if ((pgm_read_byte(s) & 0xc0) != 0x80) j++;
......@@ -1737,6 +1821,7 @@ void lcd_update() {
lcd_buttons_update();
#if ENABLED(SDSUPPORT) && PIN_EXISTS(SD_DETECT)
bool sd_status = IS_SD_INSERTED;
if (sd_status != lcd_sd_status && lcd_detected()) {
lcdDrawUpdate = 2;
......@@ -1745,13 +1830,16 @@ void lcd_update() {
currentMenu == lcd_status_screen
#endif
);
if (sd_status) {
card.initsd();
if (lcd_sd_status != 2) LCD_MESSAGEPGM(MSG_SD_INSERTED);
} else {
}
else {
card.release();
if (lcd_sd_status != 2) LCD_MESSAGEPGM(MSG_SD_REMOVED);
}
lcd_sd_status = sd_status;
}
......@@ -1830,9 +1918,10 @@ void lcd_update() {
u8g.drawPixel(127, 63); // draw alive dot
u8g.setColorIndex(1); // black on white
(*currentMenu)();
} while( u8g.nextPage() );
} while(u8g.nextPage());
}
#else
if (lcdDrawUpdate)
(*currentMenu)();
#endif
......@@ -1884,7 +1973,7 @@ void lcd_finishstatus(bool persist=false) {
void dontExpireStatus() { expire_status_ms = 0; }
#endif
void set_utf_strlen(char *s, uint8_t n) {
void set_utf_strlen(char* s, uint8_t n) {
uint8_t i = 0, j = 0;
while (s[i] && (j < n)) {
if ((s[i] & 0xc0u) != 0x80u) j++;
......@@ -1898,14 +1987,14 @@ bool lcd_hasstatus() { return (lcd_status_message[0] != '\0'); }
void lcd_setstatus(const char* message, bool persist) {
if (lcd_status_message_level > 0) return;
strncpy(lcd_status_message, message, 3*LCD_WIDTH);
strncpy(lcd_status_message, message, 3 * LCD_WIDTH);
set_utf_strlen(lcd_status_message, LCD_WIDTH);
lcd_finishstatus(persist);
}
void lcd_setstatuspgm(const char* message, uint8_t level) {
if (level >= lcd_status_message_level) {
strncpy_P(lcd_status_message, message, 3*LCD_WIDTH);
strncpy_P(lcd_status_message, message, 3 * LCD_WIDTH);
set_utf_strlen(lcd_status_message, LCD_WIDTH);
lcd_status_message_level = level;
lcd_finishstatus(level > 0);
......@@ -1969,23 +2058,23 @@ void lcd_reset_alert_level() { lcd_status_message_level = 0; }
#endif
#if ENABLED(REPRAPWORLD_KEYPAD)
// for the reprapworld_keypad
uint8_t newbutton_reprapworld_keypad=0;
uint8_t newbutton_reprapworld_keypad = 0;
WRITE(SHIFT_LD, LOW);
WRITE(SHIFT_LD, HIGH);
for(int8_t i = 0; i < 8; i++) {
for (int8_t i = 0; i < 8; i++) {
newbutton_reprapworld_keypad >>= 1;
if (READ(SHIFT_OUT)) newbutton_reprapworld_keypad |= BIT(7);
WRITE(SHIFT_CLK, HIGH);
WRITE(SHIFT_CLK, LOW);
}
buttons_reprapworld_keypad=~newbutton_reprapworld_keypad; //invert it, because a pressed switch produces a logical 0
buttons_reprapworld_keypad = ~newbutton_reprapworld_keypad; //invert it, because a pressed switch produces a logical 0
#endif
#else //read it from the shift register
uint8_t newbutton = 0;
WRITE(SHIFT_LD, LOW);
WRITE(SHIFT_LD, HIGH);
unsigned char tmp_buttons = 0;
for(int8_t i=0; i<8; i++) {
for (int8_t i = 0; i < 8; i++) {
newbutton >>= 1;
if (READ(SHIFT_OUT)) newbutton |= BIT(7);
WRITE(SHIFT_CLK, HIGH);
......@@ -1995,26 +2084,26 @@ void lcd_reset_alert_level() { lcd_status_message_level = 0; }
#endif //!NEWPANEL
//manage encoder rotation
uint8_t enc=0;
uint8_t enc = 0;
if (buttons & EN_A) enc |= B01;
if (buttons & EN_B) enc |= B10;
if (enc != lastEncoderBits) {
switch(enc) {
switch (enc) {
case encrot0:
if (lastEncoderBits==encrot3) encoderDiff++;
else if (lastEncoderBits==encrot1) encoderDiff--;
if (lastEncoderBits == encrot3) encoderDiff++;
else if (lastEncoderBits == encrot1) encoderDiff--;
break;
case encrot1:
if (lastEncoderBits==encrot0) encoderDiff++;
else if (lastEncoderBits==encrot2) encoderDiff--;
if (lastEncoderBits == encrot0) encoderDiff++;
else if (lastEncoderBits == encrot2) encoderDiff--;
break;
case encrot2:
if (lastEncoderBits==encrot1) encoderDiff++;
else if (lastEncoderBits==encrot3) encoderDiff--;
if (lastEncoderBits == encrot1) encoderDiff++;
else if (lastEncoderBits == encrot3) encoderDiff--;
break;
case encrot3:
if (lastEncoderBits==encrot2) encoderDiff++;
else if (lastEncoderBits==encrot0) encoderDiff--;
if (lastEncoderBits == encrot2) encoderDiff++;
else if (lastEncoderBits == encrot0) encoderDiff--;
break;
}
}
......@@ -2039,13 +2128,14 @@ void lcd_reset_alert_level() { lcd_status_message_level = 0; }
char conv[8];
// Convert float to string with +123.4 format
char *ftostr3(const float &x) {
return itostr3((int)x);
}
// Convert float to rj string with 123 or -12 format
char *ftostr3(const float& x) { return itostr3((int)x); }
// Convert float to rj string with _123, -123, _-12, or __-1 format
char *ftostr4sign(const float& x) { return itostr4sign((int)x); }
// Convert int to string with 12 format
char *itostr2(const uint8_t &x) {
char* itostr2(const uint8_t& x) {
//sprintf(conv,"%5.1f",x);
int xx = x;
conv[0] = (xx / 10) % 10 + '0';
......@@ -2055,7 +2145,7 @@ char *itostr2(const uint8_t &x) {
}
// Convert float to string with +123.4 format
char *ftostr31(const float &x) {
char* ftostr31(const float& x) {
int xx = abs(x * 10);
conv[0] = (x >= 0) ? '+' : '-';
conv[1] = (xx / 1000) % 10 + '0';
......@@ -2068,7 +2158,7 @@ char *ftostr31(const float &x) {
}
// Convert float to string with 123.4 format, dropping sign
char *ftostr31ns(const float &x) {
char* ftostr31ns(const float& x) {
int xx = abs(x * 10);
conv[0] = (xx / 1000) % 10 + '0';
conv[1] = (xx / 100) % 10 + '0';
......@@ -2079,8 +2169,8 @@ char *ftostr31ns(const float &x) {
return conv;
}
// Convert float to string with 123.4 format
char *ftostr32(const float &x) {
// Convert float to string with 123.45 format
char* ftostr32(const float& x) {
long xx = abs(x * 100);
conv[0] = x >= 0 ? (xx / 10000) % 10 + '0' : '-';
conv[1] = (xx / 1000) % 10 + '0';
......@@ -2093,14 +2183,12 @@ char *ftostr32(const float &x) {
}
// Convert float to string with 1.234 format
char *ftostr43(const float &x) {
char* ftostr43(const float& x) {
long xx = x * 1000;
if (xx >= 0) {
if (xx >= 0)
conv[0] = (xx / 1000) % 10 + '0';
}
else {
else
conv[0] = '-';
}
xx = abs(xx);
conv[1] = '.';
conv[2] = (xx / 100) % 10 + '0';
......@@ -2111,23 +2199,21 @@ char *ftostr43(const float &x) {
}
// Convert float to string with 1.23 format
char *ftostr12ns(const float &x) {
long xx=x*100;
xx=abs(xx);
conv[0]=(xx/100)%10+'0';
conv[1]='.';
conv[2]=(xx/10)%10+'0';
conv[3]=(xx)%10+'0';
conv[4]=0;
char* ftostr12ns(const float& x) {
long xx = x * 100;
xx = abs(xx);
conv[0] = (xx / 100) % 10 + '0';
conv[1] = '.';
conv[2] = (xx / 10) % 10 + '0';
conv[3] = (xx) % 10 + '0';
conv[4] = 0;
return conv;
}
// Convert float to space-padded string with -_23.4_ format
char *ftostr32sp(const float &x) {
char* ftostr32sp(const float& x) {
long xx = abs(x * 100);
uint8_t dig;
if (x < 0) { // negative val = -_0
conv[0] = '-';
dig = (xx / 1000) % 10;
......@@ -2170,7 +2256,7 @@ char *ftostr32sp(const float &x) {
}
// Convert int to lj string with +123.0 format
char *itostr31(const int &x) {
char* itostr31(const int& x) {
conv[0] = x >= 0 ? '+' : '-';
int xx = abs(x);
conv[1] = (xx / 100) % 10 + '0';
......@@ -2183,7 +2269,7 @@ char *itostr31(const int &x) {
}
// Convert int to rj string with 123 or -12 format
char *itostr3(const int &x) {
char* itostr3(const int& x) {
int xx = x;
if (xx < 0) {
conv[0] = '-';
......@@ -2199,7 +2285,7 @@ char *itostr3(const int &x) {
}
// Convert int to lj string with 123 format
char *itostr3left(const int &xx) {
char* itostr3left(const int& xx) {
if (xx >= 100) {
conv[0] = (xx / 100) % 10 + '0';
conv[1] = (xx / 10) % 10 + '0';
......@@ -2219,7 +2305,7 @@ char *itostr3left(const int &xx) {
}
// Convert int to rj string with 1234 format
char *itostr4(const int &xx) {
char* itostr4(const int& xx) {
conv[0] = xx >= 1000 ? (xx / 1000) % 10 + '0' : ' ';
conv[1] = xx >= 100 ? (xx / 100) % 10 + '0' : ' ';
conv[2] = xx >= 10 ? (xx / 10) % 10 + '0' : ' ';
......@@ -2228,7 +2314,31 @@ char *itostr4(const int &xx) {
return conv;
}
char *ltostr7(const long &xx) {
// Convert int to rj string with _123, -123, _-12, or __-1 format
char* itostr4sign(const int& x) {
int xx = abs(x);
int sign = 0;
if (xx >= 100) {
conv[1] = (xx / 100) % 10 + '0';
conv[2] = (xx / 10) % 10 + '0';
}
else if (xx >= 10) {
conv[0] = ' ';
sign = 1;
conv[2] = (xx / 10) % 10 + '0';
}
else {
conv[0] = ' ';
conv[1] = ' ';
sign = 2;
}
conv[sign] = x < 0 ? '-' : ' ';
conv[3] = xx % 10 + '0';
conv[4] = 0;
return conv;
}
char* ltostr7(const long& xx) {
if (xx >= 1000000)
conv[0]=(xx/1000000)%10+'0';
else
......@@ -2259,7 +2369,7 @@ char *ltostr7(const long &xx) {
}
// convert float to string with +123 format
char *ftostr30(const float &x) {
char* ftostr30(const float& x) {
int xx=x;
conv[0]=(xx>=0)?'+':'-';
xx=abs(xx);
......@@ -2271,7 +2381,7 @@ char *ftostr30(const float &x) {
}
// Convert float to rj string with 12345 format
char *ftostr5(const float &x) {
char* ftostr5(const float& x) {
long xx = abs(x);
conv[0] = xx >= 10000 ? (xx / 10000) % 10 + '0' : ' ';
conv[1] = xx >= 1000 ? (xx / 1000) % 10 + '0' : ' ';
......@@ -2283,7 +2393,7 @@ char *ftostr5(const float &x) {
}
// Convert float to string with +1234.5 format
char *ftostr51(const float &x) {
char* ftostr51(const float& x) {
long xx = abs(x * 10);
conv[0] = (x >= 0) ? '+' : '-';
conv[1] = (xx / 10000) % 10 + '0';
......@@ -2297,7 +2407,7 @@ char *ftostr51(const float &x) {
}
// Convert float to string with +123.45 format
char *ftostr52(const float &x) {
char* ftostr52(const float& x) {
conv[0] = (x >= 0) ? '+' : '-';
long xx = abs(x * 100);
conv[1] = (xx / 10000) % 10 + '0';
......
#ifndef ULTRALCD_H
#define ULTRALCD_H
#include "Marlin_main.h"
#if ENABLED(ULTRA_LCD)
int lcd_strlen(char *s);
int lcd_strlen_P(const char *s);
#include "buzzer.h"
int lcd_strlen(char* s);
int lcd_strlen_P(const char* s);
void lcd_update();
void lcd_init();
bool lcd_hasstatus();
......@@ -109,33 +112,35 @@
#define LCD_CLICKED ((buttons&B_MI)||(buttons&B_ST))
#endif//NEWPANEL
char *itostr2(const uint8_t &x);
char *itostr31(const int &xx);
char *itostr3(const int &xx);
char *itostr3left(const int &xx);
char *itostr4(const int &xx);
char *ltostr7(const long &xx);
char *ftostr3(const float &x);
char *ftostr30(const float &x);
char *ftostr31ns(const float &x); // float to string without sign character
char *ftostr31(const float &x);
char *ftostr32(const float &x);
char *ftostr43(const float &x);
char *ftostr12ns(const float &x);
char *ftostr32sp(const float &x); // remove zero-padding from ftostr32
char *ftostr5(const float &x);
char *ftostr51(const float &x);
char *ftostr52(const float &x);
char* itostr2(const uint8_t& x);
char* itostr31(const int& xx);
char* itostr3(const int& xx);
char* itostr3left(const int& xx);
char* itostr4(const int& xx);
char* itostr4sign(const int& x);
char* ltostr7(const long& xx);
char* ftostr3(const float& x);
char* ftostr4sign(const float& x);
char* ftostr30(const float& x);
char* ftostr31ns(const float& x); // float to string without sign character
char* ftostr31(const float& x);
char* ftostr32(const float& x);
char* ftostr43(const float& x);
char* ftostr12ns(const float& x);
char* ftostr32sp(const float& x); // remove zero-padding from ftostr32
char* ftostr5(const float& x);
char* ftostr51(const float& x);
char* ftostr52(const float& x);
#elif DISABLED(NEXTION)
FORCE_INLINE void lcd_update() {}
FORCE_INLINE void lcd_init() {}
FORCE_INLINE bool lcd_hasstatus() { return false; }
FORCE_INLINE void lcd_setstatus(const char* message, const bool persist=false) {}
FORCE_INLINE void lcd_setstatuspgm(const char* message, const uint8_t level=0) {}
FORCE_INLINE void lcd_setstatus(const char* message, const bool persist=false) {UNUSED(message); UNUSED(persist);}
FORCE_INLINE void lcd_setstatuspgm(const char* message, const uint8_t level=0) {UNUSED(message); UNUSED(level);}
FORCE_INLINE void lcd_buttons_update() {}
FORCE_INLINE void lcd_reset_alert_level() {}
FORCE_INLINE bool lcd_detected(void) { return true; }
......
#ifndef ULTRALCD_IMPLEMENTATION_HITACHI_HD44780_H
#define ULTRALCD_IMPLEMENTATION_HITACHI_HD44780_H
/**
* 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.
......@@ -19,28 +20,28 @@
// via a shift/i2c register.
#if ENABLED(ULTIPANEL)
// All UltiPanels might have an encoder - so this is always be mapped onto first two bits
#define BLEN_B 1
#define BLEN_A 0
// All UltiPanels might have an encoder - so this is always be mapped onto first two bits
#define BLEN_B 1
#define BLEN_A 0
#define EN_B BIT(BLEN_B) // The two encoder pins are connected through BTN_EN1 and BTN_EN2
#define EN_A BIT(BLEN_A)
#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 > -1
// encoder click is directly connected
#define BLEN_C 2
#define EN_C BIT(BLEN_C)
#endif
#endif
#if HAS(BTN_BACK)
#if HAS(BTN_BACK)
#define BLEN_D 3
#define EN_D BIT(BLEN_D)
#endif
#endif
//
// Setup other button mappings of each panel
//
#if ENABLED(LCD_I2C_VIKI)
//
// Setup other button mappings of each panel
//
#if ENABLED(LCD_I2C_VIKI)
#define B_I2C_BTN_OFFSET 3 // (the first three bit positions reserved for EN_A, EN_B, EN_C)
// button and encoder bit positions within 'buttons'
......@@ -61,7 +62,7 @@
// I2C buttons take too long to read inside an interrupt context and so we read them during lcd_update
#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
#define B_I2C_BTN_OFFSET 3 // (the first three bit positions reserved for EN_A, EN_B, EN_C)
......@@ -76,7 +77,7 @@
#define LCD_CLICKED (buttons&EN_C)
#endif
#elif ENABLED(REPRAPWORLD_KEYPAD)
#elif ENABLED(REPRAPWORLD_KEYPAD)
// define register bit values, don't change it
#define BLEN_REPRAPWORLD_KEYPAD_F3 0
#define BLEN_REPRAPWORLD_KEYPAD_F2 1
......@@ -103,13 +104,13 @@
//#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)
#define LCD_CLICKED (buttons&EN_C)
#if HAS(BTN_BACK)
#define LCD_BACK_CLICKED (buttons&EN_D)
#endif
#else // old style ULTIPANEL
#else // old style ULTIPANEL
//bits in the shift register that carry the buttons for:
// left up center down right red(stop)
#define BL_LE 7
......@@ -128,7 +129,7 @@
#define B_ST BIT(BL_ST)
#define LCD_CLICKED (buttons&(B_MI|B_ST))
#endif
#endif
#endif //ULTIPANEL
......@@ -149,7 +150,7 @@
#include <LCD.h>
#include <LiquidCrystal_I2C.h>
#define LCD_CLASS LiquidCrystal_I2C
LCD_CLASS lcd(LCD_I2C_ADDRESS,LCD_I2C_PIN_EN,LCD_I2C_PIN_RW,LCD_I2C_PIN_RS,LCD_I2C_PIN_D4,LCD_I2C_PIN_D5,LCD_I2C_PIN_D6,LCD_I2C_PIN_D7);
LCD_CLASS lcd(LCD_I2C_ADDRESS, LCD_I2C_PIN_EN, LCD_I2C_PIN_RW, LCD_I2C_PIN_RS, LCD_I2C_PIN_D4, LCD_I2C_PIN_D5, LCD_I2C_PIN_D6, LCD_I2C_PIN_D7);
#elif ENABLED(LCD_I2C_TYPE_MCP23017)
//for the LED indicators (which maybe mapped to different things in lcd_implementation_update_indicators())
......@@ -195,7 +196,7 @@
// Standard directly connected LCD implementations
#include <LiquidCrystal.h>
#define LCD_CLASS LiquidCrystal
LCD_CLASS lcd(LCD_PINS_RS, LCD_PINS_ENABLE, LCD_PINS_D4, LCD_PINS_D5,LCD_PINS_D6,LCD_PINS_D7); //RS,Enable,D4,D5,D6,D7
LCD_CLASS lcd(LCD_PINS_RS, LCD_PINS_ENABLE, LCD_PINS_D4, LCD_PINS_D5, LCD_PINS_D6, LCD_PINS_D7); //RS,Enable,D4,D5,D6,D7
#endif
#include "utf_mapper.h"
......@@ -210,24 +211,10 @@
static void lcd_set_custom_characters(
#if ENABLED(LCD_PROGRESS_BAR)
bool progress_bar_set=true
bool progress_bar_set = true
#endif
) {
#if MECH(DELTA)
byte bedTemp[8] =
{
B00000,
B01110,
B11111,
B11011,
B11111,
B01110,
B00000,
B00000
};
#else
byte bedTemp[8] =
{
byte bedTemp[8] = {
B00000,
B11111,
B10101,
......@@ -237,20 +224,17 @@ static void lcd_set_custom_characters(
B00000,
B00000
}; //thanks Sonny Mounicou
#endif //DELTA
byte degree[8] =
{
B00100,
B01010,
B00100,
B00000,
byte degree[8] = {
B01100,
B10010,
B10010,
B01100,
B00000,
B00000,
B00000,
B00000
};
byte thermometer[8] =
{
byte thermometer[8] = {
B00100,
B01010,
B01010,
......@@ -260,17 +244,17 @@ static void lcd_set_custom_characters(
B11111,
B01110
};
byte uplevel[8]={
byte uplevel[8] = {
B00100,
B01110,
B10101,
B00100,
B11111,
B00100,
B11100,
B00000,
B00000,
B00000
}; //thanks joris
byte refresh[8]={
byte refresh[8] = {
B00000,
B00110,
B11001,
......@@ -280,7 +264,7 @@ static void lcd_set_custom_characters(
B01100,
B00000,
}; //thanks joris
byte folder [8]={
byte folder[8] = {
B00000,
B11100,
B11111,
......@@ -290,7 +274,7 @@ static void lcd_set_custom_characters(
B00000,
B00000
}; //thanks joris
byte feedrate [8]={
byte feedrate[8] = {
B11100,
B10000,
B11000,
......@@ -300,7 +284,7 @@ static void lcd_set_custom_characters(
B00101,
B00000
}; //thanks Sonny Mounicou
byte clock [8]={
byte clock[8] = {
B00000,
B01110,
B10011,
......@@ -350,7 +334,7 @@ static void lcd_set_custom_characters(
lcd.createChar(LCD_STR_CLOCK[0], clock);
if (progress_bar_set) {
// Progress bar characters for info screen
for (int i=3; i--;) lcd.createChar(LCD_STR_PROGRESS[i], progress[i]);
for (int i = 3; i--;) lcd.createChar(LCD_STR_PROGRESS[i], progress[i]);
}
else {
// Custom characters for submenus
......@@ -373,7 +357,7 @@ static void lcd_set_custom_characters(
static void lcd_implementation_init(
#if ENABLED(LCD_PROGRESS_BAR)
bool progress_bar_set=true
bool progress_bar_set = true
#endif
) {
......@@ -439,7 +423,7 @@ Possible status screens:
|0123456789012345|
16x4 |000/000 B000/000|
|SD100% Z000.00 |
|SD100% Z 000.00|
|F100% T--:--|
|0123456789012345|
......@@ -447,12 +431,12 @@ Possible status screens:
|01234567890123456789|
20x4 |T000/000D B000/000D |
|X000 Y000 Z000.00 |
|X 000 Y 000 Z 000.00|
|F100% SD100% T--:--|
|01234567890123456789|
20x4 |T000/000D B000/000D |
|T000/000D Z000.00 |
|T000/000D Z 000.00|
|F100% SD100% T--:--|
|01234567890123456789|
*/
......@@ -553,33 +537,22 @@ static void lcd_implementation_status_screen() {
lcd.print('X');
if (axis_known_position[X_AXIS])
#if MECH(DELTA)
lcd.print(ftostr30(current_position[X_AXIS]));
#else
lcd.print(ftostr3(current_position[X_AXIS]));
#endif
lcd.print(ftostr4sign(current_position[X_AXIS]));
else
lcd_printPGM(PSTR("---"));
lcd_printPGM(PSTR(" ---"));
#if MECH(DELTA)
lcd_printPGM(PSTR(" Y"));
if (axis_known_position[Y_AXIS])
lcd.print(ftostr30(current_position[Y_AXIS]));
lcd.print(ftostr4sign(current_position[Y_AXIS]));
else
#else
lcd_printPGM(PSTR(" Y"));
if (axis_known_position[Y_AXIS])
lcd.print(ftostr3(current_position[Y_AXIS]));
else
#endif // DELTA
lcd_printPGM(PSTR("---"));
lcd_printPGM(PSTR(" ---"));
#endif // HOTENDS > 1 || TEMP_SENSOR_BED != 0
#endif // LCD_WIDTH >= 20
lcd.setCursor(LCD_WIDTH - 8, 1);
lcd.print('Z');
lcd_printPGM(PSTR("Z "));
if (axis_known_position[Z_AXIS])
lcd.print(ftostr32sp(current_position[Z_AXIS] + 0.00001));
else
......@@ -653,13 +626,13 @@ static void lcd_implementation_status_screen() {
if (millis() >= progress_bar_ms + PROGRESS_BAR_MSG_TIME || !lcd_status_message[0]) {
int tix = (int)(card.percentDone() * LCD_WIDTH * 3) / 100,
cel = tix / 3, rem = tix % 3, i = LCD_WIDTH;
char msg[LCD_WIDTH+1], b = ' ';
char msg[LCD_WIDTH + 1], b = ' ';
msg[i] = '\0';
while (i--) {
if (i == cel - 1)
b = LCD_STR_PROGRESS[2];
else if (i == cel && rem != 0)
b = LCD_STR_PROGRESS[rem-1];
b = LCD_STR_PROGRESS[rem - 1];
msg[i] = b;
}
lcd.print(msg);
......@@ -712,7 +685,7 @@ static void lcd_implementation_drawmenu_generic(bool sel, uint8_t row, const cha
n -= lcd_print(c);
pstr++;
}
while(n--) lcd.print(' ');
while (n--) lcd.print(' ');
lcd.print(post_char);
}
......@@ -772,7 +745,9 @@ void lcd_implementation_drawedit(const char* pstr, char* value) {
lcd_print(value);
}
static void lcd_implementation_drawmenu_sd(bool sel, uint8_t row, const char* pstr, const char* filename, char* longFilename, uint8_t concat, char post_char) {
#if ENABLED(SDSUPPORT)
static void lcd_implementation_drawmenu_sd(bool sel, uint8_t row, const char* pstr, const char* filename, char* longFilename, uint8_t concat, char post_char) {
char c;
uint8_t n = LCD_WIDTH - concat;
lcd.setCursor(0, row);
......@@ -787,15 +762,17 @@ static void lcd_implementation_drawmenu_sd(bool sel, uint8_t row, const char* ps
}
while (n--) lcd.print(' ');
lcd.print(post_char);
}
}
static void lcd_implementation_drawmenu_sdfile(bool sel, uint8_t row, const char* pstr, const char* filename, char* longFilename) {
static void lcd_implementation_drawmenu_sdfile(bool sel, uint8_t row, const char* pstr, const char* filename, char* longFilename) {
lcd_implementation_drawmenu_sd(sel, row, pstr, filename, longFilename, 2, ' ');
}
}
static void lcd_implementation_drawmenu_sddirectory(bool sel, uint8_t row, const char* pstr, const char* filename, char* longFilename) {
static void lcd_implementation_drawmenu_sddirectory(bool sel, uint8_t row, const char* pstr, const char* filename, char* longFilename) {
lcd_implementation_drawmenu_sd(sel, row, pstr, filename, longFilename, 2, LCD_STR_FOLDER[0]);
}
}
#endif // SDSUPPORT
#define lcd_implementation_drawmenu_back(sel, row, pstr, data) lcd_implementation_drawmenu_generic(sel, row, pstr, LCD_STR_UPLEVEL[0], LCD_STR_UPLEVEL[0])
#define lcd_implementation_drawmenu_submenu(sel, row, pstr, data) lcd_implementation_drawmenu_generic(sel, row, pstr, '>', LCD_STR_ARROW_RIGHT[0])
......@@ -835,8 +812,8 @@ static void lcd_implementation_drawmenu_sddirectory(bool sel, uint8_t row, const
// so they are called during normal lcd_update
slow_buttons = lcd.readButtons() << B_I2C_BTN_OFFSET;
#if ENABLED(LCD_I2C_VIKI)
if ((slow_buttons & (B_MI|B_RI)) && millis() < next_button_update_ms) // LCD clicked
slow_buttons &= ~(B_MI|B_RI); // Disable LCD clicked buttons if screen is updated
if ((slow_buttons & (B_MI | B_RI)) && millis() < next_button_update_ms) // LCD clicked
slow_buttons &= ~(B_MI | B_RI); // Disable LCD clicked buttons if screen is updated
#endif
return slow_buttons;
#endif
......
......@@ -19,10 +19,9 @@
#include <U8glib.h>
static void ST7920_SWSPI_SND_8BIT(uint8_t val)
{
static void ST7920_SWSPI_SND_8BIT(uint8_t val) {
uint8_t i;
for( i = 0; i < 8; i++ ) {
for (i = 0; i < 8; i++) {
WRITE(ST7920_CLK_PIN,0);
#if F_CPU == 20000000
__asm__("nop\n\t");
......@@ -43,16 +42,13 @@ static void ST7920_SWSPI_SND_8BIT(uint8_t val)
#define ST7920_WRITE_BYTE(a) {ST7920_SWSPI_SND_8BIT((uint8_t)((a)&0xf0u));ST7920_SWSPI_SND_8BIT((uint8_t)((a)<<4u));u8g_10MicroDelay();}
#define ST7920_WRITE_BYTES(p,l) {uint8_t i;for(i=0;i<l;i++){ST7920_SWSPI_SND_8BIT(*p&0xf0);ST7920_SWSPI_SND_8BIT(*p<<4);p++;}u8g_10MicroDelay();}
uint8_t u8g_dev_rrd_st7920_128x64_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
{
uint8_t i,y;
switch(msg)
{
case U8G_DEV_MSG_INIT:
{
OUT_WRITE(ST7920_CS_PIN,LOW);
OUT_WRITE(ST7920_DAT_PIN,LOW);
OUT_WRITE(ST7920_CLK_PIN,HIGH);
uint8_t u8g_dev_rrd_st7920_128x64_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg) {
uint8_t i, y;
switch (msg) {
case U8G_DEV_MSG_INIT: {
OUT_WRITE(ST7920_CS_PIN, LOW);
OUT_WRITE(ST7920_DAT_PIN, LOW);
OUT_WRITE(ST7920_CLK_PIN, HIGH);
ST7920_CS();
u8g_Delay(120); //initial delay for boot up
......@@ -61,12 +57,11 @@ uint8_t u8g_dev_rrd_st7920_128x64_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, vo
ST7920_WRITE_BYTE(0x01); //clear CGRAM ram
u8g_Delay(15); //delay for CGRAM clear
ST7920_WRITE_BYTE(0x3E); //extended mode + GDRAM active
for(y = 0; y < LCD_PIXEL_HEIGHT / 2; y++) //clear GDRAM
{
ST7920_WRITE_BYTE(0x80|y); //set y
for (y = 0; y < LCD_PIXEL_HEIGHT / 2; y++) { //clear GDRAM
ST7920_WRITE_BYTE(0x80 | y); //set y
ST7920_WRITE_BYTE(0x80); //set x = 0
ST7920_SET_DAT();
for(i = 0; i < 2 * LCD_PIXEL_WIDTH / 8; i++) //2x width clears both segments
for (i = 0; i < 2 * LCD_PIXEL_WIDTH / 8; i++) //2x width clears both segments
ST7920_WRITE_BYTE(0);
ST7920_SET_CMD();
}
......@@ -74,33 +69,27 @@ uint8_t u8g_dev_rrd_st7920_128x64_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, vo
ST7920_NCS();
}
break;
case U8G_DEV_MSG_STOP:
break;
case U8G_DEV_MSG_PAGE_NEXT:
{
uint8_t *ptr;
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
case U8G_DEV_MSG_PAGE_NEXT: {
uint8_t* ptr;
u8g_pb_t* pb = (u8g_pb_t*)(dev->dev_mem);
y = pb->p.page_y0;
ptr = (uint8_t*)pb->buf;
ST7920_CS();
for( i = 0; i < PAGE_HEIGHT; i ++ )
{
for (i = 0; i < PAGE_HEIGHT; i ++) {
ST7920_SET_CMD();
if ( y < 32 )
{
if (y < 32) {
ST7920_WRITE_BYTE(0x80 | y); //y
ST7920_WRITE_BYTE(0x80); //x=0
}
else
{
ST7920_WRITE_BYTE(0x80 | (y-32)); //y
else {
ST7920_WRITE_BYTE(0x80 | (y - 32)); //y
ST7920_WRITE_BYTE(0x80 | 8); //x=64
}
ST7920_SET_DAT();
ST7920_WRITE_BYTES(ptr,LCD_PIXEL_WIDTH/8); //ptr is incremented inside of macro
ST7920_WRITE_BYTES(ptr, LCD_PIXEL_WIDTH / 8); //ptr is incremented inside of macro
y++;
}
ST7920_NCS();
......@@ -116,12 +105,11 @@ uint8_t u8g_dev_rrd_st7920_128x64_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, vo
#endif
}
uint8_t u8g_dev_st7920_128x64_rrd_buf[LCD_PIXEL_WIDTH*(PAGE_HEIGHT/8)] U8G_NOCOMMON;
u8g_pb_t u8g_dev_st7920_128x64_rrd_pb = {{PAGE_HEIGHT,LCD_PIXEL_HEIGHT,0,0,0},LCD_PIXEL_WIDTH,u8g_dev_st7920_128x64_rrd_buf};
u8g_dev_t u8g_dev_st7920_128x64_rrd_sw_spi = {u8g_dev_rrd_st7920_128x64_fn,&u8g_dev_st7920_128x64_rrd_pb,&u8g_com_null_fn};
uint8_t u8g_dev_st7920_128x64_rrd_buf[LCD_PIXEL_WIDTH * (PAGE_HEIGHT / 8)] U8G_NOCOMMON;
u8g_pb_t u8g_dev_st7920_128x64_rrd_pb = {{PAGE_HEIGHT, LCD_PIXEL_HEIGHT, 0, 0, 0}, LCD_PIXEL_WIDTH, u8g_dev_st7920_128x64_rrd_buf};
u8g_dev_t u8g_dev_st7920_128x64_rrd_sw_spi = {u8g_dev_rrd_st7920_128x64_fn, &u8g_dev_st7920_128x64_rrd_pb, &u8g_com_null_fn};
class U8GLIB_ST7920_128X64_RRD : public U8GLIB
{
class U8GLIB_ST7920_128X64_RRD : public U8GLIB {
public:
U8GLIB_ST7920_128X64_RRD(uint8_t dummy) : U8GLIB(&u8g_dev_st7920_128x64_rrd_sw_spi) {}
};
......
......@@ -55,7 +55,6 @@
#elif ENABLED(DISPLAY_CHARSET_HD44780_WESTERN)
#if ENABLED(MAPPER_C2C3)
:
const PROGMEM uint8_t utf_recode[] =
{ // 0 1 2 3 4 5 6 7 8 9 a b c d e f This is relative complete.
0x20,0xa1,0xa2,0xa3,0xa4,0xa5,0xa6,0xa7,0x22,0xa9,0xaa,0xab,0x3f,0x3f,0xae,0x3f, // c2a ¡¢£¤¥¦§¨©ª«¬­®¯
......@@ -122,14 +121,17 @@
#endif // SIMULATE_ROMFONT
#if ENABLED(MAPPER_NON)
char charset_mapper(char c){
char charset_mapper(char c) {
HARDWARE_CHAR_OUT( c );
return 1;
}
#elif ENABLED(MAPPER_C2C3)
uint8_t utf_hi_char; // UTF-8 high part
bool seen_c2 = false;
char charset_mapper(char c){
char charset_mapper(char c) {
static uint8_t utf_hi_char; // UTF-8 high part
static bool seen_c2 = false;
uint8_t d = c;
if ( d >= 0x80 ) { // UTF-8 handling
if ( (d >= 0xc0) && (!seen_c2) ) {
......@@ -137,12 +139,12 @@
seen_c2 = true;
return 0;
}
else if (seen_c2){
else if (seen_c2) {
d &= 0x3f;
#if DISABLED(MAPPER_ONE_TO_ONE)
HARDWARE_CHAR_OUT( (char) pgm_read_byte_near( utf_recode + d + ( utf_hi_char << 6 ) - 0x20 ) );
HARDWARE_CHAR_OUT((char)pgm_read_byte_near(utf_recode + d + (utf_hi_char << 6) - 0x20));
#else
HARDWARE_CHAR_OUT( (char) (0x80 + ( utf_hi_char << 6 ) + d) ) ;
HARDWARE_CHAR_OUT((char)(0x80 + (utf_hi_char << 6) + d)) ;
#endif
}
else {
......@@ -155,96 +157,116 @@
seen_c2 = false;
return 1;
}
#elif ENABLED(MAPPER_D0D1_MOD)
uint8_t utf_hi_char; // UTF-8 high part
bool seen_d5 = false;
char charset_mapper(char c){
char charset_mapper(char c) {
// it is a Russian alphabet translation
// except 0401 --> 0xa2 = Ё, 0451 --> 0xb5 = ё
static uint8_t utf_hi_char; // UTF-8 high part
static bool seen_d5 = false;
uint8_t d = c;
if ( d >= 0x80 ) { // UTF-8 handling
if ((d >= 0xd0) && (!seen_d5)) {
if (d >= 0x80) { // UTF-8 handling
if (d >= 0xd0 && !seen_d5) {
utf_hi_char = d - 0xd0;
seen_d5 = true;
return 0;
} else if (seen_d5) {
}
else if (seen_d5) {
d &= 0x3f;
if ( !utf_hi_char && ( d == 1 )) {
HARDWARE_CHAR_OUT((char) 0xa2 ); // Ё
} else if ((utf_hi_char == 1) && (d == 0x11)) {
HARDWARE_CHAR_OUT((char) 0xb5 ); // ё
} else {
HARDWARE_CHAR_OUT((char) pgm_read_byte_near( utf_recode + d + ( utf_hi_char << 6 ) - 0x10 ) );
if (!utf_hi_char && d == 1) {
HARDWARE_CHAR_OUT((char) 0xa2); // Ё
}
else if (utf_hi_char == 1 && d == 0x11) {
HARDWARE_CHAR_OUT((char)0xb5); // ё
}
else {
HARDWARE_CHAR_OUT((char)pgm_read_byte_near(utf_recode + d + (utf_hi_char << 6) - 0x10));
}
}
else {
HARDWARE_CHAR_OUT('?');
}
} else {
}
else {
HARDWARE_CHAR_OUT((char) c );
}
seen_d5 = false;
return 1;
}
#elif ENABLED(MAPPER_D0D1)
uint8_t utf_hi_char; // UTF-8 high part
bool seen_d5 = false;
char charset_mapper(char c){
char charset_mapper(char c) {
static uint8_t utf_hi_char; // UTF-8 high part
static bool seen_d5 = false;
uint8_t d = c;
if ( d >= 0x80u ) { // UTF-8 handling
if ((d >= 0xd0u) && (!seen_d5)) {
if (d >= 0x80u) { // UTF-8 handling
if (d >= 0xd0u && !seen_d5) {
utf_hi_char = d - 0xd0u;
seen_d5 = true;
return 0;
} else if (seen_d5) {
}
else if (seen_d5) {
d &= 0x3fu;
#if DISABLED(MAPPER_ONE_TO_ONE)
HARDWARE_CHAR_OUT( (char) pgm_read_byte_near( utf_recode + d + ( utf_hi_char << 6 ) - 0x20 ) );
HARDWARE_CHAR_OUT((char)pgm_read_byte_near(utf_recode + d + (utf_hi_char << 6) - 0x20));
#else
HARDWARE_CHAR_OUT( (char) (0xa0u + ( utf_hi_char << 6 ) + d ) ) ;
HARDWARE_CHAR_OUT((char)(0xa0u + (utf_hi_char << 6) + d)) ;
#endif
} else {
}
else {
HARDWARE_CHAR_OUT('?');
}
} else {
}
else {
HARDWARE_CHAR_OUT((char) c );
}
seen_d5 = false;
return 1;
}
#elif ENABLED(MAPPER_E382E383)
uint8_t utf_hi_char; // UTF-8 high part
bool seen_e3 = false;
bool seen_82_83 = false;
char charset_mapper(char c){
char charset_mapper(char c) {
static uint8_t utf_hi_char; // UTF-8 high part
static bool seen_e3 = false;
static bool seen_82_83 = false;
uint8_t d = c;
if ( d >= 0x80 ) { // UTF-8 handling
if ( (d == 0xe3) && (seen_e3 == false)) {
if (d >= 0x80) { // UTF-8 handling
if (d == 0xe3 && !seen_e3) {
seen_e3 = true;
return 0; // eat 0xe3
} else if ( (d >= 0x82) && (seen_e3 == true) && (seen_82_83 == false)) {
}
else if (d >= 0x82 && seen_e3 && !seen_82_83) {
utf_hi_char = d - 0x82;
seen_82_83 = true;
return 0;
} else if ((seen_e3 == true) && (seen_82_83 == true)){
}
else if (seen_e3 && seen_82_83) {
d &= 0x3f;
#if DISABLED(MAPPER_ONE_TO_ONE)
HARDWARE_CHAR_OUT( (char) pgm_read_byte_near( utf_recode + d + ( utf_hi_char << 6 ) - 0x20 ) );
HARDWARE_CHAR_OUT((char)pgm_read_byte_near(utf_recode + d + (utf_hi_char << 6) - 0x20));
#else
HARDWARE_CHAR_OUT( (char) (0x80 + ( utf_hi_char << 6 ) + d ) ) ;
HARDWARE_CHAR_OUT((char)(0x80 + (utf_hi_char << 6) + d)) ;
#endif
} else {
}
else {
HARDWARE_CHAR_OUT((char) '?' );
}
} else {
}
else {
HARDWARE_CHAR_OUT((char) c );
}
seen_e3 = false;
seen_82_83 = false;
return 1;
}
#else
#error "You have to define one of the DISPLAY_INPUT_CODE_MAPPERs in your language_xx.h file" // should not occur because (en) will set.
#endif // code mappers
#endif // UTF_MAPPER_H
......@@ -51,9 +51,9 @@ void vector_3::normalize() {
}
void vector_3::apply_rotation(matrix_3x3 matrix) {
float resultX = x * matrix.matrix[3*0+0] + y * matrix.matrix[3*1+0] + z * matrix.matrix[3*2+0];
float resultY = x * matrix.matrix[3*0+1] + y * matrix.matrix[3*1+1] + z * matrix.matrix[3*2+1];
float resultZ = x * matrix.matrix[3*0+2] + y * matrix.matrix[3*1+2] + z * matrix.matrix[3*2+2];
float resultX = x * matrix.matrix[3 * 0 + 0] + y * matrix.matrix[3 * 1 + 0] + z * matrix.matrix[3 * 2 + 0];
float resultY = x * matrix.matrix[3 * 0 + 1] + y * matrix.matrix[3 * 1 + 1] + z * matrix.matrix[3 * 2 + 1];
float resultZ = x * matrix.matrix[3 * 0 + 2] + y * matrix.matrix[3 * 1 + 2] + z * matrix.matrix[3 * 2 + 2];
x = resultX;
y = resultY;
z = resultZ;
......@@ -66,7 +66,7 @@ void vector_3::debug(const char title[]) {
ECHO_EMV(" z: ", z, 6);
}
void apply_rotation_xyz(matrix_3x3 matrix, float &x, float& y, float& z) {
void apply_rotation_xyz(matrix_3x3 matrix, float& x, float& y, float& z) {
vector_3 vector = vector_3(x, y, z);
vector.apply_rotation(matrix);
x = vector.x;
......@@ -94,7 +94,7 @@ void matrix_3x3::set_to_identity() {
matrix_3x3 matrix_3x3::create_look_at(vector_3 target) {
vector_3 z_row = target.get_normal();
vector_3 x_row = vector_3(1, 0, -target.x/target.z).get_normal();
vector_3 x_row = vector_3(1, 0, -target.x / target.z).get_normal();
vector_3 y_row = vector_3::cross(z_row, x_row).get_normal();
// x_row.debug("x_row");
......@@ -119,9 +119,9 @@ matrix_3x3 matrix_3x3::transpose(matrix_3x3 original) {
void matrix_3x3::debug(const char title[]) {
ECHO_LV(DB, title);
int count = 0;
for(int i = 0; i < 3; i++) {
for (int i = 0; i < 3; i++) {
ECHO_S(DB);
for(int j = 0; j < 3; j++) {
for (int j = 0; j < 3; j++) {
if (matrix[count] >= 0.0) ECHO_C('+');
ECHO_V(matrix[count], 6);
ECHO_C(' ');
......
......@@ -19,10 +19,10 @@
#ifndef VECTOR_3_H
#define VECTOR_3_H
#if ENABLED(AUTO_BED_LEVELING_FEATURE)
class matrix_3x3;
struct vector_3
{
struct vector_3 {
float x, y, z;
vector_3();
......@@ -41,8 +41,7 @@ struct vector_3
void apply_rotation(matrix_3x3 matrix);
};
struct matrix_3x3
{
struct matrix_3x3 {
float matrix[9];
static matrix_3x3 create_from_rows(vector_3 row_0, vector_3 row_1, vector_3 row_2);
......@@ -55,6 +54,7 @@ struct matrix_3x3
};
void apply_rotation_xyz(matrix_3x3 rotationMatrix, float &x, float& y, float& z);
void apply_rotation_xyz(matrix_3x3 rotationMatrix, float& x, float& y, float& z);
#endif // AUTO_BED_LEVELING_FEATURE
#endif // VECTOR_3_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