Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision

Target

Select target project
  • astro/rust-card10
  • rnestler/rust-card10
  • dbrgn/rust-card10
  • toon/rust-card10
  • mwall/rust-card10
  • puzzlewolf/rust-card10
  • rnd/rust-card10
  • lilpep/rust-card10
  • rafael/rust-card10
  • squeed/rust-card10
  • arist/rust-card10
11 results
Select Git revision
Show changes
Commits on Source (114)
Showing
with 542 additions and 216 deletions
#!/usr/bin/env bash
set -e
cargo build --release
arm-none-eabi-objcopy -O binary target/thumbv7em-none-eabi/release/$2 card10.bin
python c/bootloader/crc_patch.py card10.bin
echo "Copy this file to the device in USB Mass Storage mode:"
ls -l card10.bin
...@@ -29,4 +29,5 @@ firmware: ...@@ -29,4 +29,5 @@ firmware:
- apps - apps
- main.py - main.py
- menu.py - menu.py
- card10.cfg
expire_in: 1 week expire_in: 1 week
From baef13b1adb6f7bf01a7dfd7f4f44a5a3e950b1d Mon Sep 17 00:00:00 2001
From: Astro <astro@spaceboyz.net>
Date: Thu, 5 Sep 2019 02:22:45 +0200
Subject: [PATCH] hack(epicardium): reduce init delay from 2s to 0.1s
---
epicardium/main.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/epicardium/main.c b/epicardium/main.c
index 51edbe93..7607d39d 100644
--- a/epicardium/main.c
+++ b/epicardium/main.c
@@ -32,7 +32,7 @@ int main(void)
epic_disp_print(10, 20, "Epicardium", 0xfe20, 0x0000);
epic_disp_print(off > 0 ? off : 0, 40, version_buf, 0xfe20, 0x0000);
epic_disp_update();
- mxc_delay(2000000);
+ mxc_delay(100000);
LOG_DEBUG("startup", "Initializing tasks ...");
--
2.22.1
...@@ -11,10 +11,10 @@ dependencies = [ ...@@ -11,10 +11,10 @@ dependencies = [
[[package]] [[package]]
name = "alloc-cortex-m" name = "alloc-cortex-m"
version = "0.3.5" version = "0.3.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "git+https://github.com/rust-embedded/alloc-cortex-m#761502c1c7da901d87f7ed39c000f3a80feacc13"
dependencies = [ dependencies = [
"cortex-m 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", "cortex-m 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
"linked_list_allocator 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", "linked_list_allocator 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
[[package]] [[package]]
...@@ -22,7 +22,7 @@ name = "ansi_term" ...@@ -22,7 +22,7 @@ name = "ansi_term"
version = "0.11.0" version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
[[package]] [[package]]
...@@ -30,55 +30,36 @@ name = "atty" ...@@ -30,55 +30,36 @@ name = "atty"
version = "0.2.13" version = "0.2.13"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "backtrace"
version = "0.3.35"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"backtrace-sys 0.1.31 (registry+https://github.com/rust-lang/crates.io-index)",
"cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-demangle 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "backtrace-sys"
version = "0.1.31"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"cc 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
[[package]] [[package]]
name = "bindgen" name = "bindgen"
version = "0.51.0" version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"cexpr 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", "cexpr 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
"cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
"clang-sys 0.28.1 (registry+https://github.com/rust-lang/crates.io-index)", "clang-sys 0.28.1 (registry+https://github.com/rust-lang/crates.io-index)",
"clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)", "clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)",
"env_logger 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)",
"fxhash 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "lazycell 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
"peeking_take_while 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "peeking_take_while 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"proc-macro2 0.4.28 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
"quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
"regex 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "regex 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
"shlex 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "shlex 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"which 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "which 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
[[package]] [[package]]
name = "bitflags" name = "bitflags"
version = "1.1.0" version = "1.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]] [[package]]
...@@ -88,38 +69,37 @@ source = "registry+https://github.com/rust-lang/crates.io-index" ...@@ -88,38 +69,37 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]] [[package]]
name = "card10-alloc" name = "card10-alloc"
version = "0.1.0" version = "0.1.1"
dependencies = [ dependencies = [
"alloc-cortex-m 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", "alloc-cortex-m 0.3.5 (git+https://github.com/rust-embedded/alloc-cortex-m)",
"card10-sys 0.1.0", "card10-sys 1.10.0",
] ]
[[package]] [[package]]
name = "card10-l0dable" name = "card10-l0dable"
version = "0.1.1" version = "0.3.0"
dependencies = [ dependencies = [
"card10-sys 0.1.0", "card10-sys 1.10.0",
"embedded-graphics 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", "embedded-graphics 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
[[package]] [[package]]
name = "card10-sys" name = "card10-sys"
version = "0.1.0" version = "1.10.0"
dependencies = [ dependencies = [
"bindgen 0.51.0 (registry+https://github.com/rust-lang/crates.io-index)", "bindgen 0.52.0 (registry+https://github.com/rust-lang/crates.io-index)",
"cc 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", "cc 1.0.48 (registry+https://github.com/rust-lang/crates.io-index)",
"panic-abort 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
"r0 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "r0 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
[[package]] [[package]]
name = "cc" name = "cc"
version = "1.0.37" version = "1.0.48"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]] [[package]]
name = "cexpr" name = "cexpr"
version = "0.3.5" version = "0.3.6"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"nom 4.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "nom 4.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
...@@ -127,7 +107,7 @@ dependencies = [ ...@@ -127,7 +107,7 @@ dependencies = [
[[package]] [[package]]
name = "cfg-if" name = "cfg-if"
version = "0.1.9" version = "0.1.10"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]] [[package]]
...@@ -136,7 +116,7 @@ version = "0.28.1" ...@@ -136,7 +116,7 @@ version = "0.28.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"glob 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "glob 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)",
"libloading 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", "libloading 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
...@@ -147,10 +127,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" ...@@ -147,10 +127,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", "ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
"atty 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)", "atty 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)",
"bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"strsim 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "strsim 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
"textwrap 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", "textwrap 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
"unicode-width 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-width 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)",
"vec_map 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "vec_map 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
...@@ -166,8 +146,8 @@ dependencies = [ ...@@ -166,8 +146,8 @@ dependencies = [
name = "draw-image" name = "draw-image"
version = "0.0.0" version = "0.0.0"
dependencies = [ dependencies = [
"card10-l0dable 0.1.1", "card10-l0dable 0.3.0",
"cc 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", "cc 1.0.48 (registry+https://github.com/rust-lang/crates.io-index)",
"embedded-graphics 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", "embedded-graphics 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
...@@ -178,32 +158,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" ...@@ -178,32 +158,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]] [[package]]
name = "env_logger" name = "env_logger"
version = "0.6.2" version = "0.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"atty 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)", "atty 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)",
"humantime 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "humantime 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
"regex 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "regex 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
"termcolor 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", "termcolor 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
[[package]]
name = "failure"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"backtrace 0.3.35 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "fxhash"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]] [[package]]
name = "glob" name = "glob"
version = "0.3.0" version = "0.3.0"
...@@ -211,7 +175,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" ...@@ -211,7 +175,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]] [[package]]
name = "humantime" name = "humantime"
version = "1.2.0" version = "1.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
...@@ -221,27 +185,34 @@ dependencies = [ ...@@ -221,27 +185,34 @@ dependencies = [
name = "l0dable-example" name = "l0dable-example"
version = "0.0.0" version = "0.0.0"
dependencies = [ dependencies = [
"card10-alloc 0.1.0", "card10-alloc 0.1.1",
"card10-l0dable 0.1.1", "card10-l0dable 0.3.0",
"cc 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", "cc 1.0.48 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
[[package]] [[package]]
name = "l0dable-rkanoid" name = "l0dable-rkanoid"
version = "0.0.0" version = "0.0.0"
dependencies = [ dependencies = [
"card10-l0dable 0.1.1", "card10-alloc 0.1.1",
"cc 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", "card10-l0dable 0.3.0",
"cc 1.0.48 (registry+https://github.com/rust-lang/crates.io-index)",
"embedded-graphics 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
[[package]] [[package]]
name = "lazy_static" name = "lazy_static"
version = "1.3.0" version = "1.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "lazycell"
version = "1.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]] [[package]]
name = "libc" name = "libc"
version = "0.2.62" version = "0.2.66"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]] [[package]]
...@@ -249,13 +220,13 @@ name = "libloading" ...@@ -249,13 +220,13 @@ name = "libloading"
version = "0.5.2" version = "0.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"cc 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", "cc 1.0.48 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
[[package]] [[package]]
name = "linked_list_allocator" name = "linked_list_allocator"
version = "0.6.4" version = "0.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]] [[package]]
...@@ -263,7 +234,7 @@ name = "log" ...@@ -263,7 +234,7 @@ name = "log"
version = "0.4.8" version = "0.4.8"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
[[package]] [[package]]
...@@ -280,11 +251,6 @@ dependencies = [ ...@@ -280,11 +251,6 @@ dependencies = [
"version_check 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "version_check 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
[[package]]
name = "panic-abort"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]] [[package]]
name = "peeking_take_while" name = "peeking_take_while"
version = "0.1.2" version = "0.1.2"
...@@ -292,10 +258,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" ...@@ -292,10 +258,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]] [[package]]
name = "proc-macro2" name = "proc-macro2"
version = "0.4.28" version = "1.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
[[package]] [[package]]
...@@ -305,10 +271,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" ...@@ -305,10 +271,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]] [[package]]
name = "quote" name = "quote"
version = "0.6.12" version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"proc-macro2 0.4.28 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
[[package]] [[package]]
...@@ -318,24 +284,27 @@ source = "registry+https://github.com/rust-lang/crates.io-index" ...@@ -318,24 +284,27 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]] [[package]]
name = "regex" name = "regex"
version = "1.2.1" version = "1.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"aho-corasick 0.7.6 (registry+https://github.com/rust-lang/crates.io-index)", "aho-corasick 0.7.6 (registry+https://github.com/rust-lang/crates.io-index)",
"memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"regex-syntax 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)", "regex-syntax 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)",
"thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
[[package]] [[package]]
name = "regex-syntax" name = "regex-syntax"
version = "0.6.11" version = "0.6.12"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]] [[package]]
name = "rustc-demangle" name = "rustc-hash"
version = "0.1.16" version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]] [[package]]
name = "shlex" name = "shlex"
...@@ -360,7 +329,7 @@ name = "textwrap" ...@@ -360,7 +329,7 @@ name = "textwrap"
version = "0.11.0" version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"unicode-width 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-width 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
[[package]] [[package]]
...@@ -368,17 +337,17 @@ name = "thread_local" ...@@ -368,17 +337,17 @@ name = "thread_local"
version = "0.3.6" version = "0.3.6"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
[[package]] [[package]]
name = "unicode-width" name = "unicode-width"
version = "0.1.6" version = "0.1.7"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]] [[package]]
name = "unicode-xid" name = "unicode-xid"
version = "0.1.0" version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]] [[package]]
...@@ -398,16 +367,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index" ...@@ -398,16 +367,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]] [[package]]
name = "which" name = "which"
version = "2.0.1" version = "3.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
[[package]] [[package]]
name = "winapi" name = "winapi"
version = "0.3.7" version = "0.3.8"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
...@@ -424,7 +392,7 @@ name = "winapi-util" ...@@ -424,7 +392,7 @@ name = "winapi-util"
version = "0.1.2" version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
[[package]] [[package]]
...@@ -437,60 +405,56 @@ name = "wincolor" ...@@ -437,60 +405,56 @@ name = "wincolor"
version = "1.0.2" version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi-util 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "winapi-util 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
[metadata] [metadata]
"checksum aho-corasick 0.7.6 (registry+https://github.com/rust-lang/crates.io-index)" = "58fb5e95d83b38284460a5fda7d6470aa0b8844d283a0b614b8535e880800d2d" "checksum aho-corasick 0.7.6 (registry+https://github.com/rust-lang/crates.io-index)" = "58fb5e95d83b38284460a5fda7d6470aa0b8844d283a0b614b8535e880800d2d"
"checksum alloc-cortex-m 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "6d5f7d01bc93ce089de636f946f7f1fdc5e5d751732367e019c9755440e7aef4" "checksum alloc-cortex-m 0.3.5 (git+https://github.com/rust-embedded/alloc-cortex-m)" = "<none>"
"checksum ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b" "checksum ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b"
"checksum atty 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)" = "1803c647a3ec87095e7ae7acfca019e98de5ec9a7d01343f611cf3152ed71a90" "checksum atty 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)" = "1803c647a3ec87095e7ae7acfca019e98de5ec9a7d01343f611cf3152ed71a90"
"checksum backtrace 0.3.35 (registry+https://github.com/rust-lang/crates.io-index)" = "1371048253fa3bac6704bfd6bbfc922ee9bdcee8881330d40f308b81cc5adc55" "checksum bindgen 0.52.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f1c85344eb535a31b62f0af37be84441ba9e7f0f4111eb0530f43d15e513fe57"
"checksum backtrace-sys 0.1.31 (registry+https://github.com/rust-lang/crates.io-index)" = "82a830b4ef2d1124a711c71d263c5abdc710ef8e907bd508c88be475cebc422b" "checksum bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693"
"checksum bindgen 0.51.0 (registry+https://github.com/rust-lang/crates.io-index)" = "18270cdd7065ec045a6bb4bdcd5144d14a78b3aedb3bc5111e688773ac8b9ad0"
"checksum bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3d155346769a6855b86399e9bc3814ab343cd3d62c7e985113d46a0ec3c281fd"
"checksum byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a7c3dd8985a7111efc5c80b44e23ecdd8c007de8ade3b96595387e812b957cf5" "checksum byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a7c3dd8985a7111efc5c80b44e23ecdd8c007de8ade3b96595387e812b957cf5"
"checksum cc 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)" = "39f75544d7bbaf57560d2168f28fd649ff9c76153874db88bdbdfd839b1a7e7d" "checksum cc 1.0.48 (registry+https://github.com/rust-lang/crates.io-index)" = "f52a465a666ca3d838ebbf08b241383421412fe7ebb463527bba275526d89f76"
"checksum cexpr 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "a7fa24eb00d5ffab90eaeaf1092ac85c04c64aaf358ea6f84505b8116d24c6af" "checksum cexpr 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "fce5b5fb86b0c57c20c834c1b412fd09c77c8a59b9473f86272709e78874cd1d"
"checksum cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "b486ce3ccf7ffd79fdeb678eac06a9e6c09fc88d33836340becb8fffe87c5e33" "checksum cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822"
"checksum clang-sys 0.28.1 (registry+https://github.com/rust-lang/crates.io-index)" = "81de550971c976f176130da4b2978d3b524eaa0fd9ac31f3ceb5ae1231fb4853" "checksum clang-sys 0.28.1 (registry+https://github.com/rust-lang/crates.io-index)" = "81de550971c976f176130da4b2978d3b524eaa0fd9ac31f3ceb5ae1231fb4853"
"checksum clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5067f5bb2d80ef5d68b4c87db81601f0b75bca627bc2ef76b141d7b846a3c6d9" "checksum clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5067f5bb2d80ef5d68b4c87db81601f0b75bca627bc2ef76b141d7b846a3c6d9"
"checksum cortex-m 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "3df5de9a9829f2ccb7defa8945fa020c6614cd2f6ba9b5f33db9241dcc01985e" "checksum cortex-m 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "3df5de9a9829f2ccb7defa8945fa020c6614cd2f6ba9b5f33db9241dcc01985e"
"checksum embedded-graphics 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "704679bfcb66cc748ec185ae62ccd5b03311a53793372e2abf1ff9a7e9875ff7" "checksum embedded-graphics 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "704679bfcb66cc748ec185ae62ccd5b03311a53793372e2abf1ff9a7e9875ff7"
"checksum env_logger 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "aafcde04e90a5226a6443b7aabdb016ba2f8307c847d524724bd9b346dd1a2d3" "checksum env_logger 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "44533bbbb3bb3c1fa17d9f2e4e38bbbaf8396ba82193c4cb1b6445d711445d36"
"checksum failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "795bd83d3abeb9220f257e597aa0080a508b27533824adf336529648f6abf7e2"
"checksum fxhash 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c31b6d751ae2c7f11320402d34e41349dd1016f8d5d45e48c4312bc8625af50c"
"checksum glob 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574" "checksum glob 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574"
"checksum humantime 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3ca7e5f2e110db35f93b837c81797f3714500b81d517bf20c431b16d3ca4f114" "checksum humantime 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "df004cfca50ef23c36850aaaa59ad52cc70d0e90243c3c7737a4dd32dc7a3c4f"
"checksum lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bc5729f27f159ddd61f4df6228e827e86643d4d3e7c32183cb30a1c08f604a14" "checksum lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
"checksum libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)" = "34fcd2c08d2f832f376f4173a231990fa5aef4e99fb569867318a227ef4c06ba" "checksum lazycell 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b294d6fa9ee409a054354afc4352b0b9ef7ca222c69b8812cbea9e7d2bf3783f"
"checksum libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)" = "d515b1f41455adea1313a4a2ac8a8a477634fbae63cc6100e3aebb207ce61558"
"checksum libloading 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f2b111a074963af1d37a139918ac6d49ad1d0d5e47f72fd55388619691a7d753" "checksum libloading 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f2b111a074963af1d37a139918ac6d49ad1d0d5e47f72fd55388619691a7d753"
"checksum linked_list_allocator 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)" = "47314ec1d29aa869ee7cb5a5be57be9b1055c56567d59c3fb6689926743e0bea" "checksum linked_list_allocator 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "5825aea823c659d0fdcdbe8c9b78baf56f3a10365d783db874f6d360df72626f"
"checksum log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)" = "14b6052be84e6b71ab17edffc2eeabf5c2c3ae1fdb464aae35ac50c67a44e1f7" "checksum log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)" = "14b6052be84e6b71ab17edffc2eeabf5c2c3ae1fdb464aae35ac50c67a44e1f7"
"checksum memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "88579771288728879b57485cc7d6b07d648c9f0141eb955f8ab7f9d45394468e" "checksum memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "88579771288728879b57485cc7d6b07d648c9f0141eb955f8ab7f9d45394468e"
"checksum nom 4.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2ad2a91a8e869eeb30b9cb3119ae87773a8f4ae617f41b1eb9c154b2905f7bd6" "checksum nom 4.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2ad2a91a8e869eeb30b9cb3119ae87773a8f4ae617f41b1eb9c154b2905f7bd6"
"checksum panic-abort 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2c14a66511ed17b6a8b4256b868d7fd207836d891db15eea5195dbcaf87e630f"
"checksum peeking_take_while 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099" "checksum peeking_take_while 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099"
"checksum proc-macro2 0.4.28 (registry+https://github.com/rust-lang/crates.io-index)" = "ba92c84f814b3f9a44c5cfca7d2ad77fa10710867d2bbb1b3d175ab5f47daa12" "checksum proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "9c9e470a8dc4aeae2dee2f335e8f533e2d4b347e1434e5671afc49b054592f27"
"checksum quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9274b940887ce9addde99c4eee6b5c44cc494b182b97e73dc8ffdcb3397fd3f0" "checksum quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9274b940887ce9addde99c4eee6b5c44cc494b182b97e73dc8ffdcb3397fd3f0"
"checksum quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)" = "faf4799c5d274f3868a4aae320a0a182cbd2baee377b378f080e16a23e9d80db" "checksum quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "053a8c8bcc71fcce321828dc897a98ab9760bef03a4fc36693c231e5b3216cfe"
"checksum r0 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e2a38df5b15c8d5c7e8654189744d8e396bddc18ad48041a500ce52d6948941f" "checksum r0 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e2a38df5b15c8d5c7e8654189744d8e396bddc18ad48041a500ce52d6948941f"
"checksum regex 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "88c3d9193984285d544df4a30c23a4e62ead42edf70a4452ceb76dac1ce05c26" "checksum regex 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dc220bd33bdce8f093101afe22a037b8eb0e5af33592e6a9caafff0d4cb81cbd"
"checksum regex-syntax 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)" = "b143cceb2ca5e56d5671988ef8b15615733e7ee16cd348e064333b251b89343f" "checksum regex-syntax 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)" = "11a7e20d1cce64ef2fed88b66d347f88bd9babb82845b2b858f3edbf59a4f716"
"checksum rustc-demangle 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)" = "4c691c0e608126e00913e33f0ccf3727d5fc84573623b8d65b2df340b5201783" "checksum rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7540fc8b0c49f096ee9c961cda096467dce8084bec6bdca2fc83895fd9b28cb8"
"checksum shlex 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7fdf1b9db47230893d76faad238fd6097fd6d6a9245cd7a4d90dbd639536bbd2" "checksum shlex 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7fdf1b9db47230893d76faad238fd6097fd6d6a9245cd7a4d90dbd639536bbd2"
"checksum strsim 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" "checksum strsim 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a"
"checksum termcolor 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "96d6098003bde162e4277c70665bd87c326f5a0c3f3fbfb285787fa482d54e6e" "checksum termcolor 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "96d6098003bde162e4277c70665bd87c326f5a0c3f3fbfb285787fa482d54e6e"
"checksum textwrap 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" "checksum textwrap 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060"
"checksum thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c6b53e329000edc2b34dbe8545fd20e55a333362d0a321909685a19bd28c3f1b" "checksum thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c6b53e329000edc2b34dbe8545fd20e55a333362d0a321909685a19bd28c3f1b"
"checksum unicode-width 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "7007dbd421b92cc6e28410fe7362e2e0a2503394908f417b68ec8d1c364c4e20" "checksum unicode-width 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "caaa9d531767d1ff2150b9332433f32a24622147e5ebb1f26409d5da67afd479"
"checksum unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" "checksum unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c"
"checksum vec_map 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "05c78687fb1a80548ae3250346c3db86a80a7cdd77bda190189f2d0a0987c81a" "checksum vec_map 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "05c78687fb1a80548ae3250346c3db86a80a7cdd77bda190189f2d0a0987c81a"
"checksum version_check 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "914b1a6776c4c929a602fafd8bc742e06365d4bcbe48c30f9cca5824f70dc9dd" "checksum version_check 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "914b1a6776c4c929a602fafd8bc742e06365d4bcbe48c30f9cca5824f70dc9dd"
"checksum volatile-register 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a470889aa8f2d3ad893bd43cd90c824e63e8ac0ee5fe64c5d81a932d184fd549" "checksum volatile-register 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a470889aa8f2d3ad893bd43cd90c824e63e8ac0ee5fe64c5d81a932d184fd549"
"checksum which 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b57acb10231b9493c8472b20cb57317d0679a49e0bdbee44b3b803a6473af164" "checksum which 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5475d47078209a02e60614f7ba5e645ef3ed60f771920ac1906d7c1cc65024c8"
"checksum winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)" = "f10e386af2b13e47c89e7236a7a14a086791a2b88ebad6df9bf42040195cf770" "checksum winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "8093091eeb260906a183e6ae1abdba2ef5ef2257a21801128899c3fc699229c6"
"checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" "checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
"checksum winapi-util 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7168bab6e1daee33b4557efd0e95d5ca70a03706d39fa5f3fe7a236f584b03c9" "checksum winapi-util 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7168bab6e1daee33b4557efd0e95d5ca70a03706d39fa5f3fe7a236f584b03c9"
"checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" "checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
......
...@@ -21,3 +21,6 @@ debug = true ...@@ -21,3 +21,6 @@ debug = true
opt-level = "s" opt-level = "s"
lto = true lto = true
panic = "abort" panic = "abort"
[patch.crates-io]
alloc-cortex-m = { git = 'https://github.com/rust-embedded/alloc-cortex-m' }
# Rust support for the card10 CCCamp19 badge # Rust support for the card10 CCCamp19 badge
## Prepare your card10
**Jailbreaking is no longer necessary!**
Starting with firmware v1.9, running ELF binaries requires a
`/card10.cfg` with the following content:
```
execute_elf=true
```
## Prebuilt binaries ## Prebuilt binaries
By courtesy of this Gitlab's CI system, and NixOS, we build `.elf` By courtesy of this Gitlab's CI system, and NixOS, we build `.elf`
files for you drop into the `apps/` directory of your card10 badge. files for you drop into the `apps/` directory of your card10 badge.
Because running ELF binaries requires a jailbroken base firmware For each commit in this repository, we also build complete firmware
starting with v1.5, we build this one too. It includes this project's images with the required configuration and our example binaries.
Rust binaries.
https://git.card10.badge.events.ccc.de/astro/rust-card10/-/jobs https://git.card10.badge.events.ccc.de/astro/rust-card10/-/jobs
...@@ -40,25 +50,6 @@ firmware including the matching libc. ...@@ -40,25 +50,6 @@ firmware including the matching libc.
git submodule update --init --recursive git submodule update --init --recursive
``` ```
## Setup a Rust enabled firmware
To allow rust based apps on card10 you need a firmware which allows
to run custom elf binaries on the core. This requires a custom build
with `-Djailbreak_card10=true` as bootstrapping flag.
Assuming that you installed all required dependencies mentioned in
https://firmware.card10.badge.events.ccc.de/how-to-build.html this
should work as following:
```shell
cd card10-sys/firmware
./bootstrap -Djailbreak_card10=true
ninja -C build/
```
And then copy `build/pycardium/pycardium_epicardium.bin` as
`card10.bin` onto your badge.
## Build and run Rust loadables ## Build and run Rust loadables
### Setup ### Setup
...@@ -127,14 +118,18 @@ extension (e.g `example` must be renamed as `example.elf`). ...@@ -127,14 +118,18 @@ extension (e.g `example` must be renamed as `example.elf`).
## Crates ## Crates
| Crate | Description | | Crate | Documentation | Description |
| ---- | --- | | ---- | --- | --- |
| card10-sys | Unsafe C bindings for l0dables | | card10-sys | [docs.rs][card10-sys] | Unsafe C bindings for l0dables |
| card10-alloc | alloc::* support for l0dables | | card10-alloc | [docs.rs][card10-alloc] | alloc::* support for l0dables |
| card10-l0dable | High-level crate for building l0dables | | card10-l0dable | [docs.rs][card10-l0dable] | High-level crate for building l0dables |
| example | l0dable example | | example | | l0dable example |
| rkanoid | Arkanoid clone | | rkanoid | | Arkanoid clone |
| draw-image | Example of drawing a static image to the display | | draw-image | | Example of drawing a static image to the display |
[card10-sys]: https://docs.rs/card10-sys/
[card10-alloc]: https://docs.rs/card10-alloc/
[card10-l0dable]: https://docs.rs/card10-l0dable/
## Misc ## Misc
......
[package] [package]
name = "card10-alloc" name = "card10-alloc"
version = "0.1.0" version = "0.1.1"
authors = ["Astro <astro@spaceboyz.net>"] authors = ["Astro <astro@spaceboyz.net>"]
license = "MIT/Apache-2.0" license = "MIT/Apache-2.0"
edition = "2018" edition = "2018"
...@@ -9,6 +9,7 @@ edition = "2018" ...@@ -9,6 +9,7 @@ edition = "2018"
description = "Dynamic memory allocation for card10 l0dables" description = "Dynamic memory allocation for card10 l0dables"
repository = "https://git.card10.badge.events.ccc.de/astro/rust-card10" repository = "https://git.card10.badge.events.ccc.de/astro/rust-card10"
homepage = "https://git.card10.badge.events.ccc.de/astro/rust-card10" homepage = "https://git.card10.badge.events.ccc.de/astro/rust-card10"
documentation = "https://docs.rs/card10-alloc"
categories = ["no-std", "memory-management"] categories = ["no-std", "memory-management"]
keywords = [ keywords = [
......
//! Support for dynamically allocated memory
//!
//! Reproduces l0dable hardware.c's `_sbrk()` //! Reproduces l0dable hardware.c's `_sbrk()`
//! //!
//! Unfortunately, we cannot link _sbrk()` directly because it //! Unfortunately, we cannot link `_sbrk()` directly because it
//! references the unwieldy `errno`. //! references the unwieldy `errno`.
//!
//! ## Example
//!
//! ```rust
//! #![no_std]
//! #![no_main]
//!
//! extern crate alloc;
//! use alloc::vec;
//! use card10_l0dable::*;
//!
//! main!(main);
//! fn main() {
//! // Pass stack headroom
//! card10_alloc::init(128 * 1024);
//! let mut xs = vec![];
//! xs.push(23);
//! }
//! ```
#![no_std] #![no_std]
#![feature(asm)] #![feature(asm)]
#![feature(alloc_error_handler)] #![feature(alloc_error_handler)]
...@@ -26,7 +47,10 @@ fn sp() -> usize { ...@@ -26,7 +47,10 @@ fn sp() -> usize {
value value
} }
/// You must call this before using anything from `alloc`. /// Call this before using anything from `alloc`.
///
/// Consider the size of your stack-allocated variables for the
/// `stack_headroom` parameter.
/// ///
/// Returns heap size /// Returns heap size
pub fn init(stack_headroom: usize) -> usize { pub fn init(stack_headroom: usize) -> usize {
......
[package] [package]
edition = "2018" edition = "2018"
name = "card10-l0dable" name = "card10-l0dable"
version = "0.1.1" version = "0.3.0"
authors = ["Astro <astro@spaceboyz.net>", "Kloenk <me@kloenk.de>"] authors = [
"Astro <astro@spaceboyz.net>",
"Kloenk <me@kloenk.de>",
"Bruno Kirschner <bruno.kirschner@online.de>",
"Puzzlewolf <camp@nora.pink>",
"Raphael Nestler <raphael.nestler@gmail.com>",
"Danilo Bargen <mail@dbrgn.ch>",
"toon <toon@c3d2.de>",
"Sergey Pepyakin <sergei@parity.io>",
]
license = "MIT/Apache-2.0" license = "MIT/Apache-2.0"
repository = "https://git.card10.badge.events.ccc.de/astro/rust-card10" repository = "https://git.card10.badge.events.ccc.de/astro/rust-card10"
homepage = "https://git.card10.badge.events.ccc.de/astro/rust-card10" homepage = "https://git.card10.badge.events.ccc.de/astro/rust-card10"
...@@ -15,8 +25,8 @@ keywords = [ ...@@ -15,8 +25,8 @@ keywords = [
] ]
categories = ["no-std"] categories = ["no-std"]
description = "make l0dables for the Card10 (CCCamp 2019) badge" description = "make l0dables for the Card10 (CCCamp 2019) badge"
documentation = "https://docs.rs/card10-l0dable"
[dependencies] [dependencies]
card10-sys = { path = "../card10-sys", version = "^0.1" } card10-sys = { path = "../card10-sys" }
embedded-graphics = "0.5.2" embedded-graphics = "0.5"
/// Accelerometer, Gyroscope, Orientation
use core::{ use core::{
fmt::{self, Display, Write}, fmt::{self, Display, Write},
marker::PhantomData, marker::PhantomData,
...@@ -53,6 +55,10 @@ pub struct Sensor<S: SensorType> { ...@@ -53,6 +55,10 @@ pub struct Sensor<S: SensorType> {
} }
impl<S: SensorType> Sensor<S> { impl<S: SensorType> Sensor<S> {
/// Use one of:
/// - `BHI160::<Accelerometer>::start()`
/// - `BHI160::<Gyroscope>::start()`
/// - `BHI160::<Orientation>::start()`
fn new(stream_id: i32) -> Self { fn new(stream_id: i32) -> Self {
Self { Self {
stream_id, stream_id,
......
/// Enviromental sensor
use card10_sys::*; use card10_sys::*;
use core::mem::uninitialized; use core::mem::uninitialized;
...@@ -7,7 +9,7 @@ pub type SensorData = bme680_sensor_data; ...@@ -7,7 +9,7 @@ pub type SensorData = bme680_sensor_data;
impl BME680 { impl BME680 {
pub fn start() -> Self { pub fn start() -> Self {
if unsafe { epic_bme680_init() } != 0 { if unsafe { epic_bme680_init() } != 0 {
panic!("Cannot start light sensor"); panic!("Cannot start BME680 sensor");
} }
BME680 BME680
} }
......
use card10_sys::*; use card10_sys::*;
/// Button inputs
pub struct Buttons { pub struct Buttons {
state: u32, state: u32,
} }
impl Buttons { impl Buttons {
/// Read the current button state
pub fn read() -> Self { pub fn read() -> Self {
let mask = epic_button_BUTTON_LEFT_BOTTOM let mask = epic_button_BUTTON_LEFT_BOTTOM
| epic_button_BUTTON_RIGHT_BOTTOM | epic_button_BUTTON_RIGHT_BOTTOM
......
...@@ -49,7 +49,7 @@ impl Color { ...@@ -49,7 +49,7 @@ impl Color {
} }
pub fn g8(&self) -> u8 { pub fn g8(&self) -> u8 {
self.r() << 2 self.g() << 2
} }
pub fn b(&self) -> u8 { pub fn b(&self) -> u8 {
...@@ -57,7 +57,7 @@ impl Color { ...@@ -57,7 +57,7 @@ impl Color {
} }
pub fn b8(&self) -> u8 { pub fn b8(&self) -> u8 {
self.r() << 3 self.b() << 3
} }
} }
...@@ -75,12 +75,23 @@ pub enum FillStyle { ...@@ -75,12 +75,23 @@ pub enum FillStyle {
pub struct Display; pub struct Display;
#[repr(u8)]
pub enum Font {
Font8 = disp_font_name_DISP_FONT8 as u8,
Font12 = disp_font_name_DISP_FONT12 as u8,
Font16 = disp_font_name_DISP_FONT16 as u8,
Font20 = disp_font_name_DISP_FONT20 as u8,
Font24 = disp_font_name_DISP_FONT24 as u8,
}
/// Immediate mode routines
impl Display { impl Display {
pub const W: u16 = 160; pub const W: i16 = 160;
pub const H: u16 = 80; pub const H: i16 = 80;
pub const FONT_W: u16 = 14; pub const FONT_W: i16 = 14;
pub const FONT_H: u16 = 20; pub const FONT_H: i16 = 20;
/// Open the display, return an instance
pub fn open() -> Self { pub fn open() -> Self {
unsafe { unsafe {
epic_disp_open(); epic_disp_open();
...@@ -88,37 +99,52 @@ impl Display { ...@@ -88,37 +99,52 @@ impl Display {
Display Display
} }
/// Write Epicardium's framebuffer to the display
pub fn update(&self) { pub fn update(&self) {
unsafe { unsafe {
epic_disp_update(); epic_disp_update();
} }
} }
/// Clear everything with a solid `color`
pub fn clear(&self, color: Color) { pub fn clear(&self, color: Color) {
unsafe { unsafe {
epic_disp_clear(color.0); epic_disp_clear(color.0);
} }
} }
/// Print text
///
/// s must be 0-terminated /// s must be 0-terminated
pub fn print(&self, x: u16, y: u16, s: &[u8], fg: Color, bg: Color) { pub fn print(&self, x: i16, y: i16, s: &[u8], fg: Color, bg: Color) {
unsafe { unsafe {
epic_disp_print(x, y, s.as_ptr(), fg.0, bg.0); epic_disp_print(x, y, s.as_ptr(), fg.0, bg.0);
} }
} }
pub fn pixel(&self, x: u16, y: u16, color: Color) { /// Print text with a selected font
///
/// s must be 0-terminated
pub fn print_adv(&self, font: Font, x: i16, y: i16, s: &[u8], fg: Color, bg: Color) {
unsafe {
epic_disp_print_adv(font as u8, x, y, s.as_ptr(), fg.0, bg.0);
}
}
/// Set a pixel
pub fn pixel(&self, x: i16, y: i16, color: Color) {
unsafe { unsafe {
epic_disp_pixel(x, y, color.0); epic_disp_pixel(x, y, color.0);
} }
} }
/// Draw a line
pub fn line( pub fn line(
&self, &self,
x1: u16, x1: i16,
y1: u16, y1: i16,
x2: u16, x2: i16,
y2: u16, y2: i16,
color: Color, color: Color,
linestyle: LineStyle, linestyle: LineStyle,
pixelsize: u16, pixelsize: u16,
...@@ -130,10 +156,10 @@ impl Display { ...@@ -130,10 +156,10 @@ impl Display {
pub fn rect( pub fn rect(
&self, &self,
x1: u16, x1: i16,
y1: u16, y1: i16,
x2: u16, x2: i16,
y2: u16, y2: i16,
color: Color, color: Color,
fillstyle: FillStyle, fillstyle: FillStyle,
pixelsize: u16, pixelsize: u16,
...@@ -143,10 +169,11 @@ impl Display { ...@@ -143,10 +169,11 @@ impl Display {
} }
} }
/// Draw a circle
pub fn circ( pub fn circ(
&self, &self,
x: u16, x: i16,
y: u16, y: i16,
rad: u16, rad: u16,
color: Color, color: Color,
fillstyle: FillStyle, fillstyle: FillStyle,
...@@ -157,7 +184,11 @@ impl Display { ...@@ -157,7 +184,11 @@ impl Display {
} }
} }
pub fn framebuffer<'d>(&'d self) -> FrameBuffer<'d> { /// Obtain a handle for a framebuffer.
///
/// Don't use `display.send()` but `framebuffer.send()` as long as
/// it is in use.
pub fn framebuffer<'d>(&'d mut self) -> FrameBuffer<'d> {
FrameBuffer::uninitialized(self) FrameBuffer::uninitialized(self)
} }
} }
...@@ -169,3 +200,42 @@ impl Drop for Display { ...@@ -169,3 +200,42 @@ impl Drop for Display {
} }
} }
} }
/// Convenience text display
///
/// Requires `card10_alloc::init()` and `extern crate alloc;`
#[macro_export]
macro_rules! display {
($disp: expr, $x: expr, $y: expr, $fg: expr, $bg: expr,
$fmt: expr) => ({
use alloc::format;
let s = format!(concat!($fmt, "\0"));
$disp.print($x, $y, s.as_bytes(), $fg, $bg);
});
($disp: expr, $x: expr, $y: expr, $fg: expr, $bg: expr,
$fmt: expr, $($arg: tt)*) => ({
use alloc::format;
let s = format!(concat!($fmt, "\0"), $($arg)*);
$disp.print($x, $y, s.as_bytes(), $fg, $bg);
});
}
/// Convenience text display with selected font
///
/// Requires `card10_alloc::init()` and `extern crate alloc;`
#[macro_export]
macro_rules! display_adv {
($disp: expr, $font: tt, $x: expr, $y: expr, $fg: expr, $bg: expr,
$fmt: expr) => ({
use alloc::format;
use card10_l0dable::Font;
let s = format!(concat!($fmt, "\0"));
$disp.print_adv(Font::$font, $x, $y, s.as_bytes(), $fg, $bg);
});
($disp: expr, $font: tt, $x: expr, $y: expr, $fg: expr, $bg: expr,
$fmt: expr, $($arg: tt)*) => ({
use alloc::format;
let s = format!(concat!($fmt, "\0"), $($arg)*);
$disp.print_adv(Font::$font, $x, $y, s.as_bytes(), $fg, $bg);
});
}
...@@ -3,7 +3,7 @@ use card10_sys::*; ...@@ -3,7 +3,7 @@ use card10_sys::*;
use core::mem::{transmute, uninitialized}; use core::mem::{transmute, uninitialized};
use core::ops::{Index, IndexMut}; use core::ops::{Index, IndexMut};
use embedded_graphics::pixelcolor::Rgb565; use embedded_graphics::pixelcolor::{PixelColor, Rgb565};
use embedded_graphics::prelude::Pixel; use embedded_graphics::prelude::Pixel;
use embedded_graphics::Drawing; use embedded_graphics::Drawing;
...@@ -13,12 +13,12 @@ mod text; ...@@ -13,12 +13,12 @@ mod text;
pub use text::TextRenderer; pub use text::TextRenderer;
pub struct FrameBuffer<'d> { pub struct FrameBuffer<'d> {
_display: &'d Display, _display: &'d mut Display,
buffer: disp_framebuffer, buffer: disp_framebuffer,
} }
impl<'d> FrameBuffer<'d> { impl<'d> FrameBuffer<'d> {
pub fn uninitialized(display: &'d Display) -> Self { pub fn uninitialized(display: &'d mut Display) -> Self {
FrameBuffer { FrameBuffer {
_display: display, _display: display,
buffer: unsafe { uninitialized() }, buffer: unsafe { uninitialized() },
...@@ -61,37 +61,40 @@ impl<'d> FrameBuffer<'d> { ...@@ -61,37 +61,40 @@ impl<'d> FrameBuffer<'d> {
impl<'d> Index<(u16, u16)> for FrameBuffer<'d> { impl<'d> Index<(u16, u16)> for FrameBuffer<'d> {
type Output = RawColor; type Output = RawColor;
fn index(&self, (x, y): (u16, u16)) -> &Self::Output { fn index(&self, (x, y): (u16, u16)) -> &Self::Output {
let x = usize::from(Display::W - 1 - x); let x = usize::from(Display::W as u16 - 1 - x);
let y = usize::from(Display::H - 1 - y); let y = usize::from(Display::H as u16 - 1 - y);
unsafe { transmute(&self.buffer.fb[y][x]) } unsafe { transmute(&self.buffer.fb[y][x]) }
} }
} }
impl<'d> IndexMut<(u16, u16)> for FrameBuffer<'d> { impl<'d> IndexMut<(u16, u16)> for FrameBuffer<'d> {
fn index_mut(&mut self, (x, y): (u16, u16)) -> &mut Self::Output { fn index_mut(&mut self, (x, y): (u16, u16)) -> &mut Self::Output {
let x = usize::from(Display::W - 1 - x); let x = usize::from(Display::W as u16 - 1 - x);
let y = usize::from(Display::H - 1 - y); let y = usize::from(Display::H as u16 - 1 - y);
unsafe { transmute(&mut self.buffer.fb[y][x]) } unsafe { transmute(&mut self.buffer.fb[y][x]) }
} }
} }
impl<'d> Drawing<Rgb565> for FrameBuffer<'d> { /// `embedded-graphics` support
impl<'d, C: PixelColor + Into<RawColor>> Drawing<C> for FrameBuffer<'d> {
fn draw<T>(&mut self, item: T) fn draw<T>(&mut self, item: T)
where where
T: IntoIterator<Item = Pixel<Rgb565>>, T: IntoIterator<Item = Pixel<C>>,
{ {
for Pixel(coord, color) in item { for Pixel(coord, color) in item {
let x = coord[0] as u16; let x = coord[0] as u16;
let y = coord[1] as u16; let y = coord[1] as u16;
if x >= Display::W || y >= Display::H { if x >= Display::W as u16 || y >= Display::H as u16 {
continue; continue;
} }
self[(x, y)] = RawColor::rgb8(color.r(), color.g(), color.b()); // Swap bytes
self[(x, y)] = color.into();
} }
} }
} }
/// RGB565 with swapped bytes
#[derive(Debug, Clone, Copy)] #[derive(Debug, Clone, Copy)]
#[repr(C)] #[repr(C)]
pub struct RawColor([u8; 2]); pub struct RawColor([u8; 2]);
...@@ -121,9 +124,40 @@ impl RawColor { ...@@ -121,9 +124,40 @@ impl RawColor {
Self::rgb8(0xff, 0xff, 0) Self::rgb8(0xff, 0xff, 0)
} }
/// Construct from 0..255-triple
pub fn rgb8(r8: u8, g8: u8, b8: u8) -> Self { pub fn rgb8(r8: u8, g8: u8, b8: u8) -> Self {
let b1 = (r8 & 0xF8) | (g8 >> 5); let b1 = (r8 & 0xF8) | (g8 >> 5);
let b2 = ((g8 & 0xFA) << 3) | (b8 >> 3); let b2 = ((g8 & 0xFA) << 3) | (b8 >> 3);
RawColor([b1, b2]) RawColor([b1, b2])
} }
pub fn r8(&self) -> u8 {
self.0[0] & 0xF8
}
pub fn g8(&self) -> u8 {
((self.0[0] & 0x7) << 5) |
((self.0[0] & 0xE) >> 3)
}
pub fn b8(&self) -> u8 {
(self.0[1] & 0x1F) << 3
}
}
impl PixelColor for RawColor {}
/// Most similar format, just byte-swapped
impl From<Rgb565> for RawColor {
fn from(rgb: Rgb565) -> Self {
let c = rgb.0;
RawColor([(c >> 8) as u8, c as u8])
}
}
/// Dummy implementation required for impl Drawable
impl From<u8> for RawColor {
fn from(b: u8) -> Self {
RawColor([0, b])
}
} }
...@@ -24,10 +24,10 @@ impl<'a, 'd, 'f> Write for TextRenderer<'a, 'd, 'f> { ...@@ -24,10 +24,10 @@ impl<'a, 'd, 'f> Write for TextRenderer<'a, 'd, 'f> {
Some(glyph) => { Some(glyph) => {
for y in 0..self.font.h { for y in 0..self.font.h {
let y1 = (self.y + y as isize) as u16; let y1 = (self.y + y as isize) as u16;
if y1 < Display::H { if y1 < Display::H as u16 {
for x in 0..self.font.w { for x in 0..self.font.w {
let x1 = (self.x + x as isize) as u16; let x1 = (self.x + x as isize) as u16;
if x1 < Display::W { if x1 < Display::W as u16 {
if glyph.get_pixel(x as usize, y as usize) { if glyph.get_pixel(x as usize, y as usize) {
self.framebuffer[(x1, y1)] = self.color; self.framebuffer[(x1, y1)] = self.color;
} }
......
//! File System support (unfinished)
use core::mem::uninitialized; use core::mem::uninitialized;
use core::str::from_utf8_unchecked; use core::str::from_utf8_unchecked;
......
//! Lights
use card10_sys::*;
#[derive(Clone, Copy)]
pub enum LEDColor {
RGB(u8, u8, u8),
HSV(f32, f32, f32),
}
/// Update all RGB LEDs
///
/// `f` must supply a `LEDColor` for `0..=10`.
pub fn update_rgb_leds<F>(f: F)
where
F: Fn(i32) -> LEDColor,
{
for index in 0..=10 {
let color = f(index);
match color {
LEDColor::RGB(r, g, b) => unsafe {
epic_leds_prep(index, r, g, b);
}
LEDColor::HSV(h, s, v) => unsafe {
epic_leds_prep_hsv(index, h, s, v);
}
}
unsafe {
epic_leds_update();
}
}
}
/// Set powersave mode for the RGB leds
///
/// Setting powersave mode disables the LEDs, saving
/// ~15 mA
pub fn set_rgb_leds_powersave(v: bool) {
unsafe { epic_leds_set_powersave(v); }
}
#[repr(i32)]
pub enum Rocket {
Blue = 0,
Yellow = 1,
Green = 2,
}
/// Set one of the rocket LEDs to the desired brightness.
///
/// Brightness should be 0 - 31; larger values will be clamped.
pub fn set_rocket(r: Rocket, brightness: u8) {
let v = if brightness > 31{31} else {brightness}; // clamp
unsafe { epic_leds_set_rocket(r as i32, v) }
}
//! [Repository](https://git.card10.badge.events.ccc.de/astro/rust-card10)
#![no_std] #![no_std]
mod os; mod os;
pub use os::*; pub use os::*;
mod display; mod display;
pub use display::{Color, Display, FillStyle, LineStyle}; pub use display::{Color, Display, FillStyle, Font, LineStyle};
mod buttons; mod buttons;
pub mod framebuffer; pub mod framebuffer;
pub use buttons::Buttons; pub use buttons::Buttons;
...@@ -19,12 +20,16 @@ mod fmt_buffer; ...@@ -19,12 +20,16 @@ mod fmt_buffer;
pub use fmt_buffer::{str_to_cstr, FmtBuffer}; pub use fmt_buffer::{str_to_cstr, FmtBuffer};
mod bme680; mod bme680;
pub use bme680::BME680; pub use bme680::BME680;
mod max86150;
pub use max86150::MAX86150;
mod bhi160; mod bhi160;
pub use bhi160::{ pub use bhi160::{
Accelerometer, Error as BHI160Error, Gyroscope, Orientation, Sensor as BHI160, Accelerometer, Error as BHI160Error, Gyroscope, Orientation, Sensor as BHI160,
SensorData as BHI160Data, SensorData as BHI160Data,
}; };
pub mod fs; pub mod fs;
mod leds;
pub use leds::*;
/// Type check the user-supplied entry function. /// Type check the user-supplied entry function.
#[macro_export] #[macro_export]
......
use card10_sys::*; use card10_sys::*;
/// Light sensor
pub struct LightSensor { pub struct LightSensor {
// Prevent creation of this struct by all but this module. // Prevent creation of this struct by all but this module.
_private: (), _private: (),
} }
impl LightSensor { impl LightSensor {
/// Start sensing light
pub fn start() -> Self { pub fn start() -> Self {
if unsafe { epic_light_sensor_run() } != 0 { if unsafe { epic_light_sensor_run() } != 0 {
panic!("Cannot start light sensor"); panic!("Cannot start light sensor");
...@@ -13,6 +15,7 @@ impl LightSensor { ...@@ -13,6 +15,7 @@ impl LightSensor {
LightSensor { _private: () } LightSensor { _private: () }
} }
/// Obtain current light sensor reading
pub fn get(&self) -> Option<u16> { pub fn get(&self) -> Option<u16> {
let mut result = 0; let mut result = 0;
if unsafe { epic_light_sensor_get(&mut result) } == 0 { if unsafe { epic_light_sensor_get(&mut result) } == 0 {
......
// ECG and PPG sensor
pub struct MAX86150 {
stream_id: i32,
}
use core::{mem::size_of, mem::MaybeUninit};
use card10_sys::*;
// TODO: redefine in common sensor
use crate::bhi160::Error;
const DATA_MAX: usize = 128;
impl MAX86150 {
pub fn start() -> Result<Self, Error> {
let mut cfg = max86150_sensor_config {
sample_buffer_len: DATA_MAX,
ppg_sample_rate: 200,
};
let stream_id =
unsafe { epic_max86150_enable_sensor(&mut cfg, size_of::<max86150_sensor_config>()) };
if stream_id < 0 {
let error = match -stream_id {
errno::EBUSY => Error::DriverBusy,
_ => Error::Unknown(stream_id),
};
return Err(error);
}
Ok(MAX86150 { stream_id })
}
pub fn read(&self) -> Result<MAX86150SensorData, Error> {
let mut buffer = MaybeUninit::<[max86150_sensor_data; DATA_MAX]>::zeroed();
let buffer_pointer = buffer.as_mut_ptr() as *mut _;
let packet_count = unsafe {
epic_stream_read(
self.stream_id,
buffer_pointer,
size_of::<max86150_sensor_data>() * DATA_MAX,
)
};
if packet_count < 0 {
let error = match -packet_count {
errno::ENODEV => Error::SensorUnavailable,
errno::EBADF => Error::SensorDescriptorUnknown,
errno::EINVAL => Error::InvalidSampleCount,
errno::EBUSY => Error::CouldNotAcquireLock,
_ => Error::Unknown(packet_count),
};
return Err(error);
}
Ok(MAX86150SensorData {
buf: unsafe { buffer.assume_init() },
n: packet_count as usize,
})
}
}
pub struct MAX86150SensorData {
buf: [max86150_sensor_data; DATA_MAX],
n: usize,
}
impl MAX86150SensorData {
pub const fn is_empty(&self) -> bool {
self.n == 0
}
pub const fn len(&self) -> usize {
self.n
}
}
impl<'a> IntoIterator for &'a MAX86150SensorData {
type Item = MAX86150SensorDataItem;
type IntoIter = MAX86150SensorDataIterator<'a>;
fn into_iter(self) -> Self::IntoIter {
MAX86150SensorDataIterator { data: self, pos: 0 }
}
}
pub struct MAX86150SensorDataIterator<'a> {
data: &'a MAX86150SensorData,
pos: usize,
}
#[derive(Debug, Clone)]
pub struct MAX86150SensorDataItem {
pub red_raw: u32,
pub ir_raw: u32,
pub ecg_raw: i32,
}
impl MAX86150SensorDataItem {
pub fn get_red(&self) -> u32 {
self.red_raw
}
}
impl<'a> Iterator for MAX86150SensorDataIterator<'a> {
type Item = MAX86150SensorDataItem;
fn next(&mut self) -> Option<Self::Item> {
while self.pos < self.data.n {
let vec = &self.data.buf[self.pos];
let item = MAX86150SensorDataItem {
red_raw: vec.red,
ir_raw: vec.ir,
ecg_raw: vec.ecg,
};
self.pos += 1;
return Some(item);
}
None
}
}
impl Drop for MAX86150 {
fn drop(&mut self) {
unsafe {
epic_max86150_disable_sensor();
}
}
}