build: add some pixmaps for the oled UI, and generated rust code at build time
This commit is contained in:
@@ -132,3 +132,6 @@ incremental = false
|
|||||||
lto = 'fat'
|
lto = 'fat'
|
||||||
opt-level = 's'
|
opt-level = 's'
|
||||||
overflow-checks = false
|
overflow-checks = false
|
||||||
|
|
||||||
|
[build-dependencies]
|
||||||
|
image = "0.25.8"
|
||||||
|
|||||||
12
assets/bike.pbm
Normal file
12
assets/bike.pbm
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
P1
|
||||||
|
# Created by GIMP version 3.0.4 PNM plug-in
|
||||||
|
32 19
|
||||||
|
0000000011100000000000001100000000000001010000000000111100000000000000
|
||||||
|
0101000000000000100000000000000000010000011111110000000000000000000111
|
||||||
|
1110000000100000000000000000110000000000001000000000000000001000000001
|
||||||
|
1100010000000000000110111000000010000101100000000110011001110001000001
|
||||||
|
1001100000100010010000111100001010000100010000100010000011110100010000
|
||||||
|
1001000100001000001000111001000010100001000001000100001001111000011000
|
||||||
|
0000000100111000100000000001010000000010000000000100000000100100000000
|
||||||
|
1000000000010000000010001000000100000000000010000001000001100110000000
|
||||||
|
000000011001100000000110000000000000000001100000
|
||||||
7
assets/brakelight-off.pbm
Normal file
7
assets/brakelight-off.pbm
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
P1
|
||||||
|
# Created by GIMP version 3.0.4 PNM plug-in
|
||||||
|
17 14
|
||||||
|
0000001100000000000001100100000000000100001000000000010000010000000001
|
||||||
|
0000001000000000100000010000000010000000100000000100000001000000000100
|
||||||
|
0000100000000010000001000000000010000010000000000010000100000000000011
|
||||||
|
0010000000000000011000000000
|
||||||
7
assets/brakelight-on.pbm
Normal file
7
assets/brakelight-on.pbm
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
P1
|
||||||
|
# Created by GIMP version 3.0.4 PNM plug-in
|
||||||
|
17 14
|
||||||
|
0000001100000011000001111100011000000111111011000000011111110000001101
|
||||||
|
1111111000111000111111110110000011111111100000000111111111000000000111
|
||||||
|
1111101100000011111111000111000011111110000001100011111101100000000011
|
||||||
|
1110001100000000011000000110
|
||||||
7
assets/gps-off.pbm
Normal file
7
assets/gps-off.pbm
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
P1
|
||||||
|
# Created by GIMP version 3.0.4 PNM plug-in
|
||||||
|
16 16
|
||||||
|
0100001111000010111001000010011101111011110111100011111001111100000111
|
||||||
|
0000111000000111100111100000010111111010000000101111010000000010111101
|
||||||
|
0000000001111110000000001110011100000001111001111000001110100101110001
|
||||||
|
1100011000111011100001100001110100000000000010
|
||||||
7
assets/gps-on.pbm
Normal file
7
assets/gps-on.pbm
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
P1
|
||||||
|
# Created by GIMP version 3.0.4 PNM plug-in
|
||||||
|
16 16
|
||||||
|
0000001111000000000001111110000000001111111100000001111001111000000111
|
||||||
|
0000111000000111000011100000011110011110000000111111110000000011111111
|
||||||
|
0000000001111110000000000111111000000000001111000000000000111100000000
|
||||||
|
0000011000000000000001100000000000000000000000
|
||||||
7
assets/headlight-off.pbm
Normal file
7
assets/headlight-off.pbm
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
P1
|
||||||
|
# Created by GIMP version 3.0.4 PNM plug-in
|
||||||
|
17 14
|
||||||
|
0000000001100000000000000100110000000000001000010000000000010000010000
|
||||||
|
0000001000000100000000010000001000000000100000001000000001000000010000
|
||||||
|
0000100000010000000001000000100000000010000010000000000100001000000000
|
||||||
|
0010011000000000000011000000
|
||||||
7
assets/headlight-on.pbm
Normal file
7
assets/headlight-on.pbm
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
P1
|
||||||
|
# Created by GIMP version 3.0.4 PNM plug-in
|
||||||
|
17 14
|
||||||
|
0110000001100000000011000111110000000001101111110001100000011111110000
|
||||||
|
1110001111111100000011011111111000000000111111111000000001111111110000
|
||||||
|
0110111111110001110001111111101100000011111110000000110111111000000110
|
||||||
|
0011111000001100000011000000
|
||||||
7
assets/imu-off.pbm
Normal file
7
assets/imu-off.pbm
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
P1
|
||||||
|
# Created by GIMP version 3.0.4 PNM plug-in
|
||||||
|
16 16
|
||||||
|
0100001000000010111001010000011101111000100011100011110101011100000111
|
||||||
|
0110111000000011110111000000000111111010000000011111010100000001111111
|
||||||
|
1010000001111110000100001111111110100101110000111100101110000001110011
|
||||||
|
1100000000111011101000000001110111000000000010
|
||||||
7
assets/imu-on.pbm
Normal file
7
assets/imu-on.pbm
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
P1
|
||||||
|
# Created by GIMP version 3.0.4 PNM plug-in
|
||||||
|
16 16
|
||||||
|
0000001000000000000001010000000000001000100000000001010101000000000011
|
||||||
|
0110000000000001010000000000000101000010000000010100010100000001011111
|
||||||
|
1010000001000000000100001011111110100101010000010100101010000000100010
|
||||||
|
0100000000000010001000000000000111000000000000
|
||||||
52
build.rs
52
build.rs
@@ -1,7 +1,59 @@
|
|||||||
|
use std::fs;
|
||||||
|
use std::io::Write;
|
||||||
|
use std::path::Path;
|
||||||
|
use std::fs::File;
|
||||||
|
use image::GenericImageView;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
linker_be_nice();
|
linker_be_nice();
|
||||||
// make sure linkall.x is the last linker script (otherwise might cause problems with flip-link)
|
// make sure linkall.x is the last linker script (otherwise might cause problems with flip-link)
|
||||||
println!("cargo:rustc-link-arg=-Tlinkall.x");
|
println!("cargo:rustc-link-arg=-Tlinkall.x");
|
||||||
|
|
||||||
|
let asset_path = Path::new("assets");
|
||||||
|
|
||||||
|
let mut image_output = File::create(Path::new("target/images.rs")).unwrap();
|
||||||
|
for image in fs::read_dir(asset_path).unwrap() {
|
||||||
|
let fname = image.unwrap().file_name();
|
||||||
|
let fname_str = fname.to_str().unwrap();
|
||||||
|
if fname_str.ends_with(".pbm") {
|
||||||
|
let img = image::open(asset_path.join(fname_str)).unwrap();
|
||||||
|
let img_name = fname_str.rsplit_once('.').unwrap().0.to_uppercase().replace("-", "_");
|
||||||
|
|
||||||
|
let mut converted_row = Vec::new();
|
||||||
|
let mut byte_buf = String::new();
|
||||||
|
image_output.write_all(format!("pub const {img_name}: ImageRaw<BinaryColor> = ImageRaw::new(&[\n").as_bytes()).unwrap();
|
||||||
|
for (x, _, pixel) in img.pixels() {
|
||||||
|
if pixel.0 == [0, 0, 0, 255] {
|
||||||
|
byte_buf.push('1');
|
||||||
|
} else {
|
||||||
|
byte_buf.push('0');
|
||||||
|
}
|
||||||
|
if byte_buf.len() == 8 {
|
||||||
|
converted_row.push(byte_buf);
|
||||||
|
byte_buf = String::new();
|
||||||
|
}
|
||||||
|
if x == img.width() - 1 {
|
||||||
|
if !byte_buf.is_empty() {
|
||||||
|
byte_buf.push('_');
|
||||||
|
for _ in 0..(9 - byte_buf.len()) {
|
||||||
|
byte_buf.push('0');
|
||||||
|
}
|
||||||
|
converted_row.push(byte_buf);
|
||||||
|
byte_buf = String::new();
|
||||||
|
}
|
||||||
|
image_output.write_all(b" ").unwrap();
|
||||||
|
for pix in converted_row.iter() {
|
||||||
|
image_output.write_all(format!("0b{pix}, ").as_bytes()).unwrap();
|
||||||
|
}
|
||||||
|
image_output.write_all(b"\n").unwrap();
|
||||||
|
converted_row = Vec::new();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
image_output.write_all(format!("], {});\n", img.width()).as_bytes()).unwrap();
|
||||||
|
println!("cargo::rerun-if-changed={fname_str}");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn linker_be_nice() {
|
fn linker_be_nice() {
|
||||||
|
|||||||
Reference in New Issue
Block a user