🚸 TFT backlight PWM / brightness (#22841)
This commit is contained in:
parent
34c9f64925
commit
064f91e9b0
|
@ -338,6 +338,15 @@ void MarlinUI::draw_kill_screen() {
|
||||||
|
|
||||||
void MarlinUI::clear_lcd() { } // Automatically cleared by Picture Loop
|
void MarlinUI::clear_lcd() { } // Automatically cleared by Picture Loop
|
||||||
|
|
||||||
|
#if HAS_LCD_BRIGHTNESS
|
||||||
|
void MarlinUI::_set_brightness() {
|
||||||
|
#if PIN_EXISTS(TFT_BACKLIGHT)
|
||||||
|
if (PWM_PIN(TFT_BACKLIGHT_PIN))
|
||||||
|
analogWrite(pin_t(TFT_BACKLIGHT_PIN), brightness);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#if HAS_LCD_MENU
|
#if HAS_LCD_MENU
|
||||||
|
|
||||||
#include "../menu/menu.h"
|
#include "../menu/menu.h"
|
||||||
|
|
|
@ -336,6 +336,7 @@ namespace Language_fr {
|
||||||
LSTR MSG_FILAMENT_LOAD = _UxGT("Charger mm");
|
LSTR MSG_FILAMENT_LOAD = _UxGT("Charger mm");
|
||||||
LSTR MSG_ADVANCE_K = _UxGT("Avance K");
|
LSTR MSG_ADVANCE_K = _UxGT("Avance K");
|
||||||
LSTR MSG_ADVANCE_K_E = _UxGT("Avance K *");
|
LSTR MSG_ADVANCE_K_E = _UxGT("Avance K *");
|
||||||
|
LSTR MSG_BRIGHTNESS = _UxGT("Luminosité LCD");
|
||||||
LSTR MSG_CONTRAST = _UxGT("Contraste LCD");
|
LSTR MSG_CONTRAST = _UxGT("Contraste LCD");
|
||||||
LSTR MSG_STORE_EEPROM = _UxGT("Enregistrer config.");
|
LSTR MSG_STORE_EEPROM = _UxGT("Enregistrer config.");
|
||||||
LSTR MSG_LOAD_EEPROM = _UxGT("Charger config.");
|
LSTR MSG_LOAD_EEPROM = _UxGT("Charger config.");
|
||||||
|
|
|
@ -294,7 +294,9 @@ bool Touch::get_point(int16_t *x, int16_t *y) {
|
||||||
}
|
}
|
||||||
void Touch::wakeUp() {
|
void Touch::wakeUp() {
|
||||||
if (isSleeping()) {
|
if (isSleeping()) {
|
||||||
#if PIN_EXISTS(TFT_BACKLIGHT)
|
#if HAS_LCD_BRIGHTNESS
|
||||||
|
ui._set_brightness();
|
||||||
|
#elif PIN_EXISTS(TFT_BACKLIGHT)
|
||||||
WRITE(TFT_BACKLIGHT_PIN, HIGH);
|
WRITE(TFT_BACKLIGHT_PIN, HIGH);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
@ -210,6 +210,15 @@ void MarlinUI::clear_lcd() {
|
||||||
cursor.set(0, 0);
|
cursor.set(0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if HAS_LCD_BRIGHTNESS
|
||||||
|
void MarlinUI::_set_brightness() {
|
||||||
|
#if PIN_EXISTS(TFT_BACKLIGHT)
|
||||||
|
if (PWM_PIN(TFT_BACKLIGHT_PIN))
|
||||||
|
analogWrite(pin_t(TFT_BACKLIGHT_PIN), brightness);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#if ENABLED(TOUCH_SCREEN_CALIBRATION)
|
#if ENABLED(TOUCH_SCREEN_CALIBRATION)
|
||||||
|
|
||||||
void MarlinUI::touch_calibration_screen() {
|
void MarlinUI::touch_calibration_screen() {
|
||||||
|
|
|
@ -49,6 +49,10 @@
|
||||||
#include "ili9341.h"
|
#include "ili9341.h"
|
||||||
#include "ili9328.h"
|
#include "ili9328.h"
|
||||||
|
|
||||||
|
#if HAS_LCD_BRIGHTNESS
|
||||||
|
#include "../marlinui.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#define DEBUG_OUT ENABLED(DEBUG_GRAPHICAL_TFT)
|
#define DEBUG_OUT ENABLED(DEBUG_GRAPHICAL_TFT)
|
||||||
#include "../../core/debug_out.h"
|
#include "../../core/debug_out.h"
|
||||||
|
|
||||||
|
@ -72,6 +76,9 @@ if (lcd_id != 0xFFFFFFFF) return;
|
||||||
|
|
||||||
#if PIN_EXISTS(TFT_BACKLIGHT)
|
#if PIN_EXISTS(TFT_BACKLIGHT)
|
||||||
WRITE(TFT_BACKLIGHT_PIN, DISABLED(DELAYED_BACKLIGHT_INIT));
|
WRITE(TFT_BACKLIGHT_PIN, DISABLED(DELAYED_BACKLIGHT_INIT));
|
||||||
|
#if HAS_LCD_BRIGHTNESS && DISABLED(DELAYED_BACKLIGHT_INIT)
|
||||||
|
ui._set_brightness();
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// io.Init();
|
// io.Init();
|
||||||
|
@ -141,11 +148,12 @@ if (lcd_id != 0xFFFFFFFF) return;
|
||||||
lcd_id = 0;
|
lcd_id = 0;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
#error Unsupported TFT driver
|
#error "Unsupported TFT driver"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if PIN_EXISTS(TFT_BACKLIGHT) && ENABLED(DELAYED_BACKLIGHT_INIT)
|
#if PIN_EXISTS(TFT_BACKLIGHT) && ENABLED(DELAYED_BACKLIGHT_INIT)
|
||||||
WRITE(TFT_BACKLIGHT_PIN, HIGH);
|
WRITE(TFT_BACKLIGHT_PIN, HIGH);
|
||||||
|
TERN_(HAS_LCD_BRIGHTNESS, ui._set_brightness());
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -122,7 +122,9 @@ uint8_t TouchButtons::read_buttons() {
|
||||||
}
|
}
|
||||||
void TouchButtons::wakeUp() {
|
void TouchButtons::wakeUp() {
|
||||||
if (isSleeping()) {
|
if (isSleeping()) {
|
||||||
#if PIN_EXISTS(TFT_BACKLIGHT)
|
#if HAS_LCD_BRIGHTNESS
|
||||||
|
ui._set_brightness();
|
||||||
|
#elif PIN_EXISTS(TFT_BACKLIGHT)
|
||||||
WRITE(TFT_BACKLIGHT_PIN, HIGH);
|
WRITE(TFT_BACKLIGHT_PIN, HIGH);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
@ -135,6 +135,7 @@
|
||||||
|
|
||||||
#define TFT_RESET_PIN PC4 // pin 33
|
#define TFT_RESET_PIN PC4 // pin 33
|
||||||
#define TFT_BACKLIGHT_PIN PD12 // pin 59
|
#define TFT_BACKLIGHT_PIN PD12 // pin 59
|
||||||
|
#define TFT_BACKLIGHT_PWM 150 // Brightness with alt. TIM4 chan 1 (1-255)
|
||||||
|
|
||||||
#define DOGLCD_MOSI -1 // Prevent auto-define by Conditionals_post.h
|
#define DOGLCD_MOSI -1 // Prevent auto-define by Conditionals_post.h
|
||||||
#define DOGLCD_SCK -1
|
#define DOGLCD_SCK -1
|
||||||
|
@ -143,6 +144,11 @@
|
||||||
#define TFT_BUFFER_SIZE 3200
|
#define TFT_BUFFER_SIZE 3200
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(TFT_BACKLIGHT_PWM) && !defined(MAPLE_STM32F1)
|
||||||
|
#define HAS_LCD_BRIGHTNESS 1
|
||||||
|
#define DEFAULT_LCD_BRIGHTNESS TFT_BACKLIGHT_PWM
|
||||||
|
#endif
|
||||||
|
|
||||||
#if ENABLED(SDIO_SUPPORT)
|
#if ENABLED(SDIO_SUPPORT)
|
||||||
#define SD_SS_PIN -1 // else SDSS set to PA4 in M43 (spi_pins.h)
|
#define SD_SS_PIN -1 // else SDSS set to PA4 in M43 (spi_pins.h)
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue