-
Notifications
You must be signed in to change notification settings - Fork 0
/
VMUFrame.py
40 lines (33 loc) · 1.07 KB
/
VMUFrame.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
class VMUFrameClass:
# frame size
__WIDTH = 48
__HEIGHT = 32
__SIZE = __WIDTH * __HEIGHT
# constructor given duration and frame path
def __init__(self, path, duration):
self.duration = duration
self.data = [];
self.loadFromRawFile(path);
# load frame data from raw bin file
def loadFromRawFile(self, path):
with open(path, "rb") as f:
byte = f.read(1)
while byte:
# Do stuff with byte.
if (byte == b'\x00'):
self.data.append(0x00)
else:
self.data.append(0x08)
byte = f.read(1)
# get duration
def getDelay(self):
return self.duration
# get info as byteArray
def getInfoToByteArray(self):
return bytearray([0x00, self.duration, 0x00, 0x00])
# get raw frame data as bytearray
def getDataToByteArray(self):
return bytearray(self.data)
# get frame size
def getSize(self):
return self.__SIZE