mirror of
https://github.com/Feliix42/ssd1675.git
synced 2024-11-21 18:36:30 +00:00
Fixes for embedded-graphics 0.8
This commit is contained in:
parent
45b00687aa
commit
1d4ee1a2e9
1 changed files with 51 additions and 1 deletions
52
src/color.rs
52
src/color.rs
|
@ -15,7 +15,7 @@ extern crate embedded_graphics;
|
||||||
#[cfg(feature = "graphics")]
|
#[cfg(feature = "graphics")]
|
||||||
use self::embedded_graphics::pixelcolor::raw::RawU8;
|
use self::embedded_graphics::pixelcolor::raw::RawU8;
|
||||||
#[cfg(feature = "graphics")]
|
#[cfg(feature = "graphics")]
|
||||||
use self::embedded_graphics::pixelcolor::{BinaryColor, Rgb888, RgbColor};
|
use self::embedded_graphics::pixelcolor::{BinaryColor, Rgb555, Rgb565, Rgb888, RgbColor};
|
||||||
#[cfg(feature = "graphics")]
|
#[cfg(feature = "graphics")]
|
||||||
use self::embedded_graphics::prelude::*;
|
use self::embedded_graphics::prelude::*;
|
||||||
#[cfg(feature = "graphics")]
|
#[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)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
Loading…
Reference in a new issue