mirror of
https://github.com/pimoroni/st7735-python.git
synced 2025-01-05 22:40:25 +03:00
Code QA tweaks
This commit is contained in:
@@ -19,7 +19,6 @@
|
||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
# THE SOFTWARE.
|
||||
import time
|
||||
import sys
|
||||
import math
|
||||
|
||||
from PIL import Image
|
||||
@@ -66,4 +65,7 @@ while True:
|
||||
count += 1
|
||||
time_current = time.time() - time_start
|
||||
if count % 120 == 0:
|
||||
print("Time: {}, Frames: {}, FPS: {}".format(time_current, count, count / time_current))
|
||||
print("Time: {}, Frames: {}, FPS: {}".format(
|
||||
time_current,
|
||||
count,
|
||||
count / time_current))
|
||||
|
||||
@@ -58,6 +58,6 @@ while True:
|
||||
disp.display(image.resize((WIDTH, HEIGHT)))
|
||||
frame += 1
|
||||
time.sleep(0.05)
|
||||
|
||||
except EOFError:
|
||||
frame = 0
|
||||
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
# 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.
|
||||
import time
|
||||
import sys
|
||||
|
||||
from PIL import Image
|
||||
|
||||
@@ -70,6 +70,7 @@ font = ImageFont.load_default()
|
||||
# Some other nice fonts to try: http://www.dafont.com/bitmap.php
|
||||
# font = ImageFont.truetype('Minecraftia.ttf', 16)
|
||||
|
||||
|
||||
# Define a function to create rotated text. Unfortunately PIL doesn't have good
|
||||
# native support for rotated fonts, but this function can be used to make a
|
||||
# text image and rotate it so it's easy to paste in the buffer.
|
||||
@@ -87,6 +88,7 @@ def draw_rotated_text(image, text, position, angle, font, fill=(255,255,255)):
|
||||
# Paste the text into the image, using it as a mask for transparency.
|
||||
image.paste(rotated, position, rotated)
|
||||
|
||||
|
||||
# Write two lines of white text on the buffer, rotated 90 degrees counter clockwise.
|
||||
draw_rotated_text(img, 'Hello World!', (0, 0), 90, font, fill=(255, 255, 255))
|
||||
draw_rotated_text(img, 'This is a line of text.', (10, HEIGHT - 10), 0, font, fill=(255, 255, 255))
|
||||
|
||||
Reference in New Issue
Block a user