adafruit / Adafruit_CircuitPython_CharLCD

Library code for character LCD interfacing
MIT License
69 stars 50 forks source link

Add support for LCD Keypad Kits #24

Closed caternuson closed 5 years ago

caternuson commented 5 years ago

Add support for these products: https://www.adafruit.com/category/808

The old lib had this: https://github.com/adafruit/Adafruit_Python_CharLCD/blob/master/Adafruit_CharLCD/Adafruit_CharLCD.py#L430

ladyada commented 5 years ago

oh yahh! @kattni i forgot about the buttons - wanna do this up? can return the digitalIO pins upon request

ladyada commented 5 years ago

i think we can pre-define the digitalIO's in the RGB I2C LCD object, and set them to input_pullup's, then you can acces them from like lcd.up_button.value or whatnot

abdullahsurati commented 5 years ago

sgondor from the forums made some code that worked for him. It is given below:

import adafruitmcp230xx as mcp import digitalio

Create the push buttons

up = mcp.get_pin(3) down = mcp.get_pin(2) left = mcp.get_pin(4) right = mcp.get_pin(1) select = mcp.get_pin(0)

Define buttons as inputs

up.direction = digitalio.Direction.INPUT down.direction = digitalio.Direction.INPUT left.direction = digitalio.Direction.INPUT right.direction = digitalio.Direction.INPUT select.direction = digitalio.Direction.INPUT

Create pull-ups for each button

up.pull = digitalio.Pull.UP down.pull = digitalio.Pull.UP left.pull = digitalio.Pull.UP right.pull = digitalio.Pull.UP select.pull = digitalio.Pull.UP

And then to read the status of a button just use:

up.value down.value left.value right.value select.value

@ladyada @kattni Check this out

ladyada commented 5 years ago

yep that will work just fine, we'd like to have that all done for you in the library - we'll get to it shortly, lots of people traveling this week :)

pavelruzicka commented 5 years ago

Hi, is there any update on this? I've been waiting to get my shield buttons working.

ladyada commented 5 years ago

oh yeah, this slipped over the holidays - @kattni wanna do this now?

kattni commented 5 years ago

Sure thing! I'll get started on it.

kattni commented 5 years ago

This is now included!