Exemple #1
0
    def test_device_config(self):
        """
        Test that when both omni-epd.ini file is present and device specific INI present
        that the device specific config overrides options in global config
        """
        deviceConfig = self.goodEpd + ".ini"

        # set up a global config file and device config
        copyfile(os.path.join(os.getcwd(), "tests", CONFIG_FILE),
                 os.path.join(os.getcwd(), CONFIG_FILE))
        copyfile(os.path.join(os.getcwd(), "tests", deviceConfig),
                 os.path.join(os.getcwd(), deviceConfig))
        time.sleep(1)

        epd = displayfactory.load_display_driver(self.goodEpd)

        # device should override global
        assert epd._config.has_option(IMAGE_DISPLAY, 'flip_horizontal')
        self.assertFalse(
            epd._config.getboolean(IMAGE_DISPLAY, 'flip_horizontal'))

        # test mode and palette configurations
        assert epd.mode == 'palette'
        assert len(json.loads(epd._get_device_option(
            'palette_filter',
            "[]"))) == 5  # confirms custom palette will be loaded
Exemple #2
0
    def test_loading_success(self):
        """
        Confirm a good display can be loaded and extends VirtualEPD
        """
        epd = displayfactory.load_display_driver(self.goodEpd)

        assert isinstance(epd, VirtualEPD)
Exemple #3
0
    def test_load_device_from_conf(self):
        """
        Test that a device will load when given the type= option in the omni-epd.ini file
        and no args to load_display_driver()
        """
        deviceConfig = self.goodEpd + ".ini"

        # set up a global config file
        copyfile(os.path.join(os.getcwd(), "tests", CONFIG_FILE),
                 os.path.join(os.getcwd(), CONFIG_FILE))
        copyfile(os.path.join(os.getcwd(), "tests", deviceConfig),
                 os.path.join(os.getcwd(), deviceConfig))
        time.sleep(1)

        # should load driver from ini file without error
        epd = displayfactory.load_display_driver()

        # test that driver specific file also loaded
        assert epd._config.has_option(IMAGE_DISPLAY, 'flip_horizontal')
        self.assertFalse(
            epd._config.getboolean(IMAGE_DISPLAY, 'flip_horizontal'))

        # should attempt to load passed in driver, and fail, instead of one in conf file
        self.assertRaises(EPDNotFoundError, displayfactory.load_display_driver,
                          self.badEpd)
Exemple #4
0
    def test_global_conf(self):
        """
        Test loading of omni-epd.ini config file
        Once loaded confirm options from file exist within display class config
        Also confirm values not in the config file aren't changed from defaults
        """
        # set up a global config file
        copyfile(os.path.join(os.getcwd(), "tests", CONFIG_FILE),
                 os.path.join(os.getcwd(), CONFIG_FILE))
        time.sleep(1)

        epd = displayfactory.load_display_driver(self.goodEpd)

        assert epd._config.has_option(IMAGE_DISPLAY, 'rotate')
        assert epd._config.getfloat(IMAGE_DISPLAY, 'rotate') == 90

        # test that mode is default
        assert epd.mode == 'bw'
Exemple #5
0
from PIL import Image
"""
This basic example will load your device (modify string below),
load an image, and then write it to the display. Additionally the
omni-epd.ini file will change the mode on the image from bw (default)
to palette and filter based on a color array. This is dependant on your display,
see https://github.com/robweber/omni-epd/blob/main/README.md#displays-implemented for
modes that each display supports

"""
# load your particular display using the displayfactory
displayName = "omni_epd.mock"

print('Loading display')
try:
    epd = displayfactory.load_display_driver(displayName)
except EPDNotFoundError:
    print(f"Couldn't find {displayName}")
    sys.exit()

# if now load an image file using the Pillow lib
print('Loading image')
image = Image.open('../PIA03519_small.jpg')

# resize for your display
image = image.resize((epd.width, epd.height))

# prepare the epd, write the image, and close
print('Writing to display using the palette filter')
epd.prepare()
Exemple #6
0
                    handlers=logHandlers)
logging.debug('Debug Mode On')

# check the epd driver
validEpds = displayfactory.list_supported_displays()

if (args.epd not in validEpds):
    # can't find the driver
    logging.error(f"{args.epd} is not a valid EPD name, valid names are:")
    logging.error("\n".join(map(str, validEpds)))

    # can't get past this
    exit(1)

# setup the screen and database connection
epd = displayfactory.load_display_driver(args.epd)

# pull width/height from driver
width = epd.width
height = epd.height

db = redis.Redis('localhost', decode_responses=True)

# default to False as default settings probably won't load a video
if (not db.exists(utils.DB_PLAYER_STATUS)):
    utils.write_db(db, utils.DB_PLAYER_STATUS, {'running': False})
    utils.write_db(db, utils.DB_LAST_RUN, {'last_run': 0})

# load the player configuration
config = utils.get_configuration(db)