Add Laser / Spindle bitmap for LCD (#16068)

This commit is contained in:
Luu Lac 2019-12-01 21:20:15 -06:00 committed by Scott Lahteine
parent bdd0517a5b
commit 01e4b0c067
3 changed files with 207 additions and 22 deletions

View file

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

View file

@ -598,6 +598,105 @@
#endif // !STATUS_HEATERS_WIDTH && !STATUS_HOTEND1_WIDTH #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 // Default Status Screen Bed bitmaps
// //
@ -1467,6 +1566,51 @@
#endif #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 // Chamber Bitmap Properties
// //

View file

@ -44,6 +44,10 @@
#include "../../gcode/parser.h" #include "../../gcode/parser.h"
#endif #endif
#if HAS_CUTTER
#include "../../feature/spindle_laser.h"
#endif
#if ENABLED(SDSUPPORT) #if ENABLED(SDSUPPORT)
#include "../../sd/cardreader.h" #include "../../sd/cardreader.h"
#endif #endif
@ -65,6 +69,7 @@
#define DO_DRAW_LOGO (STATUS_LOGO_WIDTH && ENABLED(CUSTOM_STATUS_SCREEN_IMAGE)) #define DO_DRAW_LOGO (STATUS_LOGO_WIDTH && ENABLED(CUSTOM_STATUS_SCREEN_IMAGE))
#define DO_DRAW_HOTENDS (HOTENDS > 0) #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_BED (HAS_HEATED_BED && STATUS_BED_WIDTH && HOTENDS <= 4)
#define DO_DRAW_CHAMBER (HAS_TEMP_CHAMBER && STATUS_CHAMBER_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)) #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_HOTEND (HOTENDS && ENABLED(STATUS_HOTEND_ANIM))
#define ANIM_BED (DO_DRAW_BED && ENABLED(STATUS_BED_ANIM)) #define ANIM_BED (DO_DRAW_BED && ENABLED(STATUS_BED_ANIM))
#define ANIM_CHAMBER (DO_DRAW_CHAMBER && ENABLED(STATUS_CHAMBER_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 #if ANIM_HBCC
uint8_t heat_bits; 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 #endif
#if ANIM_HOTEND #if ANIM_HOTEND
#define HOTEND_ALT(N) TEST(heat_bits, N) #define HOTEND_ALT(N) TEST(heat_bits, HEATBIT_HOTEND + N)
#else #else
#define HOTEND_ALT(N) false #define HOTEND_ALT(N) false
#endif #endif
#if ANIM_BED #if ANIM_BED
#define BED_ALT() TEST(heat_bits, 7) #define BED_ALT() TEST(heat_bits, HEATBIT_BED)
#else #else
#define BED_ALT() false #define BED_ALT() false
#endif #endif
#if ANIM_CHAMBER #if ANIM_CHAMBER
#define CHAMBER_ALT() TEST(heat_bits, 6) #define CHAMBER_ALT() TEST(heat_bits, HEATBIT_CHAMBER)
#else #else
#define CHAMBER_ALT() false #define CHAMBER_ALT() false
#endif #endif
#if ANIM_CUTTER
#if HOTENDS #define CUTTER_ALT(N) TEST(heat_bits, HEATBIT_CUTTER)
#define MAX_HOTEND_DRAW _MIN(HOTENDS, ((LCD_PIXEL_WIDTH - (STATUS_LOGO_BYTEWIDTH + STATUS_FAN_BYTEWIDTH) * 8) / (STATUS_HEATERS_XSPACE))) #else
#define CUTTER_ALT() false
#endif #endif
#define STATUS_HEATERS_BOT (STATUS_HEATERS_Y + STATUS_HEATERS_HEIGHT - 1) #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_X 54
#define PROGRESS_BAR_WIDTH (LCD_PIXEL_WIDTH - PROGRESS_BAR_X) #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 #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) { FORCE_INLINE void _draw_hotend_status(const heater_ind_t heater, const bool blink) {
#if !HEATER_IDLE_HANDLER #if !HEATER_IDLE_HANDLER
UNUSED(blink); 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 (PAGE_UNDER(7)) {
#if HEATER_IDLE_HANDLER #if HEATER_IDLE_HANDLER
const bool is_idle = thermalManager.hotend_idle[heater].timed_out, const bool dodraw = (blink || !thermalManager.hotend_idle[heater].timed_out);
dodraw = (blink || !is_idle);
#else #else
constexpr bool dodraw = true; constexpr bool dodraw = true;
#endif #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 #if DO_DRAW_BED
// Draw bed bitmap with current and target temperatures
FORCE_INLINE void _draw_bed_status(const bool blink) { FORCE_INLINE void _draw_bed_status(const bool blink) {
#if !HEATER_IDLE_HANDLER #if !HEATER_IDLE_HANDLER
UNUSED(blink); 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 (PAGE_UNDER(7)) {
#if HEATER_IDLE_HANDLER #if HEATER_IDLE_HANDLER
const bool is_idle = thermalManager.bed_idle.timed_out, const bool dodraw = (blink || !thermalManager.bed_idle.timed_out);
dodraw = (blink || !is_idle);
#else #else
constexpr bool dodraw = true; constexpr bool dodraw = true;
#endif #endif
@ -383,16 +399,19 @@ void MarlinUI::draw_status_screen() {
// At the first page, generate new display values // At the first page, generate new display values
if (first_page) { if (first_page) {
#if ANIM_HBC #if ANIM_HBCC
uint8_t new_bits = 0; uint8_t new_bits = 0;
#if ANIM_HOTEND #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 #endif
#if ANIM_BED #if ANIM_BED
if (thermalManager.isHeatingBed()) SBI(new_bits, 7); if (thermalManager.isHeatingBed()) SBI(new_bits, HEATBIT_BED);
#endif #endif
#if DO_DRAW_CHAMBER && HAS_HEATED_CHAMBER #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 #endif
heat_bits = new_bits; heat_bits = new_bits;
#endif #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); u8g.drawBitmapP(STATUS_HEATERS_X, STATUS_HEATERS_Y, STATUS_HEATERS_BYTEWIDTH, STATUS_HEATERS_HEIGHT, status_heaters_bmp);
#endif #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 DO_DRAW_BED && DISABLED(STATUS_COMBINE_HEATERS)
#if ANIM_BED #if ANIM_BED
#define BED_BITMAP(S) ((S) ? status_bed_on_bmp : status_bed_bmp) #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)) { if (PAGE_UNDER(6 + 1 + 12 + 1 + 6 + 1)) {
// Extruders // Extruders
#if HOTENDS #if DO_DRAW_HOTENDS
for (uint8_t e = 0; e < MAX_HOTEND_DRAW; ++e) for (uint8_t e = 0; e < MAX_HOTEND_DRAW; ++e)
_draw_hotend_status((heater_ind_t)e, blink); _draw_hotend_status((heater_ind_t)e, blink);
#endif #endif
// Heated bed // Laser / Spindle
#if DO_DRAW_BED && DISABLED(STATUS_COMBINE_HEATERS) || (HAS_HEATED_BED && ENABLED(STATUS_COMBINE_HEATERS) && HOTENDS <= 4) #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); _draw_bed_status(blink);
#endif #endif
// Heated Chamber
#if DO_DRAW_CHAMBER #if DO_DRAW_CHAMBER
_draw_chamber_status(); _draw_chamber_status();
#endif #endif