Skip to content

Commit

Permalink
Remove default type params
Browse files Browse the repository at this point in the history
  • Loading branch information
bugadani committed Dec 1, 2020
1 parent ad10732 commit 38542a6
Show file tree
Hide file tree
Showing 19 changed files with 24 additions and 34 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ fn main() -> ! {
);

let interface = I2CDIBuilder::new().init(i2c);
let mut disp: GraphicsMode<_> = Builder::new().connect(interface).into();
let mut disp: GraphicsMode<_, _> = Builder::new().connect(interface).into();

disp.init().unwrap();

Expand Down
2 changes: 1 addition & 1 deletion examples/bmp_i2c.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ fn main() -> ! {
);

let interface = I2CDIBuilder::new().init(i2c);
let mut disp: GraphicsMode<_> = Builder::new().connect(interface).into();
let mut disp: GraphicsMode<_, _> = Builder::new().connect(interface).into();
disp.init().unwrap();

let bmp =
Expand Down
2 changes: 1 addition & 1 deletion examples/graphics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ fn main() -> ! {
);

let interface = display_interface_spi::SPIInterfaceNoCS::new(spi, dc);
let mut disp: GraphicsMode<_> = Builder::new().connect(interface).into();
let mut disp: GraphicsMode<_, _> = Builder::new().connect(interface).into();

disp.reset(&mut rst, &mut delay).unwrap();
disp.init().unwrap();
Expand Down
2 changes: 1 addition & 1 deletion examples/graphics_i2c.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ fn main() -> ! {
);

let interface = I2CDIBuilder::new().init(i2c);
let mut disp: GraphicsMode<_> = Builder::new().connect(interface).into();
let mut disp: GraphicsMode<_, _> = Builder::new().connect(interface).into();
disp.init().unwrap();

let yoffset = 20;
Expand Down
1 change: 0 additions & 1 deletion examples/graphics_i2c_128x32.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ fn main() -> ! {
);

let interface = I2CDIBuilder::new().init(i2c);
// Note that, when changing display size, you need to use `GraphicsMode<_, _>`
let mut disp: GraphicsMode<_, _> = Builder::new()
.size(DisplaySize128x32)
.connect(interface)
Expand Down
1 change: 0 additions & 1 deletion examples/graphics_i2c_72x40.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ fn main() -> ! {
);

let interface = I2CDIBuilder::new().init(i2c);
// Note that, when changing display size, you need to use `GraphicsMode<_, _>`
let mut disp: GraphicsMode<_, _> = Builder::new()
.size(DisplaySize72x40)
.connect(interface)
Expand Down
2 changes: 1 addition & 1 deletion examples/image_i2c.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ fn main() -> ! {
);

let interface = I2CDIBuilder::new().init(i2c);
let mut disp: GraphicsMode<_> = Builder::new().connect(interface).into();
let mut disp: GraphicsMode<_, _> = Builder::new().connect(interface).into();
disp.init().unwrap();

let raw: ImageRaw<BinaryColor> = ImageRaw::new(include_bytes!("./rust.raw"), 64, 64);
Expand Down
4 changes: 2 additions & 2 deletions examples/noise_i2c.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
use cortex_m_rt::{entry, exception, ExceptionFrame};
use panic_halt as _;
use rand::prelude::*;
use ssd1306::{mode::displaymode::DisplayModeTrait, prelude::*, Builder, I2CDIBuilder};
use ssd1306::{prelude::*, Builder, I2CDIBuilder};
use stm32f1xx_hal::{
i2c::{BlockingI2c, DutyCycle, Mode},
prelude::*,
Expand Down Expand Up @@ -62,7 +62,7 @@ fn main() -> ! {
);

let interface = I2CDIBuilder::new().init(i2c);
let mut disp: GraphicsMode<_> = Builder::new().connect(interface).into();
let mut disp: GraphicsMode<_, _> = Builder::new().connect(interface).into();
disp.init().unwrap();

let mut props = disp.into_properties();
Expand Down
2 changes: 1 addition & 1 deletion examples/pixelsquare.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ fn main() -> ! {
);

let interface = display_interface_spi::SPIInterfaceNoCS::new(spi, dc);
let mut disp: GraphicsMode<_> = Builder::new().connect(interface).into();
let mut disp: GraphicsMode<_, _> = Builder::new().connect(interface).into();

disp.reset(&mut rst, &mut delay).unwrap();
disp.init().unwrap();
Expand Down
2 changes: 1 addition & 1 deletion examples/rotation_i2c.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ fn main() -> ! {
);

let interface = I2CDIBuilder::new().init(i2c);
let mut disp: GraphicsMode<_> = Builder::new()
let mut disp: GraphicsMode<_, _> = Builder::new()
// Set initial rotation at 90 degrees clockwise
.with_rotation(DisplayRotation::Rotate90)
.connect(interface)
Expand Down
3 changes: 2 additions & 1 deletion examples/rtic_brightness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ type Display = ssd1306::mode::graphics::GraphicsMode<
>,
gpio::gpiob::PB1<gpio::Output<gpio::PushPull>>,
>,
DisplaySize128x64,
>;

#[app(device = stm32f1xx_hal::pac, peripherals = true)]
Expand Down Expand Up @@ -94,7 +95,7 @@ const APP: () = {
);

let interface = display_interface_spi::SPIInterfaceNoCS::new(spi, dc);
let mut display: GraphicsMode<_> = Builder::new()
let mut display: GraphicsMode<_, _> = Builder::new()
.with_rotation(DisplayRotation::Rotate180)
.connect(interface)
.into();
Expand Down
3 changes: 2 additions & 1 deletion examples/rtic_dvd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ type Display = ssd1306::mode::graphics::GraphicsMode<
>,
gpio::gpiob::PB1<gpio::Output<gpio::PushPull>>,
>,
DisplaySize128x64,
>;

#[app(device = stm32f1xx_hal::pac, peripherals = true)]
Expand Down Expand Up @@ -94,7 +95,7 @@ const APP: () = {
);

let interface = display_interface_spi::SPIInterfaceNoCS::new(spi, dc);
let mut display: GraphicsMode<_> = Builder::new()
let mut display: GraphicsMode<_, _> = Builder::new()
.with_rotation(DisplayRotation::Rotate180)
.connect(interface)
.into();
Expand Down
2 changes: 1 addition & 1 deletion examples/terminal_i2c.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ fn main() -> ! {
);

let interface = I2CDIBuilder::new().init(i2c);
let mut disp: TerminalMode<_> = Builder::new().connect(interface).into();
let mut disp: TerminalMode<_, _> = Builder::new().connect(interface).into();
disp.init().unwrap();
let _ = disp.clear();

Expand Down
2 changes: 1 addition & 1 deletion examples/text_i2c.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ fn main() -> ! {
);

let interface = I2CDIBuilder::new().init(i2c);
let mut disp: GraphicsMode<_> = Builder::new().connect(interface).into();
let mut disp: GraphicsMode<_, _> = Builder::new().connect(interface).into();
disp.init().unwrap();

let text_style = TextStyleBuilder::new(Font6x8)
Expand Down
5 changes: 0 additions & 5 deletions src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,6 @@ where
///
/// This method consumes the builder and must come last in the method call chain.
///
/// Note that, display size is encoded into the type of the `Builder` and the display structures
/// (`DisplayProperties`, `GraphicsMode` and `TerminalMode`) as well. This means that, when you
/// are not using the default display size, you need to specify a second type parameter on these
/// structs.
///
/// ```rust
/// # use ssd1306::test_helpers::{PinStub, I2cStub};
/// # let i2c = I2cStub;
Expand Down
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
//! let i2c = I2cInterface;
//!
//! let interface = I2CDIBuilder::new().init(i2c);
//! let mut disp: GraphicsMode<_> = Builder::new().connect(interface).into();
//! let mut disp: GraphicsMode<_, _> = Builder::new().connect(interface).into();
//! disp.init();
//!
//! disp.set_pixel(10, 20, 1);
Expand Down Expand Up @@ -94,7 +94,7 @@
//! use ssd1306::{mode::GraphicsMode, prelude::*, Builder, I2CDIBuilder};
//!
//! let interface = I2CDIBuilder::new().init(i2c);
//! let mut disp: GraphicsMode<_> = Builder::new().connect(interface).into();
//! let mut disp: GraphicsMode<_, _> = Builder::new().connect(interface).into();
//!
//! disp.init().unwrap();
//!
Expand Down
6 changes: 3 additions & 3 deletions src/mode/graphics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
//! use ssd1306::{mode::GraphicsMode, prelude::*, Builder, I2CDIBuilder};
//!
//! let interface = I2CDIBuilder::new().init(i2c);
//! let mut display: GraphicsMode<_> = Builder::new().connect(interface).into();
//! let mut display: GraphicsMode<_, _> = Builder::new().connect(interface).into();
//!
//! display.init().unwrap();
//!
Expand Down Expand Up @@ -55,7 +55,7 @@
//!
//! [embedded_graphics]: https://crates.io/crates/embedded_graphics
use crate::displaysize::{DisplaySize, DisplaySize128x64};
use crate::displaysize::DisplaySize;
use display_interface::{DisplayError, WriteOnlyDataCommand};
use generic_array::GenericArray;

Expand All @@ -66,7 +66,7 @@ use crate::{

// TODO: Add to prelude
/// Graphics mode handler
pub struct GraphicsMode<DI, DSIZE = DisplaySize128x64>
pub struct GraphicsMode<DI, DSIZE>
where
DSIZE: DisplaySize,
{
Expand Down
2 changes: 1 addition & 1 deletion src/mode/terminal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ impl<T> IntoTerminalModeResult<T> for Result<T, DisplayError> {

// TODO: Add to prelude
/// Terminal mode handler
pub struct TerminalMode<DI, DSIZE = DisplaySize128x64>
pub struct TerminalMode<DI, DSIZE>
where
DSIZE: TerminalDisplaySize,
{
Expand Down
11 changes: 3 additions & 8 deletions src/properties.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ use crate::{
brightness::Brightness,
command::{AddrMode, Command, VcomhLevel},
displayrotation::DisplayRotation,
displaysize::{DisplaySize, DisplaySize128x64},
displaysize::DisplaySize,
};
use display_interface::{DataFormat::U8, DisplayError, WriteOnlyDataCommand};

/// Display properties struct
pub struct DisplayProperties<DI, DSIZE = DisplaySize128x64> {
pub struct DisplayProperties<DI, DSIZE> {
iface: DI,
display_rotation: DisplayRotation,
addr_mode: AddrMode,
Expand Down Expand Up @@ -243,18 +243,13 @@ where

/// Change into any mode implementing DisplayModeTrait
///
/// Note that, display size is encoded into the type of the `DisplayProperties` and the display
/// mode structures (`GraphicsMode` and `TerminalMode`) as well. This means that, when you
/// are not using the default display size, you need to specify a second type parameter on these
/// structs.
///
/// ```rust
/// # use ssd1306::test_helpers::{PinStub, I2cStub};
/// # let i2c = I2cStub;
/// use ssd1306::{mode::GraphicsMode, prelude::*, Builder, I2CDIBuilder};
///
/// let interface = I2CDIBuilder::new().init(i2c);
/// // Note that, when changing display size, you need to use `GraphicsMode<_, _>`
///
/// let di: GraphicsMode<_, _> = Builder::new()
/// .size(DisplaySize128x32)
/// .connect(interface)
Expand Down

0 comments on commit 38542a6

Please sign in to comment.