rdagger / pi-st7565 Goto Github PK
View Code? Open in Web Editor NEWST7565 Graphics LCD Display Python Library for Raspberry Pi
License: MIT License
ST7565 Graphics LCD Display Python Library for Raspberry Pi
License: MIT License
Hi, I connected a generic st7565 lcd to my raspberry pi, and noticed that the display didn't start at 0, but at one.
In st7565.c I changed two instances of
self.move_cursor(1, page)
to
self.move_cursor(0, page)
Which fixed it for me. Not sure if this is an error for other screen layouts.
st7565.Glcd#is_off_grid has an error in the error handling. it raises an error if it prints off screen.
the print function is implemented incorrectly (call format() on the string, not on the result of print).
error:
y-coordinate: {0} above maximum of {1}.
Traceback (most recent call last):
File "/scratch.py", line 30, in <module>
is_off_grid(100, 50, 10, 50)
File "/scratch.py", line 26, in is_off_grid
print('y-coordinate: {0} above maximum of {1}.').format(ymax, LCD_HEIGHT - 1)
AttributeError: 'NoneType' object has no attribute 'format'
Hi, I would like to centre a variable in the middle of the LCD. the issue is that the variable can be anything between 5 and 30 so I cant just set a position for it and leave it. Is there a way of getting the length of the piece of text to be displayed?
Thanks.
This is not a request, more a suggestion. It's not tested enough for a pull request, but maybe somebody finds this useful. ;-)
By importing the library https://github.com/DanNixon/GLCD-BitmapConverter and the following changes to Glcd
, you can load png icons. I currently use this in my setup at home.
# new imports:
import os
import numpy as np
from converter import get_average_pixel_intensity, load_image, get_pixel_intensity
# new cache for the images
imagecache = dict()
class Glcd(object):
# ...
# new method for drawing a png
def draw_png(self, name, x, y, invert_colors=False, w=16, h=16):
# TODO: find the propper way to get a relative path (in package and expanded)
filename = os.path.join(os.path.dirname(__file__), "icons/%s.png" % name)
bitmap = self._create_bitmap_from_image(filename, invert_colors, w, h)
self.draw_bitmap(bitmap, x, y)
@classmethod
def _create_bitmap_from_image(cls, filename, invert_colors, width, height):
if imagecache.has_key(filename):
bitmap = imagecache[filename]
else:
width, height, image_data = load_image(filename, width, height)
crossover_intensity = get_average_pixel_intensity(width, height, image_data, invert_colors)
bitmap = cls._convert_pixeldata_to_bitmap(width, height, image_data, crossover_intensity, invert_colors)
imagecache[filename] = bitmap
return bitmap
@classmethod
def _convert_pixeldata_to_bitmap(cls, width, height, pixel_data, crossover, invert):
"""
Outputs the data in a C bitmap array format.
"""
bitmap = np.zeros((height, width), dtype='uint8')
for y_idx in range(0, height):
for x_idx in range(0, width):
value = get_pixel_intensity(pixel_data[x_idx, y_idx], invert) > crossover
bitmap[y_idx, x_idx] = value
return bitmap
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.