mirror of
https://github.com/Feliix42/ssd1675.git
synced 2024-11-23 19:26:31 +00:00
Compare commits
3 commits
89b973b815
...
1d4ee1a2e9
Author | SHA1 | Date | |
---|---|---|---|
1d4ee1a2e9 | |||
45b00687aa | |||
3e23728e35 |
2 changed files with 55 additions and 3 deletions
|
@ -22,7 +22,7 @@ version = "0.2.6"
|
|||
|
||||
[dependencies.embedded-graphics]
|
||||
optional = true
|
||||
version = "0.7.1"
|
||||
version = "0.8.0"
|
||||
|
||||
[dependencies.linux-embedded-hal]
|
||||
optional = true
|
||||
|
@ -30,7 +30,9 @@ version = "0.3.2"
|
|||
|
||||
[dependencies.profont]
|
||||
optional = true
|
||||
version = "0.5.0"
|
||||
#version = "0.6"
|
||||
git = "https://github.com/sambenko/profont"
|
||||
branch = "embedded-graphics-0.8.0-fixes"
|
||||
|
||||
[features]
|
||||
default = ["graphics"]
|
||||
|
|
52
src/color.rs
52
src/color.rs
|
@ -15,7 +15,7 @@ extern crate embedded_graphics;
|
|||
#[cfg(feature = "graphics")]
|
||||
use self::embedded_graphics::pixelcolor::raw::RawU8;
|
||||
#[cfg(feature = "graphics")]
|
||||
use self::embedded_graphics::pixelcolor::{BinaryColor, Rgb888, RgbColor};
|
||||
use self::embedded_graphics::pixelcolor::{BinaryColor, Rgb555, Rgb565, Rgb888, RgbColor};
|
||||
#[cfg(feature = "graphics")]
|
||||
use self::embedded_graphics::prelude::*;
|
||||
#[cfg(feature = "graphics")]
|
||||
|
@ -80,6 +80,56 @@ impl Into<Rgb888> for Color {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "graphics")]
|
||||
impl From<Rgb555> for Color {
|
||||
fn from(value: Rgb555) -> Self {
|
||||
// NOTE(feliix42): This is admittedly a very simplistic approximation, it'd be more
|
||||
// accurate to map the colors accordingly, but since that's an injective mapping anyways,
|
||||
// why not keep it simple for now.
|
||||
match value {
|
||||
Rgb555::WHITE => Color::White,
|
||||
Rgb555::BLACK => Color::Black,
|
||||
_ => Color::Red,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "graphics")]
|
||||
impl Into<Rgb555> for Color {
|
||||
fn into(self) -> Rgb555 {
|
||||
match self {
|
||||
Color::White => Rgb555::WHITE,
|
||||
Color::Black => Rgb555::BLACK,
|
||||
Color::Red => Rgb555::RED,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "graphics")]
|
||||
impl From<Rgb565> for Color {
|
||||
fn from(value: Rgb565) -> Self {
|
||||
// NOTE(feliix42): This is admittedly a very simplistic approximation, it'd be more
|
||||
// accurate to map the colors accordingly, but since that's an injective mapping anyways,
|
||||
// why not keep it simple for now.
|
||||
match value {
|
||||
Rgb565::WHITE => Color::White,
|
||||
Rgb565::BLACK => Color::Black,
|
||||
_ => Color::Red,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "graphics")]
|
||||
impl Into<Rgb565> for Color {
|
||||
fn into(self) -> Rgb565 {
|
||||
match self {
|
||||
Color::White => Rgb565::WHITE,
|
||||
Color::Black => Rgb565::BLACK,
|
||||
Color::Red => Rgb565::RED,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
|
Loading…
Reference in a new issue