First init.
This commit is contained in:
33
libraries/Adafruit_SSD1306/scripts/Makefile
Normal file
33
libraries/Adafruit_SSD1306/scripts/Makefile
Normal file
@@ -0,0 +1,33 @@
|
||||
|
||||
PY=python3
|
||||
|
||||
define HEADER
|
||||
/**
|
||||
* This file is autogenerated, do not edit.
|
||||
* Run `make` from the scripts directory to produce splash.h
|
||||
*
|
||||
* Splashes will be stored in PROGMEM (flash).
|
||||
* If SSD1306_NO_SPLASH is defined, the splashes are omitted.
|
||||
*/
|
||||
|
||||
#ifndef SSD1306_NO_SPLASH
|
||||
/* clang-format off */
|
||||
endef
|
||||
|
||||
define FOOTER
|
||||
/* clang-format on */
|
||||
#endif
|
||||
endef
|
||||
|
||||
export HEADER
|
||||
export FOOTER
|
||||
|
||||
splash.h: make_splash.py splash1.png splash2.png
|
||||
echo "$$HEADER" > $@
|
||||
${PY} make_splash.py splash1.png splash1 >>$@
|
||||
${PY} make_splash.py splash2.png splash2 >>$@
|
||||
echo "$$FOOTER" >> $@
|
||||
|
||||
clean:
|
||||
rm -f splash.h
|
||||
|
||||
38
libraries/Adafruit_SSD1306/scripts/make_splash.py
Normal file
38
libraries/Adafruit_SSD1306/scripts/make_splash.py
Normal file
@@ -0,0 +1,38 @@
|
||||
#!/usr/bin/env python3
|
||||
# pip install pillow to get the PIL module
|
||||
|
||||
import sys
|
||||
from PIL import Image
|
||||
|
||||
def main(fn, id):
|
||||
image = Image.open(fn)
|
||||
print("\n"
|
||||
"#define {id}_width {w}\n"
|
||||
"#define {id}_height {h}\n"
|
||||
"\n"
|
||||
"const uint8_t PROGMEM {id}_data[] = {{\n"
|
||||
.format(id=id, w=image.width, h=image.height), end='')
|
||||
for y in range(0, image.height):
|
||||
for x in range(0, (image.width + 7)//8 * 8):
|
||||
if x == 0:
|
||||
print(" ", end='')
|
||||
if x % 8 == 0:
|
||||
print("0b", end='')
|
||||
|
||||
bit = '0'
|
||||
if x < image.width and image.getpixel((x,y)) != 0:
|
||||
bit = '1'
|
||||
print(bit, end='')
|
||||
|
||||
if x % 8 == 7:
|
||||
print(",", end='')
|
||||
print()
|
||||
print("};")
|
||||
|
||||
if __name__ == '__main__':
|
||||
if len(sys.argv) < 3:
|
||||
print("Usage: {} <imagefile> <id>\n".format(sys.argv[0]), file=sys.stderr);
|
||||
sys.exit(1)
|
||||
fn = sys.argv[1]
|
||||
id = sys.argv[2]
|
||||
main(fn, id)
|
||||
BIN
libraries/Adafruit_SSD1306/scripts/splash1.png
Normal file
BIN
libraries/Adafruit_SSD1306/scripts/splash1.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 471 B |
BIN
libraries/Adafruit_SSD1306/scripts/splash2.png
Normal file
BIN
libraries/Adafruit_SSD1306/scripts/splash2.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 417 B |
Reference in New Issue
Block a user