Various fixes for MarlinUI and ExtUI (#12439)

This commit is contained in:
Marcio Teixeira
2018-11-17 21:21:44 -07:00
committed by Scott Lahteine
parent d3605cfc26
commit c1e17037e5
24 changed files with 226 additions and 216 deletions

View File

@ -55,8 +55,7 @@ namespace ExtUI {
void onPrintTimerPaused() {}
void onPrintTimerStopped() {}
void onFilamentRunout() {}
void onStatusChanged(const char* msg) {}
void onStatusChanged(progmem_str msg) {}
void onStatusChanged(const char * const msg) {}
void onFactoryReset() {}
void onLoadSettings() {}
void onStoreSettings() {}

View File

@ -94,6 +94,7 @@ static struct {
} flags;
namespace ExtUI {
#ifdef __SAM3X8E__
/**
* Implement a special millis() to allow time measurement
@ -134,12 +135,7 @@ namespace ExtUI {
return (uint32_t)(currTime / (F_CPU / 8000));
}
#else
// TODO: Implement for AVR
FORCE_INLINE uint32_t safe_millis() { return millis(); }
#endif
#endif // __SAM3X8E__
void delay_us(unsigned long us) {
DELAY_US(us);
@ -287,12 +283,14 @@ namespace ExtUI {
}
void setActiveTool(const extruder_t extruder, bool no_move) {
const uint8_t e = extruder - E0;
#if DO_SWITCH_EXTRUDER || ENABLED(SWITCHING_NOZZLE) || ENABLED(PARKING_EXTRUDER)
if (e != active_extruder)
tool_change(e, 0, no_move);
#if EXTRUDERS > 1
const uint8_t e = extruder - E0;
#if DO_SWITCH_EXTRUDER || ENABLED(SWITCHING_NOZZLE) || ENABLED(PARKING_EXTRUDER)
if (e != active_extruder)
tool_change(e, 0, no_move);
#endif
active_extruder = e;
#endif
active_extruder = e;
}
extruder_t getActiveTool() {
@ -533,24 +531,26 @@ namespace ExtUI {
float getFeedrate_percent() { return feedrate_percentage; }
void enqueueCommands(progmem_str gcode) {
enqueue_and_echo_commands_P((PGM_P)gcode);
void enqueueCommands_P(PGM_P const gcode) {
enqueue_and_echo_commands_P(gcode);
}
bool isAxisPositionKnown(const axis_t axis) {
return TEST(axis_known_position, axis);
}
progmem_str getFirmwareName_str() {
return F("Marlin " SHORT_BUILD_VERSION);
PGM_P getFirmwareName_str() {
static const char firmware_name[] PROGMEM = "Marlin " SHORT_BUILD_VERSION;
return firmware_name;
}
void setTargetTemp_celsius(float value, const heater_t heater) {
#if HAS_HEATED_BED
if (heater == BED)
thermalManager.setTargetBed(clamp(value,0,200));
if (heater == BED)
thermalManager.setTargetBed(clamp(value,0,200));
else
#endif
thermalManager.setTargetHotend(clamp(value,0,500), heater - H0);
thermalManager.setTargetHotend(clamp(value,0,500), heater - H0);
}
void setTargetTemp_celsius(float value, const extruder_t extruder) {
@ -579,7 +579,7 @@ namespace ExtUI {
}
bool isPrinting() {
return (planner.movesplanned() || IS_SD_PRINTING() || isPrintingFromMedia());
return (planner.movesplanned() || isPrintingFromMedia() || IFSD(IS_SD_PRINTING(), false));
}
bool isMediaInserted() {
@ -593,19 +593,20 @@ namespace ExtUI {
#if ENABLED(PARK_HEAD_ON_PAUSE)
enqueue_and_echo_commands_P(PSTR("M125"));
#endif
ExtUI::onStatusChanged(PSTR(MSG_PRINT_PAUSED));
ui.set_status_P(PSTR(MSG_PRINT_PAUSED));
#endif
}
void resumePrint() {
#if ENABLED(SDSUPPORT)
ui.set_status_P(PSTR(MSG_FILAMENT_CHANGE_RESUME_1));
#if ENABLED(PARK_HEAD_ON_PAUSE)
wait_for_heatup = wait_for_user = false;
enqueue_and_echo_commands_P(PSTR("M24"));
#else
card.startFileprint();
print_job_timer.start();
#endif
ExtUI::onStatusChanged(PSTR(MSG_PRINTING));
#endif
}
@ -613,7 +614,7 @@ namespace ExtUI {
#if ENABLED(SDSUPPORT)
wait_for_heatup = wait_for_user = false;
card.flag.abort_sd_printing = true;
ExtUI::onStatusChanged(PSTR(MSG_PRINT_ABORTED));
ui.set_status_P(PSTR(MSG_PRINT_ABORTED));
#endif
}
@ -621,7 +622,7 @@ namespace ExtUI {
void FileList::refresh() { num_files = 0xFFFF; }
bool FileList::seek(uint16_t pos, bool skip_range_check) {
bool FileList::seek(const uint16_t pos, const bool skip_range_check) {
#if ENABLED(SDSUPPORT)
if (!skip_range_check && pos > (count() - 1)) return false;
const uint16_t nr =
@ -632,6 +633,8 @@ namespace ExtUI {
card.getfilename_sorted(nr);
return card.filename && card.filename[0] != '\0';
#else
return false;
#endif
}
@ -671,7 +674,7 @@ namespace ExtUI {
#endif
}
void FileList::changeDir(const char *dirname) {
void FileList::changeDir(const char * const dirname) {
#if ENABLED(SDSUPPORT)
card.chdir(dirname);
num_files = 0xFFFF;
@ -713,20 +716,6 @@ void MarlinUI::update() {
ExtUI::onIdle();
}
void MarlinUI::setstatus(const char * const message, const bool persist/*=false*/) { ExtUI::onStatusChanged(message); }
void MarlinUI::setstatusPGM(PGM_P const message, int8_t level/*=0*/) { ExtUI::onStatusChanged((progmem_str)message); }
void MarlinUI::setalertstatusPGM(PGM_P const message) { setstatusPGM(message, 0); }
void MarlinUI::status_printf_P(const uint8_t level, const char * const fmt, ...) {
char buff[64];
va_list args;
va_start(args, fmt);
vsnprintf_P(buff, sizeof(buff), fmt, args);
va_end(args);
buff[63] = '\0';
ExtUI::onStatusChanged(buff);
}
void MarlinUI::kill_screen(PGM_P const msg) {
if (!flags.printer_killed) {
flags.printer_killed = true;

View File

@ -45,8 +45,6 @@
#include "../../inc/MarlinConfig.h"
typedef const __FlashStringHelper *progmem_str;
namespace ExtUI {
enum axis_t : uint8_t { X, Y, Z };
@ -62,13 +60,13 @@ namespace ExtUI {
bool isAxisPositionKnown(const axis_t);
bool canMove(const axis_t);
bool canMove(const extruder_t);
void enqueueCommands(progmem_str);
void enqueueCommands_P(PGM_P const);
/**
* Getters and setters
* Should be used by the EXTENSIBLE_UI to query or change Marlin's state.
*/
progmem_str getFirmwareName_str();
PGM_P getFirmwareName_str();
float getActualTemp_celsius(const heater_t);
float getActualTemp_celsius(const extruder_t);
@ -178,7 +176,12 @@ namespace ExtUI {
* safe_millis must be called at least every 1 sec to guarantee time
* yield should be called within lengthy loops
*/
uint32_t safe_millis();
#ifdef __SAM3X8E__
uint32_t safe_millis();
#else
#define safe_millis() millis() // TODO: Implement for AVR
#endif
void delay_us(unsigned long us);
void delay_ms(unsigned long ms);
void yield();
@ -205,14 +208,14 @@ namespace ExtUI {
public:
FileList();
void refresh();
bool seek(uint16_t, bool skip_range_check = false);
bool seek(const uint16_t, const bool skip_range_check = false);
const char *longFilename();
const char *shortFilename();
const char *filename();
bool isDir();
void changeDir(const char *dirname);
void changeDir(const char * const dirname);
void upDir();
bool isAtRootDir();
uint16_t count();
@ -234,8 +237,7 @@ namespace ExtUI {
void onPrintTimerPaused();
void onPrintTimerStopped();
void onFilamentRunout();
void onStatusChanged(const char* msg);
void onStatusChanged(progmem_str msg);
void onStatusChanged(const char * const msg);
void onFactoryReset();
void onStoreSettings();
void onLoadSettings();