MarlinFirmware / Marlin

Marlin is an optimized firmware for RepRap 3D printers based on the Arduino platform. Many commercial 3D printers come with Marlin installed. Check with your vendor if you need source code for your specific machine.
https://marlinfw.org
GNU General Public License v3.0
16.27k stars 19.23k forks source link

Looking to have LCD_BACKLIGHT_TIMEOUT enabled (for ProUI) #24675

Closed classicrocker883 closed 1 year ago

classicrocker883 commented 2 years ago

Bug Description

So this isn't a problem with the newest bug fix per say, but as an amateur programmer, I'm looking for some help with a feature.

I had tried enabling the LCD_BACKLIGHT_TIMEOUT in _adv.h and everything almost went well.

I am able to get the lcd screen to turn off after X time, but I am having trouble getting it to come back with an encoder state like it does normally when the lcd is off.

BTW my settings are based on default Ender3V2 and ProUI DWIN lcd.

Expected behavior

Need LCD to come on and refresh timeout

refresh_backlight_timeout()

when screen is back on. perhaps adding refresh_backlight_timeout(); to the encoder.cpp with some argument, such as when Encoder_tick() makes a sound when it is pressed. I'd like it to refresh timeout when pressed AND turn of a knob. so what encoder change state code do I used? (look into encoder.cpp or .h for example)

Actual behavior

Lcd screen does not come back on at all, or by tweaking the code I can get it to come back on, but the timeout doesn't reset until either one of encoder buttons is pressed but not all like it should. so either it will be reset if I press the knob but not turn it.

Steps to Reproduce

remove comment to enable LCD_BACKLIGHT_TIMEOUT, take the code in marlinui.cpp (line 177, after if LCD_BACKLIGHT_TIMEOUT)

remove- WRITE(LCD_BACKLIGHT_PIN, HIGH);

(line 1174)

remove- WRITE(LCD_BACKLIGHT_PIN, LOW); add+ TurnOffBacklight();

but now we need a way to return this function

refresh_backlight_timeout()

whenever the encoder changes state/turn knob or press it like whenever the lcd comes on from an off state.

Version of Marlin Firmware

Mriscoc current

Printer model

Voxelab Aquila - basically Ender 3V2

github-actions[bot] commented 2 years ago

This issue has had no activity in the last 60 days. Please add a reply if you want to keep this issue active, otherwise it will be automatically closed within 10 days.

classicrocker883 commented 2 years ago

This may not be all but it is what should be changed if not already there.

in file e3v2/proui/dwin.cpp

if LCD_BACKLIGHT_TIMEOUT_MINS

void SetTimer() { SetPIntOnClick(ui.backlight_timeout_min, ui.backlight_timeout_max); }

endif

in the tune_menu AND advanced/control_menu

if LCD_BACKLIGHT_TIMEOUT_MINS

EDIT_ITEM(ICON_Box, MSG_SCREEN_TIMEOUT, onDrawPIntMenu, SetTimer, &ui.backlight_timeout_minutes);

endif

under EachMomentUpdate()

if LCD_BACKLIGHT_TIMEOUT_MINS

if (ui.backlight_off_ms && ELAPSED(ms, ui.backlight_off_ms)) { TurnOffBacklight(); ; // Backlight off ui.backlight_off_ms = 0; }

endif

in plot.cpp under PlotClass::Update and in src/feature/bedlevel/ubl/ubl_G29.cpp under unified_bed_leveling::probe_entire_mesh

if LCD_BACKLIGHT_TIMEOUT_MINS

ui.refresh_backlight_timeout();

endif

in file lcd/marlinui.cpp

if LCD_BACKLIGHT_TIMEOUT_MINS

constexpr uint8_t MarlinUI::backlight_timeout_min, MarlinUI::backlight_timeout_max; uint8_t MarlinUI::backlight_timeout_minutes; // Initialized by settings.load() millis_t MarlinUI::backlight_off_ms = 0; void MarlinUI::refresh_backlight_timeout() { backlight_off_ms = backlight_timeout_minutes ? millis() + backlight_timeout_minutes 60UL 1000UL : 0;

if PIN_EXISTS(LCD_BACKLIGHT)

WRITE(LCD_BACKLIGHT_PIN, HIGH);

endif

}

Below 2ND SCREENS_CAN_TIME_OUT ~line 1180

if LCD_BACKLIGHT_TIMEOUT_MINS

if (backlight_off_ms && ELAPSED(ms, backlight_off_ms)) {

if PIN_EXISTS(LCD_BACKLIGHT)

WRITE(LCD_BACKLIGHT_PIN, LOW); // Backlight off backlight_off_ms = 0;

above // encoder activity

if LCD_BACKLIGHT_TIMEOUT_MINS

refresh_backlight_timeout();

in file e3v2/common/encoder.cpp under Encoder_tick();

if LCD_BACKLIGHT_TIMEOUT_MINS

ui.refresh_backlight_timeout(); //reset timer on click

endif

github-actions[bot] commented 1 year ago

This issue has had no activity in the last 60 days. Please add a reply if you want to keep this issue active, otherwise it will be automatically closed within 10 days.

github-actions[bot] commented 1 year ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.