Skip to content

Instantly share code, notes, and snippets.

View teodor-stoenescu's full-sized avatar

Teodor Stoenescu teodor-stoenescu

View GitHub Profile
@teodor-stoenescu
teodor-stoenescu / bin2arr.py
Created August 18, 2017 20:54
Python tool to convert binary files to arrays of bytes (useful for loading into Arduino progmem)
from __future__ import with_statement
import sys
with open(sys.argv[1], "rb") as f:
b = f.read(1)
t = 0
while b:
sys.stdout.write("{0:#0{1}x}, ".format(ord(b), 4))
t += 1
if 8 == t :