From f3f260e17615293e82ad8ac1f9a4bb5f909bf2fc Mon Sep 17 00:00:00 2001 From: Gee Bartlett Date: Fri, 4 Nov 2022 17:23:30 +0000 Subject: [PATCH] finish docs and cmake gfx module --- micropython/modules/picographics/README.md | 1 + micropython/modules_py/gfx_pack.md | 71 ++++++++++++++++++++++ micropython/modules_py/modules_py.cmake | 2 +- 3 files changed, 73 insertions(+), 1 deletion(-) create mode 100644 micropython/modules_py/gfx_pack.md diff --git a/micropython/modules/picographics/README.md b/micropython/modules/picographics/README.md index b86b1e7d..f9bf7ada 100644 --- a/micropython/modules/picographics/README.md +++ b/micropython/modules/picographics/README.md @@ -63,6 +63,7 @@ Bear in mind that MicroPython has only 192K of RAM available- a 320x240 pixel di * 128x128 I2C OLED - `DISPLAY_I2C_OLED_128X128` * Pico Inky Pack - 296x128 mono e-ink - `DISPLAY_INKY_PACK` * Inky Frame - 600x447 7-colour e-ink - `DISPLAY_INKY_FRAME` +* Pico GFX Pack - 128x64 mono LCD Matrix - `DISPLAY_GFX_PACK` ### Supported Graphics Modes (Pen Type) diff --git a/micropython/modules_py/gfx_pack.md b/micropython/modules_py/gfx_pack.md new file mode 100644 index 00000000..6bd47ec2 --- /dev/null +++ b/micropython/modules_py/gfx_pack.md @@ -0,0 +1,71 @@ +# GFX Pack MicroPython + +This library offers convenient functions for interacting with [Pico GFX Pack](https://shop.pimoroni.com/products/gfxpack) - The Pico GFX Pack adds a 128x64 LCD Matrix display to your headered Raspberry Pi Pico or PicoW, with RGBW backlight and 5 input buttons for all your display anc control needs. + +## Table of Content +- [Table of Content](#table-of-content) +- [GFX Pack Classes](#GFX-Pack-class) + - [Switches](#switches) + - [RGB Backlight](#rgb-backlight) + + +## GFX Pack Class + +The `GfxPack` class deals with RGB backlight and buttons on the GFX Pack. To create one, import the `gfx_pack` module, then define a new `board` variable: + +```python +import gfx_pack + +board = gfx_pack.GfxPack() +``` + + +### Switches + +The GFX Pack has 5 user switchs located just under the display labeled A to E. The names of these switches in the class are: + +`.switch_a` + +`.switch_b` + +`.switch_c` + +`.switch_d` + +`.switch_e` + +These can be read with the `.is_pressed` method. + +```python + +if (board.switch_a.is_pressed): + print('You pressed Switch A') + +if (board.switch_b.is_pressed): + print('You pressed Switch B') +``` + + + +### RGB Backlight + +The GFX has an RGB backlight as well as the regular Matrix display backlight to change the colour of the backlight. This is accessed via the following method. + + +`.rgb.set_rgb(r, g, b)` + +Where r, g, b are values between 0 and 255 + + +example: + + +```python + +board.rgb.set_rgb(255, 0, 0) # Makes the Backlight Red + +board.rgb.set_rgb(0, 255, 0) # Makes the Backlight Blue + +board.rgb.set_rgb(0, 0, 255) # Makes the Backlight Green + +``` \ No newline at end of file diff --git a/micropython/modules_py/modules_py.cmake b/micropython/modules_py/modules_py.cmake index 2f45172f..d7fd2165 100644 --- a/micropython/modules_py/modules_py.cmake +++ b/micropython/modules_py/modules_py.cmake @@ -18,7 +18,7 @@ target_link_libraries(usermod INTERFACE usermod_modules_py) # .py files to copy from modules_py to ports/rp2/modules #copy_module(usermod_modules_py ${CMAKE_CURRENT_LIST_DIR}/picosystem.py picosystem) copy_module(usermod_modules_py ${CMAKE_CURRENT_LIST_DIR}/pimoroni.py pimoroni) - +copy_module(usermod_modules_py ${CMAKE_CURRENT_LIST_DIR}/gfx_pack.py gfx_pack) if(PICO_BOARD STREQUAL "pico_w") copy_module(usermod_modules_py ${CMAKE_CURRENT_LIST_DIR}/automation.py automation) copy_module(usermod_modules_py ${CMAKE_CURRENT_LIST_DIR}/inventor.py inventor)