Commit 8dabeadc authored by MagoKimbra's avatar MagoKimbra

Merge remote-tracking branch 'refs/remotes/origin/master' into dev

parents b5ad3ab5 bda01841
...@@ -43,7 +43,7 @@ ...@@ -43,7 +43,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 - Download Firmware Nextion from SD * 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 download firmware nextion from SD * 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
......
...@@ -79,7 +79,7 @@ ...@@ -79,7 +79,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 - Download Firmware Nextion from SD * 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
...@@ -4427,10 +4427,10 @@ inline void gcode_M17() { ...@@ -4427,10 +4427,10 @@ inline void gcode_M17() {
#if ENABLED(NEXTION) #if ENABLED(NEXTION)
/** /**
* M35: Download Firmware Nextion * M35: Upload Firmware to Nextion from SD
*/ */
inline void gcode_M35() { inline void gcode_M35() {
DownloadNewFirmware(); UploadNewFirmware();
} }
#endif #endif
#endif #endif
...@@ -7448,7 +7448,7 @@ void process_next_command() { ...@@ -7448,7 +7448,7 @@ void process_next_command() {
case 32: // M32 - Make directory case 32: // M32 - Make directory
gcode_M32(); break; gcode_M32(); break;
#if ENABLED(NEXTION) #if ENABLED(NEXTION)
case 35: // M35 - Download Firmware Nextion case 35: // M35 - Upload Firmware to Nextion from SD
gcode_M35(); break; gcode_M35(); break;
#endif #endif
#endif //SDSUPPORT #endif //SDSUPPORT
......
...@@ -240,7 +240,8 @@ bool nexInit(void) ...@@ -240,7 +240,8 @@ bool nexInit(void)
return ret1 && ret2; return ret1 && ret2;
// Else try to 115200 baudrate // Else try to 115200 baudrate
} else { }
else {
nexSerial.end(); nexSerial.end();
HAL::delayMilliseconds(1000); HAL::delayMilliseconds(1000);
nexSerial.begin(115200); nexSerial.begin(115200);
......
/** /**
* @file NexDownload.cpp * @file NexUpload.cpp
* *
* The implementation of download tft file for nextion. * The implementation of upload tft file for nextion.
* *
* @author Chen Zengpeng (email:<zengpeng.chen@itead.cc>) * @author Chen Zengpeng (email:<zengpeng.chen@itead.cc>)
* @date 2016/3/29 * @date 2016/3/29
...@@ -13,20 +13,20 @@ ...@@ -13,20 +13,20 @@
* the License, or (at your option) any later version. * the License, or (at your option) any later version.
*/ */
#include "NexDownload.h" #include "NexUpload.h"
#if ENABLED(SDSUPPORT) #if ENABLED(SDSUPPORT)
NexDownload::NexDownload(const char *file_name, uint32_t download_baudrate) { NexUpload::NexUpload(const char *file_name, uint32_t upload_baudrate) {
_file_name = file_name; _file_name = file_name;
_download_baudrate = download_baudrate; _upload_baudrate = upload_baudrate;
} }
NexDownload::NexDownload(const String file_Name, uint32_t download_baudrate) { NexUpload::NexUpload(const String file_Name, uint32_t upload_baudrate) {
NexDownload(file_Name.c_str(), download_baudrate); NexUpload(file_Name.c_str(), upload_baudrate);
} }
void NexDownload::startDownload(void) { void NexUpload::startUpload(void) {
if (!_checkFile()) { if (!_checkFile()) {
ECHO_LM(ER, "The file is error"); ECHO_LM(ER, "The file is error");
return; return;
...@@ -35,19 +35,19 @@ ...@@ -35,19 +35,19 @@
ECHO_LM(ER, "baudrate error"); ECHO_LM(ER, "baudrate error");
return; return;
} }
if (!_setDownloadBaudrate(_download_baudrate)) { if (!_setUploadBaudrate(_upload_baudrate)) {
ECHO_LM(ER, "modify baudrate error"); ECHO_LM(ER, "modify baudrate error");
return; return;
} }
if (!_downloadTftFile()) { if (!_uploadTftFile()) {
ECHO_LM(ER, "download file error"); ECHO_LM(ER, "upload file error");
return; return;
} }
card.closeFile(); card.closeFile();
ECHO_LM(DB, "download ok"); ECHO_LM(DB, "upload ok");
} }
uint16_t NexDownload::_getBaudrate(void) { uint16_t NexUpload::_getBaudrate(void) {
uint32_t baudrate_array[7] = {115200, 57600, 38400, 19200, 9600, 4800, 2400}; uint32_t baudrate_array[7] = {115200, 57600, 38400, 19200, 9600, 4800, 2400};
for (uint8_t i = 0; i < 7; i++) { for (uint8_t i = 0; i < 7; i++) {
if (_searchBaudrate(baudrate_array[i])) { if (_searchBaudrate(baudrate_array[i])) {
...@@ -58,17 +58,17 @@ ...@@ -58,17 +58,17 @@
return _baudrate; return _baudrate;
} }
bool NexDownload::_checkFile(void) { bool NexUpload::_checkFile(void) {
ECHO_LM(DB, "start _checkFile"); ECHO_LMT(DB, "Start checkFile ", _file_name);
if (!card.selectFile(_file_name)) { if (!card.selectFile(_file_name)) {
ECHO_LM(ER, "file is not exit"); ECHO_LM(ER, "file is not exit");
return 0; return 0;
} }
_undownloadByte = card.fileSize; _unuploadByte = card.fileSize;
return 1; return 1;
} }
bool NexDownload::_searchBaudrate(uint32_t baudrate) { bool NexUpload::_searchBaudrate(uint32_t baudrate) {
String string = String(""); String string = String("");
nexSerial.end(); nexSerial.end();
HAL::delayMilliseconds(100); HAL::delayMilliseconds(100);
...@@ -83,7 +83,7 @@ ...@@ -83,7 +83,7 @@
return 0; return 0;
} }
void NexDownload::sendCommand(const char* cmd) { void NexUpload::sendCommand(const char* cmd) {
while (nexSerial.available()) while (nexSerial.available())
nexSerial.read(); nexSerial.read();
...@@ -93,7 +93,7 @@ ...@@ -93,7 +93,7 @@
nexSerial.write(0xFF); nexSerial.write(0xFF);
} }
uint16_t NexDownload::recvRetString(String &string, uint32_t timeout,bool recv_flag) { uint16_t NexUpload::recvRetString(String &string, uint32_t timeout,bool recv_flag) {
uint16_t ret = 0; uint16_t ret = 0;
uint8_t c = 0; uint8_t c = 0;
long start; long start;
...@@ -117,11 +117,11 @@ ...@@ -117,11 +117,11 @@
return ret; return ret;
} }
bool NexDownload::_setDownloadBaudrate(uint32_t baudrate) { bool NexUpload::_setUploadBaudrate(uint32_t baudrate) {
String string = String(""); String string = String("");
String cmd = String(""); String cmd = String("");
String filesize_str = String(_undownloadByte, 10); String filesize_str = String(_unuploadByte, 10);
String baudrate_str = String(baudrate, 10); String baudrate_str = String(baudrate, 10);
cmd = "whmi-wri " + filesize_str + "," + baudrate_str + ",0"; cmd = "whmi-wri " + filesize_str + "," + baudrate_str + ",0";
...@@ -136,13 +136,13 @@ ...@@ -136,13 +136,13 @@
return 0; return 0;
} }
bool NexDownload::_downloadTftFile(void) { bool NexUpload::_uploadTftFile(void) {
uint8_t c; uint8_t c;
uint16_t send_timer = 0; uint16_t send_timer = 0;
uint16_t last_send_num = 0; uint16_t last_send_num = 0;
String string = String(""); String string = String("");
send_timer = _undownloadByte / 4096 + 1; send_timer = _unuploadByte / 4096 + 1;
last_send_num = _undownloadByte % 4096; last_send_num = _unuploadByte % 4096;
while(send_timer) { while(send_timer) {
if(send_timer == 1) { if(send_timer == 1) {
......
/** /**
* @file NexDownload.h * @file NexUpload.h
* *
* The definition of class NexDownload. * The definition of class NexUpload.
* *
* @author Chen Zengpeng (email:<zengpeng.chen@itead.cc>) * @author Chen Zengpeng (email:<zengpeng.chen@itead.cc>)
* @date 2016/3/29 * @date 2016/3/29
...@@ -14,8 +14,8 @@ ...@@ -14,8 +14,8 @@
* the License, or (at your option) any later version. * the License, or (at your option) any later version.
*/ */
#ifndef __NEXDOWNLOAD_H__ #ifndef __NEXUPLOAD_H__
#define __NEXDOWNLOAD_H__ #define __NEXUPLOAD_H__
#include "NexHardware.h" #include "NexHardware.h"
...@@ -26,9 +26,9 @@ ...@@ -26,9 +26,9 @@
/** /**
* *
* Provides the API for nextion to download the ftf file. * Provides the API for nextion to upload the ftf file.
*/ */
class NexDownload class NexUpload
{ {
public: /* methods */ public: /* methods */
...@@ -36,31 +36,31 @@ ...@@ -36,31 +36,31 @@
* Constructor. * Constructor.
* *
* @param file_name - tft file name. * @param file_name - tft file name.
* @download_baudrate - set download baudrate. * @upload_baudrate - set upload baudrate.
*/ */
NexDownload(const char *file_name, uint32_t download_baudrate); NexUpload(const char *file_name, uint32_t upload_baudrate);
/** /**
* Constructor. * Constructor.
* *
* @param file_name - tft file name. * @param file_name - tft file name.
* @param SD_chip_select - sd chip select pin. * @param SD_chip_select - sd chip select pin.
* @download_baudrate - set download baudrate. * @upload_baudrate - set upload baudrate.
*/ */
NexDownload(const String file_Name, uint32_t download_baudrate); NexUpload(const String file_Name, uint32_t upload_baudrate);
/** /**
* destructor. * destructor.
* *
*/ */
~NexDownload(){} ~NexUpload(){}
/* /*
* start download. * start upload.
* *
* @return none. * @return none.
*/ */
void startDownload(); void startUpload(void);
private: /* methods */ private: /* methods */
...@@ -89,20 +89,20 @@ ...@@ -89,20 +89,20 @@
bool _searchBaudrate(uint32_t baudrate); bool _searchBaudrate(uint32_t baudrate);
/* /*
* set download baudrate. * set upload baudrate.
* *
* @param baudrate - set download baudrate. * @param baudrate - set upload baudrate.
* *
* @return true if success, false for failure. * @return true if success, false for failure.
*/ */
bool _setDownloadBaudrate(uint32_t baudrate); bool _setUploadBaudrate(uint32_t baudrate);
/** /**
* start dowload tft file to nextion. * start dowload tft file to nextion.
* *
* @return none. * @return none.
*/ */
bool _downloadTftFile(void); bool _uploadTftFile(void);
/* /*
* Send command to Nextion. * Send command to Nextion.
...@@ -128,8 +128,8 @@ ...@@ -128,8 +128,8 @@
private: /* data */ private: /* data */
uint32_t _baudrate; /*nextion serail baudrate*/ uint32_t _baudrate; /*nextion serail baudrate*/
const char *_file_name; /*nextion tft file name*/ const char *_file_name; /*nextion tft file name*/
uint32_t _undownloadByte; /*undownload byte of tft file*/ uint32_t _unuploadByte; /*unupload byte of tft file*/
uint32_t _download_baudrate; /*download baudrate*/ uint32_t _upload_baudrate; /*upload baudrate*/
}; };
#endif /* #ifndef __NEXDOWNLOAD_H__ */ #endif /* #ifndef __NEXDOWNLOAD_H__ */
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
#include "NexConfig.h" #include "NexConfig.h"
#include "NexTouch.h" #include "NexTouch.h"
#include "NexHardware.h" #include "NexHardware.h"
#include "NexDownload.h" #include "NexUpload.h"
#include "NexButton.h" #include "NexButton.h"
//#include "NexCrop.h" //#include "NexCrop.h"
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +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
NexDownload Firmware(NEXTION_FIRMWARE_FILE, 57600); NexUpload Firmware(NEXTION_FIRMWARE_FILE, 57600);
#endif #endif
#if ENABLED(NEXTION_GFX) #if ENABLED(NEXTION_GFX)
...@@ -356,9 +356,9 @@ ...@@ -356,9 +356,9 @@
setpageSDPopCallback(&MSD1); setpageSDPopCallback(&MSD1);
} }
void DownloadNewFirmware() { void UploadNewFirmware() {
if(IS_SD_INSERTED || card.cardOK) { if(IS_SD_INSERTED || card.cardOK) {
Firmware.startDownload(); Firmware.startUpload();
nexSerial.end(); nexSerial.end();
lcd_init(); lcd_init();
} }
......
...@@ -33,7 +33,7 @@ ...@@ -33,7 +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 DownloadNewFirmware(); void UploadNewFirmware();
#endif #endif
FORCE_INLINE bool lcd_hasstatus() { return false; } FORCE_INLINE bool lcd_hasstatus() { return false; }
......
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