Add Laser / Spindle bitmap for LCD (#16068)

2.0.x
Luu Lac 5 years ago committed by Scott Lahteine
parent bdd0517a5b
commit 01e4b0c067

@ -46,6 +46,7 @@
class SpindleLaser {
public:
static cutter_power_t power;
static inline uint8_t powerPercent(const uint8_t pp) { return ui8_to_percent(pp); } // for display
static void init();

@ -598,6 +598,105 @@
#endif // !STATUS_HEATERS_WIDTH && !STATUS_HOTEND1_WIDTH
// LASER / SPINDLE
#if !STATUS_CUTTER_WIDTH && HAS_CUTTER
#define STATUS_CUTTER_WIDTH 24
#define STATUS_CUTTER_X 80
#if ENABLED(LASER_FEATURE)
#ifdef STATUS_CUTTER_ANIM
const unsigned char status_cutter_on_bmp[] PROGMEM = {
B00000000,B00100100,B00000000,
B00000000,B01100110,B00000000,
B00000000,B11000011,B00000000,
B00000001,B10011001,B10000000,
B00000011,B00100100,B11000000,
B00000000,B01000010,B00000000,
B00000000,B01000010,B00000000,
B00000011,B00100100,B11000000,
B00000001,B10011001,B10000000,
B00000000,B11000011,B00000000,
B00000000,B01100110,B00000000,
B00000000,B00100100,B00000000
};
const unsigned char status_cutter_bmp[] PROGMEM = {
B00000000,B00100100,B00000000,
B00000000,B01100110,B00000000,
B00000000,B00000000,B00000000,
B00000001,B00000000,B10000000,
B00000011,B00000000,B11000000,
B00000000,B00011000,B00000000,
B00000000,B00011000,B00000000,
B00000011,B00000000,B11000000,
B00000001,B00000000,B10000000,
B00000000,B00000000,B00000000,
B00000000,B01100110,B00000000,
B00000000,B00100100,B00000000
};
#else
const unsigned char status_cutter_bmp[] PROGMEM = {
B00000000,B00100100,B00000000,
B00000000,B01100110,B00000000,
B00000000,B11000011,B00000000,
B00000001,B10000001,B10000000,
B00000011,B00000000,B11000000,
B00000000,B00000000,B00000000,
B00000000,B00000000,B00000000,
B00000011,B00000000,B11000000,
B00000001,B10000001,B10000000,
B00000000,B11000011,B00000000,
B00000000,B01100110,B00000000,
B00000000,B00100100,B00000000
};
#endif
#else
#ifdef STATUS_CUTTER_ANIM
const unsigned char status_cutter_on_bmp[] PROGMEM = {
B00000001,B11111110,B10000000,
B00000000,B11000000,B00000000,
B00000001,B10000000,B10000000,
B00000001,B00000000,B10000000,
B00000001,B11111100,B10000000,
B00000000,B11100000,B00000000,
B00000001,B11000000,B10000000,
B00000000,B10000001,B00000000,
B00000000,B01111010,B00000000,
B00000000,B00110100,B00000000,
B00000000,B00011000,B00000000,
B00000000,B00000000,B00000000
};
const unsigned char status_cutter_bmp[] PROGMEM = {
B00000001,B11111110,B10000000,
B00000000,B11000000,B00000000,
B00000001,B10000000,B10000000,
B00000001,B00000000,B10000000,
B00000001,B11111100,B10000000,
B00000000,B11100000,B00000000,
B00000001,B11000000,B10000000,
B00000000,B10000001,B00000000,
B00000000,B01111010,B00000000,
B00000000,B00110100,B00000000,
B00000000,B00011000,B00000000,
B00000000,B00000000,B00000000
};
#else
const unsigned char status_cutter_bmp[] PROGMEM = {
B00000001,B11000010,B10000000,
B00000001,B00011100,B10000000,
B00000000,B11100001,B00000000,
B00000001,B00001110,B10000000,
B00000001,B01110000,B10000000,
B00000000,B10000111,B10000000,
B00000001,B00111111,B10000000,
B00000000,B11111111,B00000000,
B00000000,B01111110,B00000000,
B00000000,B00111100,B00000000,
B00000000,B00011000,B00000000,
B00000000,B00000000,B00000000
};
#endif
#endif
#endif // LASER / SPINDLE
//
// Default Status Screen Bed bitmaps
//
@ -1467,6 +1566,51 @@
#endif
//
// Cutter Bitmap Properties
//
#ifndef STATUS_CUTTER_BYTEWIDTH
#define STATUS_CUTTER_BYTEWIDTH BW(STATUS_CUTTER_WIDTH)
#endif
#if STATUS_CUTTER_WIDTH
#ifndef STATUS_CUTTER_X
#define STATUS_CUTTER_X (LCD_PIXEL_WIDTH - (STATUS_CUTTER_BYTEWIDTH + STATUS_CUTTER_BYTEWIDTH) * 8)
#endif
#ifndef STATUS_CUTTER_HEIGHT
#ifdef STATUS_CUTTER_ANIM
#define STATUS_CUTTER_HEIGHT(S) ((S) ? sizeof(status_cutter_on_bmp) / (STATUS_CUTTER_BYTEWIDTH) : sizeof(status_cutter_bmp) / (STATUS_CUTTER_BYTEWIDTH))
#else
#define STATUS_CUTTER_HEIGHT(S) (sizeof(status_cutter_bmp) / (STATUS_CUTTER_BYTEWIDTH))
#endif
#endif
#ifndef STATUS_CUTTER_Y
#define STATUS_CUTTER_Y(S) 4
#endif
#ifndef STATUS_CUTTER_TEXT_X
#define STATUS_CUTTER_TEXT_X (STATUS_CUTTER_X -1)
#endif
#ifndef STATUS_CUTTER_TEXT_Y
#define STATUS_CUTTER_TEXT_Y 28
#endif
static_assert(
sizeof(status_cutter_bmp) == (STATUS_CUTTER_BYTEWIDTH) * (STATUS_CUTTER_HEIGHT(0)),
"Status cutter bitmap (status_cutter_bmp) dimensions don't match data."
);
#ifdef STATUS_CUTTER_ANIM
static_assert(
sizeof(status_cutter_on_bmp) == (STATUS_CUTTER_BYTEWIDTH) * (STATUS_CUTTER_HEIGHT(1)),
"Status cutter bitmap (status_cutter_on_bmp) dimensions don't match data."
);
#endif
#endif
//
// Chamber Bitmap Properties
//

@ -44,6 +44,10 @@
#include "../../gcode/parser.h"
#endif
#if HAS_CUTTER
#include "../../feature/spindle_laser.h"
#endif
#if ENABLED(SDSUPPORT)
#include "../../sd/cardreader.h"
#endif
@ -65,6 +69,7 @@
#define DO_DRAW_LOGO (STATUS_LOGO_WIDTH && ENABLED(CUSTOM_STATUS_SCREEN_IMAGE))
#define DO_DRAW_HOTENDS (HOTENDS > 0)
#define DO_DRAW_CUTTER (HAS_CUTTER)
#define DO_DRAW_BED (HAS_HEATED_BED && STATUS_BED_WIDTH && HOTENDS <= 4)
#define DO_DRAW_CHAMBER (HAS_TEMP_CHAMBER && STATUS_CHAMBER_WIDTH && HOTENDS <= 4)
#define DO_DRAW_FAN (HAS_FAN0 && STATUS_FAN_WIDTH && HOTENDS <= 4 && defined(STATUS_FAN_FRAMES))
@ -72,33 +77,44 @@
#define ANIM_HOTEND (HOTENDS && ENABLED(STATUS_HOTEND_ANIM))
#define ANIM_BED (DO_DRAW_BED && ENABLED(STATUS_BED_ANIM))
#define ANIM_CHAMBER (DO_DRAW_CHAMBER && ENABLED(STATUS_CHAMBER_ANIM))
#define ANIM_CUTTER (DO_DRAW_CUTTER && ENABLED(STATUS_CUTTER_ANIM))
#define ANIM_HBC (ANIM_HOTEND || ANIM_BED || ANIM_CHAMBER)
#define ANIM_HBCC (ANIM_HOTEND || ANIM_BED || ANIM_CHAMBER || ANIM_CUTTER)
#if ANIM_HBC
uint8_t heat_bits;
#if ANIM_HBCC
enum HeatBits : uint8_t {
HEATBIT_HOTEND,
HEATBIT_BED = HOTENDS,
HEATBIT_CHAMBER,
HEATBIT_CUTTER
};
IF<(HEATBIT_CUTTER > 7), uint16_t, uint8_t>::type heat_bits;
#endif
#if ANIM_HOTEND
#define HOTEND_ALT(N) TEST(heat_bits, N)
#define HOTEND_ALT(N) TEST(heat_bits, HEATBIT_HOTEND + N)
#else
#define HOTEND_ALT(N) false
#endif
#if ANIM_BED
#define BED_ALT() TEST(heat_bits, 7)
#define BED_ALT() TEST(heat_bits, HEATBIT_BED)
#else
#define BED_ALT() false
#endif
#if ANIM_CHAMBER
#define CHAMBER_ALT() TEST(heat_bits, 6)
#define CHAMBER_ALT() TEST(heat_bits, HEATBIT_CHAMBER)
#else
#define CHAMBER_ALT() false
#endif
#if HOTENDS
#define MAX_HOTEND_DRAW _MIN(HOTENDS, ((LCD_PIXEL_WIDTH - (STATUS_LOGO_BYTEWIDTH + STATUS_FAN_BYTEWIDTH) * 8) / (STATUS_HEATERS_XSPACE)))
#if ANIM_CUTTER
#define CUTTER_ALT(N) TEST(heat_bits, HEATBIT_CUTTER)
#else
#define CUTTER_ALT() false
#endif
#if DO_DRAW_HOTENDS
#define MAX_HOTEND_DRAW _MIN(HOTENDS, ((LCD_PIXEL_WIDTH - (STATUS_LOGO_BYTEWIDTH + STATUS_FAN_BYTEWIDTH) * 8) / (STATUS_HEATERS_XSPACE)))
#define STATUS_HEATERS_BOT (STATUS_HEATERS_Y + STATUS_HEATERS_HEIGHT - 1)
#endif
#define PROGRESS_BAR_X 54
#define PROGRESS_BAR_WIDTH (LCD_PIXEL_WIDTH - PROGRESS_BAR_X)
@ -112,6 +128,7 @@ FORCE_INLINE void _draw_centered_temp(const int16_t temp, const uint8_t tx, cons
#if DO_DRAW_HOTENDS
// Draw hotend bitmap with current and target temperatures
FORCE_INLINE void _draw_hotend_status(const heater_ind_t heater, const bool blink) {
#if !HEATER_IDLE_HANDLER
UNUSED(blink);
@ -203,8 +220,7 @@ FORCE_INLINE void _draw_centered_temp(const int16_t temp, const uint8_t tx, cons
if (PAGE_UNDER(7)) {
#if HEATER_IDLE_HANDLER
const bool is_idle = thermalManager.hotend_idle[heater].timed_out,
dodraw = (blink || !is_idle);
const bool dodraw = (blink || !thermalManager.hotend_idle[heater].timed_out);
#else
constexpr bool dodraw = true;
#endif
@ -222,10 +238,11 @@ FORCE_INLINE void _draw_centered_temp(const int16_t temp, const uint8_t tx, cons
}
#endif // HOTENDS
#endif // DO_DRAW_HOTENDS
#if DO_DRAW_BED
// Draw bed bitmap with current and target temperatures
FORCE_INLINE void _draw_bed_status(const bool blink) {
#if !HEATER_IDLE_HANDLER
UNUSED(blink);
@ -274,8 +291,7 @@ FORCE_INLINE void _draw_centered_temp(const int16_t temp, const uint8_t tx, cons
if (PAGE_UNDER(7)) {
#if HEATER_IDLE_HANDLER
const bool is_idle = thermalManager.bed_idle.timed_out,
dodraw = (blink || !is_idle);
const bool dodraw = (blink || !thermalManager.bed_idle.timed_out);
#else
constexpr bool dodraw = true;
#endif
@ -383,16 +399,19 @@ void MarlinUI::draw_status_screen() {
// At the first page, generate new display values
if (first_page) {
#if ANIM_HBC
#if ANIM_HBCC
uint8_t new_bits = 0;
#if ANIM_HOTEND
HOTEND_LOOP() if (thermalManager.isHeatingHotend(e)) SBI(new_bits, e);
HOTEND_LOOP() if (thermalManager.isHeatingHotend(e)) SBI(new_bits, HEATBIT_HOTEND + e);
#endif
#if ANIM_BED
if (thermalManager.isHeatingBed()) SBI(new_bits, 7);
if (thermalManager.isHeatingBed()) SBI(new_bits, HEATBIT_BED);
#endif
#if DO_DRAW_CHAMBER && HAS_HEATED_CHAMBER
if (thermalManager.isHeatingChamber()) SBI(new_bits, 6);
if (thermalManager.isHeatingChamber()) SBI(new_bits, HEATBIT_CHAMBER);
#endif
#if ANIM_CUTTER
if (cutter.enabled()) SBI(new_bits, HEATBIT_CUTTER);
#endif
heat_bits = new_bits;
#endif
@ -505,6 +524,18 @@ void MarlinUI::draw_status_screen() {
u8g.drawBitmapP(STATUS_HEATERS_X, STATUS_HEATERS_Y, STATUS_HEATERS_BYTEWIDTH, STATUS_HEATERS_HEIGHT, status_heaters_bmp);
#endif
#if DO_DRAW_CUTTER
#if ANIM_CUTTER
#define CUTTER_BITMAP(S) ((S) ? status_cutter_on_bmp : status_cutter_bmp)
#else
#define CUTTER_BITMAP(S) status_cutter_bmp
#endif
const uint8_t cuttery = STATUS_CUTTER_Y(CUTTER_ALT()),
cutterh = STATUS_CUTTER_HEIGHT(CUTTER_ALT());
if (PAGE_CONTAINS(cuttery, cuttery + cutterh - 1))
u8g.drawBitmapP(STATUS_CUTTER_X, cuttery, STATUS_CUTTER_BYTEWIDTH, cutterh, CUTTER_BITMAP(CUTTER_ALT()));
#endif
#if DO_DRAW_BED && DISABLED(STATUS_COMBINE_HEATERS)
#if ANIM_BED
#define BED_BITMAP(S) ((S) ? status_bed_on_bmp : status_bed_bmp)
@ -558,16 +589,25 @@ void MarlinUI::draw_status_screen() {
//
if (PAGE_UNDER(6 + 1 + 12 + 1 + 6 + 1)) {
// Extruders
#if HOTENDS
#if DO_DRAW_HOTENDS
for (uint8_t e = 0; e < MAX_HOTEND_DRAW; ++e)
_draw_hotend_status((heater_ind_t)e, blink);
#endif
// Heated bed
#if DO_DRAW_BED && DISABLED(STATUS_COMBINE_HEATERS) || (HAS_HEATED_BED && ENABLED(STATUS_COMBINE_HEATERS) && HOTENDS <= 4)
// Laser / Spindle
#if DO_DRAW_CUTTER
if (cutter.power && PAGE_CONTAINS(STATUS_CUTTER_TEXT_Y - INFO_FONT_ASCENT, STATUS_CUTTER_TEXT_Y - 1)) {
lcd_put_u8str(STATUS_CUTTER_TEXT_X, STATUS_CUTTER_TEXT_Y, i16tostr3(cutter.powerPercent(cutter.power)));
lcd_put_wchar('%');
}
#endif
// Heated Bed
#if DO_DRAW_BED
_draw_bed_status(blink);
#endif
// Heated Chamber
#if DO_DRAW_CHAMBER
_draw_chamber_status();
#endif

Loading…
Cancel
Save