1
0
Fork 0

show animation

main
radex 2024-03-23 19:06:39 +01:00
parent 35a37f0372
commit 5e7421ec82
Signed by: radex
SSH Key Fingerprint: SHA256:hvqRXAGG1h89yqnS+cyFTLKQbzjWD4uXIqw7Y+0ws30
27 changed files with 667 additions and 31 deletions

BIN
firmware/gfx/01.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 142 B

BIN
firmware/gfx/02.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 142 B

BIN
firmware/gfx/03.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 142 B

BIN
firmware/gfx/04.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 142 B

BIN
firmware/gfx/05.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 142 B

BIN
firmware/gfx/06.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 142 B

BIN
firmware/gfx/07.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 142 B

BIN
firmware/gfx/08.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 142 B

BIN
firmware/gfx/09.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 142 B

BIN
firmware/gfx/10.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 142 B

BIN
firmware/gfx/11.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 142 B

BIN
firmware/gfx/12.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 142 B

BIN
firmware/gfx/13.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 142 B

BIN
firmware/gfx/14.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 142 B

BIN
firmware/gfx/15.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 142 B

BIN
firmware/gfx/16.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 142 B

BIN
firmware/gfx/17.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 138 B

BIN
firmware/gfx/18.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 142 B

BIN
firmware/gfx/19.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 142 B

BIN
firmware/gfx/20.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 142 B

BIN
firmware/gfx/21.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 142 B

BIN
firmware/gfx/22.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 142 B

BIN
firmware/gfx/23.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 142 B

BIN
firmware/gfx/24.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 142 B

View File

@ -0,0 +1,55 @@
# read gfx folder
import os
import sys
import PIL
from PIL import Image
def get_all_gfx():
gfx = []
for root, dirs, files in os.walk("gfx"):
for file in files:
# file name without extention
name = os.path.splitext(file)[0]
gfx.append((name, os.path.join(root, file)))
gfx.sort()
return gfx
def to_code(name, path):
img = Image.open(path)
img = img.convert("1", dither=Image.Dither.FLOYDSTEINBERG)
w, h = img.size
colors = img.getcolors()
print(colors)
code = f"uint32_t gfx_{name}[{h}] = {'{'}\n"
for y in range(h):
code += " 0b"
for x in range(w):
px = img.getpixel((x, y))
code += '1' if px == 0 else '0'
code += ",\n"
code += "};\n\n"
return code
if __name__ == "__main__":
gfx = get_all_gfx()
gfx_code = ''.join(to_code(name, path) for name, path in gfx)
header = f"#pragma once\n#include <Arduino.h>\n\n/* DO NOT MODIFY - AUTOGENERATED! */\n\n"
index = f"uint32_t* frames[{len(gfx)}] = {'{'}\n"
for name, _ in gfx:
index += f" gfx_{name},\n"
index += "};\n"
with open("src/gfx.h", "w") as f:
f.write(header)
f.write("#define GFX_COUNT " + str(len(gfx)) + "\n\n")
f.write(gfx_code)
f.write(index)
print("gfx.h generated!")

585
firmware/src/gfx.h Normal file
View File

@ -0,0 +1,585 @@
#pragma once
#include <Arduino.h>
/* DO NOT MODIFY - AUTOGENERATED! */
#define GFX_COUNT 24
uint32_t gfx_01[20] = {
0b00000000000000010111,
0b00000000000000001111,
0b00000000000000011111,
0b00000011110000001111,
0b00000010010000000111,
0b00000010110000100111,
0b00000011100000001010,
0b00000111100000000001,
0b00001110100000000000,
0b00001010011000000000,
0b00001010000000000000,
0b00000010000000000000,
0b00000010000000000000,
0b00001110000000000000,
0b00011010000000000000,
0b00010001000000000000,
0b00010000100000000000,
0b00010000100000000000,
0b00011000110000000000,
0b00000000000000000000,
};
uint32_t gfx_02[20] = {
0b00000000000000010111,
0b00000000000000001111,
0b00000000000001001111,
0b00000000111100011111,
0b00000000100100000111,
0b00000000101100000111,
0b00000000111000001000,
0b00000001111000000001,
0b00000011101000000000,
0b00000010101000000010,
0b00000100101000000000,
0b00000000100100000000,
0b00000000100000000000,
0b00000001100000000000,
0b00000011110000000000,
0b00000010001000000000,
0b00000010001000000000,
0b00000001000100000000,
0b00000001000100000000,
0b00000000000000000000,
};
uint32_t gfx_03[20] = {
0b00000000000000010111,
0b00000000000000001111,
0b00000000000001001111,
0b00000000000000011111,
0b00000000000111100111,
0b00000000000100100111,
0b00000000000101101000,
0b00000000000111000001,
0b00000000001111000000,
0b00000000011101000010,
0b00000000010101000000,
0b00000000100101000000,
0b00000000000100100000,
0b00000000000100000000,
0b00000000001100000000,
0b00000000011110000000,
0b00000000010001000000,
0b00000000010001000000,
0b00000000001000100000,
0b00000000001000100000,
};
uint32_t gfx_04[20] = {
0b00000000000000010111,
0b00000000000000001111,
0b00000000000001001111,
0b00000000000000011111,
0b00000000000000000111,
0b10000000000000000111,
0b01000000000000111100,
0b01000000000000100101,
0b01000000000000101100,
0b01000000000000111010,
0b10000000000001111000,
0b00000000000011101000,
0b00000000000010101000,
0b00000000000100101000,
0b00000000000000100100,
0b00000000000000100000,
0b00000000000001100000,
0b00000000000011110000,
0b00000000000010001000,
0b00000000000010001000,
};
uint32_t gfx_05[20] = {
0b00000000000000010111,
0b00000000000000001111,
0b00000000000001001111,
0b00000000000000011111,
0b00000000000000000111,
0b01110000000000000111,
0b01001000000000010111,
0b01001000000000000101,
0b01001000000000000101,
0b01001000000000000111,
0b01110000000000001111,
0b00000000000000011101,
0b00000000000000010101,
0b00000000000000100101,
0b00000000000000000100,
0b00000000000000000100,
0b00000000000000001100,
0b00000000000000011110,
0b00000000000000010001,
0b00000000000000010001,
};
uint32_t gfx_06[20] = {
0b00000000000000000010,
0b00000000000000000001,
0b00000000000000001001,
0b00000000000000000011,
0b00000000000000000000,
0b11011100000000000000,
0b00010010000000000010,
0b10010010000000000000,
0b00010010000000000000,
0b00010010000000000000,
0b11011100000000000001,
0b00000000000000000011,
0b00000000000000000010,
0b00000000000000000100,
0b00000000000000000000,
0b00000000000000000000,
0b00000000000000000001,
0b00000000000000000011,
0b00000000000000000010,
0b00000000000000000010,
};
uint32_t gfx_07[20] = {
0b00000000000000000000,
0b00000000000000000000,
0b00000000000000000000,
0b00000000000000000000,
0b00000000000000000000,
0b10111011100000000000,
0b00100010010000000000,
0b00110010010000000000,
0b00100010010000000000,
0b00100010010000000000,
0b10111011100000000000,
0b00000000000000000000,
0b00000000000000000000,
0b00000000000000000000,
0b00000000000000000000,
0b00000000000000000000,
0b00000000000000000000,
0b00000000000000000000,
0b00000000000000000000,
0b00000000000000000000,
};
uint32_t gfx_08[20] = {
0b00000000000000000000,
0b00000000000000000000,
0b00000000000000000000,
0b00000000000000000000,
0b00000000000000000000,
0b11101110111000000000,
0b10001000100100000000,
0b11001100100100000000,
0b10001000100100000000,
0b10001000100100000000,
0b11101110111000000000,
0b00000000000000000000,
0b00000000000000000000,
0b00000000000000000000,
0b00000000000000000000,
0b00000000000000000000,
0b00000000000000000000,
0b00000000000000000000,
0b00000000000000000000,
0b00000000000000000000,
};
uint32_t gfx_09[20] = {
0b00000000000000000000,
0b00000000000000000000,
0b00000000000000000000,
0b00000000000000000000,
0b00000000000000000000,
0b01011101110111000000,
0b01010001000100100000,
0b01011001100100100000,
0b01010001000100100000,
0b01010001000100100000,
0b10011101110111000000,
0b00000000000000000000,
0b00000000000000000000,
0b00000000000000000000,
0b00000000000000000000,
0b00000000000000000000,
0b00000000000000000000,
0b00000000000000000000,
0b00000000000000000000,
0b00000000000000000000,
};
uint32_t gfx_10[20] = {
0b00000000000000000000,
0b00000000000000000000,
0b00000000000000000000,
0b00000000000000000000,
0b00000000000000000000,
0b00010111011101110000,
0b00010100010001001000,
0b00010110011001001000,
0b01010100010001001000,
0b01010100010001001000,
0b10100111011101110000,
0b00000000000000000000,
0b00000000000000000000,
0b00000000000000000000,
0b00000000000000000000,
0b00000000000000000000,
0b00000000000000000000,
0b00000000000000000000,
0b00000000000000000000,
0b00000000000000000000,
};
uint32_t gfx_11[20] = {
0b00000000000000000000,
0b00000000000000000000,
0b00000000000000000000,
0b00000000000000000000,
0b00000000000000000000,
0b01000101110111011100,
0b01000101000100010010,
0b01000101100110010010,
0b01010101000100010010,
0b01010101000100010010,
0b00101001110111011100,
0b00000000000000000000,
0b00000000000000000000,
0b00000000000000000000,
0b00000000000000000000,
0b00000000000000000000,
0b00000000000000000000,
0b00000000000000000000,
0b00000000000000000000,
0b00000000000000000000,
};
uint32_t gfx_12[20] = {
0b00000000001000000000,
0b00000000001000000000,
0b00000000001000000000,
0b00000000000000000000,
0b00000000000000000000,
0b01000101110111011100,
0b01000101000100010010,
0b01000101100110010010,
0b01010101000100010010,
0b01010101000100010010,
0b00101001110111011100,
0b00000000001000100000,
0b00000000000000000000,
0b00000000000000000010,
0b01000000000000000000,
0b00000000000000000000,
0b00000001100000000000,
0b00000000000000000000,
0b10010000010000000000,
0b00000000000001000000,
};
uint32_t gfx_13[20] = {
0b00000000001010100100,
0b00001000011010010000,
0b00000000111001000000,
0b00000000000000000001,
0b00000010101000010000,
0b01000101111111011101,
0b01010101000100010010,
0b01000111100111011110,
0b01010101000100110111,
0b01010101000100010110,
0b01101001110111011100,
0b00000000011110110010,
0b00011000001100000000,
0b01001000000010001010,
0b01000000000010000011,
0b00100000000000010000,
0b00100001100001010000,
0b00000000000000000000,
0b11010000010000000000,
0b00000000000001000000,
};
uint32_t gfx_14[20] = {
0b00100000001111100100,
0b10011000111111010000,
0b00001000111101000000,
0b00110101011101000001,
0b00001010101101110000,
0b01110111111111111111,
0b01011111111101011010,
0b11010111110111111110,
0b01110101110110111111,
0b01111111000110110110,
0b11111011110111011111,
0b01110000011111110011,
0b10111101011101000001,
0b01011111001010111110,
0b01101000001011100011,
0b00110010000000011000,
0b10101011111011010110,
0b00001000000000110001,
0b11111111110110001110,
0b00100001100001000000,
};
uint32_t gfx_15[20] = {
0b01100000101111110111,
0b11011100111111011001,
0b00111110111101100000,
0b01110101111111110001,
0b10001111111111111000,
0b11110111111111111111,
0b01011111111111111010,
0b11110111110111111111,
0b01110111110111111111,
0b01111111101111110110,
0b11111111111111111111,
0b01111101011111110111,
0b10111101011111111111,
0b11111111111011111111,
0b01101000101011100111,
0b01110110111010011110,
0b10101011111111010110,
0b01111100000010111011,
0b11111111111111111110,
0b00110011110111011001,
};
uint32_t gfx_16[20] = {
0b11111111101111110111,
0b11011111111111111111,
0b01111111111101101111,
0b01111101111111111111,
0b10011111111111111101,
0b11111111111111111111,
0b11011111111111111011,
0b11110111111111111111,
0b11111111111111111111,
0b01111111111111110110,
0b11111111111111111111,
0b11111111111111110111,
0b10111111111111111111,
0b11111111111111111111,
0b11111111101011101111,
0b11111111111111011111,
0b11101111111111111110,
0b11111111101111111111,
0b11111111111111111111,
0b00110111111111111111,
};
uint32_t gfx_17[20] = {
0b11111111111111111111,
0b11111111111111111111,
0b11111111111111111111,
0b11111111111111111111,
0b11111111111111111111,
0b11111111111111111111,
0b11111111111111111111,
0b11111111111111111111,
0b11111111111111111111,
0b11111111111111111111,
0b11111111111111111111,
0b11111111111111111111,
0b11111111111111111111,
0b11111111111111111111,
0b11111111111111111111,
0b11111111111111111111,
0b11111111111111111111,
0b11111111111111111111,
0b11111111111111111111,
0b11111111111111111111,
};
uint32_t gfx_18[20] = {
0b01110111011101110111,
0b11111111111111111111,
0b11011111110111111101,
0b11111111111111111111,
0b01110111011101110111,
0b11111111111111111111,
0b11011101110111011101,
0b11111111111111111111,
0b01110111011101110111,
0b11111111111111111111,
0b11011111110111111101,
0b11111111111111111111,
0b01110111011101110111,
0b11111111111111111111,
0b11011101110111011101,
0b11111111111111111111,
0b01110111011101110111,
0b11111111111111111111,
0b11011111110111111101,
0b11111111111111111111,
};
uint32_t gfx_19[20] = {
0b01010101010101010101,
0b11111111111111111111,
0b01010101010101010101,
0b11111111111111111111,
0b01010101010101010101,
0b11111111111111111111,
0b01010101010101010101,
0b11111111111111111111,
0b01010101010101010101,
0b11111111111111111111,
0b01010101010101010101,
0b11111111111111111111,
0b01010101010101010101,
0b11111111111111111111,
0b01010101010101010101,
0b11111111111111111111,
0b01010101010101010101,
0b11111111111111111111,
0b01010101010101010101,
0b11111111111111111111,
};
uint32_t gfx_20[20] = {
0b01010101010101010101,
0b10101011101010111010,
0b01010101010101010101,
0b10101010101010101010,
0b01010101010101010101,
0b10111010101110101011,
0b01010101010101010101,
0b10101010101010101010,
0b01010101010101010101,
0b10101011101010111010,
0b01010101010101010101,
0b10101010101010101010,
0b01010101010101010101,
0b10111010101110101011,
0b01010101010101010101,
0b10101010101010101010,
0b01010101010101010101,
0b10101011101010111010,
0b01010101010101010101,
0b10101010101010101010,
};
uint32_t gfx_21[20] = {
0b01010101010101010101,
0b00100010001000100010,
0b01010101010101010101,
0b00001000000010000000,
0b01010101010101010101,
0b00100010001000100010,
0b01010101010101010101,
0b10000000100000001000,
0b01010101010101010101,
0b00100010001000100010,
0b01010101010101010101,
0b00001000000010000000,
0b01010101010101010101,
0b00100010001000100010,
0b01010101010101010101,
0b10000000100000001000,
0b01010101010101010101,
0b00100010001000100010,
0b01010101010101010101,
0b00001000000010000000,
};
uint32_t gfx_22[20] = {
0b00010001000100010001,
0b00000000000000000000,
0b01000101010001010100,
0b00000000000000000000,
0b00010001000100010001,
0b00000000000000000000,
0b01000100010001000100,
0b00000000000000000000,
0b00010001000100010001,
0b00000000000000000000,
0b01000101010001010100,
0b00000000000000000000,
0b00010001000100010001,
0b00000000000000000000,
0b01000100010001000100,
0b00000000000000000000,
0b00010001000100010001,
0b00000000000000000000,
0b01000101010001010100,
0b00000000000000000000,
};
uint32_t gfx_23[20] = {
0b00000000000000000000,
0b00000000000000000000,
0b00000000000000000000,
0b00000111010101100000,
0b00000010010101000000,
0b00000010011101100000,
0b00000010010101000000,
0b00000010010101100000,
0b00000000000000000000,
0b00000000000000000000,
0b11111011000110111100,
0b11111011100110111110,
0b11000011110110110111,
0b11000011110110110011,
0b11110011110110110011,
0b11110011011110110011,
0b11000011011110110011,
0b11000011011110110111,
0b11111011001110111110,
0b11111011001110111100,
};
uint32_t gfx_24[20] = {
0b00000000000000000000,
0b00000000000000000000,
0b00000000000000000000,
0b00000111010101100000,
0b00000010010101000000,
0b00000010011101100000,
0b00000010010101000000,
0b00000010010101100000,
0b00000000000000000000,
0b00000000000000000000,
0b11111011000110111100,
0b11111011100110111110,
0b11000011110110110111,
0b11000011110110110011,
0b11110011110110110011,
0b11110011011110110011,
0b11000011011110110011,
0b11000011011110110111,
0b11111011001110111110,
0b11111011001110111100,
};
uint32_t* frames[24] = {
gfx_01,
gfx_02,
gfx_03,
gfx_04,
gfx_05,
gfx_06,
gfx_07,
gfx_08,
gfx_09,
gfx_10,
gfx_11,
gfx_12,
gfx_13,
gfx_14,
gfx_15,
gfx_16,
gfx_17,
gfx_18,
gfx_19,
gfx_20,
gfx_21,
gfx_22,
gfx_23,
gfx_24,
};

View File

@ -1,4 +1,5 @@
#include <Arduino.h>
#include "gfx.h"
#define COL_SER 0
#define COL_OE 26
@ -12,35 +13,13 @@
#define ROW_SRCLK 5
#define ROW_SRCLR 4
#define ROW_COUNT 24
#define COL_COUNT 21
#define ROW_COUNT 20 //24
#define COL_COUNT 20 //21
uint32_t demo_pic[ROW_COUNT] = {
0b111011001001111011110,
0b010010101010000010000,
0b010010101001110011100,
0b010010011000001010000,
0b111010001011110011110,
0b000000000000000000000,
0b111001110001110001100,
0b100100100001001010010,
0b111000100001110011110,
0b100100100001001010010,
0b100100100001110010010,
0b000000000000000000000,
0b111000001100111001000,
0b100100010010100101000,
0b100100011110111001000,
0b100100010010100001000,
0b111000010010100001110,
0b000000000000000000000,
0b111100100101110111000,
0b100000100101000100100,
0b111000111101100111000,
0b100000100101000100100,
0b111100100101110100100,
0b000000000000000000000,
};
uint8_t frameIndex = 0;
uint16_t frameLastChangedAt;
#define MS_PER_FRAME 150
void printOut() {
Serial.println("------");
@ -120,7 +99,9 @@ void setup() {
digitalWrite(ROW_OE, LOW);
// printOut();
// clear frames
frameIndex = 0;
frameLastChangedAt = millis();
}
void loop() {
@ -129,7 +110,7 @@ void loop() {
printOut();
}
auto b4 = millis();
uint32_t *frame = frames[frameIndex];
// clear columns
digitalWrite(COL_SRCLR, LOW);
@ -152,10 +133,16 @@ void loop() {
digitalWrite(COL_SRCLK, LOW);
}
// clear row
digitalWrite(ROW_SRCLR, LOW);
digitalWrite(ROW_SRCLK, HIGH);
digitalWrite(ROW_SRCLK, LOW);
digitalWrite(ROW_SRCLR, HIGH);
// set column with rows' data
for (int y = 0; y < ROW_COUNT; y++) {
// get value
bool pxValue = demo_pic[ROW_COUNT - 1 - y] & (1 << ((COL_COUNT - 1) - x));
bool pxValue = frame[ROW_COUNT - 1 - y] & (1 << ((COL_COUNT - 1) - x));
digitalWrite(ROW_SER, pxValue);
// push value
digitalWrite(ROW_SRCLK, HIGH);
@ -172,4 +159,13 @@ void loop() {
// enable rows after latch
digitalWrite(ROW_OE, LOW);
}
// next frame
if (millis() - frameLastChangedAt > MS_PER_FRAME) {
frameLastChangedAt = millis();
frameIndex++;
if (frameIndex == GFX_COUNT) {
frameIndex = 0;
}
}
}