Created
September 2, 2013 21:41
-
-
Save chrissnell/6417507 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class FramePacket(Structure): | |
_fields_ = [ ('header', c_uint8), ('proto_version', c_uint8), ('display_width', c_uint8), ('display_height', c_uint8), \ | |
('retain_delay', c_uint8), ('RESERVED_SPACE', c_uint8 * 24) ] | |
class AssembledFramePacket(object): | |
def __init__(self,frame): | |
self._frame = frame | |
def create_packet(self): | |
# Frame ID | |
FRAME_ID = 0x7 | |
# Frame Commands | |
CMD_PING = 0x0 | |
CMD_STORE = 0x1 | |
CMD_PLAY = 0x2 | |
CMD_DEMO = 0x3 | |
CMD_CLEAR = 0xE | |
CMD_WIPE = 0xF | |
# Protocol Version (currently 1) | |
PROTO_VER = 0x1 | |
# Display Parameters | |
DISP_WIDTH = 8 | |
DISP_HEIGHT = 8 | |
# Frame Retain Delay, n * 1/10 second, n = (0x00..0xff) inclusive | |
# Max delay = 25.5 sec | |
retain_delay = self._frame._retain_delay | |
RESERVED_SPACE = 0x0, 0x0, 0x0, 0x0 | |
f_header = (FRAME_ID << 4) + CMD_STORE | |
packet = FramePacket(f_header, PROTO_VER, DISP_WIDTH, DISP_HEIGHT, retain_delay, RESERVED_SPACE) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment