mirror of
https://github.com/Hack-a-Day/Vectorscope.git
synced 2025-04-12 01:09:13 +00:00
Added a few more function stubs for GC9A01 and tweaked setup readme a little
This commit is contained in:
parent
f3999aae76
commit
a98e1de3de
setup
@ -6,17 +6,17 @@ Go to [the Thonny website](https://thonny.org/) and download the version for you
|
||||
|
||||
After installation, you start up the application and choose the serial port that your badge is connected to (if it isn't auto detected), and you can start opening and editing the python files.
|
||||
|
||||
When Thonny is connected to the badge, you will have access to the REPL in a terminal (when the main code isn't running), and you can both copy you code over to the badge and run it after a reset, or you can simply run the code you have open in Thonny directly, without saving it to the badge.
|
||||
When Thonny is connected to the badge, you will have access to the REPL in a terminal (when the main code isn't running), and you can both copy your code over to the badge and run it after a reset, or you can simply run the code you have open in Thonny directly, without saving it to the badge.
|
||||
|
||||
If you are testing out different thing, simply opening a file and running it on the badge is a quick way to experiment. If you simply want to try out a single command, runnig it in the REPL is another very quick way to get started and test stuff.
|
||||
If you are testing out different things, simply opening a file and running it on the badge is a quick way to experiment. If you only want to try out a single command, runnig it in the REPL is another very quick way to get started and test stuff.
|
||||
|
||||
## VSCode
|
||||
|
||||
After [installing VSCode](https://code.visualstudio.com/Download), you need to install the [MicroPico extension](https://marketplace.visualstudio.com/items?itemName=paulober.pico-w-go) and that is easiest done via the extension manager inside VSCode. Simply search for "MicroPico", install the extension and probably also the recommended additional extension.
|
||||
After [installing VSCode](https://code.visualstudio.com/Download), you need to install the [MicroPico extension](https://marketplace.visualstudio.com/items?itemName=paulober.pico-w-go) and that is easiest done via the extension manager inside VSCode. Simply search for "MicroPico", install the extension and probably also the recommended additional extensions.
|
||||
|
||||
When you have the extension installed, you can create a new project (open a new folder), and run ```> MicroPico > Configure Project command``` via ```Ctrl+Shift+P``` (or the equivalent on your platform). This will setup the project as a MicroPico project and add a ```.vscode``` folder, with a bit of configuration.
|
||||
|
||||
Inside this hidden folder is some project settings and a link to stub files used for IntelliSense and code completion. This is for a regular Raspberry Pi Pico and will get you most of the way, but if you also want code completion for the display driver used on the badge (GC9A01), you can add the [Vectorscope folder](Vectorscope/) and it's content to this ```.vscode``` folder next to the ```Pico-W-Stub``` folder and edit the ```settings.json``` to also include this folder:
|
||||
Inside this hidden folder is some project settings and a link to stub files used for IntelliSense and code completion. This is for a regular Raspberry Pi Pico and will get you most of the way, but if you also want code completion for the display driver used on the badge (GC9A01), you can add the [Vectorscope folder](Vectorscope/) and it's content to this ```.vscode``` folder next to the ```Pico-W-Stub``` folder either by copying in the folder or by creating a symlink to the folder in this repository, if you have it checked out. To have MicroPico use these stubs edit the ```settings.json``` to also include this folder:
|
||||
|
||||
```json
|
||||
{
|
||||
@ -47,4 +47,28 @@ The official [documentation for mpremote](https://docs.micropython.org/en/latest
|
||||
|
||||
It's really not that long a read, but the TLDR is here:
|
||||
|
||||
Install via ```pip install --user mpremote``` and then you can invoke the program with ```mpremote```
|
||||
Install via ```pip install --user mpremote``` and then you can invoke the program with ```mpremote```
|
||||
|
||||
Run file on the badge
|
||||
|
||||
```
|
||||
mpremote run file.py
|
||||
```
|
||||
|
||||
Copy file from current folder to the badge
|
||||
|
||||
```
|
||||
mpremote cp file.py :
|
||||
```
|
||||
|
||||
Copy file from the badge to current folder
|
||||
|
||||
```
|
||||
mpremote cp :main.py .
|
||||
```
|
||||
|
||||
Mount current folder on the badge
|
||||
|
||||
```
|
||||
mpremote mount .
|
||||
```
|
@ -4,7 +4,7 @@ Object and functions for GC9A01 screen
|
||||
MicroPython module: https://github.com/russhughes/gc9a01_mpy
|
||||
"""
|
||||
from _typeshed import Incomplete, Incomplete as Incomplete
|
||||
from typing import Any, List, Optional, Tuple, Union
|
||||
from typing import Any, List, Optional, Tuple, Union, overload
|
||||
from machine import Pin, SPI
|
||||
|
||||
FAST: int
|
||||
@ -56,6 +56,21 @@ class GC9A01:
|
||||
Send initialization to the display.
|
||||
"""
|
||||
...
|
||||
def hard_reset(self) -> None:
|
||||
"""
|
||||
Performs a hard reset of the display
|
||||
"""
|
||||
...
|
||||
def soft_reset(self) -> None:
|
||||
"""
|
||||
Performs a soft reset of the display
|
||||
"""
|
||||
...
|
||||
def sleep_mode(self, sleep: bool) -> None:
|
||||
"""
|
||||
Changes in and out of sleepmode
|
||||
"""
|
||||
...
|
||||
def on(self) -> None:
|
||||
"""
|
||||
Turn on the backlight pin if one was defined during init.
|
||||
@ -66,6 +81,20 @@ class GC9A01:
|
||||
Turn off the backlight pin if one was defined during init.
|
||||
"""
|
||||
...
|
||||
def set_window(self, x0: int, x1: int, y0: int, y1: int) -> None:
|
||||
"""
|
||||
Set window to column and row address.
|
||||
- `x0` column start address
|
||||
- `x1` column end address
|
||||
- `y0` row start address
|
||||
- `y1` row end address
|
||||
"""
|
||||
...
|
||||
def inversion_mode(self, inverted: bool) -> None:
|
||||
"""
|
||||
Changes inverted mode on and off
|
||||
"""
|
||||
...
|
||||
def pixel(self, x: int, y: int, color: int) -> None:
|
||||
"""
|
||||
Set the specified pixel to the given `color`.
|
||||
@ -91,6 +120,11 @@ class GC9A01:
|
||||
Draws a rectangle from (`x`, `y`) with corresponding dimensions
|
||||
"""
|
||||
...
|
||||
def fill(self, color: int) -> None:
|
||||
"""
|
||||
Fill the display with given `color`
|
||||
"""
|
||||
...
|
||||
def fill_rect(self, x: int, y: int, width: int, height: int, color: int) -> None:
|
||||
"""
|
||||
Fill a rectangle starting from (`x`, `y`) coordinates
|
||||
@ -101,28 +135,58 @@ class GC9A01:
|
||||
Copy bytes() or bytearray() content to the screen internal memory. Note: every color requires 2 bytes in the array
|
||||
"""
|
||||
...
|
||||
def text(self, font, s: int, x: int, y: int, fg: Optional[int] = None, bg: Optional[int] = None) -> None:
|
||||
@overload
|
||||
def text(self, font, s: str, x: int, y: int, fg: Optional[int] = None, bg: Optional[int] = None) -> None:
|
||||
"""
|
||||
Write text to the display using the specified bitmap font with the coordinates as the upper-left corner of the text. The foreground and background colors of the text can be set by the optional arguments fg and bg, otherwise the foreground color defaults to `WHITE` and the background color defaults to `BLACK`. See the `README.md` in the `fonts/bitmap` directory for example fonts.
|
||||
"""
|
||||
...
|
||||
def write(self, bitap_font, s: int, x: int, y: int, fg: Optional[int] = None, bg: Optional[int] = None) -> None:
|
||||
@overload
|
||||
def text(self, font, s: int, x: int, y: int, fg: Optional[int] = None, bg: Optional[int] = None) -> None:
|
||||
"""
|
||||
Write single character to the display using the specified bitmap font with the coordinates as the upper-left corner of the text. The foreground and background colors of the text can be set by the optional arguments fg and bg, otherwise the foreground color defaults to `WHITE` and the background color defaults to `BLACK`. See the `README.md` in the `fonts/bitmap` directory for example fonts.
|
||||
"""
|
||||
...
|
||||
@overload
|
||||
def write(self, bitap_font, s: str, x: int, y: int, fg: Optional[int] = None, bg: Optional[int] = None) -> None:
|
||||
"""
|
||||
Write text to the display using the specified proportional or Monospace bitmap font module with the coordinates as the upper-left corner of the text. The foreground and background colors of the text can be set by the optional arguments fg and bg, otherwise the foreground color defaults to `WHITE` and the background color defaults to `BLACK`. See the `README.md` in the `truetype/fonts` directory for example fonts. Returns the width of the string as printed in pixels.
|
||||
|
||||
The `font2bitmap` utility creates compatible 1 bit per pixel bitmap modules from Proportional or Monospaced True Type fonts. The character size, foreground, background colors and the characters to include in the bitmap module may be specified as parameters. Use the -h option for details. If you specify a buffer_size during the display initialization it must be large enough to hold the widest character (HEIGHT * MAX_WIDTH * 2).
|
||||
"""
|
||||
...
|
||||
def write_len(self, bitap_font, s) -> int:
|
||||
@overload
|
||||
def write(self, bitap_font, s: int, x: int, y: int, fg: Optional[int] = None, bg: Optional[int] = None) -> None:
|
||||
"""
|
||||
Write single character to the display using the specified proportional or Monospace bitmap font module with the coordinates as the upper-left corner of the text. The foreground and background colors of the text can be set by the optional arguments fg and bg, otherwise the foreground color defaults to `WHITE` and the background color defaults to `BLACK`. See the `README.md` in the `truetype/fonts` directory for example fonts. Returns the width of the string as printed in pixels.
|
||||
|
||||
The `font2bitmap` utility creates compatible 1 bit per pixel bitmap modules from Proportional or Monospaced True Type fonts. The character size, foreground, background colors and the characters to include in the bitmap module may be specified as parameters. Use the -h option for details. If you specify a buffer_size during the display initialization it must be large enough to hold the widest character (HEIGHT * MAX_WIDTH * 2).
|
||||
"""
|
||||
...
|
||||
@overload
|
||||
def write_len(self, bitap_font, s: str) -> int:
|
||||
"""
|
||||
Returns the width of the string in pixels if printed in the specified font.
|
||||
"""
|
||||
...
|
||||
@overload
|
||||
def write_len(self, bitap_font, s: int) -> int:
|
||||
"""
|
||||
Returns the width of the single character in pixels if printed in the specified font.
|
||||
"""
|
||||
...
|
||||
@overload
|
||||
def draw(self, vector_font, s: str, x: int, y: int, color: int, scale: Optional[float] = 1.0) -> None:
|
||||
"""
|
||||
Draw text to the display using the specified hershey vector font with the coordinates as the lower-left corner of the text. The color of the text is controlled by color and the optional argument scale, can be used to make the font larger or smaller. See the `README.md` in the `vector/fonts` directory for example fonts and the utils directory for a font conversion program.
|
||||
"""
|
||||
...
|
||||
@overload
|
||||
def draw(self, vector_font, s: int, x: int, y: int, color: int, scale: Optional[float] = 1.0) -> None:
|
||||
"""
|
||||
Draw single character to the display using the specified hershey vector font with the coordinates as the lower-left corner of the text. The color of the text is controlled by color and the optional argument scale, can be used to make the font larger or smaller. See the `README.md` in the `vector/fonts` directory for example fonts and the utils directory for a font conversion program.
|
||||
"""
|
||||
...
|
||||
def jpg(self, jpg_filename: str, x: int, y:int, method: Optional[int] = FAST) -> None:
|
||||
"""
|
||||
Draw JPG file on the display at the given x and y coordinates as the upper left corner of the image. There memory required to decode and display a JPG can be considerable as a full screen 320x240 JPG would require at least 3100 bytes for the working area + 320x240x2 bytes of ram to buffer the image. Jpg images that would require a buffer larger than available memory can be drawn by passing `SLOW` for method. The `SLOW` method will draw the image a piece at a time using the Minimum Coded Unit (MCU, typically 8x8) of the image.
|
||||
@ -170,6 +234,37 @@ class GC9A01:
|
||||
7 | 270 degrees mirrored
|
||||
"""
|
||||
...
|
||||
def offset(self, xstart: int, ystart: int) -> None:
|
||||
"""
|
||||
Offsets the origin point
|
||||
"""
|
||||
...
|
||||
def vscrdef(self, tfa: int, vsa: int, bfa: int) -> None:
|
||||
"""
|
||||
Set Vertical Scrolling Definition.
|
||||
|
||||
To scroll a 135x240 display these values should be 40, 240, 40.
|
||||
There are 40 lines above the display that are not shown followed by
|
||||
240 lines that are shown followed by 40 more lines that are not shown.
|
||||
You could write to these areas off display and scroll them into view by
|
||||
changing the TFA, VSA and BFA values.
|
||||
|
||||
- `tfa` Top Fixed Area
|
||||
- `vsa` Vertical Scrolling Area
|
||||
- `bfa` Bottom Fixed Area
|
||||
"""
|
||||
...
|
||||
def vscsad(self, vssa: int) -> None:
|
||||
"""
|
||||
Set Vertical Scroll Start Address of RAM.
|
||||
|
||||
Defines which line in the Frame Memory will be written as the first
|
||||
line after the last line of the Top Fixed Area on the display
|
||||
|
||||
- `vssa` Vertical Scrolling Start Address
|
||||
"""
|
||||
...
|
||||
|
||||
|
||||
def color565(r: int, g: int, b: int) -> int:
|
||||
"""
|
||||
|
Loading…
Reference in New Issue
Block a user