Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/bus/eightbit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::{
error::{Error, Port, Result},
};

#[derive(Debug, Clone, Copy)]
#[derive(Clone, Copy)]
pub struct EightBitBusPins<RS, EN, D0, D1, D2, D3, D4, D5, D6, D7> {
pub rs: RS,
pub en: EN,
Expand All @@ -20,6 +20,14 @@ pub struct EightBitBusPins<RS, EN, D0, D1, D2, D3, D4, D5, D6, D7> {
pub d7: D7,
}

impl<RS, EN, D0, D1, D2, D3, D4, D5, D6, D7> core::fmt::Debug
for EightBitBusPins<RS, EN, D0, D1, D2, D3, D4, D5, D6, D7>
{
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("EightBitBusPins").finish()
}
}

#[derive(Debug)]
pub struct EightBitBus<
RS: OutputPin,
Expand Down
9 changes: 8 additions & 1 deletion src/bus/fourbit.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
use embedded_hal::delay::DelayNs;
use core::fmt::Debug;
use embedded_hal::digital::{self, OutputPin};

use crate::bus::DataBus;
use crate::error::{Error, Port, Result};

#[derive(Debug, Clone, Copy)]
#[derive(Clone, Copy)]
pub struct FourBitBusPins<RS, EN, D4, D5, D6, D7> {
pub rs: RS,
pub en: EN,
Expand All @@ -14,6 +15,12 @@ pub struct FourBitBusPins<RS, EN, D4, D5, D6, D7> {
pub d7: D7,
}

impl<RS, EN, D4, D5, D6, D7> Debug for FourBitBusPins<RS, EN, D4, D5, D6, D7> {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
f.debug_struct("FourBitBusPins").finish()
}
}

#[derive(Debug)]
pub struct FourBitBus<RS: OutputPin, EN: OutputPin, D4: OutputPin, D5: OutputPin, D6: OutputPin, D7: OutputPin> {
pins: FourBitBusPins<RS, EN, D4, D5, D6, D7>,
Expand Down
35 changes: 33 additions & 2 deletions src/setup/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ pub(crate) mod non_blocking;
#[derive(Debug, Clone, Copy)]
pub struct Unspecified;

#[derive(Debug, Clone, Copy)]
#[derive(Clone, Copy)]
pub struct DisplayOptions8Bit<M: DisplayMemoryMap, C: CharsetWithFallback, RS, EN, D0, D1, D2, D3, D4, D5, D6, D7> {
/// Memory map used for mapping 2D coordinates to the display.
pub memory_map: M,
Expand All @@ -24,7 +24,23 @@ pub struct DisplayOptions8Bit<M: DisplayMemoryMap, C: CharsetWithFallback, RS, E
pub pins: EightBitBusPins<RS, EN, D0, D1, D2, D3, D4, D5, D6, D7>,
}

#[derive(Debug, Clone, Copy)]
impl<M, C, RS, EN, D0, D1, D2, D3, D4, D5, D6, D7> core::fmt::Debug
for DisplayOptions8Bit<M, C, RS, EN, D0, D1, D2, D3, D4, D5, D6, D7>
where
M: DisplayMemoryMap + core::fmt::Debug,
C: CharsetWithFallback + core::fmt::Debug,
{
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
f.debug_struct("DisplayOptions4Bit")
.field("memory_map", &self.memory_map)
.field("charset", &self.charset)
.field("entry_mode", &self.entry_mode)
.field("pins", &self.pins)
.finish()
}
}

#[derive(Clone, Copy)]
pub struct DisplayOptions4Bit<M: DisplayMemoryMap, C: CharsetWithFallback, RS, EN, D4, D5, D6, D7> {
/// Memory map used for mapping 2D coordinates to the display.
pub memory_map: M,
Expand All @@ -34,6 +50,21 @@ pub struct DisplayOptions4Bit<M: DisplayMemoryMap, C: CharsetWithFallback, RS, E
pub pins: FourBitBusPins<RS, EN, D4, D5, D6, D7>,
}

impl<M, C, RS, EN, D4, D5, D6, D7> core::fmt::Debug for DisplayOptions4Bit<M, C, RS, EN, D4, D5, D6, D7>
where
M: DisplayMemoryMap + core::fmt::Debug,
C: CharsetWithFallback + core::fmt::Debug,
{
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
f.debug_struct("DisplayOptions4Bit")
.field("memory_map", &self.memory_map)
.field("charset", &self.charset)
.field("entry_mode", &self.entry_mode)
.field("pins", &self.pins)
.finish()
}
}

pub struct DisplayOptionsI2C<M: DisplayMemoryMap, C: CharsetWithFallback, I2C> {
/// Memory map used for mapping 2D coordinates to the display.
pub memory_map: M,
Expand Down