Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The function device.backlight(False) turns on the lights, instead of device.backlight(True) #153

Open
Kyuchumimo opened this issue Nov 26, 2021 · 7 comments · May be fixed by #154
Open
Labels

Comments

@Kyuchumimo
Copy link

Type of Raspberry Pi

Raspberry Pi Zero W V1.1

Linux Kernel version

Linux raspberrypi 5.10.63+ #1459 Wed Oct 6 16:40:27 BST 2021 armv6l GNU/Linux

Expected behaviour

Hardware: Nokia 5510

Pin  -  RPi GPIO (GPIO BOARD)
RST  -          18
CE   -          24
DC   -          16
DIN  -          19
CLK  -          23
VCC  -          01
BL   -          12
GND  -          06
from luma.core.interface.serial import spi
from luma.core.render import canvas
from luma.lcd.device import pcd8544
import RPi.GPIO as GPIO

serial = spi(port=0, device=0, gpio_DC=23, gpio_RST=24, gpio_LIGHT=18)
device = pcd8544(serial)

device.backlight(True)

try:
    while True:
        print(GPIO.input(18))
        
        with canvas(device) as draw:
            draw.text((0,0), "Hello World",fill=255)
except KeyboardInterrupt:
    GPIO.cleanup()

I was waiting for GPIO.input(18) to return 1 and the lights would turn on

Actual behaviour

GPIO.input(18) returns 0 and the lights do not turn on, but when changing the device.backlight(True) function to device.backlight(False) the lights turn on and GPIO.input(18) returns 1

@thijstriemstra
Copy link
Collaborator

same happening with hd44780.

@Kyuchumimo
Copy link
Author

Kyuchumimo commented Nov 27, 2021

Using active_low=False as a parameter for the device object, makes the device.backlight(True) function turn the lights on and GPIO.input(18) returns 1. By default active_low parameter is always in boolean condition as True as long as it is not provided by the programmer.

device = pcd8544(serial, active_low=False)

device.backlight(True)

active low in electronics means a pin plugged to ground for enable a function (In this case, the backlight), and an active high is a pin plugged to 5V or 3.3V for enable a function (In this case, the backlight).
In this case, the backlight pin is an active high, since to turn on, a voltage needs to be supplied

From what I see this is normal. I suppose that for all LCD screens the backlight pin will not always be active low, as is the case with pcd8544 and hd44780 (without i2c backpack)

Please confirm if this is the case.

@thijstriemstra
Copy link
Collaborator

thijstriemstra commented Nov 27, 2021

Please confirm if this is the case.

Not sure what you want me to confirm, but my hd44780 is connected to gpio pin 27, causing the backlight to be enabled all the time unless I call backlight(True).

self.display = hd44780(self.interface, width=20, height=4, gpio_LIGHT=27)

@Kyuchumimo
Copy link
Author

Kyuchumimo commented Nov 27, 2021

@thijstriemstra
This is not how the backlight function works, backlight(True) should turn on the LED, not turn it off

see: https://luma-lcd.readthedocs.io/en/latest/python-usage.html#backlight-control
"The backlight can be programmatically switched on and off by calling device.backlight(True) or device.backlight(False) respectively."

@thijstriemstra
Copy link
Collaborator

backlight(True) disables the backlight, which is incorrect imo, sorry if I wasn't clear. I would expect it the other way around like the docs state.

@Kyuchumimo
Copy link
Author

Kyuchumimo commented Nov 27, 2021

@thijstriemstra Wait, this is not a bug, it is something expected. Haven't you read what I said?. The only thing I think is that active_low should be False by default by the luma.lcd library, since the backlight pin, which is almost always a positive pin leading to an LED must be active high for it to turn on

https://www.petervis.com/dictionary-of-digital-terms/what-does-active-low-mean/what-does-active-low-mean.html

@Kyuchumimo
Copy link
Author

Tested on ST7735 with same behavior: device.backlight(False) makes turn on backlight LED

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
2 participants