🚸 TFT backlight PWM / brightness (#22841)
This commit is contained in:
		
				
					committed by
					
						
						Scott Lahteine
					
				
			
			
				
	
			
			
			
						parent
						
							34c9f64925
						
					
				
				
					commit
					064f91e9b0
				
			@@ -338,6 +338,15 @@ void MarlinUI::draw_kill_screen() {
 | 
			
		||||
 | 
			
		||||
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
 | 
			
		||||
 | 
			
		||||
  #include "../menu/menu.h"
 | 
			
		||||
 
 | 
			
		||||
@@ -336,6 +336,7 @@ namespace Language_fr {
 | 
			
		||||
  LSTR MSG_FILAMENT_LOAD                  = _UxGT("Charger mm");
 | 
			
		||||
  LSTR MSG_ADVANCE_K                      = _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_STORE_EEPROM                   = _UxGT("Enregistrer 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() {
 | 
			
		||||
    if (isSleeping()) {
 | 
			
		||||
      #if PIN_EXISTS(TFT_BACKLIGHT)
 | 
			
		||||
      #if HAS_LCD_BRIGHTNESS
 | 
			
		||||
        ui._set_brightness();
 | 
			
		||||
      #elif PIN_EXISTS(TFT_BACKLIGHT)
 | 
			
		||||
        WRITE(TFT_BACKLIGHT_PIN, HIGH);
 | 
			
		||||
      #endif
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -210,6 +210,15 @@ void MarlinUI::clear_lcd() {
 | 
			
		||||
  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)
 | 
			
		||||
 | 
			
		||||
  void MarlinUI::touch_calibration_screen() {
 | 
			
		||||
 
 | 
			
		||||
@@ -49,6 +49,10 @@
 | 
			
		||||
#include "ili9341.h"
 | 
			
		||||
#include "ili9328.h"
 | 
			
		||||
 | 
			
		||||
#if HAS_LCD_BRIGHTNESS
 | 
			
		||||
  #include "../marlinui.h"
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#define DEBUG_OUT ENABLED(DEBUG_GRAPHICAL_TFT)
 | 
			
		||||
#include "../../core/debug_out.h"
 | 
			
		||||
 | 
			
		||||
@@ -72,6 +76,9 @@ if (lcd_id != 0xFFFFFFFF) return;
 | 
			
		||||
 | 
			
		||||
  #if PIN_EXISTS(TFT_BACKLIGHT)
 | 
			
		||||
    WRITE(TFT_BACKLIGHT_PIN, DISABLED(DELAYED_BACKLIGHT_INIT));
 | 
			
		||||
    #if HAS_LCD_BRIGHTNESS && DISABLED(DELAYED_BACKLIGHT_INIT)
 | 
			
		||||
      ui._set_brightness();
 | 
			
		||||
    #endif
 | 
			
		||||
  #endif
 | 
			
		||||
 | 
			
		||||
  // io.Init();
 | 
			
		||||
@@ -141,11 +148,12 @@ if (lcd_id != 0xFFFFFFFF) return;
 | 
			
		||||
        lcd_id = 0;
 | 
			
		||||
    }
 | 
			
		||||
  #else
 | 
			
		||||
    #error Unsupported TFT driver
 | 
			
		||||
    #error "Unsupported TFT driver"
 | 
			
		||||
  #endif
 | 
			
		||||
 | 
			
		||||
  #if PIN_EXISTS(TFT_BACKLIGHT) && ENABLED(DELAYED_BACKLIGHT_INIT)
 | 
			
		||||
    WRITE(TFT_BACKLIGHT_PIN, HIGH);
 | 
			
		||||
    TERN_(HAS_LCD_BRIGHTNESS, ui._set_brightness());
 | 
			
		||||
  #endif
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -122,7 +122,9 @@ uint8_t TouchButtons::read_buttons() {
 | 
			
		||||
  }
 | 
			
		||||
  void TouchButtons::wakeUp() {
 | 
			
		||||
    if (isSleeping()) {
 | 
			
		||||
      #if PIN_EXISTS(TFT_BACKLIGHT)
 | 
			
		||||
      #if HAS_LCD_BRIGHTNESS
 | 
			
		||||
        ui._set_brightness();
 | 
			
		||||
      #elif PIN_EXISTS(TFT_BACKLIGHT)
 | 
			
		||||
        WRITE(TFT_BACKLIGHT_PIN, HIGH);
 | 
			
		||||
      #endif
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user