|
34 | 34 |
|
35 | 35 | "* `RGB LCD Shield Kit w/ 16x2 Character Display - Negative Display
|
36 | 36 | <https://www.adafruit.com/product/714>`_"
|
| 37 | +
|
37 | 38 | "* `RGB LCD Shield Kit w/ 16x2 Character Display - Positive Display
|
38 | 39 | <https://www.adafruit.com/product/716>`_"
|
| 40 | +
|
39 | 41 | "* `Adafruit RGB Negative 16x2 LCD+Keypad Kit for Raspberry Pi
|
40 | 42 | <https://www.adafruit.com/product/1110>`_"
|
| 43 | +
|
41 | 44 | "* `Adafruit RGB Positive 16x2 LCD+Keypad Kit for Raspberry Pi
|
42 | 45 | <https://www.adafruit.com/product/1109>`_"
|
43 | 46 |
|
|
50 | 53 |
|
51 | 54 | """
|
52 | 55 |
|
| 56 | +import digitalio |
53 | 57 | from adafruit_character_lcd.character_lcd import Character_LCD_RGB
|
54 | 58 |
|
55 | 59 | __version__ = "0.0.0-auto.0"
|
@@ -91,5 +95,127 @@ def __init__(self, i2c, columns, lines):
|
91 | 95 | red = self._mcp.get_pin(6)
|
92 | 96 | green = self._mcp.get_pin(7)
|
93 | 97 | blue = self._mcp.get_pin(8)
|
| 98 | + self._left_button = self._mcp.get_pin(4) |
| 99 | + self._up_button = self._mcp.get_pin(3) |
| 100 | + self._down_button = self._mcp.get_pin(2) |
| 101 | + self._right_button = self._mcp.get_pin(1) |
| 102 | + self._select_button = self._mcp.get_pin(0) |
| 103 | + |
| 104 | + self._buttons = [self._left_button, self._up_button, self._down_button, self._right_button, |
| 105 | + self._select_button] |
| 106 | + |
| 107 | + for pin in self._buttons: |
| 108 | + pin.switch_to_input(pull=digitalio.Pull.UP) |
| 109 | + |
94 | 110 | super().__init__(reset, enable, db4, db5, db6, db7, columns, lines, red, green, blue,
|
95 | 111 | read_write)
|
| 112 | + |
| 113 | + @property |
| 114 | + def left_button(self): |
| 115 | + """The left button on the RGB Character LCD I2C Shield or Pi plate. |
| 116 | +
|
| 117 | + The following example prints "Left!" to the LCD when the left button is pressed: |
| 118 | +
|
| 119 | + .. code-block:: python |
| 120 | +
|
| 121 | + import board |
| 122 | + import busio |
| 123 | + from adafruit_character_lcd.character_lcd_rgb_i2c import Character_LCD_RGB_I2C |
| 124 | +
|
| 125 | + i2c = busio.I2C(board.SCL, board.SDA) |
| 126 | + lcd = Character_LCD_RGB_I2C(i2c, 16, 2) |
| 127 | +
|
| 128 | + while True: |
| 129 | + if lcd.left_button: |
| 130 | + lcd.message = "Left!" |
| 131 | +
|
| 132 | + """ |
| 133 | + return not self._left_button.value |
| 134 | + |
| 135 | + @property |
| 136 | + def up_button(self): |
| 137 | + """The up button on the RGB Character LCD I2C Shield or Pi plate. |
| 138 | +
|
| 139 | + The following example prints "Up!" to the LCD when the up button is pressed: |
| 140 | +
|
| 141 | + .. code-block:: python |
| 142 | +
|
| 143 | + import board |
| 144 | + import busio |
| 145 | + from adafruit_character_lcd.character_lcd_rgb_i2c import Character_LCD_RGB_I2C |
| 146 | +
|
| 147 | + i2c = busio.I2C(board.SCL, board.SDA) |
| 148 | + lcd = Character_LCD_RGB_I2C(i2c, 16, 2) |
| 149 | +
|
| 150 | + while True: |
| 151 | + if lcd.up_button: |
| 152 | + lcd.message = "Up!" |
| 153 | +
|
| 154 | + """ |
| 155 | + return not self._up_button.value |
| 156 | + |
| 157 | + @property |
| 158 | + def down_button(self): |
| 159 | + """The down button on the RGB Character LCD I2C Shield or Pi plate. |
| 160 | +
|
| 161 | + The following example prints "Down!" to the LCD when the down button is pressed: |
| 162 | +
|
| 163 | + .. code-block:: python |
| 164 | +
|
| 165 | + import board |
| 166 | + import busio |
| 167 | + from adafruit_character_lcd.character_lcd_rgb_i2c import Character_LCD_RGB_I2C |
| 168 | +
|
| 169 | + i2c = busio.I2C(board.SCL, board.SDA) |
| 170 | + lcd = Character_LCD_RGB_I2C(i2c, 16, 2) |
| 171 | +
|
| 172 | + while True: |
| 173 | + if lcd.down_button: |
| 174 | + lcd.message = "Down!" |
| 175 | +
|
| 176 | + """ |
| 177 | + return not self._down_button.value |
| 178 | + |
| 179 | + @property |
| 180 | + def right_button(self): |
| 181 | + """The right button on the RGB Character LCD I2C Shield or Pi plate. |
| 182 | +
|
| 183 | + The following example prints "Right!" to the LCD when the right button is pressed: |
| 184 | +
|
| 185 | + .. code-block:: python |
| 186 | +
|
| 187 | + import board |
| 188 | + import busio |
| 189 | + from adafruit_character_lcd.character_lcd_rgb_i2c import Character_LCD_RGB_I2C |
| 190 | +
|
| 191 | + i2c = busio.I2C(board.SCL, board.SDA) |
| 192 | + lcd = Character_LCD_RGB_I2C(i2c, 16, 2) |
| 193 | +
|
| 194 | + while True: |
| 195 | + if lcd.right_button: |
| 196 | + lcd.message = "Right!" |
| 197 | +
|
| 198 | + """ |
| 199 | + return not self._right_button.value |
| 200 | + |
| 201 | + @property |
| 202 | + def select_button(self): |
| 203 | + """The select button on the RGB Character LCD I2C Shield or Pi plate. |
| 204 | +
|
| 205 | + The following example prints "Select!" to the LCD when the select button is pressed: |
| 206 | +
|
| 207 | + .. code-block:: python |
| 208 | +
|
| 209 | + import board |
| 210 | + import busio |
| 211 | + from adafruit_character_lcd.character_lcd_rgb_i2c import Character_LCD_RGB_I2C |
| 212 | +
|
| 213 | + i2c = busio.I2C(board.SCL, board.SDA) |
| 214 | + lcd = Character_LCD_RGB_I2C(i2c, 16, 2) |
| 215 | +
|
| 216 | + while True: |
| 217 | + if lcd.select_button: |
| 218 | + lcd.message = "Select!" |
| 219 | +
|
| 220 | + """ |
| 221 | + return not self._select_button.value |
0 commit comments