Laser support for TFT GLCD (#22391)

This commit is contained in:
Serhiy-K 2021-07-19 05:39:01 +03:00 committed by Scott Lahteine
parent 2e5e5c4a1d
commit 603b65e843
2 changed files with 226 additions and 98 deletions

View File

@ -213,7 +213,7 @@
#define LCD_PROGRESS_BAR #define LCD_PROGRESS_BAR
#endif #endif
#if ENABLED(TFTGLCD_PANEL_I2C) #if ENABLED(TFTGLCD_PANEL_I2C)
#define LCD_I2C_ADDRESS 0x27 // Must be equal to panel's I2C slave addres #define LCD_I2C_ADDRESS 0x33 // Must be 0x33 for STM32 main boards and equal to panel's I2C slave addres
#endif #endif
#define LCD_USE_I2C_BUZZER // Enable buzzer on LCD, used for both I2C and SPI buses (LiquidTWI2 not required) #define LCD_USE_I2C_BUZZER // Enable buzzer on LCD, used for both I2C and SPI buses (LiquidTWI2 not required)
#define STD_ENCODER_PULSES_PER_STEP 2 #define STD_ENCODER_PULSES_PER_STEP 2

View File

@ -57,6 +57,18 @@
#include "../../gcode/parser.h" #include "../../gcode/parser.h"
#endif #endif
#if EITHER(HAS_COOLER, LASER_COOLANT_FLOW_METER)
#include "../../feature/cooler.h"
#endif
#if ENABLED(I2C_AMMETER)
#include "../../feature/ammeter.h"
#endif
#if HAS_CUTTER
#include "../../feature/spindle_laser.h"
#endif
#if ENABLED(AUTO_BED_LEVELING_UBL) #if ENABLED(AUTO_BED_LEVELING_UBL)
#include "../../feature/bedlevel/bedlevel.h" #include "../../feature/bedlevel/bedlevel.h"
#endif #endif
@ -64,12 +76,12 @@
TFTGLCD lcd; TFTGLCD lcd;
#define ICON_LOGO B00000001 #define ICON_LOGO B00000001
#define ICON_TEMP1 B00000010 //hotend 1 #define ICON_TEMP1 B00000010 // Hotend 1
#define ICON_TEMP2 B00000100 //hotend 2 #define ICON_TEMP2 B00000100 // Hotend 2
#define ICON_TEMP3 B00001000 //hotend 3 #define ICON_TEMP3 B00001000 // Hotend 3
#define ICON_BED B00010000 #define ICON_BED B00010000
#define ICON_FAN B00100000 #define ICON_FAN B00100000
#define ICON_HOT B01000000 //when any T > 50deg #define ICON_HOT B01000000 // When any T > 50deg
#define PIC_MASK 0x7F #define PIC_MASK 0x7F
// LEDs not used, for compatibility with Smoothieware // LEDs not used, for compatibility with Smoothieware
@ -433,7 +445,9 @@ FORCE_INLINE void _draw_axis_value(const AxisEnum axis, const char *value, const
lcd_put_u8str(value); lcd_put_u8str(value);
} }
FORCE_INLINE void _draw_heater_status(const heater_id_t heater_id, const char *prefix, const bool blink) { #if HAS_HOTEND || HAS_HEATED_BED
FORCE_INLINE void _draw_heater_status(const heater_id_t heater_id, const char *prefix, const bool blink) {
uint8_t pic_hot_bits; uint8_t pic_hot_bits;
#if HAS_HEATED_BED #if HAS_HEATED_BED
const bool isBed = heater_id < 0; const bool isBed = heater_id < 0;
@ -495,7 +509,97 @@ FORCE_INLINE void _draw_heater_status(const heater_id_t heater_id, const char *p
if (hotBits) picBits |= ICON_HOT; if (hotBits) picBits |= ICON_HOT;
else picBits &= ~ICON_HOT; else picBits &= ~ICON_HOT;
} }
#endif // HAS_HOTEND || HAS_HEATED_BED
#if HAS_COOLER
FORCE_INLINE void _draw_cooler_status(const bool blink) {
const celsius_t t2 = thermalManager.degTargetCooler();
lcd.setCursor(0, 5); lcd_put_u8str_P(PSTR("COOL"));
lcd.setCursor(1, 6); lcd_put_u8str(i16tostr3rj(thermalManager.wholeDegCooler()));
lcd.setCursor(1, 7);
#if !HEATER_IDLE_HANDLER
UNUSED(blink);
#else
if (!blink && thermalManager.heater_idle[thermalManager.idle_index_for_id(heater_id)].timed_out) {
lcd_put_wchar(' ');
if (t2 >= 10) lcd_put_wchar(' ');
if (t2 >= 100) lcd_put_wchar(' ');
}
else
#endif
lcd_put_u8str(i16tostr3left(t2));
lcd_put_wchar(' ');
if (t2 < 10) lcd_put_wchar(' ');
if (t2) picBits |= ICON_TEMP1;
else picBits &= ~ICON_TEMP1;
}
#endif // HAS_COOLER
#if ENABLED(LASER_COOLANT_FLOW_METER)
FORCE_INLINE void _draw_flowmeter_status() {
lcd.setCursor(5, 5); lcd_put_u8str_P(PSTR("FLOW"));
lcd.setCursor(7, 6); lcd_put_wchar('L');
lcd.setCursor(6, 7); lcd_put_u8str(ftostr11ns(cooler.flowrate));
if (cooler.flowrate) picBits |= ICON_FAN;
else picBits &= ~ICON_FAN;
}
#endif
#if ENABLED(I2C_AMMETER)
FORCE_INLINE void _draw_ammeter_status() {
lcd.setCursor(10, 5); lcd_put_u8str_P(PSTR("ILAZ"));
ammeter.read();
lcd.setCursor(11, 6);
if (ammeter.current <= 0.999f)
{
lcd_put_u8str("mA");
lcd.setCursor(10, 7);
lcd_put_wchar(' '); lcd_put_u8str(ui16tostr3rj(uint16_t(ammeter.current * 1000 + 0.5f)));
}
else {
lcd_put_u8str(" A");
lcd.setCursor(10, 7);
lcd_put_u8str(ftostr12ns(ammeter.current));
}
if (ammeter.current) picBits |= ICON_BED;
else picBits &= ~ICON_BED;
}
#endif // I2C_AMMETER
#if HAS_CUTTER
FORCE_INLINE void _draw_cutter_status() {
lcd.setCursor(15, 5); lcd_put_u8str_P(PSTR("CUTT"));
#if CUTTER_UNIT_IS(RPM)
lcd.setCursor(16, 6); lcd_put_u8str_P(PSTR("RPM"));
lcd.setCursor(15, 7); lcd_put_u8str(ftostr31ns(float(cutter.unitPower) / 1000));
lcd_put_wchar('K');
#elif CUTTER_UNIT_IS(PERCENT)
lcd.setCursor(17, 6); lcd_put_wchar('%');
lcd.setCursor(18, 7); lcd_put_u8str(cutter_power2str(cutter.unitPower));
#else
lcd.setCursor(17, 7); lcd_put_u8str(cutter_power2str(cutter.unitPower));
#endif
if (cutter.unitPower) picBits |= ICON_HOT;
else picBits &= ~ICON_HOT;
}
#endif // HAS_CUTTER
#if HAS_PRINT_PROGRESS #if HAS_PRINT_PROGRESS
@ -533,7 +637,7 @@ FORCE_INLINE void _draw_heater_status(const heater_id_t heater_id, const char *p
} }
} }
#endif #endif // LCD_PROGRESS_BAR
void MarlinUI::draw_status_message(const bool blink) { void MarlinUI::draw_status_message(const bool blink) {
if (!PanelDetected) return; if (!PanelDetected) return;
@ -648,6 +752,19 @@ or
or or
|X 000 Y 000 Z 000.00|
|FR100% SD100% C--:--|
| Progress bar line |
|Status message |
| |
|COOL FLOW ILAZ CUTT |
| ttc L mA RPM |
| tts f.f aaa rr.rK|
| ICO ICO ICO ICO |
| ICO ICO ICO ICO |
or
Equal to 24x10 text LCD Equal to 24x10 text LCD
|X 000 Y 000 Z 000.00 | |X 000 Y 000 Z 000.00 |
@ -745,9 +862,11 @@ void MarlinUI::draw_status_screen() {
#endif #endif
// //
// Line 6..8 Temperatures, FAN // Line 6..8 Temperatures, FAN for printer or Cooler, Flowmetter, Ampermeter, Cutter for laser/spindle
// //
#if HAS_HOTEND
#if HOTENDS < 2 #if HOTENDS < 2
_draw_heater_status(H_E0, "HE", blink); // Hotend Temperature _draw_heater_status(H_E0, "HE", blink); // Hotend Temperature
#else #else
@ -790,6 +909,15 @@ void MarlinUI::draw_status_screen() {
#endif // HAS_FAN #endif // HAS_FAN
#else
TERN_(HAS_COOLER, _draw_cooler_status(blink));
TERN_(LASER_COOLANT_FLOW_METER, _draw_flowmeter_status());
TERN_(I2C_AMMETER, _draw_ammeter_status());
TERN_(HAS_CUTTER, _draw_cutter_status());
#endif
// //
// Line 9, 10 - icons // Line 9, 10 - icons
// //