예제 #1
0
 def read(self):
     ret = Mask()
     debug("framebuffer read")
     if not self.noread:
         rsp = http.get(self.address, "framebuffer", None)
         ret = Framebuffer.MaskFromResponse(rsp)
     return ret
예제 #2
0
 def GetTiming(self):  #TODO
     debug("rendering timings get {:s}".format(self.address))
     if self.noread:
         return None
     rsp = http.get(self.address, "rendering/timings", None)
     if rsp == None:
         return None
     val = rsp.read()
     # todo
     return None
예제 #3
0
 def getMode(self):
     debug("rendering mode get {:s}".format(self.address))
     if self.noread:
         return None
     rsp = http.get(self.address, "rendering/mode", None)
     if rsp == None:
         return None
     val = rsp.read()
     if val == Rendering.Mode.full.value:
         return Rendering.Mode.full
     if val == Rendering.Mode.diff.value:
         return Rendering.Mode.diff
     return None
예제 #4
0
    def read(self, x, y):
        y = FRAMESIZE.h - y - 1
        if x >= FRAMESIZE.w or y >= FRAMESIZE.h:
            raise Error("invalid read pixel {:d}/{:d}".format(x, y))
        params = {'x': x, 'y': y}

        val = False
        if not self.noread:
            rsp = http.get(self.address, "pixel", params)
            if rsp == None:
                raise Error("fail read pixel {:d}/{:d}".format(x, y))
            val = rsp.read()

        if val == b'X\x00':
            return True
        return False
예제 #5
0
    def flip(self, x, y, val=None):

        y = FRAMESIZE.h - y - 1
        if x >= FRAMESIZE.w or y >= FRAMESIZE.h:
            error("invalid write pixel {:d}/{:d}".format(x, y))
            return False

        params = {'x': x, 'y': y}
        rsp = None

        if val == None:  # get current pixel value
            val = False
            if not self.noread:
                rsp = http.get(self.address, "pixel", params)
                if rsp == None:
                    error("fail flip pixel {:d}/{:d}".format(x, y))
                    return False
                if rsp.read() == b'X\x00':
                    val = True

        ret = False
        if val == True:
            debug("pixel {:3d}/{:2d} flip ⬛︎ bright".format(x, y))
            if self.nowrite:
                return True
            rsp = http.post(self.address, "pixel", params, data=None)
            if rsp == None:
                error("fail flip bright pixel {:3d}/{:2d}".format(x, y))
                return False
            ret = rsp.read()

        elif val == False:
            debug("pixel {:3d}/{:2d} flip ⬜︎ dark".format(x, y))
            if self.nowrite:
                return False
            rsp = http.delete(self.address, "pixel", params)
            if rsp == None:
                error("fail flip dark pixel {:3d}/{:2d}".format(x, y))
                return False
            ret = rsp.read()

        if ret == b'X\x00':
            return True
        return False