C1 Android - Backlight PWM

Moderators: odroid, mdrjr

C1 Android - Backlight PWM

Unread postby asg8198 » Mon Oct 19, 2015 4:59 am

Hello All,

Still very new to Android under the hood.

I'm looking to enable PWM support for a backlight controller linked to the brightness slider in android. I believe I've enabled some kernel support for it but am not sure how to hook Android into the loop. Any resources would be greatly appreciated.

Goal:
PWM signal out on a GPIO pin that corresponds with the brightness slider in android.

Secondary Goal:
Add in light sensor for auto-dimming.

Thanks!
asg8198
 
Posts: 5
Joined: Mon Aug 03, 2015 3:39 am
languages_spoken: english
ODROIDs: C1

Re: C1 Android - Backlight PWM

Unread postby asg8198 » Wed Nov 11, 2015 3:40 am

Any Suggestions?
asg8198
 
Posts: 5
Joined: Mon Aug 03, 2015 3:39 am
languages_spoken: english
ODROIDs: C1

Re: C1 Android - Backlight PWM

Unread postby Beezer » Wed Nov 11, 2015 4:51 am

I'd too be interested in this too. If I can't get the C1 to do it, I'll be creating a standalone board with a light sensor & PWM just to auto-control the backlight. I've got a spare PIC and even an Electric Imp that can do this quite well.
Beezer
 
Posts: 4
Joined: Sat Oct 03, 2015 7:53 pm
languages_spoken: english
ODROIDs: C1+

Re: C1 Android - Backlight PWM

Unread postby tobetter » Wed Nov 11, 2015 10:38 am

asg8198 wrote:Any Suggestions?

I've not tested this on C1 yet/ It would be possible to port below source code and make install lights.so into system/lib/hw/. If you can debug the library, you would be able to receive the brightness value from framework and based on that you can set the value to the device node where PWM works.
tobetter
 
Posts: 2159
Joined: Mon Feb 25, 2013 10:55 am
Location: Kitchener, ON, Canada
languages_spoken: Korean, English
ODROIDs: X, X2, U2, U3, XU3, C1

Re: C1 Android - Backlight PWM

Unread postby asg8198 » Thu May 25, 2017 4:54 am

@ tobetter
This project got put aside some time ago and I'm just picking it back up - albeit on the C2. Any new thoughts here in 2017?
asg8198
 
Posts: 5
Joined: Mon Aug 03, 2015 3:39 am
languages_spoken: english
ODROIDs: C1

Re: C1 Android - Backlight PWM

Unread postby odroid » Thu May 25, 2017 8:27 am

The PWM brightness control was enabled in Android image since we launched the ODROID-VU8C in late last year.
You have to configure some files. Refer this WiKi page.
http://odroid.com/dokuwiki/doku.php?id=en:vu8c_backlightcontrol
User avatar
odroid
Site Admin
 
Posts: 27660
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID

Re: C1 Android - Backlight PWM

Unread postby joerg » Fri May 26, 2017 3:29 pm

Thank you guys, specially to tobetter, you have pointed me to the right direction. I was also interested in having the VU7+ to be dimmed and now I managed to have a lights.odroidc.so that does pwm on pin 33. Once I am ready with the circuit I will publish all together. For the circuit I am waiting some low saturation pnp transistors. I have a sample with normal transistor working, but looses voltage and becomes hot, the collector of the pnp is connected to the middle pin of the backlight switch of the VU7+. It can be dimmed by the Android slider and if daydream is switched off, the backlight is also off after time.
joerg
 
Posts: 791
Joined: Tue Apr 01, 2014 2:14 am
Location: Germany
languages_spoken: german, english, español
ODROIDs: C1, C1+, C2

Re: C1 Android - Backlight PWM

Unread postby tobetter » Fri May 26, 2017 3:58 pm

joerg wrote:Thank you guys, specially to tobetter, you have pointed me to the right direction. I was also interested in having the VU7+ to be dimmed and now I managed to have a lights.odroidc.so that does pwm on pin 33. Once I am ready with the circuit I will publish all together. For the circuit I am waiting some low saturation pnp transistors. I have a sample with normal transistor working, but looses voltage and becomes hot, the collector of the pnp is connected to the middle pin of the backlight switch of the VU7+. It can be dimmed by the Android slider and if daydream is switched off, the backlight is also off after time.

Hey, I am so eager to see how it works, it would be very nice. I expect you to share the code so that can be merged into Android branch. Also, thank you for mentioning my nick. ;)
tobetter
 
Posts: 2159
Joined: Mon Feb 25, 2013 10:55 am
Location: Kitchener, ON, Canada
languages_spoken: Korean, English
ODROIDs: X, X2, U2, U3, XU3, C1

Re: C1 Android - Backlight PWM

Unread postby joerg » Fri May 26, 2017 5:12 pm

For the impatient ;) here is the lib:
liblights.odroidc.so.zip
(7.12 KiB) Downloaded 29 times


Install:
Code: Select all
adb remount
adb push ../libs/armeabi/liblights.odroidc.so /system/lib/hw/lights.odroidc.so
adb reboot


It makes use of the kernel modules pwm-meson and pwm-ctrl. So you won't be able to use them for other than backlight. It loads the kernel modules automatically. Pin 33 changes pwm duty with slider.

[edit]
This is not the final version. I think about to invert the duty, so zero means full light. It's because the pin 33 is zero from booting and there should be a boot animation visible until the driver is loaded.

[edit]
I decided to stay with this. Means that 100% duty is full light. It was a missing pull up resistor in my amplifier circuit.

To log:
Code: Select all
adb shell logcat|grep lights

D/lights.odroidc(  416): level: 983
D/lights.odroidc(  416): level: 995
D/lights.odroidc(  416): level: 1011
D/lights.odroidc(  416): level: 1023
joerg
 
Posts: 791
Joined: Tue Apr 01, 2014 2:14 am
Location: Germany
languages_spoken: german, english, español
ODROIDs: C1, C1+, C2


Return to Android

Who is online

Users browsing this forum: No registered users and 3 guests