GFX HAT

This documentation will guide you through the methods available in the GFX HAT library.

At A Glance

Library for the GFX HAT ST7567 SPI LCD.

gfxhat.lcd.clear()[source]
gfxhat.lcd.set_pixel(x, y, value)[source]
gfxhat.lcd.show()[source]

Library for the GFX HAT SN3218 backlight.

gfxhat.backlight.set_all(r, g, b)[source]
gfxhat.backlight.set_pixel(x, r, g, b)[source]
gfxhat.backlight.setup()[source]
gfxhat.backlight.show()[source]

Library for the GFX HAT Cap1166 touch controller.

gfxhat.touch.enable_repeat(enable)[source]
gfxhat.touch.get_name(index)[source]
gfxhat.touch.high_sensitivity()[source]
gfxhat.touch.on(buttons, handler=None)[source]
gfxhat.touch.set_led(index, state)[source]
gfxhat.touch.set_repeat_rate(rate)[source]
gfxhat.touch.setup()[source]

LCD

lcd.clear()

Clear GFX HAT’s display buffer.

lcd.set_pixel(x, y, value)

Set a single pixel in GTX HAT’s display buffer.

Parameters:
  • x – X position (from 0 to 127)
  • y – Y position (from 0 to 63)
  • value – pixel state 1 = On, 0 = Off
lcd.show()

Update GFX HAT with the current buffer contents.

Backlight

backlight.set_pixel(x, r, g, b)

Set a single backlight zone.

Parameters:
  • x – pixel index (0 = left most, 5 = right most)
  • r – amount of red from 0 to 255
  • g – amount of green from 0 to 255
  • b – amount of blue from 0 to 255
backlight.set_all(r, g, b)

Set all backlight zones.

Parameters:
  • r – amount of red from 0 to 255
  • g – amount of green from 0 to 255
  • b – amount of blue from 0 to 255
backlight.show()

Show changes to the backlight.

Touch

touch.set_led(index, state)

Set LED state.

Parameters:
  • index – LED index
  • state – LED state (1 = on, 0 = off)
touch.enable_repeat(enable)

Enable touch hold repeat.

If enable is true, repeat will be enabled. This will trigger new touch events at the set repeat_rate when a touch input is held.

Parameters:enable – enable/disable repeat: True/False
touch.high_sensitivity()

Switch to high sensitivity mode.

This predetermined high sensitivity mode is for using touch through 3mm perspex or similar materials.

touch.on(buttons, handler=None)

Handle a press of one or more buttons.

Decorator. Use with @captouch.on(UP)

Parameters:
  • buttons – List, or single instance of cap touch button constant
  • bounce – Maintained for compatibility with Dot3k joystick, unused
touch.set_repeat_rate(rate)

Set hold repeat rate.

Repeat rate values are clamped to the nearest 35ms, values from 35 to 560 are valid.

Parameters:rate – time in ms from 35 to 560