include display driver,

and use rust_tls to make crosscompile easy
This commit is contained in:
2025-09-03 03:47:52 +02:00
parent a10f466538
commit b1b4356686
17 changed files with 3240 additions and 1534 deletions

View File

@@ -1,73 +1,37 @@
use embedded_graphics::{
mono_font::{MonoTextStyle, ascii::FONT_6X10},
pixelcolor::Gray8,
};
use image::{GrayImage, Pixel, RgbImage};
pub mod graphics;
pub mod traits;
pub mod color;
pub mod rect;
/// Interface for the physical connection between display and the controlling device
pub mod interface;
pub mod epd7in5_v2;
pub mod display;
pub mod killinfo;
pub mod model;
pub mod services;
pub mod epaper;
pub mod type_a;
use crate::killinfo::KillInfo;
use crate::services::esi_static::EsiClient;
use crate::services::zkill::ZkillClient;
fn rgb_to_gray8(img: &RgbImage) -> GrayImage {
let mut gray = GrayImage::new(img.width(), img.height());
for (x, y, pixel) in img.enumerate_pixels() {
let luma = pixel.to_luma()[0]; // simple conversion
gray.put_pixel(x, y, image::Luma([luma]));
}
gray
pub const fn buffer_len(width: usize, height: usize) -> usize {
(width + 7) / 8 * height
}
// Example function to render kill info on a display buffer
fn render_killmails(killmails: &[KillInfo], buffer: &mut GrayImage, x_off: i64) {
let mut y_offset = 0;
for k in killmails {
// Draw victim portrait
if let Some(alli) = &k.victim.alliance {
let logo = &alli.logo;
let gray_logo = rgb_to_gray8(logo);
// copy portrait into buffer at (0, y_offset)
image::imageops::overlay(buffer, &gray_logo, x_off + 0, y_offset as i64);
}
if let Some(ship) = &k.victim.ship {
let icon = &ship.icon;
let gray_icon = rgb_to_gray8(icon);
// copy portrait into buffer at (0, y_offset)
image::imageops::overlay(buffer, &gray_icon, x_off + 64, y_offset as i64);
}
// Draw victim name
//let text_style = MonoTextStyle::new(&FONT_6X10, Gray8::new(255));
// You can use embedded_graphics Text or a real framebuffer draw function
// Example with embedded_graphics (requires DrawTarget)
// Text::new(&k.victim.character.name, Point::new(50, y_offset as i32), text_style)
// .draw(display)?;
// Draw system name and value
println!(
"{} {:.2}M ISK in {}",
k.victim.character.name,
k.total_value / 1_000_000.0,
k.system_name
);
// Advance y offset
y_offset += 60; // adjust spacing
if y_offset >= buffer.height() as usize {
break;
}
}
}
fn main() {
// Simulated 800x480 grayscale display buffer
let mut buffer = GrayImage::new(800, 480);
let esi = EsiClient::new();
let zkill = ZkillClient::new();
@@ -76,6 +40,12 @@ fn main() {
let my_corp_id = 98685373;
let mut display = display::Display::new();
let mut epaper = epaper::EPaper::new().expect("DisplayError");
display.clear(true);
epaper.clear(true);
epaper.flush().expect("flush error");
let response = zkill
.get_corporation_kills(my_corp_id, past_seconds)
@@ -95,6 +65,7 @@ fn main() {
let y : i32 = ii * 60;
display.draw_kill_info(k, 0, y);
epaper.draw_kill_info(k, 0, y);
}
let response = zkill
@@ -112,11 +83,12 @@ fn main() {
let ii = i as i32;
let y : i32 = ii * 60;
display.draw_kill_info(k, 400, y);
display.draw_loss_info(k, 400, y);
epaper.draw_loss_info(k, 400, y);
}
display.flush();;
display.flush();
epaper.flush().expect("flush error");
// Save buffer for debugging
buffer.save("killmails_display.png").unwrap();
}