robweber / omni-epd

An EPD (electronic paper display) class abstraction to simplify communications across multiple display types.
GNU General Public License v3.0
77 stars 16 forks source link

Specific Device Customization #12

Closed robweber closed 3 years ago

robweber commented 3 years ago

This is the implementation of #9

The VirtualEPD class now has support for checking the config file for options set for the current device specifically. These can be queried, with a fallback value, to allow for device specific config options to exist as part of config files. Users, or individual project maintainers, can offer device specific options by using the ini file.

The mock display class implements these as an example through the use of file to set the location of the JPEG file or write_file as a True/False value of if the file should be written at all.

Before merging additional Inky and Waveshare devices will implement their own options. One method for keeping track of these would be to use the Wiki feature of Github.

robweber commented 3 years ago

Just to make sure all device types are covered:

robweber commented 3 years ago

Updated to support modes of bw, red/yellow, 4 tone grayscale, or color (7 color) for displays that support it. New is the concept of a mode for all display classes. This is set to black and white by default but additional modes can be added for each display class type. Class families, like Waveshare 4 Grayscale or Inky pHAT,wHAT devices, share a common class with available modes.

Modes are checked when the class is loaded to make sure a given mode is supported by the class. For Inky devices and Tri color Waveshare displays Pillow is used to filter colors from images prior to sending to the display. For other Waveshare devices and the Inky Impression this filtering is done with the device driver.

missionfloyd commented 3 years ago
Installed /usr/local/lib/python3.7/dist-packages/omni_epd-0.1.7-py3.7.egg
Processing dependencies for omni-epd==0.1.7
Searching for waveshare-epd@ git+https://github.com/waveshare/e-Paper.git#subdirectory=RaspberryPi_JetsonNano/python&egg=waveshare-epd
Reading https://pypi.org/simple/waveshare-epd/
Couldn't find index page for 'waveshare-epd' (maybe misspelled?)
Scanning index of all packages (this may take a while)
Reading https://pypi.org/simple/
No local packages or working download links found for waveshare-epd@ git+https://github.com/waveshare/e-Paper.git#subdirectory=RaspberryPi_JetsonNano/python&egg=waveshare-epd
error: Could not find suitable distribution for Requirement.parse('waveshare-epd@ git+https://github.com/waveshare/e-Paper.git#subdirectory=RaspberryPi_JetsonNano/python&egg=waveshare-epd')

Use dependency_links for that.

robweber commented 3 years ago

dependency_links is deprecated. I haven't been having any issues using pip3 install.

missionfloyd commented 3 years ago

So it is. Anyway, I that error when installing omni-epd on a system that doesn't already have waveshare-epd installed. I was doing it wrong.

One more minor thing, some of the files have windows line endings.

missionfloyd commented 3 years ago

I got inky impression working. Some of it is outside this PR, so here's the class. A few things had to be changed.

class InkyImpressionDisplay(VirtualEPD):
    """
    This is an abstraction for Pimoroni Inky Impression devices
    https://shop.pimoroni.com/products/inky-impression
    https://github.com/pimoroni/inky
    """

    pkg_name = 'inky'
    mode = 'color'  # this uses color by default
    max_colors = 8  # 7 + transparent
    modes_available = ('bw', 'color')

    def __init__(self, deviceName, config):
        from inky.inky_uc8159 import DESATURATED_PALETTE
        super(InkyImpressionDisplay, self).__init__(deviceName, config)

        # load the device driver
        deviceObj = self.load_display_driver(self.pkg_name, 'inky_uc8159')
        self._device = deviceObj.Inky()

        # set the width and height
        self.width = self._device.width
        self.height = self._device.height

        # get colors from the inky lib (won't be used normally as inky does conversion)
        self.palette_filter = DESATURATED_PALETTE

    @staticmethod
    def get_supported_devices():
        result = []

        # python libs for this might not be installed - that's ok, return nothing
        if(InkyImpressionDisplay.check_module_installed('inky')):
            # if passed return list of devices
            result = [f"{InkyDisplay.pkg_name}.impression"]

        return result

    def _display(self, image):
        # no palette adjustments need to be done as the Inky lib does them from the image
        self._device.set_image(image.convert("RGB"), saturation=self._getfloat_device_option('saturation', .5))  # .5 is default from Inky lib
        self._device.show()

    def clear(self):
        from inky.inky_uc8159 import CLEAN

        for _ in range(2):
            for y in range(self.height - 1):
                for x in range(self.width - 1):
                    self._device.set_pixel(x, y, CLEAN)

        self._device.show()
robweber commented 3 years ago

Thanks for testing Inky Impression. I figured that class name was wrong as soon as you mentioned it wasn't working. I've missed that more than once when copying for new display types.

I think I fixed most of the other issues but if something else is missing let me know. I'm going to run this on my Waveshare 7.5 in and the Inky pHat I have to make sure something critical isn't missing. After that I'll merge in and then we can finally get back to the SlowMovie PR where this all started.

robweber commented 3 years ago

Wonder why they defined those twice, within the class and outside of it? Good catch, simplifies things.

missionfloyd commented 3 years ago

BW works fine on the impression.

robweber commented 3 years ago

Going to give this a once over later today and then merge it in. I added the Inky border stuff to the wiki page I've been documenting the device options. This is linked to in the updated README