Our new official repo is on github
LCD Smartie version 5.6 is released!
Download it now: https://github.com/LCD-Smartie/LCDSmartie/releases

Backlight pwm control

Discussing issues that occur during plugin development.

Moderators: _X7JAY7X_, caesar, IFR, mattcro, limbo

Post Reply
lucas_siglo21
Posts: 71
Joined: November 18th, 2007, 6:11 pm
Location: Bariloche, Argentina
Contact:

Backlight pwm control

Post by lucas_siglo21 »

does lcdsmartie support backlight brightness control using pwm in pin 17 of lpt port?

caesar
Forum Supporter
Posts: 734
Joined: October 15th, 2005, 10:39 am
Location: Romania
Contact:

Post by caesar »

no, not pwm, just on/off.

lucas_siglo21
Posts: 71
Joined: November 18th, 2007, 6:11 pm
Location: Bariloche, Argentina
Contact:

Post by lucas_siglo21 »

ok
i've made some tests and it is technicaly possible if you achieve stable timings, it would be a good feature for a next version of lcdsmatrie, i think

caesar
Forum Supporter
Posts: 734
Joined: October 15th, 2005, 10:39 am
Location: Romania
Contact:

Post by caesar »

How did you do it without hanging the display dll?

Of course it is possible but how to bitbang the pin and also release control?
BTW, that pin is used for E2 on 4x40 displays.

lucas_siglo21
Posts: 71
Joined: November 18th, 2007, 6:11 pm
Location: Bariloche, Argentina
Contact:

Post by lucas_siglo21 »

i didn't do it with lcdsmartie, i wrote a program to test the concept

i think it is not possible to do if you don't touch the code of the program, maybe with the display dll but i'm not sure

caesar
Forum Supporter
Posts: 734
Joined: October 15th, 2005, 10:39 am
Location: Romania
Contact:

Post by caesar »

It should be possible to implement in the dll, if there is some special need, I can try to put it in the new Smartie release.

What compiler do you use? So we can see what is to be done.

lucas_siglo21
Posts: 71
Joined: November 18th, 2007, 6:11 pm
Location: Bariloche, Argentina
Contact:

Post by lucas_siglo21 »

compiler?, what do you mean?, i use visual basic .net 2008 and its compiler

caesar
Forum Supporter
Posts: 734
Joined: October 15th, 2005, 10:39 am
Location: Romania
Contact:

Post by caesar »

the display dll's are written in delphi, but can be done in vb too.

I mean that now the display dll is just a interface to the hardware, it just sends data and immediately releases control.

I don't think that PWM can be used with the current method, and it's a pretty good method to just change it to allow parallel port backlight pwm.

It's easier and looks a lot better to make a PIC or Atmel backpack!

lucas_siglo21
Posts: 71
Joined: November 18th, 2007, 6:11 pm
Location: Bariloche, Argentina
Contact:

Post by lucas_siglo21 »

yes, of course you can make a backpack, but with this method the hardware remains simple and you only need to update the software to have the new feature. anyway, is it possible to implement in a new version of lcdsmartie?.

caesar
Forum Supporter
Posts: 734
Joined: October 15th, 2005, 10:39 am
Location: Romania
Contact:

Post by caesar »

As I see it now:
- it's either removing the display driver feature - won't happen
- or finding a way to keep control over the display when smartie doesn't send data to the display driver - but how?

A complicated idea: a smartie display plugin that relays data to a small executable that manages the display directly... but be prepared for high CPU usage just for the PWM setting!

Try doing a small executable that outputs PWM to the parallel port and see for yourself. Make sure to code the ability to set PWM in 256 steps.

lucas_siglo21
Posts: 71
Joined: November 18th, 2007, 6:11 pm
Location: Bariloche, Argentina
Contact:

Post by lucas_siglo21 »

well, i tried to control it while lcdsmartie were enabled, it works, but it is a bit unstable, when smartie gets the control of the backlight, it goes to the smartie's state and the rest of the time my program sets the brightness pretty well, but the pwm via software is a bit unstable, timing depends of a lot of things and the program colapses while it is executing the doevents instruction(it tells to the operative system that must pay attention to the rest of the programs, if i don't use it the program just freezes the pc)

here is my code:

Code: Select all

    Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
    Private Sub TrackBar1_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TrackBar1.Scroll
        Do
            Application.DoEvents()
            OUT(&H248A, 3)
            Sleep(TrackBar1.Value / 20)
            OUT(&H248A, 11)
            Sleep((255 - TrackBar1.Value) / 20)
        Loop
    End Sub
of course it uses a lot of resources and is not very necessary(you can do it with a potentiometer, i am complicating something easy), i think i will not continue with this, at least via software

Post Reply