Пример #1
0
 def create_device(self) -> device:
     if self.debug:
         return pygame(width=32, height=8)
     else:
         serial = spi(gpio=noop())
         return max7219(serial,
                        cascaded=4,
                        block_orientation=-90,
                        contrast=0)
Пример #2
0
    def __init__(self, init_menu):
        super(Screen, self).__init__()
        self.sleep_timer = None
        self.state = 'OFF'

        self.oled = sh1106(i2c(port=1, address=0x3C)) if is_pi() else pygame(
            width=128, height=64)
        self._welcome()
        time.sleep(1)
        self.draw_menu(init_menu)
        atexit.register(self.cleanup)
Пример #3
0
 def __init__(self) -> None:
     self.font = ImageFont.truetype(FONT_FILE, 8)
     viewport.refresh = refresh
     if (os.environ.get('MODE', None) == 'PYGAME'):
         self.device = pygame(width=64, height=8)
     else:
         serial = spi(port=0, device=0, gpio=noop())
         self.device = max7219(serial,
                               cascaded=8,
                               block_orientation=-90,
                               rotate=0,
                               blocks_arranged_in_reverse_order=False)
Пример #4
0
def get_device(width, height):
    """
    Devuelve un dispositivo. En caso de que la matriz esté conectada
    devuelve la misma, en caso contrario devuelve un dispositivo de
    simulación de pygame.
    """
    try:
        serial = spi(port=0, device=0, gpio=noop())
        device = max7219(serial,
                         width=width,
                         height=height,
                         block_orientation=-90)
    except DeviceNotFoundError:
        device = pygame(width=width,
                        height=height,
                        mode="1",
                        transform='led_matrix')
    return device
Пример #5
0
    def start(self):
        self.logger.info("Starting")

        if self.mode == 'emulator':
            from luma.emulator.device import pygame
            self.device = pygame(self.width, self.height, 0, '1', "led_matrix")

        elif self.mode == 'max7219':
            from luma.core.interface.serial import spi, noop
            from luma.led_matrix.device import max7219

            serial = spi(port=1, device=0, gpio=noop())
            self.device = max7219(serial,
                                  self.width,
                                  self.height,
                                  block_orientation=self.config['orientation'])
            self.device.contrast(self.config.get('contrast', 0) << 4)
        else:
            raise Exception("Unsupported mode")
        self.logger.info("Started")
Пример #6
0
    def __init__(self):
        global level

        logger.debug('__init__')
        threading.Thread.__init__(self)

        if platform.machine().startswith('arm'):
            # create matrix7219 device
            serial = spi(port=0, device=1, gpio=noop())
            self.device = max7219(serial, cascaded=4, block_orientation=-90)
        else:
            # create emulator device
            self.device = pygame(width=32,
                                 height=8,
                                 rotate=0,
                                 mode='RGB',
                                 transform='led_matrix',
                                 scale=2,
                                 frame_rate=60)

        self.device.contrast(level)
Пример #7
0
    def __init__(self, winch):
        if (config.GUI == GuiType.SH1106_I2C.name):
            from luma.core.interface.serial import i2c
            from luma.oled.device import sh1106

            serial_interface = i2c(port=1, address=LCD_ADDR)
            self.__device = sh1106(serial_interface,
                                   width=LCD_WIDTH,
                                   height=LCD_HEIGHT,
                                   rotate=0)
        elif (config.GUI == GuiType.VGA.name):
            from luma.emulator.device import pygame

            self.__device = pygame(width=LCD_WIDTH,
                                   height=LCD_HEIGHT,
                                   rotate=0,
                                   mode='1',
                                   transform='scale2x',
                                   scale=2,
                                   frame_rate=60)
        elif (config.GUI == GuiType.CAPTURE.name):
            from luma.emulator.device import capture

            self.__device = capture(
                width=LCD_WIDTH,
                height=LCD_HEIGHT,
                rotate=0,
                mode='1',
                transform='scale2x',
                scale=2,
                file_template="docs/images/screens/OpenWinch_{0:06}.png")

        if (self.__device is not None):
            self.__device.show()

        self.__winch = winch
        self.__font = ImageFont.truetype(FONT_TEXT, 8)
        self.__regulator = framerate_regulator(fps=LCD_FPS)

        self.screen = MainScreen(self)
Пример #8
0
def main():
    try:
        serial = i2c(port=1, address=0x3C)
        device = ssd1306(serial)
        forever = True
    except NameError:
        device = pygame()
        forever = False

    # custom fonts
    font_path = "%s/fonts/%%s" % os.path.dirname(__file__)
    font = dict(
        text_small=ImageFont.truetype(font_path % 'Montserrat-Light.ttf', 12),
        text_large=ImageFont.truetype(font_path % 'Montserrat-Medium.ttf', 19),
        icon_small=ImageFont.truetype(font_path % 'fontawesome-webfont.ttf',
                                      14),
        icon_large=ImageFont.truetype(font_path % 'fontawesome-webfont.ttf',
                                      19),
    )

    # layout: (x, y, icon, dx, dy, size, function)
    info = (
        (1, 0, None, 0, 0, 'small', sinfo('host')),
        (1, 15, None, 0, 0, 'small', sinfo('ip')),
        (0, 29, '\uf2db', 22, -2, 'large', sinfo('cpu')),
        (0, 50, None, 0, 0, 'small', sinfo('mem')),
        (74, 15, '\uf1eb', 18, 0, 'small', sinfo('wifi')),
        (76, 50, '\uf1c0', 13, 0, 'small', sinfo('disk')),
        (78, 33, '\uf2c8', 10, 0, 'small', sinfo('temp')),
    )

    stats(device, info, font)
    time.sleep(15)  # 1st update after 15s
    while forever:
        stats(device, info, font)
        time.sleep(60)  # update every minute
Пример #9
0
# Raspberry Pi hardware SPI config:
DC = 23
RST = 24
SPI_PORT = 0
SPI_DEVICE = 0

# Beaglebone Black hardware SPI config:
# DC = 'P9_15'
# RST = 'P9_12'
# SPI_PORT = 1
# SPI_DEVICE = 0

# Hardware SPI usage:
if configure.pc:
    device = pygame(width=84, height=48, mode="1")
else:
    serial = spi(port=SPI_PORT, device=SPI_DEVICE, gpio_DC=DC, gpio_RST=RST)
    device = pcd8544(serial)
    device.contrast(50)

fore_col = 0
back_col = 1


# Controls text objects drawn to the LCD
class LabelObj(object):
    def __init__(self, string, font, draw):
        self.font = font
        self.draw = draw
        self.string = string
Пример #10
0
 def Setup(self):
     """Sets up the device."""
     self._device = device.pygame()
     self.process = multiprocessing.Process(target=self._SetupUI,
                                            daemon=True)
     self.process.start()
Пример #11
0
logo = Image.open('assets/picorderOS_logo.png')

# Raspberry Pi hardware SPI config:
DC = 23
RST = 24
SPI_PORT = 0
SPI_DEVICE = 0

TRANSITION = [False]


if not configure.pc:
	serial = spi(port = SPI_PORT, device = SPI_DEVICE, gpio_DC = DC, gpio_RST = RST)# ,bus_speed_hz=24000000)
	device = st7735(serial, width = 160, height = 128, mode = "RGB")
else:
	device = pygame(width = 160, height = 128)


# Standard LCARS colours
lcars_orange = (255,153,0)
lcars_pink = (204,153,204)
lcars_blue = (153,153,204)
lcars_red = (204,102,102)
lcars_peach = (255,204,153)
lcars_bluer = (153,153,255)
lcars_orpeach = (255,153,102)
lcars_pinker = (204,102,153)

theme1 =  [lcars_orange,lcars_blue,lcars_pinker]

fore_col = 0
Пример #12
0
 def Setup(self):  # pylint: disable=arguments-differ
     """Sets up the device."""
     self._emulator = device.pygame()
Пример #13
0
 def __init__(self, width, height, fontFile, largeFontSize, smallFontSize):
     Video.device = pygame(width=width, height=height, mode="1")
     super().__init__(width, height, fontFile, largeFontSize, smallFontSize)