Seeed-Studio / Grove_LCD_RGB_Backlight

Seeedstudio, Grove - LCD RGB Backlight
MIT License
79 stars 90 forks source link

Please add API to turn the backlight off/on- save energy #14

Open sglebs opened 3 years ago

sglebs commented 3 years ago

Is it possible to add this API? Unfortunately setReg is private, but I think it would be something like:

void lcd_backlight_off() {
  lcd.setReg(0x07, 0x0);
  lcd.setReg(0x06, 0x0);
}

void lcd_backlight_on() {
  lcd.setReg(0x07, 0x0);
  lcd.setReg(0x06, 0xff); 
}
rgerhards commented 3 years ago

@sglebs I need this functionality as well, but can't get your code to work. I also do not find a reference on the registers and there control values -- do you have a link?

sglebs commented 3 years ago

Hi @rgerhards. I believe the implementation can be done inspired by this:

https://github.com/Seeed-Studio/Grove_LCD_RGB_Backlight/blob/master/rgb_lcd.cpp#L220

Register 06 seems to be the intensity. 0x0 probably means "all turned off". Try a fork, add the APIs to the .cpp and give that a try. Maybe it will work. I switched to an OLED display for my toy project.

rgerhards commented 3 years ago

Actually I added the code to my local version and it did not work at all. Thus I asked. It's always bad if you do not have a spec.

Anyways, thx for the answer and taken the time to look at this in the first place. Good luck with your project.

sglebs commented 3 years ago

Does the original API of blinking the background work at all? If it doesn't, then that would be the root cause. If it does work, try changing the 0x0 to 0x7F (like the original API) and decrease it (trial and error) to smaller values, to see if you can at least get it to work wasting as little energy as possible. Something as close to 0x0 ideally. Just an idea.