teeminus / NoTouchScreenFirmware

Stripped down version of BIGTREETECH-TouchScreenFirmware which only supports ST7920 emulation (Marlin Mode)
GNU General Public License v3.0
149 stars 37 forks source link

Feature Request: Brightness for supported models #6

Closed RomRider closed 3 years ago

RomRider commented 3 years ago

Amazing work with this firmware, it just works perfectly :)

I'm trying to add brightness support through PWM, but it seems that the screen just blinks instead reducing the brightness. I'm probably doing something wrong as I'm not super familiar with the code.

I'm wondering if this would be something you could add and let the user define in some .h file for supported models?

Thanks a lot for your great work again!

teeminus commented 3 years ago

If I would add that feature you would have to recompile it yourself as this wouldn't be a dynamic config option.

BTW.: Which display/mainboard combo are you using? If this combo is not listed in the wiki please post the config for me to add to the wiki.

RomRider commented 3 years ago

I'm fine with recompiling, I've done so already while experimenting with adding the feature back. It just doesn't dim, but blinks instead 😊

I'm using the TFT35 v3 with SKR v1.3

[board_pins]
aliases:
    # EXP1 header
    EXP1_1=P1.30, EXP1_3=P1.18, EXP1_5=P1.20, EXP1_7=P1.22, EXP1_9=<GND>,
    EXP1_2=P0.28, EXP1_4=P1.19, EXP1_6=P1.21, EXP1_8=P1.23, EXP1_10=<5V>,
    # EXP2 header
    EXP2_1=P0.17, EXP2_3=P3.26, EXP2_5=P3.25, EXP2_7=P1.31, EXP2_9=<GND>,
    EXP2_2=P0.15, EXP2_4=P0.16, EXP2_6=P0.18, EXP2_8=<RST>, EXP2_10=<NC>
    # Pins EXP2_1, EXP2_6, EXP2_2 are also MISO, MOSI, SCK of bus "ssp0"

[display]
lcd_type: st7920
cs_pin: EXP1_7
sclk_pin: EXP1_6
sid_pin: EXP1_8
encoder_pins: ^EXP1_5, ^EXP1_3
click_pin: ^!EXP1_2
teeminus commented 3 years ago

Thanks for the config. I will update the wiki with that :smiley:

The problem with the feature request is that it requires more work to be than than it seems at first sight. I would have to implement the PWM timer for the backlight LED, read the pins of the encoder knob and implement some kind of time tracking and dim logic.

RomRider commented 3 years ago

Thanks for your answer.

I've made it compile using:

But the result is that it blinks. What is it with reading the encoder?

teeminus commented 3 years ago

If you just want to dim your display to a constant brightness you don't need the encoder. But if you want to dim your display when there has been no user interaction, then you need the encoder.

RomRider commented 3 years ago

Yeah, I just want to reduce the brightness and always keep it this way, no brightness increase on user interaction etc... like on the initial firmware. The default 100% is very bright this is why I've tried experimenting with reducing it.

teeminus commented 3 years ago

Implementing that is a piece of a cake :wink:

I created a feature branch for that for you to test: https://github.com/teeminus/NoTouchScreenFirmware/tree/add_static_dim_support For your TFT35v3 you need the change the LCD_LED_PWM_BRIGHTNESS define here and recompile the firmware for that display.

RomRider commented 3 years ago

Works perfectly, thanks a lot! I did the same thing as you but I f***ed up with... rccClocks 🤦