Skip to content

Commit

Permalink
Embedded graphics 0.6.0-alpha.3 (#2)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
jamwaffles authored Jan 13, 2020
1 parent 85f36ea commit ba63b21
Show file tree
Hide file tree
Showing 13 changed files with 247 additions and 169 deletions.
107 changes: 107 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
target_steps: &target_steps
docker:
- image: circleci/rust:1.40.0
steps:
- checkout
- restore_cache:
key: v1-ssd1331-{{ .Environment.CIRCLE_JOB }}-{{ checksum "Cargo.toml" }}
- run: sudo apt install -qq libsdl2-dev python-pip
- run: sudo pip install linkchecker
- run: rustup default ${RUST_VERSION:-stable}
- run: rustup component add rustfmt
- run: |
SYSROOT=$(rustc --print sysroot)
if [[ ! "$SYSROOT" =~ "$TARGET" ]]; then
rustup target add $TARGET
else
echo "Target $TARGET is already installed"
fi
- run: ./build.sh
- save_cache:
key: v1-ssd1331-{{ .Environment.CIRCLE_JOB }}-{{ checksum "Cargo.toml" }}
paths:
- ./target
- /home/ubuntu/.cargo

version: 2
jobs:
target-arm-unknown-linux-eabi:
environment:
- TARGET: "arm-unknown-linux-gnueabi"
- DISABLE_EXAMPLES: 1
<<: *target_steps

target-armv7-unknown-linux-gnueabihf:
environment:
- TARGET: "armv7-unknown-linux-gnueabihf"
- DISABLE_EXAMPLES: 1
<<: *target_steps

target-x86_64-unknown-linux-gnu:
environment:
- TARGET: "x86_64-unknown-linux-gnu"
- DISABLE_EXAMPLES: 1
<<: *target_steps

target-x86_64-unknown-linux-musl:
environment:
- TARGET: "x86_64-unknown-linux-musl"
- DISABLE_EXAMPLES: 1
<<: *target_steps

target-thumbv6m-none-eabi:
environment:
- TARGET: "thumbv6m-none-eabi"
# Disable example builds as they target thumbv7 and up
- DISABLE_EXAMPLES: 1
<<: *target_steps

target-thumbv7em-none-eabi:
environment:
- TARGET: "thumbv7em-none-eabi"
<<: *target_steps

target-thumbv7em-none-eabihf:
environment:
- TARGET: "thumbv7em-none-eabihf"
<<: *target_steps

target-thumbv7m-none-eabi:
environment:
- TARGET: "thumbv7m-none-eabi"
<<: *target_steps

build_jobs: &build_jobs
jobs:
# Raspberry Pi 1
- target-arm-unknown-linux-eabi

# Raspberry Pi 2, 3, etc
- target-armv7-unknown-linux-gnueabihf

# Linux
- target-x86_64-unknown-linux-gnu
- target-x86_64-unknown-linux-musl

# Bare metal
- target-thumbv6m-none-eabi
- target-thumbv7em-none-eabi
- target-thumbv7em-none-eabihf
- target-thumbv7m-none-eabi

workflows:
version: 2
build_all:
<<: *build_jobs

# Build every day
nightly:
<<: *build_jobs
triggers:
- schedule:
cron: "0 0 * * *"
filters:
branches:
only:
- master
65 changes: 0 additions & 65 deletions .travis.yml

This file was deleted.

7 changes: 3 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,18 @@

## Unreleased

- None

### Added

- None

### Changed

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

### Fixed

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

### Security

Expand Down
10 changes: 6 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,18 @@ readme = "README.md"
repository = "https://github.com/jamwaffles/ssd1331"
version = "0.2.0-alpha.1"
edition = "2018"
[badges.travis-ci]
branch = "master"
repository = "jamwaffles/ssd1331"
[badges]
circle-ci = { repository = "jamwaffles/ssd1331", branch = "master" }

[package.metadata.docs.rs]
default-target = "x86_64-unknown-linux-gnu"

[dependencies]
embedded-hal = "0.2.3"

[dependencies.embedded-graphics]
optional = true
version = "0.6.0-alpha.2"
version = "0.6.0-alpha.3"

[dev-dependencies]
cortex-m = "0.6.1"
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# SSD1331 driver

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

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

Expand Down
8 changes: 5 additions & 3 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,16 @@ cargo fmt --all -- --check
cargo build --target $TARGET --all-features --release

cargo test --lib --target x86_64-unknown-linux-gnu

# Always test docs against thumbv7m target as the complete readme example needs to compile against it
cargo test --doc --target thumbv7m-none-eabi
cargo test --doc --target x86_64-unknown-linux-gnu

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

# Remove stale docs - the linkchecker might miss links to old files if they're not removed
cargo clean --doc
cargo clean --doc --target $TARGET

cargo doc --all-features --target $TARGET

linkchecker target/$TARGET/doc/ssd1331/index.html
2 changes: 1 addition & 1 deletion examples/bmp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ fn main() -> ! {
(h as u32 - im.height()) as i32 / 2,
));

disp.draw(moved.into_iter());
moved.draw(&mut disp);

disp.flush().unwrap();

Expand Down
52 changes: 31 additions & 21 deletions examples/graphics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ use embedded_graphics::{
geometry::Point,
pixelcolor::Rgb565,
prelude::*,
primitives::{Circle, Line, Rectangle, Triangle},
primitives::{Circle, Rectangle, Triangle},
style::PrimitiveStyleBuilder,
};
use panic_semihosting as _;
use ssd1331::{DisplayRotation::Rotate0, Ssd1331};
Expand Down Expand Up @@ -80,27 +81,36 @@ fn main() -> ! {
disp.init().unwrap();
disp.flush().unwrap();

disp.draw(
Triangle::new(
Point::new(8, 16 + 16),
Point::new(8 + 16, 16 + 16),
Point::new(8 + 8, 16),
Triangle::new(
Point::new(8, 16 + 16),
Point::new(8 + 16, 16 + 16),
Point::new(8 + 8, 16),
)
.into_styled(
PrimitiveStyleBuilder::new()
.stroke_color(Rgb565::RED)
.stroke_width(1)
.build(),
)
.draw(&mut disp);

Rectangle::new(Point::new(36, 16), Point::new(36 + 16, 16 + 16))
.into_styled(
PrimitiveStyleBuilder::new()
.stroke_color(Rgb565::GREEN)
.stroke_width(1)
.build(),
)
.stroke(Some(Rgb565::RED))
.into_iter(),
);

disp.draw(
Rectangle::new(Point::new(36, 16), Point::new(36 + 16, 16 + 16))
.stroke(Some(Rgb565::GREEN))
.into_iter(),
);

disp.draw(
Circle::new(Point::new(72, 16 + 8), 8)
.stroke(Some(Rgb565::BLUE))
.into_iter(),
);
.draw(&mut disp);

Circle::new(Point::new(72, 16 + 8), 8)
.into_styled(
PrimitiveStyleBuilder::new()
.stroke_color(Rgb565::BLUE)
.stroke_width(1)
.build(),
)
.draw(&mut disp);

disp.flush().unwrap();

Expand Down
2 changes: 1 addition & 1 deletion examples/image.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ fn main() -> ! {
let im = ImageLE::new(include_bytes!("./ferris.raw"), 86, 64)
.translate(Point::new((96 - 86) / 2, 0));

disp.draw(im.into_iter());
im.draw(&mut disp);

disp.flush().unwrap();

Expand Down
6 changes: 4 additions & 2 deletions examples/rotation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#![no_main]

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

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

disp.flush().unwrap();

Expand Down
Loading

0 comments on commit ba63b21

Please sign in to comment.