Commit 8db93807 authored by Franco (nextime) Lanza's avatar Franco (nextime) Lanza

Merge remote-tracking branch 'upstream/dev' into dev

parents 8c4b09e6 1e3fc326
...@@ -45,6 +45,7 @@ ...@@ -45,6 +45,7 @@
* M30 - Delete file from SD (M30 filename.g) * M30 - Delete file from SD (M30 filename.g)
* M31 - Output time since last M109 or SD card start to serial * M31 - Output time since last M109 or SD card start to serial
* M32 - Make directory * M32 - Make directory
* M35 - Upload Firmware to Nextion from SD
* M42 - Change pin status via gcode Use M42 Px Sy to set pin x to value y, when omitting Px the onboard led will be used. * M42 - Change pin status via gcode Use M42 Px Sy to set pin x to value y, when omitting Px the onboard led will be used.
* M49 - Z probe repetability test * M49 - Z probe repetability test
* M80 - Turn on Power Supply * M80 - Turn on Power Supply
......
### Version 4.2.8 ### Version 4.2.8
* Add board folder with files of various board containing the pins * Add board folder with files of various board containing the pins
* Add End time on Graphics display when SD print * Add End time on Graphics display when SD print
* Add M35 for upload firmware to Nextion from SD
* Rewrite macros * Rewrite macros
* Fix M109 so it won't wait for cooling * Fix M109 so it won't wait for cooling
* Clear code * Clear code
......
...@@ -50,8 +50,36 @@ ...@@ -50,8 +50,36 @@
// if you want use new function comment this (using // at the start of the line) // if you want use new function comment this (using // at the start of the line)
#define DELTA_SEGMENTS_PER_SECOND 200 #define DELTA_SEGMENTS_PER_SECOND 200
// NOTE: All following values for DELTA_* MUST be floating point,
// so always have a decimal point in them.
//
// Towers and rod nomenclature for the following defines:
//
// C, Y-axis
// |
// DELTA_ALPHA_CA=120° | DELTA_ALPHA_CB=120°
// |
// |______ X-axis
// / \
// / \
// / \
// / \
// A B
//
// |___| DELTA CARRIAGE OFFSET
// | \
// | \
// | \ DELTA DIAGONAL ROD
// | \
// | \ | Effector is at printer center!
// | \__|__/
// | |--| DELTA EFFECTOR OFFSET
// |----| DELTA RADIUS Calculated in fw (DELTA SMOOTH ROD OFFSET - DELTA EFFECTOR OFFSET - DELTA CARRIAGE OFFSET)
// |---------| DELTA PRINTABLE RADIUS
// |-----------| DELTA SMOOTH ROD OFFSET
// Center-to-center distance of the holes in the diagonal push rods. // Center-to-center distance of the holes in the diagonal push rods.
#define DEFAULT_DELTA_DIAGONAL_ROD 220.0 // mm #define DELTA_DIAGONAL_ROD 220.0 // mm
// Horizontal offset from middle of printer to smooth rod center. // Horizontal offset from middle of printer to smooth rod center.
#define DELTA_SMOOTH_ROD_OFFSET 150.0 // mm #define DELTA_SMOOTH_ROD_OFFSET 150.0 // mm
...@@ -62,8 +90,8 @@ ...@@ -62,8 +90,8 @@
// Horizontal offset of the universal joints on the carriages. // Horizontal offset of the universal joints on the carriages.
#define DELTA_CARRIAGE_OFFSET 20.0 // mm #define DELTA_CARRIAGE_OFFSET 20.0 // mm
// Bed Printer radius // Delta Printable radius
#define BED_PRINTER_RADIUS 75 // mm #define DELTA_PRINTABLE_RADIUS 75.0 // mm
//Endstop Offset Adjustment - All values are in mm and must be negative (to move down away from endstop switches) //Endstop Offset Adjustment - All values are in mm and must be negative (to move down away from endstop switches)
#define TOWER_A_ENDSTOP_ADJ 0 // Front Left Tower #define TOWER_A_ENDSTOP_ADJ 0 // Front Left Tower
...@@ -80,7 +108,7 @@ ...@@ -80,7 +108,7 @@
#define TOWER_B_RADIUS_ADJ 0 //Front Right Tower #define TOWER_B_RADIUS_ADJ 0 //Front Right Tower
#define TOWER_C_RADIUS_ADJ 0 //Rear Tower #define TOWER_C_RADIUS_ADJ 0 //Rear Tower
//Diagonal Rod Adjustment - Adj diag rod for Tower by x mm from DEFAULT_DELTA_DIAGONAL_ROD value //Diagonal Rod Adjustment - Adj diag rod for Tower by x mm from DELTA_DIAGONAL_ROD value
#define TOWER_A_DIAGROD_ADJ 0 //Front Left Tower #define TOWER_A_DIAGROD_ADJ 0 //Front Left Tower
#define TOWER_B_DIAGROD_ADJ 0 //Front Right Tower #define TOWER_B_DIAGROD_ADJ 0 //Front Right Tower
#define TOWER_C_DIAGROD_ADJ 0 //Rear Tower #define TOWER_C_DIAGROD_ADJ 0 //Rear Tower
...@@ -298,10 +326,10 @@ ...@@ -298,10 +326,10 @@
* Travel limits after homing (units are in mm) * * Travel limits after homing (units are in mm) *
* * * *
*****************************************************************************************/ *****************************************************************************************/
#define X_MAX_POS BED_PRINTER_RADIUS #define X_MAX_POS DELTA_PRINTABLE_RADIUS
#define X_MIN_POS -BED_PRINTER_RADIUS #define X_MIN_POS -DELTA_PRINTABLE_RADIUS
#define Y_MAX_POS BED_PRINTER_RADIUS #define Y_MAX_POS DELTA_PRINTABLE_RADIUS
#define Y_MIN_POS -BED_PRINTER_RADIUS #define Y_MIN_POS -DELTA_PRINTABLE_RADIUS
#define Z_MAX_POS MANUAL_Z_HOME_POS #define Z_MAX_POS MANUAL_Z_HOME_POS
#define Z_MIN_POS 0 #define Z_MIN_POS 0
#define E_MIN_POS 0 #define E_MIN_POS 0
......
...@@ -543,7 +543,7 @@ void Config_ResetDefault() { ...@@ -543,7 +543,7 @@ void Config_ResetDefault() {
#if MECH(DELTA) #if MECH(DELTA)
delta_radius = DEFAULT_DELTA_RADIUS; delta_radius = DEFAULT_DELTA_RADIUS;
delta_diagonal_rod = DEFAULT_DELTA_DIAGONAL_ROD; delta_diagonal_rod = DELTA_DIAGONAL_ROD;
endstop_adj[0] = TOWER_A_ENDSTOP_ADJ; endstop_adj[0] = TOWER_A_ENDSTOP_ADJ;
endstop_adj[1] = TOWER_B_ENDSTOP_ADJ; endstop_adj[1] = TOWER_B_ENDSTOP_ADJ;
endstop_adj[2] = TOWER_C_ENDSTOP_ADJ; endstop_adj[2] = TOWER_C_ENDSTOP_ADJ;
......
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
* MK Firmware * MK Firmware
* *
* Based on Marlin, Sprinter and grbl * Based on Marlin, Sprinter and grbl
* Copyright (C) 2013 MagoKimbra
* Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
* Copyright (C) 2013 - 2016 Alberto Cotronei @MagoKimbra
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
...@@ -81,6 +81,7 @@ ...@@ -81,6 +81,7 @@
* M30 - Delete file from SD (M30 filename.g) * M30 - Delete file from SD (M30 filename.g)
* M31 - Output time since last M109 or SD card start to serial * M31 - Output time since last M109 or SD card start to serial
* M32 - Make directory * M32 - Make directory
* M35 - Upload Firmware to Nextion from SD
* M42 - Change pin status via gcode Use M42 Px Sy to set pin x to value y, when omitting Px the onboard led will be used. * M42 - Change pin status via gcode Use M42 Px Sy to set pin x to value y, when omitting Px the onboard led will be used.
* M48 - Measure Z_Probe repeatability. M48 [P # of points] [X position] [Y position] [V_erboseness #] [E_ngage Probe] [L # of legs of travel] * M48 - Measure Z_Probe repeatability. M48 [P # of points] [X position] [Y position] [V_erboseness #] [E_ngage Probe] [L # of legs of travel]
* M70 - Power consumption sensor calibration * M70 - Power consumption sensor calibration
......
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
* MK Firmware * MK Firmware
* *
* Based on Marlin, Sprinter and grbl * Based on Marlin, Sprinter and grbl
* Copyright (C) 2013 MagoKimbra
* Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
* Copyright (C) 2013 - 2016 Alberto Cotronei @MagoKimbra
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
...@@ -184,8 +184,8 @@ double printer_usage_filament; ...@@ -184,8 +184,8 @@ double printer_usage_filament;
float diagrod_adj[3] = { 0 }; float diagrod_adj[3] = { 0 };
float saved_endstop_adj[3] = { 0 }; float saved_endstop_adj[3] = { 0 };
float tower_adj[6] = { 0 }; float tower_adj[6] = { 0 };
float delta_radius; // = DEFAULT_delta_radius; float delta_radius; // = delta_radius;
float delta_diagonal_rod; // = DEFAULT_DELTA_DIAGONAL_ROD; float delta_diagonal_rod; // = DELTA_DIAGONAL_ROD;
float delta_diagonal_rod_1; float delta_diagonal_rod_1;
float delta_diagonal_rod_2; float delta_diagonal_rod_2;
float delta_diagonal_rod_3; float delta_diagonal_rod_3;
...@@ -2703,8 +2703,9 @@ static void clean_up_after_endstop_move() { ...@@ -2703,8 +2703,9 @@ static void clean_up_after_endstop_move() {
#endif #endif
#if HOTENDS > 1 #if HOTENDS > 1
for (uint8_t h = 0; h < HOTENDS; ++h) { for (uint8_t h = 0; h < HOTENDS; ++h) {
ECHO_MV(" T", h); ECHO_MV(" T", (int)h);
ECHO_MV(":", degHotend(h), 1); ECHO_C(':');
ECHO_V(degHotend(h), 1);
ECHO_MV(" /", degTargetHotend(h), 1); ECHO_MV(" /", degTargetHotend(h), 1);
} }
#endif #endif
...@@ -2724,7 +2725,7 @@ static void clean_up_after_endstop_move() { ...@@ -2724,7 +2725,7 @@ static void clean_up_after_endstop_move() {
#endif #endif
#if HOTENDS > 1 #if HOTENDS > 1
for (uint8_t h = 0; h < HOTENDS; ++h) { for (uint8_t h = 0; h < HOTENDS; ++h) {
ECHO_MV(" " SERIAL_AT, h); ECHO_MV(" " SERIAL_AT, (int)h);
ECHO_C(':'); ECHO_C(':');
#if ENABLED(HOTEND_WATTS) #if ENABLED(HOTEND_WATTS)
ECHO_VM(((HOTEND_WATTS) * getHeaterPower(h)) / 127, "W"); ECHO_VM(((HOTEND_WATTS) * getHeaterPower(h)) / 127, "W");
...@@ -2739,8 +2740,9 @@ static void clean_up_after_endstop_move() { ...@@ -2739,8 +2740,9 @@ static void clean_up_after_endstop_move() {
ECHO_MV("C->", rawBedTemp() / OVERSAMPLENR, 0); ECHO_MV("C->", rawBedTemp() / OVERSAMPLENR, 0);
#endif #endif
for (uint8_t h = 0; h < HOTENDS; ++h) { for (uint8_t h = 0; h < HOTENDS; ++h) {
ECHO_MV(" T", h); ECHO_MV(" T", (int)h);
ECHO_MV(":", degHotend(h), 1); ECHO_C(':');
ECHO_V(degHotend(h), 1);
ECHO_MV("C->", rawHotendTemp(h) / OVERSAMPLENR, 0); ECHO_MV("C->", rawHotendTemp(h) / OVERSAMPLENR, 0);
} }
#endif #endif
...@@ -2833,7 +2835,7 @@ void gcode_get_destination() { ...@@ -2833,7 +2835,7 @@ void gcode_get_destination() {
if(code_seen(axis_codes[E_AXIS])) IDLE_OOZING_retract(false); if(code_seen(axis_codes[E_AXIS])) IDLE_OOZING_retract(false);
#endif #endif
for (int i = 0; i < Z_AXIS; i++) { for (int i = 0; i < 3; i++) {
if (code_seen(axis_codes[i])) if (code_seen(axis_codes[i]))
destination[i] = code_value() + (axis_relative_modes[i] || relative_mode ? current_position[i] : -hotend_offset[i][active_extruder]); destination[i] = code_value() + (axis_relative_modes[i] || relative_mode ? current_position[i] : -hotend_offset[i][active_extruder]);
else else
...@@ -3988,6 +3990,9 @@ inline void gcode_G28() { ...@@ -3988,6 +3990,9 @@ inline void gcode_G28() {
// Sled assembly for Cartesian bots // Sled assembly for Cartesian bots
#if HAS(Z_PROBE_SLED) #if HAS(Z_PROBE_SLED)
dock_sled(true); // dock the probe dock_sled(true); // dock the probe
#elif HASNT(SERVO_ENDSTOPS) && Z_RAISE_AFTER_PROBING > 0
// Raise Z axis for non servo based probes
raise_z_after_probing();
#endif #endif
#if ENABLED(Z_PROBE_END_SCRIPT) #if ENABLED(Z_PROBE_END_SCRIPT)
...@@ -4640,6 +4645,15 @@ inline void gcode_M17() { ...@@ -4640,6 +4645,15 @@ inline void gcode_M17() {
card.mount(); card.mount();
} }
} }
#if ENABLED(NEXTION)
/**
* M35: Upload Firmware to Nextion from SD
*/
inline void gcode_M35() {
UploadNewFirmware();
}
#endif
#endif #endif
/** /**
...@@ -7746,6 +7760,10 @@ void process_next_command() { ...@@ -7746,6 +7760,10 @@ void process_next_command() {
gcode_M31(); break; gcode_M31(); break;
case 32: // M32 - Make directory case 32: // M32 - Make directory
gcode_M32(); break; gcode_M32(); break;
#if ENABLED(NEXTION)
case 35: // M35 - Upload Firmware to Nextion from SD
gcode_M35(); break;
#endif
#endif //SDSUPPORT #endif //SDSUPPORT
case 42: // M42 -Change pin status via gcode case 42: // M42 -Change pin status via gcode
...@@ -7834,7 +7852,7 @@ void process_next_command() { ...@@ -7834,7 +7852,7 @@ void process_next_command() {
gcode_M120(); break; gcode_M120(); break;
case 121: // M121 Disable endstops case 121: // M121 Disable endstops
gcode_M121(); break; gcode_M121(); break;
case 122: // M121 Disable or enable software endstops case 122: // M122 Disable or enable software endstops
gcode_M122(); break; gcode_M122(); break;
#if ENABLED(BARICUDA) #if ENABLED(BARICUDA)
......
...@@ -70,6 +70,12 @@ ...@@ -70,6 +70,12 @@
#define ORIG_HEATER_BED_PIN 8 // BED #define ORIG_HEATER_BED_PIN 8 // BED
#define ORIG_TEMP_BED_PIN 14 // ANALOG NUMBERING #define ORIG_TEMP_BED_PIN 14 // ANALOG NUMBERING
#if ENABLED(REPRAP_DISCOUNT_SMART_CONTROLLER) || ENABLED(G3D_PANEL)
#define KILL_PIN 41
#else
#define KILL_PIN -1
#endif
#if NUM_SERVOS > 0 #if NUM_SERVOS > 0
#define SERVO0_PIN 11 #define SERVO0_PIN 11
#if NUM_SERVOS > 1 #if NUM_SERVOS > 1
......
...@@ -70,6 +70,12 @@ ...@@ -70,6 +70,12 @@
#define ORIG_HEATER_BED_PIN -1 // BED #define ORIG_HEATER_BED_PIN -1 // BED
#define ORIG_TEMP_BED_PIN 14 // ANALOG NUMBERING #define ORIG_TEMP_BED_PIN 14 // ANALOG NUMBERING
#if ENABLED(REPRAP_DISCOUNT_SMART_CONTROLLER) || ENABLED(G3D_PANEL)
#define KILL_PIN 41
#else
#define KILL_PIN -1
#endif
#if NUM_SERVOS > 0 #if NUM_SERVOS > 0
#define SERVO0_PIN 11 #define SERVO0_PIN 11
#if NUM_SERVOS > 1 #if NUM_SERVOS > 1
......
...@@ -70,6 +70,12 @@ ...@@ -70,6 +70,12 @@
#define ORIG_HEATER_BED_PIN 8 // BED #define ORIG_HEATER_BED_PIN 8 // BED
#define ORIG_TEMP_BED_PIN 14 // ANALOG NUMBERING #define ORIG_TEMP_BED_PIN 14 // ANALOG NUMBERING
#if ENABLED(REPRAP_DISCOUNT_SMART_CONTROLLER) || ENABLED(G3D_PANEL)
#define KILL_PIN 41
#else
#define KILL_PIN -1
#endif
#if NUM_SERVOS > 0 #if NUM_SERVOS > 0
#define SERVO0_PIN 11 #define SERVO0_PIN 11
#if NUM_SERVOS > 1 #if NUM_SERVOS > 1
......
...@@ -70,6 +70,12 @@ ...@@ -70,6 +70,12 @@
#define ORIG_HEATER_BED_PIN -1 // BED #define ORIG_HEATER_BED_PIN -1 // BED
#define ORIG_TEMP_BED_PIN -1 // ANALOG NUMBERING #define ORIG_TEMP_BED_PIN -1 // ANALOG NUMBERING
#if ENABLED(REPRAP_DISCOUNT_SMART_CONTROLLER) || ENABLED(G3D_PANEL)
#define KILL_PIN 41
#else
#define KILL_PIN -1
#endif
#if NUM_SERVOS > 0 #if NUM_SERVOS > 0
#define SERVO0_PIN 11 #define SERVO0_PIN 11
#if NUM_SERVOS > 1 #if NUM_SERVOS > 1
......
...@@ -373,7 +373,7 @@ ...@@ -373,7 +373,7 @@
#define BACK_PROBE_BED_POSITION DELTA_PROBABLE_RADIUS #define BACK_PROBE_BED_POSITION DELTA_PROBABLE_RADIUS
// Radius for probe // Radius for probe
#define DELTA_PROBABLE_RADIUS BED_PRINTER_RADIUS - 5 #define DELTA_PROBABLE_RADIUS DELTA_PRINTABLE_RADIUS - 5
#endif #endif
/** /**
......
...@@ -1011,7 +1011,7 @@ static void _lcd_move(const char* name, AxisEnum axis, int min, int max) { ...@@ -1011,7 +1011,7 @@ static void _lcd_move(const char* name, AxisEnum axis, int min, int max) {
} }
#if MECH(DELTA) #if MECH(DELTA)
static float delta_clip_radius_2 = BED_PRINTER_RADIUS * BED_PRINTER_RADIUS; static float delta_clip_radius_2 = DELTA_PRINTABLE_RADIUS * DELTA_PRINTABLE_RADIUS;
static int delta_clip( float a ) { return sqrt(delta_clip_radius_2 - a * a); } static int delta_clip( float a ) { return sqrt(delta_clip_radius_2 - a * a); }
static void lcd_move_x() { int clip = delta_clip(current_position[Y_AXIS]); _lcd_move(PSTR(MSG_MOVE_X), X_AXIS, max(X_MIN_POS, -clip), min(X_MAX_POS, clip)); } static void lcd_move_x() { int clip = delta_clip(current_position[Y_AXIS]); _lcd_move(PSTR(MSG_MOVE_X), X_AXIS, max(X_MIN_POS, -clip), min(X_MAX_POS, clip)); }
static void lcd_move_y() { int clip = delta_clip(current_position[X_AXIS]); _lcd_move(PSTR(MSG_MOVE_X), X_AXIS, max(X_MIN_POS, -clip), min(X_MAX_POS, clip)); } static void lcd_move_y() { int clip = delta_clip(current_position[X_AXIS]); _lcd_move(PSTR(MSG_MOVE_X), X_AXIS, max(X_MIN_POS, -clip), min(X_MAX_POS, clip)); }
......
...@@ -1458,7 +1458,7 @@ void digipot_init() { ...@@ -1458,7 +1458,7 @@ void digipot_init() {
#if MB(ALLIGATOR) #if MB(ALLIGATOR)
unsigned int digipot_motor = 0; unsigned int digipot_motor = 0;
for (uint8_t i = 0; i < 3 + DRIVER_EXTRUDERS; i++) { for (uint8_t i = 0; i < 3 + DRIVER_EXTRUDERS; i++) {
digipot_motor = 255 * (motor_current[i] / 2.5); digipot_motor = 255 * motor_current[i] / 3.3;
ExternalDac::setValue(i, digipot_motor); ExternalDac::setValue(i, digipot_motor);
} }
#endif//MB(ALLIGATOR) #endif//MB(ALLIGATOR)
......
...@@ -84,7 +84,6 @@ __return: ...@@ -84,7 +84,6 @@ __return:
return ret; return ret;
} }
/* /*
* Receive string data. * Receive string data.
* *
...@@ -232,19 +231,20 @@ bool nexInit(void) ...@@ -232,19 +231,20 @@ bool nexInit(void)
sendCommand("page 0"); sendCommand("page 0");
ret2 = recvRetCommandFinished(); ret2 = recvRetCommandFinished();
// If baudrate is 9600 set to 57600 and reconnect // If baudrate is 9600 set to 115200 and reconnect
if (ret1 && ret2) { if (ret1 && ret2) {
sendCommand("baud=57600"); sendCommand("baud=115200");
nexSerial.end(); nexSerial.end();
HAL::delayMilliseconds(1000); HAL::delayMilliseconds(1000);
nexSerial.begin(57600); nexSerial.begin(115200);
return ret1 && ret2; return ret1 && ret2;
// Else try to 57600 baudrate // Else try to 115200 baudrate
} else { }
else {
nexSerial.end(); nexSerial.end();
HAL::delayMilliseconds(1000); HAL::delayMilliseconds(1000);
nexSerial.begin(57600); nexSerial.begin(115200);
sendCommand(""); sendCommand("");
sendCommand("bkcmd=1"); sendCommand("bkcmd=1");
ret1 = recvRetCommandFinished(); ret1 = recvRetCommandFinished();
......
/**
* @file NexUpload.cpp
*
* The implementation of upload tft file for nextion.
*
* @author Chen Zengpeng (email:<zengpeng.chen@itead.cc>)
* @date 2016/3/29
* @copyright
* Copyright (C) 2014-2015 ITEAD Intelligent Systems Co., Ltd. \n
* 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 "NexUpload.h"
#if ENABLED(SDSUPPORT)
NexUpload::NexUpload(const char *file_name, uint32_t upload_baudrate) {
_file_name = file_name;
_upload_baudrate = upload_baudrate;
}
NexUpload::NexUpload(const String file_Name, uint32_t upload_baudrate) {
NexUpload(file_Name.c_str(), upload_baudrate);
}
void NexUpload::startUpload(void) {
if (!_checkFile()) {
ECHO_LM(ER, "The file is error");
return;
}
if (_getBaudrate() == 0) {
ECHO_LM(ER, "baudrate error");
return;
}
if (!_setUploadBaudrate(_upload_baudrate)) {
ECHO_LM(ER, "modify baudrate error");
return;
}
if (!_uploadTftFile()) {
ECHO_LM(ER, "upload file error");
return;
}
card.closeFile();
ECHO_LM(DB, "upload ok");
}
uint16_t NexUpload::_getBaudrate(void) {
uint32_t baudrate_array[7] = {115200, 57600, 38400, 19200, 9600, 4800, 2400};
for (uint8_t i = 0; i < 7; i++) {
if (_searchBaudrate(baudrate_array[i])) {
_baudrate = baudrate_array[i];
break;
}
}
return _baudrate;
}
bool NexUpload::_checkFile(void) {
ECHO_LMT(DB, "Start checkFile ", _file_name);
if (!card.selectFile(_file_name)) {
ECHO_LM(ER, "file is not exit");
return 0;
}
_unuploadByte = card.fileSize;
return 1;
}
bool NexUpload::_searchBaudrate(uint32_t baudrate) {
String string = String("");
nexSerial.end();
HAL::delayMilliseconds(100);
nexSerial.begin(baudrate);
this->sendCommand("");
this->sendCommand("connect");
this->recvRetString(string);
if(string.indexOf("comok") != -1)
return 1;
return 0;
}
void NexUpload::sendCommand(const char* cmd) {
while (nexSerial.available())
nexSerial.read();
nexSerial.print(cmd);
nexSerial.write(0xFF);
nexSerial.write(0xFF);
nexSerial.write(0xFF);
}
uint16_t NexUpload::recvRetString(String &string, uint32_t timeout,bool recv_flag) {
uint16_t ret = 0;
uint8_t c = 0;
long start;
bool exit_flag = false;
start = millis();
while (millis() - start <= timeout) {
while (nexSerial.available()) {
c = nexSerial.read();
if(c == 0) continue;
string += (char)c;
if(recv_flag) {
if(string.indexOf(0x05) != -1)
exit_flag = true;
}
}
if(exit_flag) break;
}
ret = string.length();
return ret;
}
bool NexUpload::_setUploadBaudrate(uint32_t baudrate) {
String string = String("");
String cmd = String("");
String filesize_str = String(_unuploadByte, 10);
String baudrate_str = String(baudrate, 10);
cmd = "whmi-wri " + filesize_str + "," + baudrate_str + ",0";
this->sendCommand("");
this->sendCommand(cmd.c_str());
HAL::delayMilliseconds(50);
nexSerial.begin(baudrate);
this->recvRetString(string, 500);
if(string.indexOf(0x05) != -1)
return 1;
return 0;
}
bool NexUpload::_uploadTftFile(void) {
uint8_t c;
uint16_t send_timer = 0;
uint16_t last_send_num = 0;
String string = String("");
send_timer = _unuploadByte / 4096 + 1;
last_send_num = _unuploadByte % 4096;
while(send_timer) {
if(send_timer == 1) {
for(uint16_t j = 1; j <= 4096; j++) {
if(j <= last_send_num) {
c = card.get();
nexSerial.write(c);
}
else
break;
}
}
else {
for(uint16_t i = 1; i <= 4096; i++) {
c = card.get();
nexSerial.write(c);
}
}
this->recvRetString(string, 500, true);
if(string.indexOf(0x05) != -1)
string = "";
else
return 0;
--send_timer;
}
}
#endif // SDSUPPORT
/**
* @file NexUpload.h
*
* The definition of class NexUpload.
*
* @author Chen Zengpeng (email:<zengpeng.chen@itead.cc>)
* @date 2016/3/29
*
* @copyright
* Copyright (C) 2014-2015 ITEAD Intelligent Systems Co., Ltd. \n
* 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 __NEXUPLOAD_H__
#define __NEXUPLOAD_H__
#include "NexHardware.h"
/**
* @addtogroup CoreAPI
* @{
*/
/**
*
* Provides the API for nextion to upload the ftf file.
*/
class NexUpload
{
public: /* methods */
/**
* Constructor.
*
* @param file_name - tft file name.
* @upload_baudrate - set upload baudrate.
*/
NexUpload(const char *file_name, uint32_t upload_baudrate);
/**
* Constructor.
*
* @param file_name - tft file name.
* @param SD_chip_select - sd chip select pin.
* @upload_baudrate - set upload baudrate.
*/
NexUpload(const String file_Name, uint32_t upload_baudrate);
/**
* destructor.
*
*/
~NexUpload(){}
/*
* start upload.
*
* @return none.
*/
void startUpload(void);
private: /* methods */
/*
* get communicate baudrate.
*
* @return communicate baudrate.
*
*/
uint16_t _getBaudrate(void);
/*
* check tft file.
*
* @return true if success, false for failure.
*/
bool _checkFile(void);
/*
* search communicate baudrate.
*
* @param baudrate - communicate baudrate.
*
* @return true if success, false for failure.
*/
bool _searchBaudrate(uint32_t baudrate);
/*
* set upload baudrate.
*
* @param baudrate - set upload baudrate.
*
* @return true if success, false for failure.
*/
bool _setUploadBaudrate(uint32_t baudrate);
/**
* start dowload tft file to nextion.
*
* @return none.
*/
bool _uploadTftFile(void);
/*
* Send command to Nextion.
*
* @param cmd - the string of command.
*
* @return none.
*/
void sendCommand(const char* cmd);
/*
* Receive string data.
*
* @param buffer - save string data.
* @param timeout - set timeout time.
* @param recv_flag - if recv_flag is true,will braak when receive 0x05.
*
* @return the length of string buffer.
*
*/
uint16_t recvRetString(String &string, uint32_t timeout = 100,bool recv_flag = false);
private: /* data */
uint32_t _baudrate; /*nextion serail baudrate*/
const char *_file_name; /*nextion tft file name*/
uint32_t _unuploadByte; /*unupload byte of tft file*/
uint32_t _upload_baudrate; /*upload baudrate*/
};
#endif /* #ifndef __NEXDOWNLOAD_H__ */
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#include "NexConfig.h" #include "NexConfig.h"
#include "NexTouch.h" #include "NexTouch.h"
#include "NexHardware.h" #include "NexHardware.h"
#include "NexUpload.h"
#include "NexButton.h" #include "NexButton.h"
//#include "NexCrop.h" //#include "NexCrop.h"
......
...@@ -148,7 +148,7 @@ ...@@ -148,7 +148,7 @@
cmd += ","; cmd += ",";
cmd += buf2; cmd += buf2;
cmd += ","; cmd += ",";
cmd +=buf3; cmd += buf3;
cmd += ","; cmd += ",";
cmd += buf4; cmd += buf4;
sendCommand(cmd.c_str()); sendCommand(cmd.c_str());
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
#if ENABLED(SDSUPPORT) #if ENABLED(SDSUPPORT)
uint8_t SDstatus = 0; // 0 SD not insert, 1 SD insert, 2 SD printing uint8_t SDstatus = 0; // 0 SD not insert, 1 SD insert, 2 SD printing
NexUpload Firmware(NEXTION_FIRMWARE_FILE, 57600);
#endif #endif
#if ENABLED(NEXTION_GFX) #if ENABLED(NEXTION_GFX)
...@@ -43,9 +44,7 @@ ...@@ -43,9 +44,7 @@
NexText Hotend2 = NexText(1, 6, "t2"); NexText Hotend2 = NexText(1, 6, "t2");
NexText LedStatus = NexText(1, 7, "status"); NexText LedStatus = NexText(1, 7, "status");
NexText LedCoord1 = NexText(1, 8, "icoord"); NexText LedCoord1 = NexText(1, 8, "icoord");
NexPicture Menu = NexPicture(1, 9, "p0");
NexPicture MSD1 = NexPicture(1, 10, "p1"); NexPicture MSD1 = NexPicture(1, 10, "p1");
NexPicture MSetup = NexPicture(1, 11, "p2");
NexPicture Hend0 = NexPicture(1, 12, "p3"); NexPicture Hend0 = NexPicture(1, 12, "p3");
NexHotspot hot0 = NexHotspot(1, 13, "hot0"); NexHotspot hot0 = NexHotspot(1, 13, "hot0");
NexPicture Hend1 = NexPicture(1, 14, "p4"); NexPicture Hend1 = NexPicture(1, 14, "p4");
...@@ -123,12 +122,10 @@ ...@@ -123,12 +122,10 @@
NexTouch *nex_listen_list[] = NexTouch *nex_listen_list[] =
{ {
&Pstart, &Pstart,
&Menu,
&MSD1, &MSD1,
&MSD3, &MSD3,
&MSD5, &MSD5,
&MSD6, &MSD6,
&MSetup,
&Fanpic, &Fanpic,
&Speedpic, &Speedpic,
&NPlay, &NPlay,
...@@ -222,7 +219,6 @@ ...@@ -222,7 +219,6 @@
} }
Pinfo.show(); Pinfo.show();
NextionPage = 1;
#if ENABLED(NEXTION_GFX) #if ENABLED(NEXTION_GFX)
#if MECH(DELTA) #if MECH(DELTA)
...@@ -291,7 +287,6 @@ ...@@ -291,7 +287,6 @@
} }
void setpageSDPopCallback(void *ptr) { void setpageSDPopCallback(void *ptr) {
NextionPage = 4;
Psdcard.show(); Psdcard.show();
uint16_t fileCnt = card.getnrfilenames(); uint16_t fileCnt = card.getnrfilenames();
...@@ -360,6 +355,14 @@ ...@@ -360,6 +355,14 @@
card.updir(); card.updir();
setpageSDPopCallback(&MSD1); setpageSDPopCallback(&MSD1);
} }
void UploadNewFirmware() {
if(IS_SD_INSERTED || card.cardOK) {
Firmware.startUpload();
nexSerial.end();
lcd_init();
}
}
#endif #endif
void ExitPopCallback(void *ptr) { void ExitPopCallback(void *ptr) {
...@@ -372,7 +375,6 @@ ...@@ -372,7 +375,6 @@
void hotPopCallback(void *ptr) { void hotPopCallback(void *ptr) {
Ptemp.show(); Ptemp.show();
NextionPage = 2;
memset(buffer, 0, sizeof(buffer)); memset(buffer, 0, sizeof(buffer));
if (ptr == &hot0) { if (ptr == &hot0) {
if (degTargetHotend(0) != 0) { if (degTargetHotend(0) != 0) {
...@@ -437,24 +439,15 @@ ...@@ -437,24 +439,15 @@
Pmenu.show(); Pmenu.show();
} }
void setpagePopCallback(void *ptr) { void setfanPopCallback(void *ptr) {
if (ptr == &Menu) { if (fanSpeed) {
NextionPage = 3; fanSpeed = 0;
Pmenu.show(); fantimer.disable();
}
else if (ptr == &MSetup) {
NextionPage = 5;
Psetup.show();
}
else if (ptr == &Speedpic) {
NextionPage = 7;
Pspeed.show();
} }
else {
fanSpeed = 255;
fantimer.enable();
} }
void setfanPopCallback(void *ptr) {
if (fanSpeed) fanSpeed = 0;
else fanSpeed = 255;
} }
void setmovePopCallback(void *ptr) { void setmovePopCallback(void *ptr) {
...@@ -463,7 +456,6 @@ ...@@ -463,7 +456,6 @@
enqueuecommands_P(PSTR("G91")); enqueuecommands_P(PSTR("G91"));
enqueuecommands_P(buffer); enqueuecommands_P(buffer);
enqueuecommands_P(PSTR("G90")); enqueuecommands_P(PSTR("G90"));
NextionPage = 6;
} }
#if ENABLED(SDSUPPORT) #if ENABLED(SDSUPPORT)
...@@ -534,9 +526,6 @@ ...@@ -534,9 +526,6 @@
hot2.attachPop(hotPopCallback, &hot2); hot2.attachPop(hotPopCallback, &hot2);
#endif #endif
Menu.attachPop(setpagePopCallback, &Menu);
MSetup.attachPop(setpagePopCallback, &MSetup);
Speedpic.attachPop(setpagePopCallback, &Speedpic);
Fanpic.attachPop(setfanPopCallback, &Fanpic); Fanpic.attachPop(setfanPopCallback, &Fanpic);
m11.attachPop(sethotPopCallback, &m11); m11.attachPop(sethotPopCallback, &m11);
tup.attachPop(settempPopCallback, &tup); tup.attachPop(settempPopCallback, &tup);
...@@ -619,8 +608,10 @@ ...@@ -619,8 +608,10 @@
millis_t ms = millis(); millis_t ms = millis();
if (ms > next_lcd_update_ms) { if (ms > next_lcd_update_ms) {
if (NextionPage == 1) {
sendCurrentPageId(&NextionPage);
if (NextionPage == 1) {
if (fanSpeed > 0) fantimer.enable(); if (fanSpeed > 0) fantimer.enable();
else fantimer.disable(); else fantimer.disable();
......
...@@ -3,9 +3,9 @@ ...@@ -3,9 +3,9 @@
#if ENABLED(NEXTION) #if ENABLED(NEXTION)
#define LCD_UPDATE_INTERVAL 4000 #define LCD_UPDATE_INTERVAL 4000
#define NEXTION_FIRMWARE_FILE "marlinkimbra.tft"
void ExitPopCallback(void *ptr); void ExitPopCallback(void *ptr);
void setpagePopCallback(void *ptr);
void hotPopCallback(void *ptr); void hotPopCallback(void *ptr);
void sethotPopCallback(void *ptr); void sethotPopCallback(void *ptr);
void settempPopCallback(void *ptr); void settempPopCallback(void *ptr);
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
void sdfolderUpPopCallback(void *ptr); void sdfolderUpPopCallback(void *ptr);
void PlayPausePopCallback(void *ptr); void PlayPausePopCallback(void *ptr);
void StopPopCallback(void *ptr); void StopPopCallback(void *ptr);
void UploadNewFirmware();
#endif #endif
FORCE_INLINE bool lcd_hasstatus() { return false; } FORCE_INLINE bool lcd_hasstatus() { return false; }
......
...@@ -1235,8 +1235,8 @@ ...@@ -1235,8 +1235,8 @@
#endif #endif
#if MECH(DELTA) #if MECH(DELTA)
#if DISABLED(DEFAULT_DELTA_DIAGONAL_ROD) #if DISABLED(DELTA_DIAGONAL_ROD)
#error DEPENDENCY ERROR: Missing setting DEFAULT_DELTA_DIAGONAL_ROD #error DEPENDENCY ERROR: Missing setting DELTA_DIAGONAL_ROD
#endif #endif
#if DISABLED(DELTA_SMOOTH_ROD_OFFSET) #if DISABLED(DELTA_SMOOTH_ROD_OFFSET)
#error DEPENDENCY ERROR: Missing setting DELTA_SMOOTH_ROD_OFFSET #error DEPENDENCY ERROR: Missing setting DELTA_SMOOTH_ROD_OFFSET
...@@ -1244,8 +1244,8 @@ ...@@ -1244,8 +1244,8 @@
#if DISABLED(DELTA_CARRIAGE_OFFSET) #if DISABLED(DELTA_CARRIAGE_OFFSET)
#error DEPENDENCY ERROR: Missing setting DELTA_CARRIAGE_OFFSET #error DEPENDENCY ERROR: Missing setting DELTA_CARRIAGE_OFFSET
#endif #endif
#if DISABLED(BED_PRINTER_RADIUS) #if DISABLED(DELTA_PRINTABLE_RADIUS)
#error DEPENDENCY ERROR: Missing setting BED_PRINTER_RADIUS #error DEPENDENCY ERROR: Missing setting DELTA_PRINTABLE_RADIUS
#endif #endif
#if DISABLED(DEFAULT_DELTA_RADIUS) #if DISABLED(DEFAULT_DELTA_RADIUS)
#error DEPENDENCY ERROR: Missing setting DEFAULT_DELTA_RADIUS #error DEPENDENCY ERROR: Missing setting DEFAULT_DELTA_RADIUS
......
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