mirror of
https://github.com/thooge/esp32-nmea2000-obp60.git
synced 2025-12-24 19:23:06 +01:00
Config data for tracker page
This commit is contained in:
17
lib/obp60task/utils/auto_version.py
Normal file
17
lib/obp60task/utils/auto_version.py
Normal file
@@ -0,0 +1,17 @@
|
||||
import subprocess
|
||||
|
||||
# Import("env")
|
||||
|
||||
def get_firmware_specifier_build_flag():
|
||||
#ret = subprocess.run(["git", "describe"], stdout=subprocess.PIPE, text=True) #Uses only annotated tags
|
||||
ret = subprocess.run(["git", "describe", "--tags"], stdout=subprocess.PIPE, text=True) #Uses any tags
|
||||
build_version = ret.stdout.strip()
|
||||
build_flag = "-D AUTO_VERSION=\\\"" + build_version + "\\\""
|
||||
print ("Firmware Revision: " + build_version)
|
||||
return (build_flag)
|
||||
|
||||
#env.Append(
|
||||
# BUILD_FLAGS=[get_firmware_specifier_build_flag()]
|
||||
#)
|
||||
|
||||
get_firmware_specifier_build_flag()
|
||||
61
lib/obp60task/utils/xbmconvert.py
Executable file
61
lib/obp60task/utils/xbmconvert.py
Executable file
@@ -0,0 +1,61 @@
|
||||
#!/usr/bin/python
|
||||
#
|
||||
# Convert a Gimp-created XBM file to bitmap useable by drawBitmap()
|
||||
#
|
||||
|
||||
import os
|
||||
import sys
|
||||
import re
|
||||
from PIL import Image
|
||||
|
||||
if len(sys.argv) < 2:
|
||||
print("Usage: xbmconvert.py <filename>")
|
||||
sys.exit(1)
|
||||
|
||||
xbmfilename = sys.argv[1]
|
||||
if not os.path.isfile(xbmfilename):
|
||||
print(f"The file '{xbmfilename}' does not exists.")
|
||||
sys.exit(1)
|
||||
|
||||
im = Image.open(xbmfilename)
|
||||
imname = "image"
|
||||
with open(xbmfilename, 'r') as fh:
|
||||
pattern = r'static\s+unsigned\s+char\s+(\w+)_bits$$$$'
|
||||
for line in fh:
|
||||
match = re.search(pattern, line)
|
||||
if match:
|
||||
imname = match.group(1)
|
||||
break
|
||||
bytecount = int(im.width * im.height / 8)
|
||||
|
||||
print(f"#ifndef _{imname.upper()}_H_")
|
||||
print(f"#define _{imname.upper()}_H_ 1\n")
|
||||
print(f"#define {imname}_width {im.width}")
|
||||
print(f"#define {imname}_height {im.height}")
|
||||
print(f"const unsigned char {imname}_bits[{bytecount}] PROGMEM = {{")
|
||||
|
||||
n = 0
|
||||
print(" ", end='')
|
||||
f = im.tobytes()
|
||||
|
||||
switched_bytes = bytearray()
|
||||
for i in range(0, len(f), 2):
|
||||
# Switch LSB and MSB
|
||||
switched_bytes.append(f[i + 1]) # Append MSB
|
||||
switched_bytes.append(f[i]) # Append LSB
|
||||
|
||||
#for b in im.tobytes():
|
||||
for b in switched_bytes:
|
||||
#b2 = 0
|
||||
#for i in range(8):
|
||||
# # b2 |= ((b >> i) & 1) << (7 - i)
|
||||
# b2 <<= 1
|
||||
# b2 |= b & 1
|
||||
# b >>= 1
|
||||
n += 1
|
||||
print(f"0x{b:02x}", end='')
|
||||
if n < bytecount:
|
||||
print(', ', end='')
|
||||
if n % 12 == 0:
|
||||
print("\n ", end='')
|
||||
print("};\n\n#endif")
|
||||
Reference in New Issue
Block a user