ESL Blaster FW V2 (PP16 support)

Updated python tools to support PP16
This commit is contained in:
Furrtek
2022-12-23 09:28:21 +01:00
parent b1978643f4
commit bfa9457b4c
234 changed files with 187474 additions and 85866 deletions

View File

@@ -37,13 +37,14 @@ def record_run(run_count):
def usage():
print("img2dm - Transmits image to Dot Matrix ESL\n")
print("Usage:")
print("img2dm.py port image barcode (page color x y)\n")
print("img2dm.py port image barcode (page color x y pp4)\n")
print(" port: serial port name (0 for ESL Blaster)")
print(" image: image file")
print(" barcode: 17-character barcode data")
print(" page: page number to update (0~15), default: 0")
print(" color: 0:Black and white only, 1:Color-capable ESL, default: 0")
print(" x y: top-left position of image, default: 0 0")
print(" pp4: force slow PP4 protocol, default: 0")
exit()
arg_count = len(sys.argv)
@@ -56,15 +57,18 @@ if arg_count >= 5:
print("Page must be between 0 and 15.")
exit()
else:
page = 0
page = 1
port = sys.argv[1]
pp16 = 0
# Search for connected ESL Blaster if required
if (port == "0"):
blaster_port = tx.search_esl_blaster()
if (blaster_port == "0"):
blaster_info = tx.search_esl_blaster()
if blaster_info[0] == False:
exit()
if blaster_info[2] == 1:
pp16 = 1 # ESL Blaster FW V2 is PP16 compatible
# Open image file
image = imread(sys.argv[2])
@@ -79,6 +83,9 @@ PLID = pr.get_plid(sys.argv[3])
color_mode = int(sys.argv[5]) if arg_count >= 6 else 0
pos_x = int(sys.argv[6]) if arg_count >= 7 else 0
pos_y = int(sys.argv[7]) if arg_count >= 8 else 0
if arg_count >= 9:
if int(sys.argv[8]):
pp16 = 0
# First pass for black and white
pixels = image_convert(image, 0)
@@ -137,7 +144,7 @@ print("Data size: %i (%i frames)" % (data_size, frame_count))
frames = []
# Wake-up ping frame
frames.append(pr.make_ping_frame(PLID, 400))
frames.append(pr.make_ping_frame(PLID, pp16, 400))
print("Generating frames...")
@@ -155,7 +162,7 @@ pr.append_word(frame, 0x0000) # Keycode
frame.append(0x88) # 0x80 = update, 0x08 = set base page
pr.append_word(frame, 0x0000) # Enabled pages (bitmap)
frame.extend([0x00, 0x00, 0x00, 0x00])
pr.terminate_frame(frame, 1)
pr.terminate_frame(frame, pp16, 1)
frames.append(frame)
# Data frames
@@ -171,11 +178,11 @@ for fr in range(0, frame_count):
v += data[i + bi]
frame.append(v)
i += 8
pr.terminate_frame(frame, 1)
pr.terminate_frame(frame, pp16, 1)
frames.append(frame)
# Refresh frame
frames.append(pr.make_refresh_frame(PLID))
frames.append(pr.make_refresh_frame(PLID, pp16))
# DEBUG
f = open("frames.txt", "w")
@@ -184,11 +191,11 @@ for fr in frames:
f.write(format(b, '02X') + " ")
f.write("\n")
input("Place ESL in front of transmitter and press any key.")
input("Place ESL in front of transmitter and press enter.")
# Send data to IR transmitter
if (port == "0"):
tx.transmit_esl_blaster(frames, blaster_port)
tx.transmit_esl_blaster(frames, pp16, blaster_info[0])
else:
tx.transmit_serial(frames, port)
print("Done. Please allow a few seconds for the ESL to refresh.")

View File

@@ -17,8 +17,10 @@ def crc16(data):
return result
def terminate_frame(frame, repeats):
def terminate_frame(frame, pp16, repeats):
crc = crc16(frame)
if pp16:
frame[0:0] = [0x00, 0x00, 0x00, 0x40] # Prepend special PP16 header
frame.append(crc & 255)
frame.append((crc // 256) & 255)
frame.append(repeats & 255) # This is used by the transmitter, it's not part of the transmitted data
@@ -47,7 +49,7 @@ def get_plid(barcode):
PLID[3] = (id_value >> 16) & 0xFF
return PLID
def make_ping_frame(PLID, repeats):
def make_ping_frame(PLID, pp16, repeats):
frame = make_raw_frame(0x85, PLID, 0x17) # 0x97 ?
frame.append(0x01)
frame.append(0x00)
@@ -55,12 +57,12 @@ def make_ping_frame(PLID, repeats):
frame.append(0x00)
for b in range(0, 22):
frame.append(0x01)
terminate_frame(frame, repeats)
terminate_frame(frame, pp16, repeats)
return frame
def make_refresh_frame(PLID):
def make_refresh_frame(PLID, pp16):
frame = make_mcu_frame(PLID, 0x01)
for b in range(0, 22):
frame.append(0x00)
terminate_frame(frame, 1)
terminate_frame(frame, pp16, 1)
return frame

View File

@@ -2,6 +2,8 @@
# 2018 furrtek - furrtek.org
# See LICENSE
# 85 06 C9 00 00 00 00: Blink green LED DM
import pr
import tx
import sys
@@ -12,7 +14,7 @@ def usage():
print(" port: serial port name (0 for ESL Blaster)")
print(" barcode: 17-character barcode data, or 0")
print(" type: DM for graphic ESL, SEG for segment")
print(" hex: frame data as hex string without CRC")
print(" hex: frame data as hex string without first byte and CRC")
print(" count: number of times the frame is transmitted")
exit()
@@ -40,12 +42,11 @@ pr.terminate_frame(frame, int(sys.argv[5]))
frames.append(frame)
# DEBUG
#f = open("out.txt", "w")
#for fr in frames:
# for b in fr:
# f.write(format(b, '02X') + " ")
# f.write("\n")
#exit()
f = open("frames.txt", "w")
for fr in frames:
for b in fr:
f.write(format(b, '02X') + " ")
f.write("\n")
# Send data to IR transmitter
if (port == "0"):