Code Monkey home page Code Monkey logo

pi-st7565's People

Contributors

rdagger avatar synox avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

pi-st7565's Issues

Start at column 0

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.

AttributeError: 'NoneType' object has no attribute 'format': y-coordinate: {0} above maximum of {1}.

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'

Centre text in the middle of the display

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.

Loading PNG Icons

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.