Add Bluepill example & some other minor improvements (#28)
- added bluepill example - improved ci config - travis: run fmt only once - travis: fixed target issuesdigi-v2-tests
parent
34c03c5486
commit
60f48a8273
@ -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
|
@ -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
|
@ -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