2018-10-23 02:37:48 +02:00
|
|
|
/**
|
|
|
|
* Marlin 3D Printer Firmware
|
|
|
|
* Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
|
|
|
*
|
|
|
|
* Based on Sprinter and grbl.
|
|
|
|
* Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
|
|
|
|
*
|
|
|
|
* 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 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2018-10-08 22:44:05 +02:00
|
|
|
/************
|
|
|
|
* ui_api.h *
|
|
|
|
************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Written By Marcio Teixeira 2018 - Aleph Objects, Inc. *
|
|
|
|
* *
|
|
|
|
* 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 3 of the License, or *
|
|
|
|
* (at your option) any later version. *
|
|
|
|
* *
|
|
|
|
* This program is distributed in the hope that it will be useful, *
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
|
|
* GNU General Public License for more details. *
|
|
|
|
* *
|
|
|
|
* To view a copy of the GNU General Public License, go to the following *
|
|
|
|
* location: <http://www.gnu.org/licenses/>. *
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "../../inc/MarlinConfig.h"
|
|
|
|
|
|
|
|
typedef const __FlashStringHelper *progmem_str;
|
|
|
|
|
|
|
|
namespace UI {
|
|
|
|
|
2018-10-31 01:42:26 +01:00
|
|
|
enum axis_t : uint8_t { X, Y, Z };
|
|
|
|
enum extruder_t : uint8_t { E0, E1, E2, E3, E4, E5 };
|
|
|
|
enum heater_t : uint8_t { H0, H1, H2, H3, H4, H5, BED };
|
|
|
|
enum fan_t : uint8_t { FAN0, FAN1, FAN2, FAN3, FAN4, FAN5 };
|
2018-10-08 22:44:05 +02:00
|
|
|
|
|
|
|
constexpr uint8_t extruderCount = EXTRUDERS;
|
2018-10-31 01:42:26 +01:00
|
|
|
constexpr uint8_t hotendCount = HOTENDS;
|
2018-10-08 22:44:05 +02:00
|
|
|
constexpr uint8_t fanCount = FAN_COUNT;
|
|
|
|
|
|
|
|
bool isMoving();
|
2018-10-31 01:42:26 +01:00
|
|
|
bool isAxisPositionKnown(const axis_t);
|
|
|
|
bool canMove(const axis_t);
|
|
|
|
bool canMove(const extruder_t);
|
|
|
|
void enqueueCommands(progmem_str);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Getters and setters
|
|
|
|
* Should be used by the EXTENSIBLE_UI to query or change Marlin's state.
|
|
|
|
*/
|
|
|
|
progmem_str getFirmwareName_str();
|
|
|
|
|
|
|
|
float getActualTemp_celsius(const heater_t);
|
|
|
|
float getActualTemp_celsius(const extruder_t);
|
|
|
|
float getTargetTemp_celsius(const heater_t);
|
|
|
|
float getTargetTemp_celsius(const extruder_t);
|
|
|
|
float getFan_percent(const fan_t);
|
|
|
|
float getAxisPosition_mm(const axis_t);
|
|
|
|
float getAxisPosition_mm(const extruder_t);
|
|
|
|
float getAxisSteps_per_mm(const axis_t);
|
|
|
|
float getAxisSteps_per_mm(const extruder_t);
|
|
|
|
float getAxisMaxFeedrate_mm_s(const axis_t);
|
|
|
|
float getAxisMaxFeedrate_mm_s(const extruder_t);
|
|
|
|
float getAxisMaxAcceleration_mm_s2(const axis_t);
|
|
|
|
float getAxisMaxAcceleration_mm_s2(const extruder_t);
|
2018-10-08 22:44:05 +02:00
|
|
|
float getMinFeedrate_mm_s();
|
|
|
|
float getMinTravelFeedrate_mm_s();
|
2018-10-16 23:58:29 +02:00
|
|
|
float getPrintingAcceleration_mm_s2();
|
|
|
|
float getRetractAcceleration_mm_s2();
|
|
|
|
float getTravelAcceleration_mm_s2();
|
2018-10-31 01:42:26 +01:00
|
|
|
float getFeedrate_percent();
|
2018-10-08 22:44:05 +02:00
|
|
|
uint8_t getProgress_percent();
|
|
|
|
uint32_t getProgress_seconds_elapsed();
|
|
|
|
|
2018-10-16 23:58:29 +02:00
|
|
|
#if ENABLED(PRINTCOUNTER)
|
2018-10-31 01:42:26 +01:00
|
|
|
char* getTotalPrints_str(char buffer[21]);
|
|
|
|
char* getFinishedPrints_str(char buffer[21]);
|
|
|
|
char* getTotalPrintTime_str(char buffer[21]);
|
|
|
|
char* getLongestPrint_str(char buffer[21]);
|
|
|
|
char* getFilamentUsed_str(char buffer[21]);
|
2018-10-16 23:58:29 +02:00
|
|
|
#endif
|
|
|
|
|
2018-10-31 01:42:26 +01:00
|
|
|
void setTargetTemp_celsius(const float, const heater_t);
|
|
|
|
void setTargetTemp_celsius(const float, const extruder_t);
|
|
|
|
void setFan_percent(const float, const fan_t);
|
|
|
|
void setAxisPosition_mm(const float, const axis_t);
|
|
|
|
void setAxisPosition_mm(const float, const extruder_t);
|
|
|
|
void setAxisSteps_per_mm(const float, const axis_t);
|
|
|
|
void setAxisSteps_per_mm(const float, const extruder_t);
|
|
|
|
void setAxisMaxFeedrate_mm_s(const float, const axis_t);
|
|
|
|
void setAxisMaxFeedrate_mm_s(const float, const extruder_t);
|
|
|
|
void setAxisMaxAcceleration_mm_s2(const float, const axis_t);
|
|
|
|
void setAxisMaxAcceleration_mm_s2(const float, const extruder_t);
|
|
|
|
void setFeedrate_mm_s(const float);
|
|
|
|
void setMinFeedrate_mm_s(const float);
|
|
|
|
void setMinTravelFeedrate_mm_s(const float);
|
|
|
|
void setPrintingAcceleration_mm_s2(const float);
|
|
|
|
void setRetractAcceleration_mm_s2(const float);
|
|
|
|
void setTravelAcceleration_mm_s2(const float);
|
|
|
|
void setFeedrate_percent(const float);
|
2018-10-08 22:44:05 +02:00
|
|
|
|
|
|
|
#if ENABLED(LIN_ADVANCE)
|
2018-10-31 01:42:26 +01:00
|
|
|
float getLinearAdvance_mm_mm_s(const extruder_t);
|
|
|
|
void setLinearAdvance_mm_mm_s(const float, const extruder_t);
|
2018-10-08 22:44:05 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if ENABLED(JUNCTION_DEVIATION)
|
|
|
|
float getJunctionDeviation_mm();
|
2018-10-31 01:42:26 +01:00
|
|
|
void setJunctionDeviation_mm(const float);
|
2018-10-08 22:44:05 +02:00
|
|
|
#else
|
2018-10-31 01:42:26 +01:00
|
|
|
float getAxisMaxJerk_mm_s(const axis_t);
|
|
|
|
float getAxisMaxJerk_mm_s(const extruder_t);
|
|
|
|
void setAxisMaxJerk_mm_s(const float, const axis_t);
|
|
|
|
void setAxisMaxJerk_mm_s(const float, const extruder_t);
|
2018-10-08 22:44:05 +02:00
|
|
|
#endif
|
|
|
|
|
2018-10-31 01:42:26 +01:00
|
|
|
extruder_t getActiveTool();
|
|
|
|
void setActiveTool(const extruder_t, bool no_move);
|
|
|
|
|
2018-10-08 22:44:05 +02:00
|
|
|
|
|
|
|
#if HOTENDS > 1
|
2018-10-31 01:42:26 +01:00
|
|
|
float getNozzleOffset_mm(const axis_t, const extruder_t);
|
|
|
|
void setNozzleOffset_mm(const float, const axis_t, const extruder_t);
|
2018-10-08 22:44:05 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if ENABLED(BABYSTEP_ZPROBE_OFFSET)
|
|
|
|
float getZOffset_mm();
|
2018-10-31 01:42:26 +01:00
|
|
|
void setZOffset_mm(const float);
|
|
|
|
void addZOffset_steps(const int16_t);
|
2018-10-08 22:44:05 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if ENABLED(BACKLASH_GCODE)
|
2018-10-31 01:42:26 +01:00
|
|
|
float getAxisBacklash_mm(const axis_t);
|
|
|
|
void setAxisBacklash_mm(const float, const axis_t);
|
2018-10-08 22:44:05 +02:00
|
|
|
|
|
|
|
float getBacklashCorrection_percent();
|
2018-10-31 01:42:26 +01:00
|
|
|
void setBacklashCorrection_percent(const float);
|
2018-10-08 22:44:05 +02:00
|
|
|
|
|
|
|
#ifdef BACKLASH_SMOOTHING_MM
|
|
|
|
float getBacklashSmoothing_mm();
|
2018-10-31 01:42:26 +01:00
|
|
|
void setBacklashSmoothing_mm(const float);
|
2018-10-08 22:44:05 +02:00
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
2018-10-16 14:28:52 +02:00
|
|
|
#if ENABLED(FILAMENT_RUNOUT_SENSOR)
|
2018-10-31 01:42:26 +01:00
|
|
|
bool getFilamentRunoutEnabled();
|
|
|
|
void setFilamentRunoutEnabled(const bool);
|
2018-10-16 14:28:52 +02:00
|
|
|
|
|
|
|
#if FILAMENT_RUNOUT_DISTANCE_MM > 0
|
|
|
|
float getFilamentRunoutDistance_mm();
|
2018-10-31 01:42:26 +01:00
|
|
|
void setFilamentRunoutDistance_mm(const float);
|
2018-10-16 14:28:52 +02:00
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
2018-10-31 01:42:26 +01:00
|
|
|
/**
|
|
|
|
* Delay and timing routines
|
|
|
|
* Should be used by the EXTENSIBLE_UI to safely pause or measure time
|
|
|
|
* safe_millis must be called at least every 1 sec to guarantee time
|
|
|
|
* yield should be called within lengthy loops
|
|
|
|
*/
|
2018-10-23 02:37:48 +02:00
|
|
|
uint32_t safe_millis();
|
|
|
|
void delay_us(unsigned long us);
|
2018-10-08 22:44:05 +02:00
|
|
|
void delay_ms(unsigned long ms);
|
2018-10-31 01:42:26 +01:00
|
|
|
void yield();
|
2018-10-08 22:44:05 +02:00
|
|
|
|
2018-10-31 01:42:26 +01:00
|
|
|
/**
|
|
|
|
* Media access routines
|
|
|
|
*
|
|
|
|
* Should be used by the EXTENSIBLE_UI to operate on files
|
|
|
|
*/
|
|
|
|
bool isMediaInserted();
|
2018-10-20 08:44:46 +02:00
|
|
|
bool isPrintingFromMediaPaused();
|
2018-10-08 22:44:05 +02:00
|
|
|
bool isPrintingFromMedia();
|
|
|
|
bool isPrinting();
|
2018-10-31 01:42:26 +01:00
|
|
|
|
|
|
|
void printFile(const char *filename);
|
2018-10-08 22:44:05 +02:00
|
|
|
void stopPrint();
|
|
|
|
void pausePrint();
|
|
|
|
void resumePrint();
|
|
|
|
|
|
|
|
class FileList {
|
|
|
|
private:
|
|
|
|
uint16_t num_files;
|
|
|
|
|
|
|
|
public:
|
|
|
|
FileList();
|
2018-10-31 01:42:26 +01:00
|
|
|
void refresh();
|
|
|
|
bool seek(uint16_t, bool skip_range_check = false);
|
2018-10-08 22:44:05 +02:00
|
|
|
|
|
|
|
const char *longFilename();
|
|
|
|
const char *shortFilename();
|
|
|
|
const char *filename();
|
2018-10-31 01:42:26 +01:00
|
|
|
bool isDir();
|
2018-10-08 22:44:05 +02:00
|
|
|
|
2018-10-31 01:42:26 +01:00
|
|
|
void changeDir(const char *dirname);
|
|
|
|
void upDir();
|
|
|
|
bool isAtRootDir();
|
2018-10-08 22:44:05 +02:00
|
|
|
uint16_t count();
|
|
|
|
};
|
|
|
|
|
2018-10-31 01:42:26 +01:00
|
|
|
/**
|
|
|
|
* Event callback routines
|
|
|
|
*
|
|
|
|
* Should be declared by EXTENSIBLE_UI and will be called by Marlin
|
|
|
|
*/
|
2018-10-08 22:44:05 +02:00
|
|
|
void onStartup();
|
2018-10-16 23:58:29 +02:00
|
|
|
void onIdle();
|
2018-10-08 22:44:05 +02:00
|
|
|
void onMediaInserted();
|
|
|
|
void onMediaError();
|
|
|
|
void onMediaRemoved();
|
|
|
|
void onPlayTone(const uint16_t frequency, const uint16_t duration);
|
|
|
|
void onPrinterKilled(const char* msg);
|
|
|
|
void onPrintTimerStarted();
|
|
|
|
void onPrintTimerPaused();
|
|
|
|
void onPrintTimerStopped();
|
|
|
|
void onFilamentRunout();
|
|
|
|
void onStatusChanged(const char* msg);
|
|
|
|
void onStatusChanged(progmem_str msg);
|
|
|
|
void onFactoryReset();
|
|
|
|
void onStoreSettings();
|
2018-10-16 23:58:29 +02:00
|
|
|
void onLoadSettings();
|
2018-10-08 22:44:05 +02:00
|
|
|
};
|
2018-10-31 01:42:26 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Helper macros to increment or decrement a value. For example:
|
|
|
|
*
|
|
|
|
* UI_INCREMENT_BY(TargetTemp_celsius, 10, E0)
|
|
|
|
*
|
|
|
|
* Expands to:
|
|
|
|
*
|
|
|
|
* setTargetTemp_celsius(getTargetTemp_celsius(E0) + 10, E0);
|
|
|
|
*
|
|
|
|
* Or, in the case where a constant increment is desired:
|
|
|
|
*
|
|
|
|
* constexpr float increment = 10;
|
|
|
|
*
|
|
|
|
* UI_INCREMENT(TargetTemp_celsius, E0)
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
#define UI_INCREMENT_BY(method, inc, ...) UI::set ## method(UI::get ## method (__VA_ARGS__) + inc, ##__VA_ARGS__)
|
|
|
|
#define UI_DECREMENT_BY(method, inc, ...) UI::set ## method(UI::get ## method (__VA_ARGS__) - inc, ##__VA_ARGS__)
|
|
|
|
|
|
|
|
#define UI_INCREMENT(method, ...) UI_INCREMENT_BY(method, increment, ##__VA_ARGS__)
|
|
|
|
#define UI_DECREMENT(method, ...) UI_DECREMENT_BY(method, increment, ##__VA_ARGS__)
|