-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from pimoroni/feature/round-lcd
Update library and examples for RLCD
- Loading branch information
Showing
14 changed files
with
272 additions
and
124 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
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
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,23 @@ | ||
Examples originally modified from Adafruit_Python_ILI9341 | ||
https://github.com/adafruit/Adafruit_Python_ILI9341 | ||
|
||
Copyright (c 2014 Adafruit Industries | ||
Author: Tony DiCola | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. |
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
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
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
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,89 @@ | ||
#!/usr/bin/env python3 | ||
import sys | ||
import math | ||
import time | ||
import colorsys | ||
|
||
from PIL import Image | ||
from PIL import ImageDraw | ||
from PIL import ImageFont | ||
|
||
import ST7789 | ||
|
||
print(""" | ||
round.py - Shiny shiny round LCD! | ||
If you're using Breakout Garden, plug a 1.3" ROUND LCD | ||
(SPI) breakout into the front slot. | ||
Usage: {} <style> | ||
Where style is one of: | ||
* dots - swirly swooshy dots | ||
* lines - 3D depth effect lines | ||
""".format(sys.argv[0])) | ||
|
||
try: | ||
style = sys.argv[1] | ||
except IndexError: | ||
style = "dots" | ||
|
||
# Create ST7789 LCD display class. | ||
disp = ST7789.ST7789( | ||
port=0, | ||
cs=ST7789.BG_SPI_CS_FRONT, # BG_SPI_CS_BACK or BG_SPI_CS_FRONT | ||
dc=9, | ||
backlight=19, # 18 for back BG slot, 19 for front BG slot. | ||
rotation=90, | ||
spi_speed_hz=80 * 1000 * 1000, | ||
offset_left=40 | ||
) | ||
|
||
# Initialize display. | ||
disp.begin() | ||
|
||
RADIUS = disp.width // 2 | ||
|
||
img = Image.new('RGB', (disp.width, disp.height), color=(0, 0, 0)) | ||
draw = ImageDraw.Draw(img) | ||
|
||
|
||
while True: | ||
t = time.time() | ||
draw.rectangle((0, 0, disp.width, disp.height), (0, 0, 0)) | ||
angle = t % (math.pi * 2) | ||
|
||
prev_x = RADIUS | ||
prev_y = RADIUS | ||
|
||
steps = 100.0 | ||
angle_step = 1.0 | ||
|
||
if style == "lines": | ||
steps *= 5 | ||
angle_step = 0.1 | ||
|
||
for step in range(int(steps)): | ||
angle += angle_step | ||
|
||
distance = RADIUS / steps * step | ||
distance += step * 0.2 | ||
|
||
r, g, b = [int(c * 255) for c in colorsys.hsv_to_rgb((t / 10.0) + distance / 120.0, 1.0, 1.0)] | ||
|
||
x = RADIUS + int(distance * math.cos(angle)) | ||
y = RADIUS + int(distance * math.sin(angle)) | ||
|
||
l = ((math.sin(t + angle) + 1) / 2.0) * 10 | ||
if style == "lines": | ||
draw.line((prev_x + l, prev_y + l, x - l, y - l), fill=(r, g, b)) | ||
else: | ||
l += 1 | ||
draw.ellipse((x - l, y - l, x + (l * 2), y + (l * 2)), fill=(r, g, b)) | ||
|
||
prev_x = x | ||
prev_y = y | ||
|
||
disp.display(img) |
Oops, something went wrong.