Skip to content

Commit

Permalink
Minor Bugfixing and support of non 5-bpp waveforms in waveform_hdrgen…
Browse files Browse the repository at this point in the history
….py (#378)

This pull request addresses two issues: 

1. Issue [326](#326) describes:
- Last pixel in line not updated 
- Framebuffer shifted by one row on display (first row on display not
updated)

2. Issue [377](#377) describes
minor bugs and improvements in waveform_hdrgen.py:
- Default mode_filter is wrong
- Temperature interval is too long if temperature range is limited
- Approach to support non 5-bpp waveforms
  • Loading branch information
dapeda42 authored Dec 29, 2024
1 parent cbdaaa7 commit 1bee9c3
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 14 deletions.
36 changes: 25 additions & 11 deletions scripts/waveform_hdrgen.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,36 @@

total_size = 0

def phase_to_c(phase):
"""
Convert a 5 bit phase to a 4 bit C LUT.
"""
global total_size
def phase_to_c(phase,bits_per_pixel_c=4):

N1 = len(phase)
N2 = len(phase[0])
N = 2**bits_per_pixel_c

if N1%N != 0:
raise ValueError(f"first dimension of phases is {N1}. Allowed are multiples of {N}")

step1 = int(N1/N)

if N2%N != 0:
raise ValueError(f"second dimension of phases is {N2}. Allowed are multiples of {N}")

step2 = int(N2/N)

targets = []
for t in range(0, 32, 2):
for t in range(0, N1, step1):
chunk = 0
line = []
for f in range(0, 32, 2):
i = 0
for f in range(0, N2, step2):
fr = phase[t][f]
chunk = (chunk << 2) | fr
if f and f % 8 == 6:
i += 1
if i == 4:
i = 0
line.append(chunk)
chunk = 0
targets.append(line)
total_size += len(line)

return targets

Expand All @@ -61,7 +73,7 @@ def list_to_c(l):

modes = []

mode_filter = list(range(len(waveforms["modes"])))
mode_filter = [wm["mode"] for wm in waveforms["modes"]]

if args.export_modes:
mode_filter = list(map(int, args.export_modes.split(",")))
Expand All @@ -72,6 +84,8 @@ def list_to_c(l):

temp_intervals = []
for bounds in waveforms["temperature_ranges"]["range_bounds"]:
if bounds["to"] < tmin or bounds["from"] > tmax:
continue
temp_intervals.append(f"{{ .min = {bounds['from']}, .max = {bounds['to']} }}")

modes = []
Expand All @@ -84,7 +98,7 @@ def list_to_c(l):
ranges = []
for i, r in enumerate(mode["ranges"]):
bounds = waveforms["temperature_ranges"]["range_bounds"][i]
if bounds["from"] < tmin or bounds["from"] > tmax:
if bounds["to"] < tmin or bounds["from"] > tmax:
continue

phases = []
Expand Down
4 changes: 2 additions & 2 deletions src/highlevel.c
Original file line number Diff line number Diff line change
Expand Up @@ -172,12 +172,12 @@ enum EpdDrawError epd_hl_update_area(
x += 1;
}

if (x_last % 2) {
if (!(x_last % 2)) {
*(lbb + x_last / 2) = (*(lfb + x_last / 2) & 0x0F) | (*(lbb + x_last / 2) & 0xF0);
x_last -= 1;
}

memcpy(lbb + (x / 2), lfb + (x / 2), (x_last - x) / 2);
memcpy(lbb + (x / 2), lfb + (x / 2), (x_last - x + 1) / 2);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/output_lcd/lcd_driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -653,7 +653,7 @@ void IRAM_ATTR epd_lcd_start_frame() {
lcd.lcd_res_h + (lcd.dummy_bytes > 0),
end_line
);
lcd_ll_set_vertical_timing(lcd.hal.dev, 1, 1, initial_lines, 1);
lcd_ll_set_vertical_timing(lcd.hal.dev, 1, 0, initial_lines, 1);

// generate the hsync at the very beginning of line
lcd_ll_set_hsync_position(lcd.hal.dev, 1);
Expand Down

0 comments on commit 1bee9c3

Please sign in to comment.