Skip to content

Commit

Permalink
📝 More ExtUI documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkyhead committed Oct 3, 2023
1 parent 15dfbab commit be031e1
Show file tree
Hide file tree
Showing 4 changed files with 140 additions and 46 deletions.
2 changes: 1 addition & 1 deletion Marlin/src/inc/Conditionals_LCD.h
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@

// Extensible UI serial touch screens. (See src/lcd/extui)
#if ANY(HAS_DGUS_LCD, MALYAN_LCD, ANYCUBIC_LCD_I3MEGA, ANYCUBIC_LCD_CHIRON, NEXTION_TFT, TOUCH_UI_FTDI_EVE)
#define IS_EXTUI 1
#define IS_EXTUI 1 // Just for sanity check.
#define EXTENSIBLE_UI
#endif

Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/lcd/e3v2/common/dwin_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ void dwinDrawFloatValue(uint8_t bShow, bool zeroFill, uint8_t zeroMode, uint8_t
//uint8_t *fvalue = (uint8_t*)&value;
size_t i = 0;
#if DISABLED(DWIN_CREALITY_LCD_JYERSUI)
dwinDrawRectangle(1, bColor, x, y, x + fontWidth(size) * (iNum+fNum+1), y + fontHeight(size));
dwinDrawRectangle(1, bColor, x, y, x + fontWidth(size) * (iNum + fNum + 1), y + fontHeight(size));
#endif
dwinByte(i, 0x14);
dwinByte(i, (bShow * 0x80) | (zeroFill * 0x20) | (zeroMode * 0x10) | size);
Expand Down
98 changes: 68 additions & 30 deletions Marlin/src/lcd/extui/ui_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,35 +172,6 @@ namespace ExtUI {
if (!flags.printer_killed) thermalManager.task();
}

void enableHeater(const extruder_t extruder) {
#if HAS_HOTEND && HEATER_IDLE_HANDLER
thermalManager.reset_hotend_idle_timer(extruder - E0);
#else
UNUSED(extruder);
#endif
}

void enableHeater(const heater_t heater) {
#if HEATER_IDLE_HANDLER
switch (heater) {
#if HAS_HEATED_BED
case BED: thermalManager.reset_bed_idle_timer(); return;
#endif
#if HAS_HEATED_CHAMBER
case CHAMBER: return; // Chamber has no idle timer
#endif
#if HAS_COOLER
case COOLER: return; // Cooler has no idle timer
#endif
default:
TERN_(HAS_HOTEND, thermalManager.reset_hotend_idle_timer(heater - H0));
break;
}
#else
UNUSED(heater);
#endif
}

#if ENABLED(JOYSTICK)
/**
* Jogs in the direction given by the vector (dx, dy, dz).
Expand Down Expand Up @@ -237,6 +208,39 @@ namespace ExtUI {
}
#endif

//
// Heaters locked / idle
//

void enableHeater(const extruder_t extruder) {
#if HAS_HOTEND && HEATER_IDLE_HANDLER
thermalManager.reset_hotend_idle_timer(extruder - E0);
#else
UNUSED(extruder);
#endif
}

void enableHeater(const heater_t heater) {
#if HEATER_IDLE_HANDLER
switch (heater) {
#if HAS_HEATED_BED
case BED: thermalManager.reset_bed_idle_timer(); return;
#endif
#if HAS_HEATED_CHAMBER
case CHAMBER: return; // Chamber has no idle timer
#endif
#if HAS_COOLER
case COOLER: return; // Cooler has no idle timer
#endif
default:
TERN_(HAS_HOTEND, thermalManager.reset_hotend_idle_timer(heater - H0));
break;
}
#else
UNUSED(heater);
#endif
}

bool isHeaterIdle(const extruder_t extruder) {
#if HAS_HOTEND && HEATER_IDLE_HANDLER
return thermalManager.heater_idle[extruder - E0].timed_out;
Expand Down Expand Up @@ -302,6 +306,9 @@ namespace ExtUI {
return GET_TEMP_ADJUSTMENT(thermalManager.degTargetHotend(extruder - E0));
}

//
// Fan target/actual speed
//
float getTargetFan_percent(const fan_t fan) {
UNUSED(fan);
return TERN0(HAS_FAN, thermalManager.fanSpeedPercent(fan - FAN0));
Expand All @@ -312,6 +319,9 @@ namespace ExtUI {
return TERN0(HAS_FAN, thermalManager.scaledFanSpeedPercent(fan - FAN0));
}

//
// High level axis and extruder positions
//
float getAxisPosition_mm(const axis_t axis) {
return current_position[axis];
}
Expand Down Expand Up @@ -349,6 +359,9 @@ namespace ExtUI {
line_to_current_position(feedrate ?: manual_feedrate_mm_s.e);
}

//
// Tool changing
//
void setActiveTool(const extruder_t extruder, bool no_move) {
#if HAS_MULTI_EXTRUDER
const uint8_t e = extruder - E0;
Expand All @@ -370,11 +383,17 @@ namespace ExtUI {

extruder_t getActiveTool() { return getTool(active_extruder); }

//
// Moving axes and extruders
//
bool isMoving() { return planner.has_blocks_queued(); }

//
// Motion might be blocked by NO_MOTION_BEFORE_HOMING
//
bool canMove(const axis_t axis) {
switch (axis) {
#if IS_KINEMATIC || ENABLED(NO_MOTION_BEFORE_HOMING)
#if ANY(IS_KINEMATIC, NO_MOTION_BEFORE_HOMING)
OPTCODE(HAS_X_AXIS, case X: return !axis_should_home(X_AXIS))
OPTCODE(HAS_Y_AXIS, case Y: return !axis_should_home(Y_AXIS))
OPTCODE(HAS_Z_AXIS, case Z: return !axis_should_home(Z_AXIS))
Expand All @@ -385,20 +404,34 @@ namespace ExtUI {
}
}

//
// E Motion might be prevented by cold material
//
bool canMove(const extruder_t extruder) {
return !thermalManager.tooColdToExtrude(extruder - E0);
}

//
// Host Keepalive, used by awaitingUserConfirm
//
#if ENABLED(HOST_KEEPALIVE_FEATURE)
GcodeSuite::MarlinBusyState getHostKeepaliveState() { return gcode.busy_state; }
bool getHostKeepaliveIsPaused() { return gcode.host_keepalive_is_paused(); }
#endif

//
// Soft Endstops Enabled/Disabled State
//

#if HAS_SOFTWARE_ENDSTOPS
bool getSoftEndstopState() { return soft_endstop._enabled; }
void setSoftEndstopState(const bool value) { soft_endstop._enabled = value; }
#endif

//
// Trinamic Current / Bump Sensitivity
//

#if HAS_TRINAMIC_CONFIG
float getAxisCurrent_mA(const axis_t axis) {
switch (axis) {
Expand Down Expand Up @@ -626,6 +659,10 @@ namespace ExtUI {
}
#endif

//
// Planner Accessors / Setters
//

float getAxisSteps_per_mm(const axis_t axis) {
return planner.settings.axis_steps_per_mm[axis];
}
Expand Down Expand Up @@ -1103,6 +1140,7 @@ namespace ExtUI {

bool isMediaInserted() { return TERN0(HAS_MEDIA, IS_SD_INSERTED()); }

// Pause/Resume/Stop are implemented in MarlinUI
void pausePrint() { ui.pause_print(); }
void resumePrint() { ui.resume_print(); }
void stopPrint() { ui.abort_print(); }
Expand Down
Loading

0 comments on commit be031e1

Please sign in to comment.