예제 #1
0
    def _to_display(self, arguments):
        device = self.getDevice()
        if self.emulate:
            device = '/tmp/fb.bin'
            self.depth = 32

        if self.depth in [24, 32]:
            with open(device, 'wb') as f:
                debug.subprocess_call(arguments, stdout=f, stderr=self.void)
        elif self.depth == 16:  # Typically RGB565
            # For some odd reason, cannot pipe the output directly to the framebuffer, use temp file
            with open(device, 'wb') as fb:
                src = subprocess.Popen(arguments,
                                       stdout=subprocess.PIPE,
                                       stderr=self.void)
                pip = subprocess.Popen(['/root/photoframe/rgb565/rgb565'],
                                       stdin=src.stdout,
                                       stdout=fb)
                src.stdout.close()
                pip.communicate()
        else:
            logging.error('Do not know how to render this, depth is %d',
                          self.depth)

        self.lastMessage = None
예제 #2
0
 def clear(self):
     if self.emulate:
         self.message('')
         return
     with open(self.getDevice(), 'wb') as f:
         debug.subprocess_call(['cat', '/dev/zero'],
                               stdout=f,
                               stderr=self.void)
예제 #3
0
    def enable(self, enable, force=False):
        if enable == self.enabled and not force:
            return

        # Do not do things if we don't know how to display
        if self.params is None:
            return

        if enable:
            if self.isHDMI():
                if force:  # Make sure display is ON and set to our preference
                    if os.path.exists('/opt/vc/bin/tvservice'):
                        debug.subprocess_call(
                            ['/opt/vc/bin/tvservice', '-e', self.params],
                            stderr=self.void,
                            stdout=self.void)
                    time.sleep(1)
                    debug.subprocess_call(
                        ['/bin/fbset', '-fb',
                         self.getDevice(), '-depth', '8'],
                        stderr=self.void)
                    debug.subprocess_call([
                        '/bin/fbset', '-fb',
                        self.getDevice(), '-depth',
                        str(self.depth), '-xres',
                        str(self.width), '-yres',
                        str(self.height), '-vxres',
                        str(self.width), '-vyres',
                        str(self.height)
                    ],
                                          stderr=self.void)
                else:
                    debug.subprocess_call(
                        ['/usr/bin/vcgencmd', 'display_power', '1'],
                        stderr=self.void)
        else:
            self.clear()
            if self.isHDMI():
                debug.subprocess_call(
                    ['/usr/bin/vcgencmd', 'display_power', '0'],
                    stderr=self.void)
        self.enabled = enable