mirror of
https://github.com/furrtek/PrecIR.git
synced 2026-03-29 07:39:59 +00:00
Simplified progress display
Added note about corrupt red layer in bw mode
This commit is contained in:
@@ -46,3 +46,6 @@ No. For two reasons:
|
|||||||
***Is possession and use of such devices legal ?***
|
***Is possession and use of such devices legal ?***
|
||||||
|
|
||||||
There's no cracking, exploit, patent or copyright infrigement going on so IMO it's safe to assume this is perfectly legal. Just don't try changing price displays so you can get discounts, the price in the store's database obviously remains unchanged so you'll end up having to pay the correct price anyways.
|
There's no cracking, exploit, patent or copyright infrigement going on so IMO it's safe to assume this is perfectly legal. Just don't try changing price displays so you can get discounts, the price in the store's database obviously remains unchanged so you'll end up having to pay the correct price anyways.
|
||||||
|
|
||||||
|
***My tricolor-capable ESL shows red garbage after an image update***
|
||||||
|
Transmit the image in tricolor mode. Transmitting black and white images to tricolor ESLs doesn't clear the red layer.
|
||||||
|
|||||||
@@ -31,14 +31,14 @@ static const uint32_t pp4_errors[4] = {
|
|||||||
// 0101: 123us (TIM16 31*4=124 Err=1)
|
// 0101: 123us (TIM16 31*4=124 Err=1)
|
||||||
// 0110: 139us (TIM16 35*4=140 Err=1)
|
// 0110: 139us (TIM16 35*4=140 Err=1)
|
||||||
// 0111: 131us (TIM16 33*4=132 Err=1)
|
// 0111: 131us (TIM16 33*4=132 Err=1)
|
||||||
// 0100: 83us (TIM16 21*4=84 Err=1)
|
// 1100: 83us (TIM16 21*4=84 Err=1)
|
||||||
// 0101: 59us (TIM16 15*4=60 Err=1)
|
// 1101: 59us (TIM16 15*4=60 Err=1)
|
||||||
// 0110: 75us (TIM16 19*4=76 Err=1)
|
// 1110: 75us (TIM16 19*4=76 Err=1)
|
||||||
// 0111: 67us (TIM16 17*4=68 Err=1)
|
// 1111: 67us (TIM16 17*4=68 Err=1)
|
||||||
// 0100: 91us (TIM16 23*4=92 Err=1)
|
// 1100: 91us (TIM16 23*4=92 Err=1)
|
||||||
// 0101: 115us (TIM16 29*4=116 Err=1)
|
// 1101: 115us (TIM16 29*4=116 Err=1)
|
||||||
// 0110: 99us (TIM16 25*4=100 Err=1)
|
// 1110: 99us (TIM16 25*4=100 Err=1)
|
||||||
// 0111: 107us (TIM16 27*4=108 Err=1)
|
// 1111: 107us (TIM16 27*4=108 Err=1)
|
||||||
// Burst: 21us (TIM16 5 *4=20 Err=-1)
|
// Burst: 21us (TIM16 5 *4=20 Err=-1)
|
||||||
static const uint32_t pp16_steps[16] = {
|
static const uint32_t pp16_steps[16] = {
|
||||||
7-2-1, 13-2-1, 9-2-1, 11-2-1, 37-2-1, 31-2-1, 35-2-1, 33-2-1,
|
7-2-1, 13-2-1, 9-2-1, 11-2-1, 37-2-1, 31-2-1, 35-2-1, 33-2-1,
|
||||||
|
|||||||
BIN
images/152bwr.png
Normal file
BIN
images/152bwr.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 848 B |
Binary file not shown.
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 803 B |
BIN
images/dm_64x64.png
Normal file
BIN
images/dm_64x64.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 653 B |
Binary file not shown.
|
Before Width: | Height: | Size: 68 KiB |
@@ -15,6 +15,7 @@ if (blaster_info[0] == "0"):
|
|||||||
ser = serial.Serial(blaster_info[0], 57600, timeout = 5) # 5s timeout for read
|
ser = serial.Serial(blaster_info[0], 57600, timeout = 5) # 5s timeout for read
|
||||||
ser.reset_input_buffer()
|
ser.reset_input_buffer()
|
||||||
|
|
||||||
|
# Flags Repeats Delay Size Data
|
||||||
frameA = [0x00, 0x00, 0x20, 0x00, 0x10, 0x00, 0x0B, 0x00, 0x84, 0x00, 0x00, 0x00, 0x00, 0xAB, 0x09, 0x00, 0x00, 0xF2, 0xA7] # Segment change page
|
frameA = [0x00, 0x00, 0x20, 0x00, 0x10, 0x00, 0x0B, 0x00, 0x84, 0x00, 0x00, 0x00, 0x00, 0xAB, 0x09, 0x00, 0x00, 0xF2, 0xA7] # Segment change page
|
||||||
frameB = [0x00, 0x00, 0x20, 0x00, 0x10, 0x00, 0x0D, 0x00, 0x85, 0x00, 0x00, 0x00, 0x00, 0x06, 0xF1, 0x00, 0x00, 0x00, 0x0A, 0x5D, 0x14] # DM show debug infos
|
frameB = [0x00, 0x00, 0x20, 0x00, 0x10, 0x00, 0x0D, 0x00, 0x85, 0x00, 0x00, 0x00, 0x00, 0x06, 0xF1, 0x00, 0x00, 0x00, 0x0A, 0x5D, 0x14] # DM show debug infos
|
||||||
|
|
||||||
@@ -44,6 +45,15 @@ for p in range(0, 8):
|
|||||||
|
|
||||||
print(ser.read())
|
print(ser.read())
|
||||||
|
|
||||||
|
ba = bytearray()
|
||||||
|
ba.append(82) # R:Read flash
|
||||||
|
ser.write(ba)
|
||||||
|
ser.flush()
|
||||||
|
i = 0
|
||||||
|
while ser.inWaiting():
|
||||||
|
print(str(i) + " " + str(ser.read()))
|
||||||
|
i += 1
|
||||||
|
|
||||||
ser.close()
|
ser.close()
|
||||||
|
|
||||||
print("Done. Read flash to verify now.")
|
print("Done. Read flash to verify now.")
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ def image_convert(image, color_pass):
|
|||||||
pixels.append(0 if luma >= 0.1 and luma < 0.9 else 1) # 0 codes color (anything mid grey)
|
pixels.append(0 if luma >= 0.1 and luma < 0.9 else 1) # 0 codes color (anything mid grey)
|
||||||
else:
|
else:
|
||||||
pixels.append(0 if luma < 0.5 else 1) # 0 codes black
|
pixels.append(0 if luma < 0.5 else 1) # 0 codes black
|
||||||
|
|
||||||
return pixels
|
return pixels
|
||||||
|
|
||||||
def record_run(run_count):
|
def record_run(run_count):
|
||||||
@@ -28,7 +27,7 @@ def record_run(run_count):
|
|||||||
while run_count:
|
while run_count:
|
||||||
bits.insert(0, run_count & 1)
|
bits.insert(0, run_count & 1)
|
||||||
run_count >>= 1
|
run_count >>= 1
|
||||||
# Zero length coding
|
# Zero length coding - 1
|
||||||
for b in bits[1:]:
|
for b in bits[1:]:
|
||||||
compressed.append(0)
|
compressed.append(0)
|
||||||
if len(bits):
|
if len(bits):
|
||||||
@@ -40,7 +39,7 @@ def usage():
|
|||||||
print("img2dm.py port image barcode (page color x y pp4)\n")
|
print("img2dm.py port image barcode (page color x y pp4)\n")
|
||||||
print(" port: serial port name (0 for ESL Blaster)")
|
print(" port: serial port name (0 for ESL Blaster)")
|
||||||
print(" image: image file")
|
print(" image: image file")
|
||||||
print(" barcode: 17-character barcode data")
|
print(" barcode: 17-character ESL barcode data")
|
||||||
print(" page: page number to update (0~15), default: 0")
|
print(" page: page number to update (0~15), default: 0")
|
||||||
print(" color: 0:Black and white only, 1:Color-capable ESL, 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(" x y: top-left position of image, default: 0 0")
|
||||||
@@ -74,8 +73,6 @@ if (port == "0"):
|
|||||||
image = imread(sys.argv[2])
|
image = imread(sys.argv[2])
|
||||||
width = image.shape[1]
|
width = image.shape[1]
|
||||||
height = image.shape[0]
|
height = image.shape[0]
|
||||||
# Medium size is 208*112
|
|
||||||
print("Image is %i*%i, please make sure that this is equal or less than the ESL's display size." % (width, height))
|
|
||||||
|
|
||||||
# Get PLID from barcode string
|
# Get PLID from barcode string
|
||||||
PLID = pr.get_plid(sys.argv[3])
|
PLID = pr.get_plid(sys.argv[3])
|
||||||
@@ -86,16 +83,18 @@ pos_y = int(sys.argv[7]) if arg_count >= 8 else 0
|
|||||||
if arg_count >= 9:
|
if arg_count >= 9:
|
||||||
if int(sys.argv[8]):
|
if int(sys.argv[8]):
|
||||||
pp16 = 0
|
pp16 = 0
|
||||||
|
|
||||||
|
# Medium size is 208*112
|
||||||
|
print("Image is %i*%i in %s mode, please make sure that this suits your ESL's display." % (width, height, "color" if color_mode else "black and white"))
|
||||||
|
|
||||||
# First pass for black and white
|
# First pass for black and white
|
||||||
pixels = image_convert(image, 0)
|
pixels = image_convert(image, 0)
|
||||||
|
|
||||||
if color_mode:
|
if color_mode:
|
||||||
# Append second pass for color if needed
|
# Append second pass for color, if needed
|
||||||
pixels += image_convert(image, 1)
|
pixels += image_convert(image, 1)
|
||||||
|
|
||||||
size_raw = len(pixels)
|
size_raw = len(pixels)
|
||||||
print("Compressing %i bits..." % size_raw)
|
|
||||||
|
|
||||||
# First pixel
|
# First pixel
|
||||||
bits = []
|
bits = []
|
||||||
@@ -122,11 +121,11 @@ size_compressed = len(compressed)
|
|||||||
# Decide on compression or not
|
# Decide on compression or not
|
||||||
# size_compressed = size_raw # Disable compression
|
# size_compressed = size_raw # Disable compression
|
||||||
if size_compressed < size_raw:
|
if size_compressed < size_raw:
|
||||||
print("Compression ratio: %.1f%%" % (100 - ((size_compressed * 100) / float(size_raw))))
|
print("Compression ratio: %.1f%% (%d -> %d bytes)" % (100 - ((size_compressed * 100) / float(size_raw)), size_raw, size_compressed))
|
||||||
data = compressed
|
data = compressed
|
||||||
compression_type = 2
|
compression_type = 2
|
||||||
else:
|
else:
|
||||||
print("Compression ratio suxx, using raw data")
|
print("Compression ratio suxx, using raw data instead")
|
||||||
data = pixels
|
data = pixels
|
||||||
compression_type = 0
|
compression_type = 0
|
||||||
|
|
||||||
@@ -139,15 +138,13 @@ for b in range(0, padding):
|
|||||||
padded_data_size = len(data)
|
padded_data_size = len(data)
|
||||||
frame_count = padded_data_size // bits_per_frame
|
frame_count = padded_data_size // bits_per_frame
|
||||||
|
|
||||||
print("Data size: %i (%i frames)" % (data_size, frame_count))
|
#print("Data size: %i (%i frames)" % (data_size, frame_count))
|
||||||
|
|
||||||
frames = []
|
frames = []
|
||||||
|
|
||||||
# Wake-up ping frame
|
# Wake-up ping frame
|
||||||
frames.append(pr.make_ping_frame(PLID, pp16, 400))
|
frames.append(pr.make_ping_frame(PLID, pp16, 400))
|
||||||
|
|
||||||
print("Generating frames...")
|
|
||||||
|
|
||||||
# Parameters frame
|
# Parameters frame
|
||||||
frame = pr.make_mcu_frame(PLID, 0x05)
|
frame = pr.make_mcu_frame(PLID, 0x05)
|
||||||
pr.append_word(frame, data_size // 8) # Total byte count for group
|
pr.append_word(frame, data_size // 8) # Total byte count for group
|
||||||
|
|||||||
@@ -49,6 +49,12 @@ def search_esl_blaster():
|
|||||||
result[0] = comport
|
result[0] = comport
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
def show_progress(i, total, size, repeats, pp16):
|
||||||
|
if repeats > 100:
|
||||||
|
print("Transmitting wake-up frames, please wait...") # Lots of repeats certainly means this is a wake-up frame
|
||||||
|
else:
|
||||||
|
print("Transmitting frame %u/%u using %s, length %u, repeated %u times." % (i, total, "PP16" if pp16 else "PP4", size, repeats), end="\r", flush=True)
|
||||||
|
|
||||||
def transmit_serial(frames, port):
|
def transmit_serial(frames, port):
|
||||||
ser = serial.Serial(port, 57600, timeout = 10) # 10s timeout for read
|
ser = serial.Serial(port, 57600, timeout = 10) # 10s timeout for read
|
||||||
@@ -58,9 +64,9 @@ def transmit_serial(frames, port):
|
|||||||
for fr in frames:
|
for fr in frames:
|
||||||
data_size = len(fr) - 2
|
data_size = len(fr) - 2
|
||||||
repeats = fr[-2] + (fr[-1] * 256)
|
repeats = fr[-2] + (fr[-1] * 256)
|
||||||
if repeats > 255: # Cap to one byte for the simple serial transmitter
|
if repeats > 255:
|
||||||
repeats = 255
|
repeats = 255 # Cap to one byte for the simple serial transmitter
|
||||||
print("Transmitting frame %u/%u, length %u, repeated %u times." % (i, frame_count, data_size, repeats))
|
show_progress(i, frame_count, data_size, repeats, 0)
|
||||||
|
|
||||||
ba = bytearray()
|
ba = bytearray()
|
||||||
ba.append(data_size)
|
ba.append(data_size)
|
||||||
@@ -72,7 +78,7 @@ def transmit_serial(frames, port):
|
|||||||
ser.flush()
|
ser.flush()
|
||||||
ser.read_until('A')
|
ser.read_until('A')
|
||||||
i += 1
|
i += 1
|
||||||
|
print("")
|
||||||
ser.close()
|
ser.close()
|
||||||
|
|
||||||
def transmit_esl_blaster(frames, pp16, port):
|
def transmit_esl_blaster(frames, pp16, port):
|
||||||
@@ -88,10 +94,13 @@ def transmit_esl_blaster(frames, pp16, port):
|
|||||||
data_size = len(fr) - 2
|
data_size = len(fr) - 2
|
||||||
repeats = fr[-2] + (fr[-1] * 256)
|
repeats = fr[-2] + (fr[-1] * 256)
|
||||||
|
|
||||||
if repeats > 32767: # Cap to 15 bits because FW V2 uses bit 16 to indicate PP16 protocol
|
if repeats > 32767:
|
||||||
repeats = 32767
|
repeats = 32767 # Cap to 15 bits because FW V2 uses bit 16 to indicate PP16 protocol
|
||||||
|
#if repeats > 100:
|
||||||
print("Transmitting frame %u/%u using %s, length %u, repeated %u times." % (i, frame_count, "PP16" if pp16 else "PP4", data_size, repeats))
|
# print("Transmitting wake-up frames, please wait...") # Lots of repeats certainly means this is a wake-up frame
|
||||||
|
#else:
|
||||||
|
# print("Transmitting frame %u/%u using %s, length %u, repeated %u times." % (i, frame_count, "PP16" if pp16 else "PP4", data_size, repeats), end="\r", flush=True)
|
||||||
|
show_progress(i, frame_count, data_size, repeats, pp16)
|
||||||
|
|
||||||
if pp16:
|
if pp16:
|
||||||
repeats |= 0x8000
|
repeats |= 0x8000
|
||||||
@@ -99,7 +108,7 @@ def transmit_esl_blaster(frames, pp16, port):
|
|||||||
ba = bytearray()
|
ba = bytearray()
|
||||||
ba.append(76) # L:Load
|
ba.append(76) # L:Load
|
||||||
ba.append(data_size)
|
ba.append(data_size)
|
||||||
ba.append(30) # 30*50 = 1500 timer ticks between repeats
|
ba.append(10) # 30*50 = 1500 timer ticks between repeats
|
||||||
ba.append(repeats & 255)
|
ba.append(repeats & 255)
|
||||||
ba.append((repeats // 256) & 255)
|
ba.append((repeats // 256) & 255)
|
||||||
for b in range(0, data_size):
|
for b in range(0, data_size):
|
||||||
@@ -115,5 +124,5 @@ def transmit_esl_blaster(frames, pp16, port):
|
|||||||
ser.flush()
|
ser.flush()
|
||||||
ser.read_until(b'K') # Wait for transmit done
|
ser.read_until(b'K') # Wait for transmit done
|
||||||
i += 1
|
i += 1
|
||||||
|
print("")
|
||||||
ser.close()
|
ser.close()
|
||||||
|
|||||||
Reference in New Issue
Block a user