Add Bluepill example & some other minor improvements (#28)
- added bluepill example - improved ci config - travis: run fmt only once - travis: fixed target issuesembedded-hal-1.0
parent
34c03c5486
commit
60f48a8273
62
.travis.yml
62
.travis.yml
|
|
@ -6,12 +6,14 @@ rust:
|
||||||
- beta
|
- beta
|
||||||
- nightly
|
- nightly
|
||||||
sudo: required
|
sudo: required
|
||||||
|
env: TARGET=x86_64-unknown-linux-gnu
|
||||||
|
|
||||||
# TODO Rust builds on stable by default, this can be
|
# TODO Rust builds on stable by default, this can be
|
||||||
# overridden on a case by case basis down below.
|
# overridden on a case by case basis down below.
|
||||||
matrix:
|
matrix:
|
||||||
allow_failures:
|
allow_failures:
|
||||||
- nightly
|
- rust: nightly
|
||||||
|
fast_finish: true
|
||||||
# TODO These are all the build jobs. Adjust as necessary. Comment out what you
|
# TODO These are all the build jobs. Adjust as necessary. Comment out what you
|
||||||
# don't need
|
# don't need
|
||||||
include:
|
include:
|
||||||
|
|
@ -22,43 +24,67 @@ matrix:
|
||||||
# Raspberry Pi 3...
|
# Raspberry Pi 3...
|
||||||
- env: TARGET=armv7-unknown-linux-gnueabihf
|
- env: TARGET=armv7-unknown-linux-gnueabihf
|
||||||
|
|
||||||
- env: TARGET=x86_64-unknown-linux-gnu
|
# is already included as global env
|
||||||
|
#- env: TARGET=x86_64-unknown-linux-gnu
|
||||||
- env: TARGET=x86_64-unknown-linux-musl
|
- env: TARGET=x86_64-unknown-linux-musl
|
||||||
|
|
||||||
# Bare metal
|
# Bare metal
|
||||||
# These targets don't support std and as such are likely not suitable for
|
# These targets don't support std and as such are likely not suitable for
|
||||||
# most crates.
|
# most crates.
|
||||||
- env: TARGET=thumbv6m-none-eabi
|
- env: TARGET=thumbv6m-none-eabi
|
||||||
|
before_script: rustup target add $TARGET
|
||||||
|
script: cargo check --verbose --target $TARGET
|
||||||
- env: TARGET=thumbv7em-none-eabi
|
- env: TARGET=thumbv7em-none-eabi
|
||||||
|
before_script: rustup target add $TARGET
|
||||||
|
script: cargo check --verbose --target $TARGET
|
||||||
- env: TARGET=thumbv7em-none-eabihf
|
- env: TARGET=thumbv7em-none-eabihf
|
||||||
|
before_script: rustup target add $TARGET
|
||||||
|
script: cargo check --verbose --target $TARGET
|
||||||
- env: TARGET=thumbv7m-none-eabi
|
- env: TARGET=thumbv7m-none-eabi
|
||||||
|
before_script: rustup target add $TARGET
|
||||||
|
script: cargo check --verbose --target $TARGET
|
||||||
|
|
||||||
|
- name: "clippy und fmt"
|
||||||
|
rust: stable
|
||||||
|
env: RUN=FMT
|
||||||
|
before_script:
|
||||||
|
- rustup component add clippy-preview
|
||||||
|
- rustup component add rustfmt-preview
|
||||||
|
script:
|
||||||
|
- cargo fmt --all -- --check
|
||||||
|
- cargo clippy --all-targets --all-features -- -D warnings -A clippy::new_ret_no_self
|
||||||
|
- cargo doc --all-features --release
|
||||||
|
- cd examples/epd4in2_full && cargo fmt --all -- --check && cd ../../
|
||||||
|
- cd examples/epd2in9_full && cargo fmt --all -- --check && cd ../../
|
||||||
|
- cd examples/epd1in54_full && cargo fmt --all -- --check && cd ../../
|
||||||
|
- cd examples/epd1in54_no_graphics && cargo fmt --all -- --check && cd ../../
|
||||||
|
- cd examples/epd4in2_var_display_buffer && cargo fmt --all -- --check && cd ../../
|
||||||
|
- cd examples/epd4in2_full_blue_pill && cargo fmt --all -- --check && cd ../../
|
||||||
|
- name: "check examples"
|
||||||
|
rust: stable
|
||||||
|
before_script:
|
||||||
|
- rustup target add thumbv7m-none-eabi
|
||||||
|
script:
|
||||||
|
- cd examples/epd4in2_full_blue_pill && cargo check && cd ../../
|
||||||
|
- cd examples/epd4in2_full && cargo check && cd ../../
|
||||||
|
- cd examples/epd2in9_full && cargo check && cd ../../
|
||||||
|
- cd examples/epd1in54_full && cargo check && cd ../../
|
||||||
|
- cd examples/epd1in54_no_graphics && cargo check && cd ../../
|
||||||
|
- cd examples/epd4in2_var_display_buffer && cargo check && cd ../../
|
||||||
|
|
||||||
before_install:
|
before_install:
|
||||||
- set -e
|
- set -e
|
||||||
- rustup self update
|
- rustup self update
|
||||||
|
|
||||||
|
|
||||||
install:
|
install:
|
||||||
- cargo install cargo-update || echo "cargo-update already installed"
|
- cargo install cargo-update || echo "cargo-update already installed"
|
||||||
- cargo install-update -a # update outdated cached binaries
|
- cargo install-update -a # update outdated cached binaries
|
||||||
- rustup target add thumbv7m-none-eabi
|
- cargo install cross || echo "cross already installed"
|
||||||
- rustup component add clippy-preview
|
|
||||||
- rustup component add rustfmt-preview
|
|
||||||
|
|
||||||
#TODO: remove -A clippy::new_ret_no_self when new version of clippy gets released!
|
#TODO: remove -A clippy::new_ret_no_self when new version of clippy gets released!
|
||||||
script:
|
script:
|
||||||
- cargo fmt --all -- --check
|
- cross check --verbose --target $TARGET
|
||||||
- cargo clippy --all-targets --all-features -- -D warnings -A clippy::new_ret_no_self
|
- cross test --all-features --release --verbose --target $TARGET
|
||||||
- cargo check
|
|
||||||
- cargo test --all-features --release
|
|
||||||
- cargo doc --all-features --release
|
|
||||||
- cd examples/epd4in2_full && cargo fmt --all -- --check && cargo check && cd ../../
|
|
||||||
- cd examples/epd2in9_full && cargo fmt --all -- --check && cargo check && cd ../../
|
|
||||||
- cd examples/epd1in54_full && cargo fmt --all -- --check && cargo check && cd ../../
|
|
||||||
- cd examples/epd1in54_no_graphics && cargo fmt --all -- --check && cargo check && cd ../../
|
|
||||||
- cd examples/epd4in2_var_display_buffer && cargo fmt --all -- --check && cargo check && cd ../../
|
|
||||||
|
|
||||||
|
|
||||||
cache: cargo
|
cache: cargo
|
||||||
before_cache:
|
before_cache:
|
||||||
|
|
|
||||||
|
|
@ -1,23 +0,0 @@
|
||||||
# This script takes care of packaging the build artifacts that will go in the
|
|
||||||
# release zipfile
|
|
||||||
|
|
||||||
$SRC_DIR = $PWD.Path
|
|
||||||
$STAGE = [System.Guid]::NewGuid().ToString()
|
|
||||||
|
|
||||||
Set-Location $ENV:Temp
|
|
||||||
New-Item -Type Directory -Name $STAGE
|
|
||||||
Set-Location $STAGE
|
|
||||||
|
|
||||||
$ZIP = "$SRC_DIR\$($Env:CRATE_NAME)-$($Env:APPVEYOR_REPO_TAG_NAME)-$($Env:TARGET).zip"
|
|
||||||
|
|
||||||
# TODO Update this to package the right artifacts
|
|
||||||
Copy-Item "$SRC_DIR\target\$($Env:TARGET)\release\hello.exe" '.\'
|
|
||||||
|
|
||||||
7z a "$ZIP" *
|
|
||||||
|
|
||||||
Push-AppveyorArtifact "$ZIP"
|
|
||||||
|
|
||||||
Remove-Item *.* -Force
|
|
||||||
Set-Location ..
|
|
||||||
Remove-Item $STAGE
|
|
||||||
Set-Location $SRC_DIR
|
|
||||||
|
|
@ -1,33 +0,0 @@
|
||||||
# This script takes care of building your crate and packaging it for release
|
|
||||||
|
|
||||||
set -ex
|
|
||||||
|
|
||||||
main() {
|
|
||||||
local src=$(pwd) \
|
|
||||||
stage=
|
|
||||||
|
|
||||||
case $TRAVIS_OS_NAME in
|
|
||||||
linux)
|
|
||||||
stage=$(mktemp -d)
|
|
||||||
;;
|
|
||||||
osx)
|
|
||||||
stage=$(mktemp -d -t tmp)
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
test -f Cargo.lock || cargo generate-lockfile
|
|
||||||
|
|
||||||
# TODO Update this to build the artifacts that matter to you
|
|
||||||
cross rustc --bin hello --target $TARGET --release -- -C lto
|
|
||||||
|
|
||||||
# TODO Update this to package the right artifacts
|
|
||||||
cp target/$TARGET/release/hello $stage/
|
|
||||||
|
|
||||||
cd $stage
|
|
||||||
tar czf $src/$CRATE_NAME-$TRAVIS_TAG-$TARGET.tar.gz *
|
|
||||||
cd $src
|
|
||||||
|
|
||||||
rm -rf $stage
|
|
||||||
}
|
|
||||||
|
|
||||||
main
|
|
||||||
|
|
@ -1,47 +0,0 @@
|
||||||
set -ex
|
|
||||||
|
|
||||||
main() {
|
|
||||||
local target=
|
|
||||||
if [ $TRAVIS_OS_NAME = linux ]; then
|
|
||||||
target=x86_64-unknown-linux-musl
|
|
||||||
sort=sort
|
|
||||||
else
|
|
||||||
target=x86_64-apple-darwin
|
|
||||||
sort=gsort # for `sort --sort-version`, from brew's coreutils.
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Builds for iOS are done on OSX, but require the specific target to be
|
|
||||||
# installed.
|
|
||||||
case $TARGET in
|
|
||||||
aarch64-apple-ios)
|
|
||||||
rustup target install aarch64-apple-ios
|
|
||||||
;;
|
|
||||||
armv7-apple-ios)
|
|
||||||
rustup target install armv7-apple-ios
|
|
||||||
;;
|
|
||||||
armv7s-apple-ios)
|
|
||||||
rustup target install armv7s-apple-ios
|
|
||||||
;;
|
|
||||||
i386-apple-ios)
|
|
||||||
rustup target install i386-apple-ios
|
|
||||||
;;
|
|
||||||
x86_64-apple-ios)
|
|
||||||
rustup target install x86_64-apple-ios
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
# This fetches latest stable release
|
|
||||||
local tag=$(git ls-remote --tags --refs --exit-code https://github.com/japaric/cross \
|
|
||||||
| cut -d/ -f3 \
|
|
||||||
| grep -E '^v[0.1.0-9.]+$' \
|
|
||||||
| $sort --version-sort \
|
|
||||||
| tail -n1)
|
|
||||||
curl -LSfs https://japaric.github.io/trust/install.sh | \
|
|
||||||
sh -s -- \
|
|
||||||
--force \
|
|
||||||
--git japaric/cross \
|
|
||||||
--tag $tag \
|
|
||||||
--target $target
|
|
||||||
}
|
|
||||||
|
|
||||||
main
|
|
||||||
24
ci/script.sh
24
ci/script.sh
|
|
@ -1,24 +0,0 @@
|
||||||
# This script takes care of testing your crate
|
|
||||||
|
|
||||||
set -ex
|
|
||||||
|
|
||||||
# TODO This is the "test phase", tweak it as you see fit
|
|
||||||
main() {
|
|
||||||
cross build --target $TARGET
|
|
||||||
cross build --target $TARGET --release
|
|
||||||
|
|
||||||
if [ ! -z $DISABLE_TESTS ]; then
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
|
|
||||||
cross test --target $TARGET
|
|
||||||
cross test --target $TARGET --release
|
|
||||||
|
|
||||||
cross run --target $TARGET
|
|
||||||
cross run --target $TARGET --release
|
|
||||||
}
|
|
||||||
|
|
||||||
# we don't run the "test phase" when doing deploys
|
|
||||||
if [ -z $TRAVIS_TAG ]; then
|
|
||||||
main
|
|
||||||
fi
|
|
||||||
|
|
@ -16,5 +16,32 @@ This examples used the graphics feature with VarDisplay and therefore a variable
|
||||||
|
|
||||||
This example doesn't use the graphics feature and handles all the "drawing" by itself. It also has a speeddemonstration included.
|
This example doesn't use the graphics feature and handles all the "drawing" by itself. It also has a speeddemonstration included.
|
||||||
|
|
||||||
|
### epd4in2_full_blue_pill
|
||||||
|
|
||||||
|
Connect epd4in2 display to blue pill board:
|
||||||
|
- BUSY -> A10
|
||||||
|
- RST -> A9
|
||||||
|
- DC -> A8
|
||||||
|
- CS -> B12
|
||||||
|
- CLK -> B13
|
||||||
|
- DIN -> B15
|
||||||
|
- GND -> G
|
||||||
|
- VCC -> 3.3
|
||||||
|
|
||||||
|
For compiling and flashing, please refer to [TeXitois blue pill quickstart](https://github.com/TeXitoi/blue-pill-quickstart/blob/master/README.md).
|
||||||
|
|
||||||
|
Basically:
|
||||||
|
|
||||||
|
```shell
|
||||||
|
curl https://sh.rustup.rs -sSf | sh
|
||||||
|
rustup target add thumbv7m-none-eabi
|
||||||
|
sudo apt-get install gdb-arm-none-eabi openocd
|
||||||
|
cd epd4in2_full_blue_pill
|
||||||
|
# connect ST-Link v2 to the blue pill and the computer
|
||||||
|
# openocd in another terminal
|
||||||
|
cargo run --release
|
||||||
|
```
|
||||||
|
|
||||||
|
Ff you can't connect to openocd you might need to adapt your udev rules or use sudo ([openOCD Problems](https://rust-embedded.github.io/discovery/03-setup/linux.html#udev-rules))
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,12 @@
|
||||||
|
[target.thumbv7m-none-eabi]
|
||||||
|
|
||||||
|
# uncomment ONE of these three option to make `cargo run` start a GDB session
|
||||||
|
# which option to pick depends on your system
|
||||||
|
runner = "arm-none-eabi-gdb -q -x openocd.gdb"
|
||||||
|
# runner = "gdb-multiarch -q -x openocd.gdb"
|
||||||
|
# runner = "gdb -q -x openocd.gdb"
|
||||||
|
|
||||||
|
rustflags = ["-C", "link-arg=-Tlink.x"]
|
||||||
|
|
||||||
|
[build]
|
||||||
|
target = "thumbv7m-none-eabi"
|
||||||
|
|
@ -0,0 +1,19 @@
|
||||||
|
[package]
|
||||||
|
name = "embedded_linux_eink_example"
|
||||||
|
version = "0.1.0"
|
||||||
|
authors = ["Christoph Groß <christoph-gross@mailbox.org>"]
|
||||||
|
edition = "2018"
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
|
||||||
|
## The Only difference between this one and the one without default features sizewise seems to be a different .d-file Size (dependencies-file)
|
||||||
|
#epd_waveshare = { path = "../../"}
|
||||||
|
epd-waveshare = { path = "../../", default-features = false, features = ["epd4in2", "graphics"]}
|
||||||
|
|
||||||
|
embedded-graphics = "0.4.5"
|
||||||
|
embedded-hal = { version = "0.2.2", features = ["unproven"] }
|
||||||
|
|
||||||
|
stm32f1xx-hal = { version = "0.2", features = ["rt", "stm32f103" ] }
|
||||||
|
cortex-m = "0.5.0"
|
||||||
|
cortex-m-rt = { version = "0.6.6", features = ["device"] }
|
||||||
|
panic-semihosting = "0.5"
|
||||||
|
|
@ -0,0 +1,6 @@
|
||||||
|
/* Linker script for the STM32F103C8T6 */
|
||||||
|
MEMORY
|
||||||
|
{
|
||||||
|
FLASH : ORIGIN = 0x08000000, LENGTH = 64K
|
||||||
|
RAM : ORIGIN = 0x20000000, LENGTH = 20K
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,2 @@
|
||||||
|
source [find interface/stlink-v2.cfg]
|
||||||
|
source [find target/stm32f1x.cfg]
|
||||||
|
|
@ -0,0 +1,10 @@
|
||||||
|
target remote :3333
|
||||||
|
set print asm-demangle on
|
||||||
|
monitor arm semihosting enable
|
||||||
|
|
||||||
|
# detect unhandled exceptions, hard faults and panics
|
||||||
|
break DefaultHandler
|
||||||
|
break HardFault
|
||||||
|
break rust_begin_unwind
|
||||||
|
|
||||||
|
load
|
||||||
|
|
@ -0,0 +1,192 @@
|
||||||
|
#![no_main]
|
||||||
|
#![no_std]
|
||||||
|
|
||||||
|
// set the panic handler
|
||||||
|
#[allow(unused_imports)]
|
||||||
|
use panic_semihosting;
|
||||||
|
|
||||||
|
use cortex_m_rt::entry;
|
||||||
|
use stm32f1xx_hal::prelude::*;
|
||||||
|
use stm32f1xx_hal::{delay, spi};
|
||||||
|
|
||||||
|
use embedded_graphics::{
|
||||||
|
coord::Coord,
|
||||||
|
fonts::{Font12x16, Font6x8},
|
||||||
|
prelude::*,
|
||||||
|
primitives::{Circle, Line},
|
||||||
|
Drawing,
|
||||||
|
};
|
||||||
|
use epd_waveshare::{
|
||||||
|
epd4in2::Display4in2,
|
||||||
|
graphics::{Display, DisplayRotation},
|
||||||
|
prelude::*,
|
||||||
|
};
|
||||||
|
|
||||||
|
#[entry]
|
||||||
|
fn main() -> ! {
|
||||||
|
let core = cortex_m::Peripherals::take().unwrap();
|
||||||
|
let device = stm32f1xx_hal::stm32::Peripherals::take().unwrap();
|
||||||
|
let mut rcc = device.RCC.constrain();
|
||||||
|
let mut flash = device.FLASH.constrain();
|
||||||
|
|
||||||
|
let clocks = rcc
|
||||||
|
.cfgr
|
||||||
|
.use_hse(8.mhz())
|
||||||
|
.sysclk(72.mhz())
|
||||||
|
.pclk1(36.mhz())
|
||||||
|
.freeze(&mut flash.acr);
|
||||||
|
|
||||||
|
let mut gpioa = device.GPIOA.split(&mut rcc.apb2);
|
||||||
|
let mut gpiob = device.GPIOB.split(&mut rcc.apb2);
|
||||||
|
|
||||||
|
let mut delay = delay::Delay::new(core.SYST, clocks);
|
||||||
|
|
||||||
|
// spi setup
|
||||||
|
let sck = gpiob.pb13.into_alternate_push_pull(&mut gpiob.crh);
|
||||||
|
let miso = gpiob.pb14;
|
||||||
|
let mosi = gpiob.pb15.into_alternate_push_pull(&mut gpiob.crh);
|
||||||
|
let mut spi = spi::Spi::spi2(
|
||||||
|
device.SPI2,
|
||||||
|
(sck, miso, mosi),
|
||||||
|
epd_waveshare::SPI_MODE,
|
||||||
|
4.mhz(),
|
||||||
|
clocks,
|
||||||
|
&mut rcc.apb1,
|
||||||
|
);
|
||||||
|
// epd setup
|
||||||
|
let mut epd4in2 = epd_waveshare::epd4in2::EPD4in2::new(
|
||||||
|
&mut spi,
|
||||||
|
gpiob.pb12.into_push_pull_output(&mut gpiob.crh),
|
||||||
|
gpioa.pa10.into_floating_input(&mut gpioa.crh),
|
||||||
|
gpioa.pa8.into_push_pull_output(&mut gpioa.crh),
|
||||||
|
gpioa.pa9.into_push_pull_output(&mut gpioa.crh),
|
||||||
|
&mut delay,
|
||||||
|
)
|
||||||
|
.unwrap();
|
||||||
|
epd4in2.set_lut(&mut spi, Some(RefreshLUT::QUICK)).unwrap();
|
||||||
|
epd4in2.clear_frame(&mut spi).unwrap();
|
||||||
|
|
||||||
|
//println!("Test all the rotations");
|
||||||
|
let mut display = Display4in2::default();
|
||||||
|
display.set_rotation(DisplayRotation::Rotate0);
|
||||||
|
display.draw(
|
||||||
|
Font6x8::render_str("Rotate 0!")
|
||||||
|
.with_stroke(Some(Color::Black))
|
||||||
|
.with_fill(Some(Color::White))
|
||||||
|
.translate(Coord::new(5, 50))
|
||||||
|
.into_iter(),
|
||||||
|
);
|
||||||
|
|
||||||
|
display.set_rotation(DisplayRotation::Rotate90);
|
||||||
|
display.draw(
|
||||||
|
Font6x8::render_str("Rotate 90!")
|
||||||
|
.with_stroke(Some(Color::Black))
|
||||||
|
.with_fill(Some(Color::White))
|
||||||
|
.translate(Coord::new(5, 50))
|
||||||
|
.into_iter(),
|
||||||
|
);
|
||||||
|
|
||||||
|
display.set_rotation(DisplayRotation::Rotate180);
|
||||||
|
display.draw(
|
||||||
|
Font6x8::render_str("Rotate 180!")
|
||||||
|
.with_stroke(Some(Color::Black))
|
||||||
|
.with_fill(Some(Color::White))
|
||||||
|
.translate(Coord::new(5, 50))
|
||||||
|
.into_iter(),
|
||||||
|
);
|
||||||
|
|
||||||
|
display.set_rotation(DisplayRotation::Rotate270);
|
||||||
|
display.draw(
|
||||||
|
Font6x8::render_str("Rotate 270!")
|
||||||
|
.with_stroke(Some(Color::Black))
|
||||||
|
.with_fill(Some(Color::White))
|
||||||
|
.translate(Coord::new(5, 50))
|
||||||
|
.into_iter(),
|
||||||
|
);
|
||||||
|
|
||||||
|
epd4in2.update_frame(&mut spi, &display.buffer()).unwrap();
|
||||||
|
epd4in2
|
||||||
|
.display_frame(&mut spi)
|
||||||
|
.expect("display frame new graphics");
|
||||||
|
delay.delay_ms(5000u16);
|
||||||
|
|
||||||
|
//println!("Now test new graphics with default rotation and some special stuff:");
|
||||||
|
display.clear_buffer(Color::White);
|
||||||
|
|
||||||
|
// draw a analog clock
|
||||||
|
display.draw(
|
||||||
|
Circle::new(Coord::new(64, 64), 64)
|
||||||
|
.with_stroke(Some(Color::Black))
|
||||||
|
.into_iter(),
|
||||||
|
);
|
||||||
|
display.draw(
|
||||||
|
Line::new(Coord::new(64, 64), Coord::new(0, 64))
|
||||||
|
.with_stroke(Some(Color::Black))
|
||||||
|
.into_iter(),
|
||||||
|
);
|
||||||
|
display.draw(
|
||||||
|
Line::new(Coord::new(64, 64), Coord::new(80, 80))
|
||||||
|
.with_stroke(Some(Color::Black))
|
||||||
|
.into_iter(),
|
||||||
|
);
|
||||||
|
|
||||||
|
// draw white on black background
|
||||||
|
display.draw(
|
||||||
|
Font6x8::render_str("It's working-WoB!")
|
||||||
|
// Using Style here
|
||||||
|
.with_style(Style {
|
||||||
|
fill_color: Some(Color::Black),
|
||||||
|
stroke_color: Some(Color::White),
|
||||||
|
stroke_width: 0u8, // Has no effect on fonts
|
||||||
|
})
|
||||||
|
.translate(Coord::new(175, 250))
|
||||||
|
.into_iter(),
|
||||||
|
);
|
||||||
|
|
||||||
|
// use bigger/different font
|
||||||
|
display.draw(
|
||||||
|
Font12x16::render_str("It's working-BoW!")
|
||||||
|
// Using Style here
|
||||||
|
.with_style(Style {
|
||||||
|
fill_color: Some(Color::White),
|
||||||
|
stroke_color: Some(Color::Black),
|
||||||
|
stroke_width: 0u8, // Has no effect on fonts
|
||||||
|
})
|
||||||
|
.translate(Coord::new(50, 200))
|
||||||
|
.into_iter(),
|
||||||
|
);
|
||||||
|
|
||||||
|
// a moving `Hello World!`
|
||||||
|
let limit = 10;
|
||||||
|
epd4in2.set_lut(&mut spi, Some(RefreshLUT::QUICK)).unwrap();
|
||||||
|
epd4in2.clear_frame(&mut spi).unwrap();
|
||||||
|
for i in 0..limit {
|
||||||
|
//println!("Moving Hello World. Loop {} from {}", (i + 1), limit);
|
||||||
|
|
||||||
|
display.draw(
|
||||||
|
Font6x8::render_str(" Hello World! ")
|
||||||
|
.with_style(Style {
|
||||||
|
fill_color: Some(Color::White),
|
||||||
|
stroke_color: Some(Color::Black),
|
||||||
|
stroke_width: 0u8, // Has no effect on fonts
|
||||||
|
})
|
||||||
|
.translate(Coord::new(5 + i * 12, 50))
|
||||||
|
.into_iter(),
|
||||||
|
);
|
||||||
|
|
||||||
|
epd4in2.update_frame(&mut spi, &display.buffer()).unwrap();
|
||||||
|
epd4in2
|
||||||
|
.display_frame(&mut spi)
|
||||||
|
.expect("display frame new graphics");
|
||||||
|
|
||||||
|
delay.delay_ms(1_000u16);
|
||||||
|
}
|
||||||
|
|
||||||
|
//println!("Finished tests - going to sleep");
|
||||||
|
epd4in2.sleep(&mut spi).expect("epd goes to sleep");
|
||||||
|
|
||||||
|
loop {
|
||||||
|
// sleep
|
||||||
|
cortex_m::asm::wfi();
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue