Skip to content

Commit

Permalink
fx2.format: allow configurable fill in flatten_data().
Browse files Browse the repository at this point in the history
  • Loading branch information
whitequark committed Jan 26, 2020
1 parent d3e37f6 commit 69c5909
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions software/fx2/format.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ def autodetect(file):
raise ValueError("Specify file format explicitly")


def flatten_data(data):
def flatten_data(data, *, fill=0x00):
"""
Flatten a list of ``(addr, chunk)`` pairs, such as that returned by :func:`input_data`,
to a flat byte array, such as that accepted by :func:`output_data`.
"""
data_flat = bytearray(max([addr + len(chunk) for (addr, chunk) in data]))
data_flat = bytearray([fill]) * max([addr + len(chunk) for (addr, chunk) in data])
for (addr, chunk) in data:
data_flat[addr:addr+len(chunk)] = chunk
return data_flat
Expand Down

0 comments on commit 69c5909

Please sign in to comment.