adafruit / Adafruit_CircuitPython_CharLCD

Library code for character LCD interfacing
MIT License
70 stars 49 forks source link

Added sainsmart lcd with led #35

Closed wiryonolau closed 5 years ago

wiryonolau commented 5 years ago

Added sainsmart lcd with led

ladyada commented 5 years ago

awesome, thank you for the contribution - can you update the documentation and some spacing stuff so that pylint is happy?

see: https://travis-ci.com/adafruit/Adafruit_CircuitPython_CharLCD/builds/106145058#L605

you can use our files as examples https://github.com/adafruit/Adafruit_CircuitPython_CharLCD/blob/master/adafruit_character_lcd/character_lcd_rgb_i2c.py

wiryonolau commented 5 years ago

Oh.. I see it's because of the space. Ok will do.

wiryonolau commented 5 years ago

Hi I kept getting this error on Ci Test

Warning, treated as error: ../README.rst:119:undefined label: bundle_installation (if the link has no caption the label must precede a section header) The command "cd docs && sphinx-build -E -W -b html . _build/html && cd .." exited with 2.

can you help me, I never use sphinx

caternuson commented 5 years ago

@ladyada Should this somehow live in the community bundle side of things?

ladyada commented 5 years ago

@caternuson it could but i dont think that's likely to happen :/

caternuson commented 5 years ago

@wiryonolau You didn't do anything to this file, but the README.rst looks older style. I'd say just go ahead and delete that entire "Installation" section that's between "Contributing" and "Building Locally". It's not even in the current boiler plate: https://github.com/adafruit/cookiecutter-adafruit-circuitpython/blob/master/%7B%7B%20cookiecutter.library_name%20%7D%7D/README.rst Hopefully that'll at least get travis to pass.

ladyada commented 5 years ago

@wiryonolau this looks like its just a direct clone of our i2c shield, so why dont you use https://github.com/adafruit/Adafruit_CircuitPython_CharLCD/blob/master/adafruit_character_lcd/character_lcd_rgb_i2c.py ?

wiryonolau commented 5 years ago

Sorry I thought changing the iodira after Character_LCD init() will not work. After retesting it work ok.

import adafruit_character_lcd.character_lcd_rgb_i2c as character_lcd
from adafruit_character_lcd.character_lcd import _set_bit as set_bit
import time
import board
import busio

i2c = busio.I2C(board.SCL, board.SDA)
lcd_columns = 16
lcd_rows = 2
lcd = character_lcd.Character_LCD_RGB_I2C(i2c, lcd_columns, lcd_rows)

# This is the only difference when using sainsmart. It has mono lcd with rgb led on top of the lcd.
lcd._mcp.iodira = set_bit(lcd._mcp.iodira, 5, 0)

lcd.clear()

# Turn on backlight LCD, LED become purple so have to clear it
lcd._mcp.gpioa = set_bit(lcd._mcp.gpioa, 5, 0)
lcd.color = [0,0,0]

# Other function work normally as rgb_i2c example

# Turn off backlight LCD, LED color is not affected so require to clear it manually
lcd._mcp.gpioa = set_bit(lcd._mcp.gpioa, 5, 1)
lcd.color = [0,0,0]

Maybe changing _set_bit to public set_bit and _mcp to mcp will be cleanner. Since I require to access it multiple time :D

wiryonolau commented 5 years ago

I will withdraw the pull request then