Skip to content

Commit 78fee5a

Browse files
authored
Merge pull request #176 from vhdirk/graphics
fix build when feature graphics is not enabled
2 parents d77a57a + d5286a8 commit 78fee5a

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

src/color.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ pub enum OctColor {
6666
}
6767

6868
/// Color trait for use in `Display`s
69-
pub trait ColorType: PixelColor {
69+
pub trait ColorType {
7070
/// Number of bit used to represent this color type in a single buffer.
7171
/// To get the real number of bits per pixel you should multiply this by `BUFFER_COUNT`
7272
const BITS_PER_PIXEL_PER_BUFFER: usize;

src/graphics.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ pub struct Display<
5151
const HEIGHT: u32,
5252
const BWRBIT: bool,
5353
const BYTECOUNT: usize,
54-
COLOR: ColorType,
54+
COLOR: ColorType + PixelColor,
5555
> {
5656
buffer: [u8; BYTECOUNT],
5757
rotation: DisplayRotation,
@@ -63,7 +63,7 @@ impl<
6363
const HEIGHT: u32,
6464
const BWRBIT: bool,
6565
const BYTECOUNT: usize,
66-
COLOR: ColorType,
66+
COLOR: ColorType + PixelColor,
6767
> Default for Display<WIDTH, HEIGHT, BWRBIT, BYTECOUNT, COLOR>
6868
{
6969
/// Initialize display with the color '0', which may not be the same on all device.
@@ -91,7 +91,7 @@ impl<
9191
const HEIGHT: u32,
9292
const BWRBIT: bool,
9393
const BYTECOUNT: usize,
94-
COLOR: ColorType,
94+
COLOR: ColorType + PixelColor,
9595
> DrawTarget for Display<WIDTH, HEIGHT, BWRBIT, BYTECOUNT, COLOR>
9696
{
9797
type Color = COLOR;
@@ -114,7 +114,7 @@ impl<
114114
const HEIGHT: u32,
115115
const BWRBIT: bool,
116116
const BYTECOUNT: usize,
117-
COLOR: ColorType,
117+
COLOR: ColorType + PixelColor,
118118
> OriginDimensions for Display<WIDTH, HEIGHT, BWRBIT, BYTECOUNT, COLOR>
119119
{
120120
fn size(&self) -> Size {
@@ -130,7 +130,7 @@ impl<
130130
const HEIGHT: u32,
131131
const BWRBIT: bool,
132132
const BYTECOUNT: usize,
133-
COLOR: ColorType,
133+
COLOR: ColorType + PixelColor,
134134
> Display<WIDTH, HEIGHT, BWRBIT, BYTECOUNT, COLOR>
135135
{
136136
/// get internal buffer to use it (to draw in epd)
@@ -182,7 +182,7 @@ impl<const WIDTH: u32, const HEIGHT: u32, const BWRBIT: bool, const BYTECOUNT: u
182182
/// Same as `Display`, except that its characteristics are defined at runtime.
183183
/// See display for documentation as everything is the same except that default
184184
/// is replaced by a `new` method.
185-
pub struct VarDisplay<'a, COLOR: ColorType> {
185+
pub struct VarDisplay<'a, COLOR: ColorType + PixelColor> {
186186
width: u32,
187187
height: u32,
188188
bwrbit: bool,
@@ -192,7 +192,7 @@ pub struct VarDisplay<'a, COLOR: ColorType> {
192192
}
193193

194194
/// For use with embedded_grahics
195-
impl<'a, COLOR: ColorType> DrawTarget for VarDisplay<'a, COLOR> {
195+
impl<'a, COLOR: ColorType + PixelColor> DrawTarget for VarDisplay<'a, COLOR> {
196196
type Color = COLOR;
197197
type Error = core::convert::Infallible;
198198

@@ -208,7 +208,7 @@ impl<'a, COLOR: ColorType> DrawTarget for VarDisplay<'a, COLOR> {
208208
}
209209

210210
/// For use with embedded_grahics
211-
impl<'a, COLOR: ColorType> OriginDimensions for VarDisplay<'a, COLOR> {
211+
impl<'a, COLOR: ColorType + PixelColor> OriginDimensions for VarDisplay<'a, COLOR> {
212212
fn size(&self) -> Size {
213213
match self.rotation {
214214
DisplayRotation::Rotate0 | DisplayRotation::Rotate180 => {
@@ -228,7 +228,7 @@ pub enum VarDisplayError {
228228
BufferTooSmall,
229229
}
230230

231-
impl<'a, COLOR: ColorType> VarDisplay<'a, COLOR> {
231+
impl<'a, COLOR: ColorType + PixelColor> VarDisplay<'a, COLOR> {
232232
/// You must allocate the buffer by yourself, it must be large enough to contain all pixels.
233233
///
234234
/// Parameters are documented in `Display` as they are the same as the const generics there.
@@ -312,7 +312,7 @@ impl<'a> VarDisplay<'a, TriColor> {
312312
// It sets a specific pixel in a buffer to a given color.
313313
// The big number of parameters is due to the fact that it is an internal function to both
314314
// strctures.
315-
fn set_pixel<COLOR: ColorType>(
315+
fn set_pixel<COLOR: ColorType + PixelColor>(
316316
buffer: &mut [u8],
317317
width: u32,
318318
height: u32,

0 commit comments

Comments
 (0)