Skip to content

Commit 9f2ac6b

Browse files
committed
Upgrade to embedded-graphics 0.7
1 parent aa092da commit 9f2ac6b

File tree

11 files changed

+61
-51
lines changed

11 files changed

+61
-51
lines changed

CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ with the [embedded-hal](crates.io/crates/embedded-hal) traits for maximum portab
88

99
## [Unreleased] - ReleaseDate
1010

11+
### Changed
12+
13+
- **(breaking)** [#25](https://github.com/jamwaffles/sh1106/pull/25) Upgrade to `embedded-graphics` 0.7.
14+
1115
## [0.3.4] - 2020-12-28
1216

1317
### Fixed
@@ -81,8 +85,8 @@ Upgrade to new embedded-graphics `0.6.0-alpha.1` release. Please see the [embedd
8185
- **(breaking)** #9 Upgraded to [embedded-graphics](https://crates.io/crates/embedded-graphics) 0.6.0-alpha.1
8286

8387
<!-- next-url -->
84-
[unreleased]: https://github.com/jamwaffles/sh1106/compare/v0.3.4...HEAD
8588

89+
[unreleased]: https://github.com/jamwaffles/sh1106/compare/v0.3.4...HEAD
8690
[0.3.4]: https://github.com/jamwaffles/sh1106/compare/v0.3.3...v0.3.4
8791
[0.3.3]: https://github.com/jamwaffles/sh1106/compare/v0.3.2...v0.3.3
8892
[0.3.2]: https://github.com/jamwaffles/sh1106/compare/v0.3.1...v0.3.2

Cargo.toml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,12 @@ circle-ci = { repository = "jamwaffles/sh1106", branch = "master" }
2020

2121
[dependencies]
2222
embedded-hal = "0.2.3"
23-
24-
[dependencies.embedded-graphics]
25-
optional = true
26-
version = "0.6.0"
23+
embedded-graphics-core = { version = "0.3.2", optional = true }
2724

2825
[dev-dependencies]
2926
cortex-m = "0.6.0"
3027
cortex-m-rt = "0.6.10"
28+
embedded-graphics = "0.7.1"
3129
panic-semihosting = "0.5.2"
3230

3331
[dev-dependencies.stm32f1xx-hal]
@@ -36,7 +34,8 @@ features = [ "rt", "stm32f103" ]
3634

3735
[features]
3836
default = ["graphics"]
39-
graphics = ["embedded-graphics"]
37+
graphics = ["embedded-graphics-core"]
38+
4039
[profile.dev]
4140
codegen-units = 1
4241
incremental = false

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,12 @@ fn main() -> ! {
7676

7777
Text::new("Hello world!", Point::zero())
7878
.into_styled(TextStyle::new(Font6x8, BinaryColor::On))
79-
.draw(&mut disp)
79+
.draw(&mut display)
8080
.unwrap();
8181

8282
Text::new("Hello Rust!", Point::new(0, 16))
8383
.into_styled(TextStyle::new(Font6x8, BinaryColor::On))
84-
.draw(&mut disp)
84+
.draw(&mut display)
8585
.unwrap();
8686

8787
disp.flush().unwrap();

examples/graphics.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@ use cortex_m_rt::{entry, exception, ExceptionFrame};
2121
use embedded_graphics::{
2222
pixelcolor::BinaryColor,
2323
prelude::*,
24-
primitives::{Circle, Line, Rectangle},
25-
style::PrimitiveStyle,
24+
primitives::{Circle, Line, PrimitiveStyle, Rectangle},
2625
};
2726
use panic_semihosting as _;
2827
use sh1106::{prelude::*, Builder};
@@ -53,7 +52,7 @@ fn main() -> ! {
5352
(scl, sda),
5453
&mut afio.mapr,
5554
Mode::Fast {
56-
frequency: 400_000,
55+
frequency: 100_000,
5756
duty_cycle: DutyCycle::Ratio2to1,
5857
},
5958
clocks,
@@ -84,12 +83,12 @@ fn main() -> ! {
8483
.draw(&mut display)
8584
.unwrap();
8685

87-
Rectangle::new(Point::new(48, 16), Point::new(48 + 16, 16 + 16))
86+
Rectangle::with_corners(Point::new(48, 16), Point::new(48 + 16, 16 + 16))
8887
.into_styled(PrimitiveStyle::with_stroke(BinaryColor::On, 1))
8988
.draw(&mut display)
9089
.unwrap();
9190

92-
Circle::new(Point::new(96, 16 + 8), 8)
91+
Circle::new(Point::new(88, 16), 16)
9392
.into_styled(PrimitiveStyle::with_stroke(BinaryColor::On, 1))
9493
.draw(&mut display)
9594
.unwrap();

examples/graphics_128x32.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ use cortex_m_rt::{entry, exception, ExceptionFrame};
1111
use embedded_graphics::{
1212
pixelcolor::BinaryColor,
1313
prelude::*,
14-
primitives::{Circle, Line, Rectangle},
15-
style::PrimitiveStyle,
14+
primitives::{Circle, Line, PrimitiveStyle, Rectangle},
1615
};
1716
use panic_semihosting as _;
1817
use sh1106::{prelude::*, Builder};
@@ -43,7 +42,7 @@ fn main() -> ! {
4342
(scl, sda),
4443
&mut afio.mapr,
4544
Mode::Fast {
46-
frequency: 400_000,
45+
frequency: 100_000,
4746
duty_cycle: DutyCycle::Ratio2to1,
4847
},
4948
clocks,
@@ -81,12 +80,12 @@ fn main() -> ! {
8180
.draw(&mut display)
8281
.unwrap();
8382

84-
Rectangle::new(Point::new(48, yoffset), Point::new(48 + 16, 16 + yoffset))
83+
Rectangle::with_corners(Point::new(48, yoffset), Point::new(48 + 16, 16 + yoffset))
8584
.into_styled(PrimitiveStyle::with_stroke(BinaryColor::On, 1))
8685
.draw(&mut display)
8786
.unwrap();
8887

89-
Circle::new(Point::new(96, yoffset + 8), 8)
88+
Circle::new(Point::new(88, yoffset), 16)
9089
.into_styled(PrimitiveStyle::with_stroke(BinaryColor::On, 1))
9190
.draw(&mut display)
9291
.unwrap();

examples/image.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ fn main() -> ! {
5858
(scl, sda),
5959
&mut afio.mapr,
6060
Mode::Fast {
61-
frequency: 400_000,
61+
frequency: 100_000,
6262
duty_cycle: DutyCycle::Ratio2to1,
6363
},
6464
clocks,
@@ -74,7 +74,7 @@ fn main() -> ! {
7474
display.init().unwrap();
7575
display.flush().unwrap();
7676

77-
let im: ImageRawLE<BinaryColor> = ImageRawLE::new(include_bytes!("./rust.raw"), 64, 64);
77+
let im: ImageRawLE<BinaryColor> = ImageRawLE::new(include_bytes!("./rust.raw"), 64);
7878

7979
Image::new(&im, Point::new(32, 0))
8080
.draw(&mut display)

examples/image_spi.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ fn main() -> ! {
7575
display.init().unwrap();
7676
display.flush().unwrap();
7777

78-
let im: ImageRawLE<BinaryColor> = ImageRawLE::new(include_bytes!("./rust.raw"), 64, 64);
78+
let im: ImageRawLE<BinaryColor> = ImageRawLE::new(include_bytes!("./rust.raw"), 64);
7979

8080
Image::new(&im, Point::new(32, 0))
8181
.draw(&mut display)

examples/pixelsquare.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ fn main() -> ! {
5353
(scl, sda),
5454
&mut afio.mapr,
5555
Mode::Fast {
56-
frequency: 400_000,
56+
frequency: 100_000,
5757
duty_cycle: DutyCycle::Ratio2to1,
5858
},
5959
clocks,

examples/rotation.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ fn main() -> ! {
5858
(scl, sda),
5959
&mut afio.mapr,
6060
Mode::Fast {
61-
frequency: 400_000,
61+
frequency: 100_000,
6262
duty_cycle: DutyCycle::Ratio2to1,
6363
},
6464
clocks,
@@ -84,7 +84,7 @@ fn main() -> ! {
8484

8585
let (w, h) = display.get_dimensions();
8686

87-
let im: ImageRawLE<BinaryColor> = ImageRawLE::new(include_bytes!("./rust.raw"), 64, 64);
87+
let im: ImageRawLE<BinaryColor> = ImageRawLE::new(include_bytes!("./rust.raw"), 64);
8888

8989
Image::new(
9090
&im,

examples/text.rs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@
2020

2121
use cortex_m_rt::{entry, exception, ExceptionFrame};
2222
use embedded_graphics::{
23-
fonts::{Font6x8, Text},
23+
mono_font::{ascii::FONT_6X10, MonoTextStyleBuilder},
2424
pixelcolor::BinaryColor,
2525
prelude::*,
26-
style::TextStyle,
26+
text::{Baseline, Text},
2727
};
2828
use panic_semihosting as _;
2929
use sh1106::{prelude::*, Builder};
@@ -54,7 +54,7 @@ fn main() -> ! {
5454
(scl, sda),
5555
&mut afio.mapr,
5656
Mode::Fast {
57-
frequency: 400_000,
57+
frequency: 100_000,
5858
duty_cycle: DutyCycle::Ratio2to1,
5959
},
6060
clocks,
@@ -70,13 +70,16 @@ fn main() -> ! {
7070
display.init().unwrap();
7171
display.flush().unwrap();
7272

73-
Text::new("Hello world!", Point::zero())
74-
.into_styled(TextStyle::new(Font6x8, BinaryColor::On))
73+
let text_style = MonoTextStyleBuilder::new()
74+
.font(&FONT_6X10)
75+
.text_color(BinaryColor::On)
76+
.build();
77+
78+
Text::with_baseline("Hello world!", Point::zero(), text_style, Baseline::Top)
7579
.draw(&mut display)
7680
.unwrap();
7781

78-
Text::new("Hello Rust!", Point::new(0, 16))
79-
.into_styled(TextStyle::new(Font6x8, BinaryColor::On))
82+
Text::with_baseline("Hello Rust!", Point::new(0, 16), text_style, Baseline::Top)
8083
.draw(&mut display)
8184
.unwrap();
8285

0 commit comments

Comments
 (0)