Skip to content

Commit ba63b21

Browse files
authored
Embedded graphics 0.6.0-alpha.3 (#2)
* Upgrade lib to e-g 0.6.0-alpha.3 * Fix examples * Fix doc examples, test them in CI * Format doc example * Migrate to CircleCI * Add/update badges * Add changelog entry * Remove empty values from cache checksum * Clean docs more thoroughly * Fix(?) docs.rs build * Fix graphics example styles
1 parent 85f36ea commit ba63b21

File tree

13 files changed

+247
-169
lines changed

13 files changed

+247
-169
lines changed

.circleci/config.yml

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
target_steps: &target_steps
2+
docker:
3+
- image: circleci/rust:1.40.0
4+
steps:
5+
- checkout
6+
- restore_cache:
7+
key: v1-ssd1331-{{ .Environment.CIRCLE_JOB }}-{{ checksum "Cargo.toml" }}
8+
- run: sudo apt install -qq libsdl2-dev python-pip
9+
- run: sudo pip install linkchecker
10+
- run: rustup default ${RUST_VERSION:-stable}
11+
- run: rustup component add rustfmt
12+
- run: |
13+
SYSROOT=$(rustc --print sysroot)
14+
15+
if [[ ! "$SYSROOT" =~ "$TARGET" ]]; then
16+
rustup target add $TARGET
17+
else
18+
echo "Target $TARGET is already installed"
19+
fi
20+
- run: ./build.sh
21+
- save_cache:
22+
key: v1-ssd1331-{{ .Environment.CIRCLE_JOB }}-{{ checksum "Cargo.toml" }}
23+
paths:
24+
- ./target
25+
- /home/ubuntu/.cargo
26+
27+
version: 2
28+
jobs:
29+
target-arm-unknown-linux-eabi:
30+
environment:
31+
- TARGET: "arm-unknown-linux-gnueabi"
32+
- DISABLE_EXAMPLES: 1
33+
<<: *target_steps
34+
35+
target-armv7-unknown-linux-gnueabihf:
36+
environment:
37+
- TARGET: "armv7-unknown-linux-gnueabihf"
38+
- DISABLE_EXAMPLES: 1
39+
<<: *target_steps
40+
41+
target-x86_64-unknown-linux-gnu:
42+
environment:
43+
- TARGET: "x86_64-unknown-linux-gnu"
44+
- DISABLE_EXAMPLES: 1
45+
<<: *target_steps
46+
47+
target-x86_64-unknown-linux-musl:
48+
environment:
49+
- TARGET: "x86_64-unknown-linux-musl"
50+
- DISABLE_EXAMPLES: 1
51+
<<: *target_steps
52+
53+
target-thumbv6m-none-eabi:
54+
environment:
55+
- TARGET: "thumbv6m-none-eabi"
56+
# Disable example builds as they target thumbv7 and up
57+
- DISABLE_EXAMPLES: 1
58+
<<: *target_steps
59+
60+
target-thumbv7em-none-eabi:
61+
environment:
62+
- TARGET: "thumbv7em-none-eabi"
63+
<<: *target_steps
64+
65+
target-thumbv7em-none-eabihf:
66+
environment:
67+
- TARGET: "thumbv7em-none-eabihf"
68+
<<: *target_steps
69+
70+
target-thumbv7m-none-eabi:
71+
environment:
72+
- TARGET: "thumbv7m-none-eabi"
73+
<<: *target_steps
74+
75+
build_jobs: &build_jobs
76+
jobs:
77+
# Raspberry Pi 1
78+
- target-arm-unknown-linux-eabi
79+
80+
# Raspberry Pi 2, 3, etc
81+
- target-armv7-unknown-linux-gnueabihf
82+
83+
# Linux
84+
- target-x86_64-unknown-linux-gnu
85+
- target-x86_64-unknown-linux-musl
86+
87+
# Bare metal
88+
- target-thumbv6m-none-eabi
89+
- target-thumbv7em-none-eabi
90+
- target-thumbv7em-none-eabihf
91+
- target-thumbv7m-none-eabi
92+
93+
workflows:
94+
version: 2
95+
build_all:
96+
<<: *build_jobs
97+
98+
# Build every day
99+
nightly:
100+
<<: *build_jobs
101+
triggers:
102+
- schedule:
103+
cron: "0 0 * * *"
104+
filters:
105+
branches:
106+
only:
107+
- master

.travis.yml

Lines changed: 0 additions & 65 deletions
This file was deleted.

CHANGELOG.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,18 @@
55

66
## Unreleased
77

8-
- None
9-
108
### Added
119

1210
- None
1311

1412
### Changed
1513

16-
- None
14+
- **(breaking)** Upgraded to embedded-graphics 0.6.0-alpha.3
15+
- Migrated from Travis to CircleCI for repo builds
1716

1817
### Fixed
1918

20-
- None
19+
- Tell docs.rs to build against `x86_64-unknown-linux-gnu` so doc builds work again
2120

2221
### Security
2322

Cargo.toml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,18 @@ readme = "README.md"
1111
repository = "https://github.com/jamwaffles/ssd1331"
1212
version = "0.2.0-alpha.1"
1313
edition = "2018"
14-
[badges.travis-ci]
15-
branch = "master"
16-
repository = "jamwaffles/ssd1331"
14+
[badges]
15+
circle-ci = { repository = "jamwaffles/ssd1331", branch = "master" }
16+
17+
[package.metadata.docs.rs]
18+
default-target = "x86_64-unknown-linux-gnu"
1719

1820
[dependencies]
1921
embedded-hal = "0.2.3"
2022

2123
[dependencies.embedded-graphics]
2224
optional = true
23-
version = "0.6.0-alpha.2"
25+
version = "0.6.0-alpha.3"
2426

2527
[dev-dependencies]
2628
cortex-m = "0.6.1"

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# SSD1331 driver
22

3-
[![Build Status](https://travis-ci.org/jamwaffles/ssd1331.svg?branch=master)](https://travis-ci.org/jamwaffles/ssd1331)
3+
[![Build Status](https://circleci.com/gh/jamwaffles/ssd1331/tree/master.svg?style=shield)](https://circleci.com/gh/jamwaffles/ssd1331/tree/master)
4+
[![Crates.io](https://img.shields.io/crates/v/ssd1331.svg)](https://crates.io/crates/ssd1331)
5+
[![Docs.rs](https://docs.rs/ssd1331/badge.svg)](https://docs.rs/ssd1331)
46

57
[![SSD1331 display showing Ferris](readme_banner.jpg?raw=true)](examples/image.rs)
68

build.sh

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,16 @@ cargo fmt --all -- --check
1717
cargo build --target $TARGET --all-features --release
1818

1919
cargo test --lib --target x86_64-unknown-linux-gnu
20-
21-
# Always test docs against thumbv7m target as the complete readme example needs to compile against it
22-
cargo test --doc --target thumbv7m-none-eabi
20+
cargo test --doc --target x86_64-unknown-linux-gnu
2321

2422
if [ -z $DISABLE_EXAMPLES ]; then
2523
cargo build --target $TARGET --all-features --examples
2624
fi
2725

26+
# Remove stale docs - the linkchecker might miss links to old files if they're not removed
27+
cargo clean --doc
28+
cargo clean --doc --target $TARGET
29+
2830
cargo doc --all-features --target $TARGET
2931

3032
linkchecker target/$TARGET/doc/ssd1331/index.html

examples/bmp.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ fn main() -> ! {
8787
(h as u32 - im.height()) as i32 / 2,
8888
));
8989

90-
disp.draw(moved.into_iter());
90+
moved.draw(&mut disp);
9191

9292
disp.flush().unwrap();
9393

examples/graphics.rs

Lines changed: 31 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ use embedded_graphics::{
2525
geometry::Point,
2626
pixelcolor::Rgb565,
2727
prelude::*,
28-
primitives::{Circle, Line, Rectangle, Triangle},
28+
primitives::{Circle, Rectangle, Triangle},
29+
style::PrimitiveStyleBuilder,
2930
};
3031
use panic_semihosting as _;
3132
use ssd1331::{DisplayRotation::Rotate0, Ssd1331};
@@ -80,27 +81,36 @@ fn main() -> ! {
8081
disp.init().unwrap();
8182
disp.flush().unwrap();
8283

83-
disp.draw(
84-
Triangle::new(
85-
Point::new(8, 16 + 16),
86-
Point::new(8 + 16, 16 + 16),
87-
Point::new(8 + 8, 16),
84+
Triangle::new(
85+
Point::new(8, 16 + 16),
86+
Point::new(8 + 16, 16 + 16),
87+
Point::new(8 + 8, 16),
88+
)
89+
.into_styled(
90+
PrimitiveStyleBuilder::new()
91+
.stroke_color(Rgb565::RED)
92+
.stroke_width(1)
93+
.build(),
94+
)
95+
.draw(&mut disp);
96+
97+
Rectangle::new(Point::new(36, 16), Point::new(36 + 16, 16 + 16))
98+
.into_styled(
99+
PrimitiveStyleBuilder::new()
100+
.stroke_color(Rgb565::GREEN)
101+
.stroke_width(1)
102+
.build(),
88103
)
89-
.stroke(Some(Rgb565::RED))
90-
.into_iter(),
91-
);
92-
93-
disp.draw(
94-
Rectangle::new(Point::new(36, 16), Point::new(36 + 16, 16 + 16))
95-
.stroke(Some(Rgb565::GREEN))
96-
.into_iter(),
97-
);
98-
99-
disp.draw(
100-
Circle::new(Point::new(72, 16 + 8), 8)
101-
.stroke(Some(Rgb565::BLUE))
102-
.into_iter(),
103-
);
104+
.draw(&mut disp);
105+
106+
Circle::new(Point::new(72, 16 + 8), 8)
107+
.into_styled(
108+
PrimitiveStyleBuilder::new()
109+
.stroke_color(Rgb565::BLUE)
110+
.stroke_width(1)
111+
.build(),
112+
)
113+
.draw(&mut disp);
104114

105115
disp.flush().unwrap();
106116

examples/image.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ fn main() -> ! {
8585
let im = ImageLE::new(include_bytes!("./ferris.raw"), 86, 64)
8686
.translate(Point::new((96 - 86) / 2, 0));
8787

88-
disp.draw(im.into_iter());
88+
im.draw(&mut disp);
8989

9090
disp.flush().unwrap();
9191

examples/rotation.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
#![no_main]
2727

2828
use cortex_m_rt::{entry, exception, ExceptionFrame};
29-
use embedded_graphics::{pixelcolor::BinaryColor, prelude::*};
29+
use embedded_graphics::{image::ImageLE, pixelcolor::BinaryColor, prelude::*};
3030
use panic_semihosting as _;
3131
use ssd1331::{DisplayRotation, Ssd1331};
3232
use stm32f1xx_hal::{
@@ -89,7 +89,9 @@ fn main() -> ! {
8989
let im = ImageLE::<BinaryColor>::new(include_bytes!("./rust.raw"), 64, 64);
9090

9191
// Map on/off image colours to Rgb565::BLACK/Rgb565::WHITE
92-
disp.draw(im.into_iter().map(|p| Pixel(p.0, p.1.into())));
92+
im.into_iter()
93+
.map(|p| Pixel(p.0, p.1.into()))
94+
.draw(&mut disp);
9395

9496
disp.flush().unwrap();
9597

0 commit comments

Comments
 (0)