forked from Musicted/pyghthouse
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Gedusim
committed
Dec 1, 2023
1 parent
b4b917b
commit a52598a
Showing
1 changed file
with
66 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
''' | ||
This example should give a simple overview on how to use the Pyghthouse. | ||
A generel orientation of what you need: | ||
- Import of pyghthouse | ||
- Creating an instance of Pyghthouse | ||
- start connection | ||
- Sending images with either a given function or set_image(image) | ||
- close connection (not needed but recommend) | ||
More examples can be found in the examples folder. | ||
Note that this skript handles Pyghthouse as a local module compared to | ||
the skripts in examples; These handle Pyghthouse as an installed package. | ||
Check examples/README.md for more informations. | ||
''' | ||
|
||
from pyghthouse import Pyghthouse | ||
import pyghthouse.utils as utils | ||
from examples.config import UNAME, TOKEN | ||
|
||
# Optional: This condition only executes if run as a skript. | ||
# Importing this program won't execute this block. | ||
if __name__ == '__main__': | ||
|
||
# Create instance of Pyghthouse and start connection | ||
username = UNAME | ||
token = TOKEN | ||
p = Pyghthouse(username, token) | ||
p.start() | ||
|
||
# the image is a 3 dimensional list, meaning a list with [[[r,g,b]]] entries | ||
# create a black image | ||
img = p.empty_image() | ||
|
||
pos_x = 10 | ||
pos_y = 5 | ||
# color entries are in rgb | ||
color = [100, 124, 24] | ||
|
||
# sends the given image | ||
img[pos_y][pos_x] = color | ||
p.set_image(img) | ||
|
||
key = input("Enter 'n' for the next image, enter any other key to skip\n") | ||
if key.upper() == "N": | ||
# set rgb color with a converted hsv color | ||
color = utils.from_hsv(0.5, 1.0, 0.7) | ||
|
||
# set all pixels to the current color | ||
for x in range(28): | ||
for y in range(14): | ||
img[y][x] = color | ||
p.set_image(img) | ||
|
||
key = input("Enter 'n' for the next image, enter any other key to skip\n") | ||
if key.upper() == "N": | ||
color = [255, 255, 255] | ||
|
||
# create 3 white lines | ||
for x in range(28): | ||
for y in range(3,10,3): | ||
img[y][x] = color | ||
p.set_image(img) | ||
|
||
p.close() |