add some code
This commit is contained in:
18
managed_components/lvgl__lvgl/scripts/filetohex.py
Normal file
18
managed_components/lvgl__lvgl/scripts/filetohex.py
Normal file
@@ -0,0 +1,18 @@
|
||||
#!/usr/bin/env python3
|
||||
import sys
|
||||
import textwrap
|
||||
import re
|
||||
|
||||
with open(sys.argv[1], 'r') as file:
|
||||
s = file.read()
|
||||
|
||||
b = bytearray()
|
||||
|
||||
if '--filter-character' in sys.argv:
|
||||
s = re.sub(r'[^\x00-\xff]', '', s)
|
||||
if '--null-terminate' in sys.argv:
|
||||
s += '\x00'
|
||||
|
||||
b.extend(map(ord, s))
|
||||
|
||||
print(textwrap.fill(', '.join([hex(a) for a in b]), 96))
|
||||
Reference in New Issue
Block a user