Adaptive background lighting Ambient light

ambilight

Adaptive background lighting Ambient light, without exaggeration, an amazing technology. With its adaptive illumination, eyes become less tired when you watch TV in the dark. Also the presence effect enhances, the image viewing area extends, etc. Ambient light is applicable not only to video and photo content, but also to games. The implementation of such a feature on the Android TV set-top box or Android TV based on Android OS above 5.1 (Lollipop) is now possible using the Ambient light Application for Android program. Here is a guide how to setup your own Ambient light hardware and software with acceptable cost.

About Software



Ambient light Application for Android is one of the few programs for Android based devices that allows you to implement Ambient light backlighting directly on your smart TV with no need of PC. There are three operating modes, that are:

Screenshot_1527689167

!!! It is important to know !!!
The analog TV signal is not processed by the Android OS level, so the backlight application will not work with regular TV channels. The backlight works only with Android OS applications that do not use protected content. 4K performance depends only on your hardware.
Unfortunately, programs such as YouTube and Netflix use protected content (DRM), Ambient light application has no ability to work with them. In order to make it work you should use the special client. For example SmartYoutube.

SINGLE COLOR MODE – his mode allows you to include all the backlighting with one color selected in the program settings. This mode suits well as a night room lighting, surprisingly changing the familiar interior.

COLOR EFFECT MODE – This is the mode for displaying color effects. Dynamic backlighting can change colors, depending on which preset effect you have selected in the settings.

SCREEN CAPTURE MODE – This is probably the most in-demand mode of the backlight, which allows you to change its colors depending on what content is currently displayed on the screen.

The program interface is presented on four screens, the first one you could already see above, with it we can control the main functions of the application and go to the settings screens.

The following picture shows the screen for setting the main parameters. You may choose the number of LEDs horizontally and vertically, define speed of the serial port connection, set the direction of the LED ribbon installation, set the order of color output, the depth of image capture and some other parameters that are described in the Setup section.

Screenshot_1527689091

This image shows the screen for setting the color gamut, adjusting the brightness, saturation and selecting color effects.

Screenshot_1527580065

The output screen is for auxiliary information – instructions for assembling and setting up the hardware, instructions for configuring the program Ambient light Application for Android.

Screenshot_1526590961

Hardware Setup



Hardware

For implementation, you will need four main components:

1. Controllable LED RGB strip,
2. Power supply,
3. Arduino Nano microcontroller PCB,
4. Ambient light Application for Android.

First a little theory.

WS2811 is a three-channel controller / driver (chip) for RGB LEDs with one-wire control (addressing to an arbitary LED). The WS2812B is an RGB LED in the SMD 5050 case with WS2811 controller already integrated.

Suitable for the project LED strip here and later we’ll call WS2811 or WS2812B.

WS2812B strip is a LED strip on which the LEDs WS2812B are sequentially placed. The LED strip works with a voltage of 5 V. There are several types of LED stripes with different amount of LEDs per meter. Usually there are 144, 90, 74, 60, 30 per one meter. Also there are different levels of protection. Most common cases are IP20-30 (protection from solid particles), IP65 (protection against dust and water vapor), IP67 (dust protection and protection for partial or short-time immersion in water to a depth of 1 m). The substrate is black and white.

Here is an example of this LED strip:

ws2812b

WS2811 strip is a LED strip on which the WS2811 controller and some kind of RGB LED are sequentially located. They can be designed for both 5 V and 12 V. Density and protection levels are the same.

Here is an example of such a LED strip:

ws2811

Which LED strip should I choose, WS2812B or WS2811?

An important moment is the power of the LED strip, which I’ll talk a little later.

If you have a suitable power supply then choose a LED strip based on the power supply voltage, i.e. 5V – WS2812B, 12V – WS2811. In this case it will simply save money.

An advice: If the total number of LEDs in the system is not greater than 120, then choose WS2812B. If more than 120, then your choice should be WS2811 with a working voltage of 12 V. It will be explained later when it comes to connecting the LED strip to the power supply.

What level of LED strip protection should I choose?

The most suitable is IP65, as on one side it is covered with “silicone” (epoxy), and on the other there is a self-adhesive surface. This LED strip is conveniently mounted on a TV or monitor and dust can be easily wiped of it.

What density of light-emitting diodes to choose?

For the project, LED stripes with a density of 30 to 60 LEDs per meter (of course, you can use also 144). The higher the density, the greater the Ambient light resolution (the number of zones) and the greater the maximum l brightness will be. But notice that the more LEDs are in the project, the more complicated the power scheme will be, and more powerful supply should be needed. The maximum number of LEDs in the project is 300.

Which power supply to choose for a LED strip?

The power supply is selected for power and voltage. For WS2812B – voltage 5 V. For WS2811 – 5 or 12 V. The maximum power consumption of one WS2812B LED is 0.3 Watts. For WS2811 in most cases the same. Then, the power supply should not be less than N * 0.3 W, where N is the number of LEDs in the project.

For example, you have a TV 42 “and you’ve chosen the WS2812B LED strip with 30 LEDs per meter, you need 3 meters of LED strip (all 4 sides of the screen) .You need a power supply with a voltage of 5 V and a maximum power of 5 V / 6 A. If there are less diodes on the lower horizontal of the screen than on the top, it is only about 60 LEDs ,then the power source should be at least 5 V / 4 A.

Example of a power supply for a LED strip:

power supply

Which microcontroller to choose?

Ambient light hardware is an Arduino microcomputer. Arduino Nano on Aliexpress costs about $ 2.5 apiece.

Example of such microcontroller:

arduino

Project costs for a conventional 42 “TV:

12 $ – 3 meters WS2812B (30 LEDs per meter)
4 $ – power supply 5 V / 4 A
$ 2.5 – Arduino Nano
$ 3 – Ambient light Application for Android program


Total:  ~ $ 21.5


Arduino Nano:

AliExpress
Banggood
Amazon US
Amazon UK
Amazon DE

WS2812B RGB LED lights:

AliExpress
Banggood
Amazon US
Amazon UK
Amazon DE


Hardware implementation

The most important thing is to properly organize the feeding of the LED strip. According to the LED strip is long, the voltage drops with a large current consumption, especially when using 5 V tape. Most problems that face those who set up Ambient light by themselves occure due to improper LED’s feeding. There is a general rule – you need the separate power supply for every 10 W of maximum power consumed at 5 V and 25 W of power consumption at 12 V. The length of the wiring (from the power supply to the LED strip itself) should be minimal (without reserve), especially at 5 AT.

The general connection scheme is as follows (Arduino is powered from USB, and the LED strip from the PSU):

connection scheme

We make two parallel connections to the both ends of the LED strip. For example, if we install the backlight on all 4 sides, and the LED strip would have 60 LEDs per meter (that is, the maximum power 54W), then our power scheme should be like this:

power connection

There are two contacts to Arduino PCB from the LED strip. 1 – GND, which must be connected to the corresponding contact on Arduino. And 2 – DATA, which must be connected to the sixth digital contact on Arduino through a 470 Ohm resistor. If you do not have a resistor, in most cases everything will work fine, but it is better to get one. The resistor can be bought for a couple of cents in any radio store. The Arduino microcomputer itself can be placed in any convenient box, I used for this purpose a container from “Kinder Surprise”. Arduino PCB should be placed as close as possible to the LED strip, so that the connection from DATA to Arduino was of minimum length.

Soldering the wires to the LED strip is easy. The main rule – the time of contact with the soldering iron should be minimal!

How to bend the tape at right angles?

There are two options. 1 – the LED strip should be cut and connected with short wires (placing it all in a shrink tube). 2 – You can buy special angled connectors for three contacts for LED stripes:

angled connectors

The software part

This is the simplest way.

Download and install Arduino IDE. We load the last available version of the FastLED library, unpack it and put the FastLED folder from the archive into the folder with the Arduino IDE libraries (C:\Program Files (x86)\Arduino\libraries). Start Arduino IDE and close it. The folder Arduino will be created in the Documents folder. There we create a folder AAA and copy there sketch – AAA.ino.

Connect the Arduino microcomputer to USB. The driver (serial interface CH340) will be installed automatically. If this does not happen, then in the folder Arduino IDE there is a folder Drivers with everything you need.

Run Arduino IDE and open the file AAA.ino.

aaa-1en

We change (if necessary) the data transfer rate:

aaa-2en

We change the number of LEDs. The number should be equal to the number of LEDs in your LED strip:

aaa-4en

Tools> Board> Arduino nano
Tools> Port> Select the COM port (there will be the desired option). For the Chinese clone of Arduino use the old bootloader.

Press the button “Upload”:

aaa-3en

The program will inform you when the download is complete (this is literally a couple of seconds).

Done. It is necessary to disconnect Arduino from USB and reconnect. The LED strip will turn on in succession in red, green and blue – Arduino is activated and ready to go.

Now you can connect the Arduino to the TV-box and start setting up the program.



Программная часть для контроллеров ESP8266 WeMos D1R2 или NodeMCU V1.0. Подключение по WiFi.

 
WeMos D1R2

WeMos D1R2 (ESP-8266) – Binary firmware for WS2812/WS2813/WS2815 stripes:
LEDStripWiFi_AAA.ino.d1_mini_WS2812.bin

LED strip type NeoPixels (APA106, WS2811, WS2812, WS2813, WS2815 & SK6812, SK6813, SK6815)

Connection:


WeMos D1R2 (ESP-8266) – Binary firmware for APA102 (DotStar) stripes:
LEDStripWiFi_AAA.ino.d1_mini_APA102.bin

LED strip type DotStars (APA102, LPD8806, SK9822, WS2801, P9813)

Connection:



NodeMCU V1.0

NodeMCU V1.0 (ESP-12E) – Binary firmware for WS2812/WS2813/WS2815 stripes:
LEDStripWiFi_AAA.ino.nodemcu_WS2812.bin

ED strip type NeoPixels (APA106, WS2811, WS2812, WS2813, WS2815 & SK6812, SK6813, SK6815)

Connection:


NodeMCU V1.0 (ESP-12E) – Binary firmware for APA102 (DotStar) stripes:
LEDStripWiFi_AAA.ino.nodemcu_APA102.bin

LED strip type DotStars (APA102, LPD8806, SK9822, WS2801, P9813)

Connection:


To download firmware to the controller, you can use a utility for example:
Flash Download Tool

How does the firmware work

You do not need to specify the number of LEDs in the firmware, it is determined automatically.
The maximum possible number of LEDs in the firmware is 1500.

There are 3 main display colors in the firmware
1 – Blue, 2 – Red, 3 – Green.

Determination of the firmware status according to the color of the indication:

Blue – Start of work (initialization), at this moment the connection reset buttons to reset the saved Wi-Fi parameters, which the firmware will inform about with triple blinking of blue color.

Red – Start the process of initializing WiFi and connecting to the WiFi network. If the WiFi connection parameters were saved and the connection failed, we will see a green indication. If the WiFi connection parameters have not been previously saved, the indication will remain red.

Green – WiFi connection successful, system is waiting for Ambient light Application for Android

I would like to draw your attention to the fact that to transfer data from the program, the controller uses the UDP protocol, which allows us to provide the speed of streaming data, but does not provide any means of guaranteeing the delivery of the message, pay attention to the quality of the Wi-Fi signal coverage, which will be the controller’s connection with WiFi, the more data loss will be.

Connecting the controller to WiFi

To connect to a WiFi network you need:

1. Connect the LED strip to the controller
2. Connect power to the controller
3. Wait until the LED strip turns red
4. On any WiFi device (phone/tablet/PC), search for available WiFi networks
5. Connect to a network with a type name – AAA_b3da7c (default password – password), where b3da7c is the last 3 segments of the MAC address of your controller.
6. If the connection was successful, a browser with the WiFi controller settings page should open, if the browser did not open, go to the link http://192.168.4.1 manually:

7. Select the desired connection type (Static IP / DHCP), when connecting with DHCP, the IP address will be assigned automatically and you can find out which address is assigned only on the router. Consider the option with the assignment of a static address:

8. In the list of networks, select our home network and enter the password to connect to it, also enter the IP address, Gateway and Network Mask:

9. This completes the setup of the WiFi connection, the LED strip should turn green and go out:

10. Your device (phone/tablet/PC) should reconnect to your home network, and the controller will go into standby mode for connecting to the program.

Reset and reset WiFi settings

A single click on the reset button of the controller will reboot it, the settings for connecting to the WiFi network will be saved.
Pressing reset again while the LED strip is blue will reset the WiFi connection and reboot the controller.

Software Setup



The program settings are represented by two screens of settings: the BASE SETTINGS screen (LED Stripe settings) and the COLOR CORRECTION SETTINGS screen (Color settings). On each screen, the settings are divided into tabs — switching is done with the buttons at the top of the screen. Below is a list of settings for each of the screens:

Base application settings

To go to the base settings screen, press the settings button in the bottom panel of the main screen of the program (the sliders icon), as shown in the picture below:

Main screen - settings button

Next, the base settings window opens:

On this screen there are three sections of settings: LED STRIP, DEVICE and SCREEN CAPTURE, consider these sections in detail:

Base settings screen - tabs LED STRIP, DEVICE, SCREEN CAPTURE

LED STRIP – This section contains settings describing the configuration and placement of your LED strip on a TV or monitor. This section has several settings, let’s consider them in more detail:

LED STRIP tab

LEDs Horizontal – This setting specifies the number of LEDs in our LED strip horizontally, in my case, for the 42″ screen, 35 LEDs:

LEDs Horizontal

LEDs Vertical – This setting sets the number of LEDs vertically, in my case, for the 42″ screen, 19 LEDs:

LEDs Vertical

LED Strip Direction – This setting determines the direction of your LED strip and must correspond to the marking applied to the LED strip itself, can take the values “CW” (Clockwise) and “CCW” (Counterclockwise).

LED Strip Direction

LED Count – Reference information: the total number of strip LEDs the program uses to build the frame. It is calculated automatically as the sum of all four sides: 2 × (LEDs Horizontal + LEDs Vertical).

LED Count

LEDs Bottom Gap – If your screen is on a stand, you may need a gap in which there are no LEDs in the bottom horizontal segment of the LED strip, this setting allows you to set this gap (measured in the number of LEDs). LEDs inside the gap stay off, while the frame length remains full, so no desynchronization with the controller firmware occurs.

LEDs Bottom Gap gap scheme on the strip
LEDs Bottom Gap 1
LEDs Bottom Gap 2

First LED Offset – This setting is responsible for shifting the location of the first LED in the LED strip relative to the upper-left corner of the screen (viewed from the front). This setting shows where our LED strip starts, where we will connect our microcontroller and where the signal will go along the chain in the direction indicated in the “LED Strip Direction” setting.

First LED Offset

 

back to top


DEVICE – This section contains the basic settings of the program: the connection speed with the microcontroller, the color output order, the frame rate, autostart at system startup and the behavior of the program when the screen is turned off:

DEVICE tab

Consider these settings in more detail:

Serial Baud Rate – This setting allows you to choose the data transfer speed between your Android device and the microcontroller over USB. It is important to understand that the same data transfer speed should be selected in the controller firmware settings. For an ESP8266 controller connected over Wi-Fi (UDP), this setting is not used — data is delivered over the network regardless of the serial port speed.

Serial Baud Rate
Serial Baud Rate

RGB Byte Order – The setting determines in what order to send color data to the microcontroller, RGB, RBG, GBR, GRB, etc. If you use a controller with the firmware from the Hardware Setup description, this parameter should not be changed, by default RGB:

RGB Byte Order

Frame Rate – This setting sets the backlight frame rate: 30, 45, 60 or 120 FPS. The higher the rate, the smoother and faster the backlight reacts to the image, but the higher the load on the device:

Frame Rate

Start On Boot – Setting allows you to enable/disable autorun program at system startup and start it in the last active mode:

Start On Boot

Screen Off Action – The setting allows you to select the behavior of the backlight when the display is turned off:

  • “NO ACTION” – do nothing (the backlight keeps working);
  • “STOP ALL” – stop all active modes;
  • “SINGLE COLOR” – switch to the single color mode;
  • “COLOR EFFECT” – switch to the color effect mode.

When the display is turned on again, the program will return to the last active mode of operation that was before the display was turned off:

Screen Off Action

 

back to top


SCREEN CAPTURE – In this section there are settings intended for controlling the operation mode of the “SCREEN CAPTURE”:

SCREEN CAPTURE tab

Consider these settings in more detail:

Horizontal Depth – The setting specifies the depth of the image capture area horizontally. The depth of the capture zone is measured as a percentage of the screen size in height. The yellow dotted line in the picture shows the current depth of the capture zone:

Horizontal Depth
Horizontal capture zone scheme

Vertical Depth – The setting specifies the depth of the image capture area vertically. The depth of the capture zone is measured as a percentage of the screen size in width. The green dashed line in the picture shows the current depth of the capture zone:

Vertical Depth
Vertical capture zone scheme

Horizontal Frame Offset – This setting shifts the starting scan position along the horizontal sides of the strip (top/bottom) within ±5 LEDs. The shift is non-cyclic: LEDs whose image zone would go beyond the edge repeat the color of the edge segment, so the picture does not “wrap around” the edge:

Horizontal Frame Offset

Vertical Frame Offset – This setting shifts the starting scan position along the vertical sides of the strip (right/left) within ±5 LEDs. It works the same way as the horizontal offset: no wrap-around, edges are filled with the edge segment color:

Vertical Frame Offset

Capture Quality – The setting specifies the quality level of the captured image (Lowest/Low/Normal/High/Highest). The higher the quality, the more accurate and detailed the backlight will match the image on the screen. High values of this setting can reduce performance on weak systems:

Capture Quality

 

back to top


Color correction

To go to the color correction settings screen, press the palette button in the bottom panel of the main screen of the program, as shown in the picture below:

Main screen - color settings button

Next, the color correction settings window opens:

This screen shows three sections of settings: CORRECTION, EFFECTS and ADVANCED, consider these sections in detail:

Color correction settings screen - tabs CORRECTION, EFFECTS, ADVANCED

CORRECTION – This tab contains the image color correction settings:

CORRECTION tab

Red/Green/Blue Color Balance – Balance adjustments for each of the three primary colors in the RGB palette. They let you even out the color temperature of the backlight if the strip has a tint in one of the channels:

Color Balance

Red/Green/Blue Color Gamma – Gamma correction settings for each of the three primary colors in the RGB palette. They affect how the backlight brightness depends on the image brightness:

Color Gamma

Color Saturation – Adjust the color saturation of the backlight. Adjusting allows you to increase/decrease the backlight saturation level:

Color Saturation

Color Brightness – Adjust the brightness of the backlight colors. Adjusting allows you to increase/decrease the brightness level of the backlight color:

Color Brightness

Shadow Depth – Sets the shadow depth (dark cutoff threshold). It defines the level below which dark image areas produce no light: the higher the value, the deeper and more contrasty dark scenes look:

Shadow Depth

 

back to top


EFFECTS – This tab contains the single color mode and color effects settings:

EFFECTS tab

Single Color – The setting is used to select the backlight color. The setting is for the “SINGLE COLOR” mode:

Single Color

Single Color Lightness – This setting adjusts the brightness (lightness) of the selected single color mode:

Single Color Lightness

Color Effect – The setting allows you to select the desired color effect of the backlight. The setting is for the “COLOR EFFECT” mode. Available effects: Rainbow swirl CW, Rainbow swirl CCW, RGB swirl CW, RGB swirl CCW, Running lights, Twinkle random, Slow colors, Fast colors, Shine (aurora):

Color Effect

 

back to top


ADVANCED – Additional image processing settings:

ADVANCED tab

Black Border Detection – Black border (“letterbox”) detector. It finds dark bars at the frame edges (e.g., in movies) and fills them with the color of adjacent image areas instead of cropping them. Sensitivity: Disabled or Black Level 3–15. The higher the level, the lighter bars are treated as a border:

Black Border Detection

Color Smoothing – Smoothness of color transitions. It slows down the changes between frames, removing harsh “steps” when the image changes. Levels: Disabled, Lowest, Low, Normal, High, Highest – the higher the level, the smoother and slower the transitions:

Color Smoothing

Color Test Image – A test image used to verify color reproduction of the backlight without an external video signal. It lets you make sure the strip and its layout are configured correctly:

Color Test Image

 

back to top


Controller connection – The program supports two ways of connecting the LED controller: USB (serial port) and Wi-Fi (ESP8266 / ESP32 UDP controller). When connected over Wi-Fi, the controller is discovered by the program automatically — the port speed are not used; if the connection is lost, the controller keeps showing the last received frame.

back to top


News