--- /dev/null
+# This file is automatically @generated by Cargo.
+# It is not intended for manual editing.
+[[package]]
+name = "aligned"
+version = "0.3.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "as-slice 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[[package]]
+name = "as-slice"
+version = "0.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "generic-array 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)",
+ "stable_deref_trait 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[[package]]
+name = "bare-metal"
+version = "0.2.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[[package]]
+name = "byteorder"
+version = "1.3.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+
+[[package]]
+name = "cast"
+version = "0.2.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[[package]]
+name = "cortex-m"
+version = "0.6.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "aligned 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
+ "bare-metal 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)",
+ "volatile-register 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[[package]]
+name = "cortex-m-rt"
+version = "0.6.10"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "cortex-m-rt-macros 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
+ "r0 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[[package]]
+name = "cortex-m-rt-macros"
+version = "0.1.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
+ "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rand 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)",
+ "syn 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[[package]]
+name = "embedded-graphics"
+version = "0.6.2"
+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]]
+name = "embedded-hal"
+version = "0.2.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "nb 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
+ "void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[[package]]
+name = "fpa"
+version = "0.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "cast 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
+ "typenum 1.11.2 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[[package]]
+name = "generic-array"
+version = "0.12.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "typenum 1.11.2 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[[package]]
+name = "generic-array"
+version = "0.13.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "typenum 1.11.2 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[[package]]
+name = "hash32"
+version = "0.1.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]]
+name = "heapless"
+version = "0.5.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "as-slice 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "generic-array 0.13.2 (registry+https://github.com/rust-lang/crates.io-index)",
+ "hash32 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[[package]]
+name = "ili9341"
+version = "0.3.0"
+dependencies = [
+ "embedded-graphics 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)",
+ "embedded-hal 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[[package]]
+name = "nb"
+version = "0.1.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+
+[[package]]
+name = "nrf-hal-common"
+version = "0.10.0"
+dependencies = [
+ "cast 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
+ "cortex-m 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)",
+ "embedded-hal 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
+ "fpa 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "nb 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
+ "nrf52840-pac 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
+ "void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[[package]]
+name = "nrf52840-hal"
+version = "0.10.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "cast 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
+ "cortex-m 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)",
+ "embedded-hal 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
+ "nb 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
+ "nrf-hal-common 0.10.0",
+ "nrf52840-pac 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[[package]]
+name = "nrf52840-pac"
+version = "0.9.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "bare-metal 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)",
+ "cortex-m 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)",
+ "cortex-m-rt 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)",
+ "vcell 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[[package]]
+name = "panic-persist"
+version = "0.2.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "cortex-m 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[[package]]
+name = "proc-macro2"
+version = "1.0.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[[package]]
+name = "quote"
+version = "1.0.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[[package]]
+name = "r0"
+version = "0.2.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+
+[[package]]
+name = "rand"
+version = "0.5.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[[package]]
+name = "rand_core"
+version = "0.3.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "rand_core 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[[package]]
+name = "rand_core"
+version = "0.4.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+
+[[package]]
+name = "rand_core"
+version = "0.5.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+
+[[package]]
+name = "rtt-target"
+version = "0.2.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "cortex-m 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)",
+ "ufmt-write 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "vcell 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[[package]]
+name = "rustc_version"
+version = "0.2.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[[package]]
+name = "semver"
+version = "0.9.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[[package]]
+name = "semver-parser"
+version = "0.7.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+
+[[package]]
+name = "stable_deref_trait"
+version = "1.1.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+
+[[package]]
+name = "syn"
+version = "1.0.8"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
+ "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
+ "unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[[package]]
+name = "tiny-nrf52"
+version = "0.1.0"
+dependencies = [
+ "cortex-m 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)",
+ "cortex-m-rt 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)",
+ "embedded-graphics 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)",
+ "embedded-hal 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
+ "heapless 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
+ "ili9341 0.3.0",
+ "nb 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
+ "nrf52840-hal 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "panic-persist 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rtt-target 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[[package]]
+name = "typenum"
+version = "1.11.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+
+[[package]]
+name = "ufmt-write"
+version = "0.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+
+[[package]]
+name = "unicode-xid"
+version = "0.2.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+
+[[package]]
+name = "vcell"
+version = "0.1.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+
+[[package]]
+name = "void"
+version = "1.0.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+
+[[package]]
+name = "volatile-register"
+version = "0.2.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "vcell 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[metadata]
+"checksum aligned 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d3a316c7ea8e1e9ece54862c992def5a7ac14de9f5832b69d71760680efeeefa"
+"checksum as-slice 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "293dac66b274fab06f95e7efb05ec439a6b70136081ea522d270bc351ae5bb27"
+"checksum bare-metal 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "5deb64efa5bd81e31fcd1938615a6d98c82eafcbcd787162b6f63b91d6bac5b3"
+"checksum byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a7c3dd8985a7111efc5c80b44e23ecdd8c007de8ade3b96595387e812b957cf5"
+"checksum cast 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "4b9434b9a5aa1450faa3f9cb14ea0e8c53bb5d2b3c1bfd1ab4fc03e9f33fbfb0"
+"checksum cortex-m 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "2954942fbbdd49996704e6f048ce57567c3e1a4e2dc59b41ae9fde06a01fc763"
+"checksum cortex-m-rt 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)" = "17805910e3ecf029bdbfcc42b7384d9e3d9e5626153fa810002c1ef9839338ac"
+"checksum cortex-m-rt-macros 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "2a6dc359ebb215c4924bffacfe46a8f02ef80fe2071bba1635a2ded42b40f936"
+"checksum embedded-graphics 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "40a69991ceb896bd4810a0cf2bcc46fc94b7860573c71f965d8e5b3d66942fed"
+"checksum embedded-hal 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ee4908a155094da7723c2d60d617b820061e3b4efcc3d9e293d206a5a76c170b"
+"checksum fpa 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f074479d683e5a8fd0bf1251d0a5d91b0d9178b867b44962191ed0eaaf8d4009"
+"checksum generic-array 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)" = "c68f0274ae0e023facc3c97b2e00f076be70e254bc851d972503b328db79b2ec"
+"checksum generic-array 0.13.2 (registry+https://github.com/rust-lang/crates.io-index)" = "0ed1e761351b56f54eb9dcd0cfaca9fd0daecf93918e1cfc01c8a3d26ee7adcd"
+"checksum hash32 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d4041af86e63ac4298ce40e5cca669066e75b6f1aa3390fe2561ffa5e1d9f4cc"
+"checksum heapless 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f339aa7d51777fc0af6aa7cbeb277dfc6e6c029cbdeda48d0fbb92c2337f0e69"
+"checksum nb 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "b1411551beb3c11dedfb0a90a0fa256b47d28b9ec2cdff34c25a2fa59e45dbdc"
+"checksum nrf52840-hal 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6aab4c41abc02fcefbdbedfa773d213302bc00c57a0b2237c6b5bf0456da10d3"
+"checksum nrf52840-pac 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e1b780a5afd2621774652f28c82837f6aa6d19cf0ad71c734fc1fe53298a2d73"
+"checksum panic-persist 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dd2e692a5954e3eb0c16f5dbaa75c4332a78d85851521f138c04ad95d6f5ee42"
+"checksum proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "9c9e470a8dc4aeae2dee2f335e8f533e2d4b347e1434e5671afc49b054592f27"
+"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 rand 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c618c47cd3ebd209790115ab837de41425723956ad3ce2e6a7f09890947cacb9"
+"checksum rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b"
+"checksum rand_core 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9c33a3c44ca05fa6f1807d8e6743f3824e8509beca625669633be0acbdf509dc"
+"checksum rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19"
+"checksum rtt-target 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "58b1f36984bbcf227044b3b7af1de14a6ebe51b9d21cd856a3d5ba41c70ec191"
+"checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a"
+"checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403"
+"checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3"
+"checksum stable_deref_trait 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dba1a27d3efae4351c8051072d619e3ade2820635c3958d826bfea39d59b54c8"
+"checksum syn 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)" = "661641ea2aa15845cddeb97dad000d22070bb5c1fb456b96c1cba883ec691e92"
+"checksum typenum 1.11.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6d2783fe2d6b8c1101136184eb41be8b1ad379e4657050b8aaff0c79ee7575f9"
+"checksum ufmt-write 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e87a2ed6b42ec5e28cc3b94c09982969e9227600b2e3dcbc1db927a84c06bd69"
+"checksum unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c"
+"checksum vcell 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "876e32dcadfe563a4289e994f7cb391197f362b6315dc45e8ba4aa6f564a4b3c"
+"checksum void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d"
+"checksum volatile-register 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0d67cb4616d99b940db1d6bd28844ff97108b498a6ca850e5b6191a532063286"
--- /dev/null
+#![no_std]
+#![no_main]
+
+// Panic provider crate
+use panic_persist;
+use cortex_m;
+
+// Used to set the program entry point
+use cortex_m_rt::entry;
+
+// Provides definitions for our development board
+use nrf52840_hal::{
+ prelude::*,
+ target::{Peripherals, CorePeripherals},
+ Timer,
+ Rng,
+ Spim,
+ spim::{
+ Pins as SpimPins,
+ Frequency as SpimFrequency,
+ MODE_0,
+ },
+ gpio::{
+ p0::Parts as P0Parts,
+ p1::Parts as P1Parts,
+ Level,
+ },
+ Clocks,
+};
+
+use rtt_target::{
+ rprint, rprintln,
+ rtt_init_print,
+};
+
+use embedded_graphics::{
+ fonts::{Font8x16, Text},
+ pixelcolor::Rgb565,
+ prelude::*,
+ style::{TextStyle, TextStyleBuilder},
+};
+
+mod buffer;
+
+use ili9341::{Ili9341, Orientation};
+
+const TEXT_SAMPLE: &[&str] = &[
+ "for x in 0..10 {",
+ " for y in 0..10 {",
+ " let rand: u16 = rng.random_u16();",
+ " buffy.iter_mut().for_each(|px| {",
+ " *px = swap(rand)",
+ " });",
+ " lcd.draw_raw(",
+ " 32 * x,",
+ " 24 * y,",
+ " (32 * (x + 1)) - 1,",
+ " (24 * (y + 1)) - 1,",
+ " &buffy,",
+ " ).unwrap();",
+ " }",
+ "}",
+];
+
+const TEXT_SAMPLE2: &[&[(i32, Rgb565, &str)]] = &[
+ // "for x in 0..10 {",
+ &[(0, Rgb565::RED, "for "), (4, Rgb565::WHITE, "x "), (6, Rgb565::RED, "in "), (9, Rgb565::MAGENTA, "0"), (10, Rgb565::RED, ".."), (12, Rgb565::MAGENTA, "10"), (14, Rgb565::WHITE, " {")],
+ // " for y in 0..10 {",
+ &[(2, Rgb565::RED, "for "), (6, Rgb565::WHITE, "y "), (8, Rgb565::RED, "in "), (11, Rgb565::MAGENTA, "0"), (12, Rgb565::RED, ".."), (14, Rgb565::MAGENTA, "10"), (16, Rgb565::WHITE, " {")],
+ // " let rand: u16 = rng.random_u16();",
+ &[(4, Rgb565::CYAN, "let "), (8, Rgb565::WHITE, "rand: "), (14, Rgb565::CYAN, "u16 "), (18, Rgb565::RED, "= "), (20, Rgb565::WHITE, "rng."), (24, Rgb565::CYAN, "random_u16"), (34, Rgb565::WHITE, "();")],
+ // " buffy.iter_mut().for_each(|px| {",
+ &[(4, Rgb565::WHITE, "buffy."), (10, Rgb565::CYAN, "iter_mut"), (18, Rgb565::WHITE, "()."), (21, Rgb565::CYAN, "for_each"), (29, Rgb565::WHITE, "(|"), (31, Rgb565::YELLOW, "px"), (33, Rgb565::WHITE, "| {")],
+ // " *px = swap(rand)",
+ &[(6, Rgb565::RED, "*"), (7, Rgb565::WHITE, "px "), (10, Rgb565::RED, "= "), (12, Rgb565::CYAN, "swap"), (16, Rgb565::WHITE, "(rand)")],
+ // " });",
+ &[(4, Rgb565::WHITE, "});")],
+ // " lcd.draw_raw(",
+ &[(4, Rgb565::WHITE, "lcd."), (8, Rgb565::CYAN, "draw_raw"), (16, Rgb565::WHITE, "(")],
+ // " 32 * x,",
+ &[(6, Rgb565::MAGENTA, "32 "), (9, Rgb565::RED, "* "), (11, Rgb565::WHITE, "x,")],
+ // " 24 * y,",
+ &[(6, Rgb565::MAGENTA, "24 "), (9, Rgb565::RED, "* "), (11, Rgb565::WHITE, "y,")],
+ // " (32 * (x + 1)) - 1,",
+ &[(6, Rgb565::WHITE, "("), (7, Rgb565::MAGENTA,"32 "), (10, Rgb565::RED, "* "), (12, Rgb565::WHITE, "(x "), (15, Rgb565::RED, "+ "), (17, Rgb565::MAGENTA, "1"), (18, Rgb565::WHITE, ")) "), (21, Rgb565::RED, "- "), (23, Rgb565::MAGENTA, "1"), (24, Rgb565::WHITE, ",")],
+ // " (24 * (y + 1)) - 1,",
+ &[(6, Rgb565::WHITE, "("), (7, Rgb565::MAGENTA,"24 "), (10, Rgb565::RED, "* "), (12, Rgb565::WHITE, "(y "), (15, Rgb565::RED, "+ "), (17, Rgb565::MAGENTA, "1"), (18, Rgb565::WHITE, ")) "), (21, Rgb565::RED, "- "), (23, Rgb565::MAGENTA, "1"), (24, Rgb565::WHITE, ",")],
+ // " &buffy,",
+ &[(6, Rgb565::RED, "&"), (7, Rgb565::WHITE, "buffy,")],
+ // " ).unwrap();",
+ &[(4, Rgb565::WHITE, ")."), (6, Rgb565::CYAN, "unwrap"), (12, Rgb565::WHITE, "();")],
+ // " }",
+ &[(2, Rgb565::WHITE, "}")],
+ // "}",
+ &[(0, Rgb565::WHITE, "}")],
+];
+
+#[entry]
+fn main() -> ! {
+ match inner_main() {
+ Ok(()) => cortex_m::peripheral::SCB::sys_reset(),
+ Err(e) => panic!(e),
+ }
+}
+
+fn inner_main() -> Result<(), &'static str> {
+ let mut board = Peripherals::take().ok_or("Error getting board!")?;
+ let mut corep = CorePeripherals::take().ok_or("Error")?;
+ let mut timer = Timer::new(board.TIMER0);
+ let mut delay = Timer::new(board.TIMER1);
+ let mut rng = Rng::new(board.RNG);
+ let mut toggle = false;
+ let _clocks = Clocks::new(board.CLOCK).enable_ext_hfosc();
+
+ // use ChannelMode::NoBlockS
+ rtt_init_print!(NoBlockSkip, 4096);
+
+ if let Some(msg) = panic_persist::get_panic_message_utf8() {
+ rprintln!("{}", msg);
+ } else {
+ rprintln!("Clean boot!");
+ }
+
+
+ let p0 = P0Parts::new(board.P0);
+ let p1 = P1Parts::new(board.P1);
+
+ let kbd_lcd_reset = p1.p1_08; // GPIO5, D5
+ let stm_cs = p0.p0_07; // GPIO6, D6,
+ let lcd_cs = p0.p0_26; // GPIO9, D9,
+ let lcd_dc = p0.p0_27; // GPIO10, D10
+
+ // Pull the neopixel line low so noise doesn't make it turn on spuriously
+ let keywing_neopixel = p0.p0_06.into_push_pull_output(Level::Low); // GPIO11, D11
+
+ let spim = Spim::new(
+ board.SPIM3,
+ SpimPins {
+ sck: p0.p0_14.into_push_pull_output(Level::Low).degrade(),
+ miso: Some(p0.p0_15.into_floating_input().degrade()),
+ mosi: Some(p0.p0_13.into_push_pull_output(Level::Low).degrade()),
+ },
+ SpimFrequency::M32,
+ MODE_0,
+ 0x00,
+ );
+
+ let mut lcd = Ili9341::new_spi(
+ spim,
+ lcd_cs.into_push_pull_output(Level::High),
+ lcd_dc.into_push_pull_output(Level::High),
+ kbd_lcd_reset.into_push_pull_output(Level::High),
+ &mut delay,
+ ).unwrap();
+
+ lcd.set_orientation(Orientation::Landscape).unwrap();
+
+ let mut buffy = [0u16; 24 * 32];
+ let mut buffy2 = [[0u16; 320]; 240];
+
+ let mut fbuffy = buffer::FrameBuffer::new(&mut buffy2);
+
+ // // rrrrr gggggg bbbbb
+ // buffy.iter_mut().for_each(|px| *px = 0b11111_000000_00000);
+
+ let style = TextStyleBuilder::new(Font8x16)
+ .text_color(Rgb565::WHITE)
+ .background_color(Rgb565::BLACK)
+ .build();
+
+ loop {
+
+ rprintln!("Start colors raw");
+
+ for x in 0..10 {
+ for y in 0..10 {
+ let rand: u16 = rng.random_u16();
+ buffy.iter_mut().for_each(|px| {
+ *px = swap(rand)
+ });
+
+ lcd.draw_raw(
+ 32 * x,
+ 24 * y,
+ (32 * (x + 1)) - 1,
+ (24 * (y + 1)) - 1,
+ &buffy,
+ ).unwrap();
+ }
+ }
+
+ rprintln!("Done.\n");
+
+ timer.delay_ms(1000u16);
+
+ rprintln!("Start colors raw");
+
+ for x in 0..10 {
+ for y in 0..10 {
+ let rand: u16 = 0;
+ buffy.iter_mut().for_each(|px| {
+ *px = swap(rand)
+ });
+
+ lcd.draw_raw(
+ 32 * x,
+ 24 * y,
+ (32 * (x + 1)) - 1,
+ (24 * (y + 1)) - 1,
+ &buffy,
+ ).unwrap();
+ }
+ }
+
+ rprintln!("Done.\n");
+
+
+ timer.delay_ms(1000u16);
+
+ // buffy2.iter_mut().for_each(|px| *px = swap(0b00000_000000_00000));
+ // rprintln!("Start black");
+ // lcd.draw_raw(0, 0, 319, 239, &buffy2).unwrap();
+ // rprintln!("Done.\n");
+
+ rprintln!("text start");
+
+ for row in 0..15 {
+ Text::new(
+ TEXT_SAMPLE[row as usize],
+ Point::new(0, row * 16)
+ ).into_styled(style)
+ .draw(&mut lcd)
+ .unwrap();
+ }
+
+ rprintln!("text done");
+
+ timer.delay_ms(3000u16);
+
+ rprintln!("Start colors raw");
+
+ for x in 0..10 {
+ for y in 0..10 {
+ let rand: u16 = 0;
+ buffy.iter_mut().for_each(|px| {
+ *px = swap(rand)
+ });
+
+ lcd.draw_raw(
+ 32 * x,
+ 24 * y,
+ (32 * (x + 1)) - 1,
+ (24 * (y + 1)) - 1,
+ &buffy,
+ ).unwrap();
+ }
+ }
+
+ rprintln!("Done.\n");
+
+
+ timer.delay_ms(1000u16);
+
+ // buffy2.iter_mut().for_each(|px| *px = swap(0b00000_000000_00000));
+ // rprintln!("Start black");
+ // lcd.draw_raw(0, 0, 319, 239, &buffy2).unwrap();
+ // rprintln!("Done.\n");
+
+ rprintln!("text2 start");
+
+ for (i, row) in TEXT_SAMPLE2.iter().enumerate() {
+ for (offset, color, text) in row.iter() {
+ let styled = TextStyleBuilder::new(Font8x16)
+ .text_color(*color)
+ .background_color(Rgb565::BLACK)
+ .build();
+
+ Text::new(
+ text,
+ Point::new(*offset * 8, i as i32 * 16)
+ ).into_styled(styled)
+ .draw(&mut lcd)
+ .unwrap();
+ }
+ }
+
+ rprintln!("text2 done");
+
+ timer.delay_ms(3000u16);
+
+ rprintln!("Start colors raw");
+
+ for x in 0..10 {
+ for y in 0..10 {
+ let rand: u16 = 0;
+ buffy.iter_mut().for_each(|px| {
+ *px = swap(rand)
+ });
+
+ lcd.draw_raw(
+ 32 * x,
+ 24 * y,
+ (32 * (x + 1)) - 1,
+ (24 * (y + 1)) - 1,
+ &buffy,
+ ).unwrap();
+ }
+ }
+
+ rprintln!("Done.\n");
+
+ timer.delay_ms(1000u16);
+
+ // buffy2.iter_mut().for_each(|px| *px = swap(0b00000_000000_00000));
+ // rprintln!("Start black");
+ // lcd.draw_raw(0, 0, 319, 239, &buffy2).unwrap();
+ // rprintln!("Done.\n");
+
+ timer.start(1_000_000u32);
+
+ let start: u32 = timer.read();
+
+ for row in 0..15 {
+ Text::new(
+ TEXT_SAMPLE[row as usize],
+ Point::new(0, row * 16)
+ ).into_styled(style)
+ .draw(&mut fbuffy)
+ .unwrap();
+ }
+
+ let middle: u32 = timer.read();
+
+ lcd.draw_raw(0, 0, 319, 239, fbuffy.inner()).unwrap();
+
+ let end: u32 = timer.read();
+
+ rprintln!("text buffered done");
+ rprintln!("start: 0x{:08X}, middle: 0x{:08X}, end: 0x{:08X}", start, middle, end);
+ rprintln!("render: {} cycs", middle - start);
+ rprintln!("draw: {} cycs", end - middle);
+
+
+
+
+
+ timer.delay_ms(3000u16);
+
+ rprintln!("Start colors raw");
+
+ for x in 0..10 {
+ for y in 0..10 {
+ let rand: u16 = 0;
+ buffy.iter_mut().for_each(|px| {
+ *px = swap(rand)
+ });
+
+ lcd.draw_raw(
+ 32 * x,
+ 24 * y,
+ (32 * (x + 1)) - 1,
+ (24 * (y + 1)) - 1,
+ &buffy,
+ ).unwrap();
+ }
+ }
+
+ rprintln!("Done.\n");
+
+
+ timer.delay_ms(1000u16);
+
+ rprintln!("text2 buffered middle");
+
+ for (i, row) in TEXT_SAMPLE2.iter().enumerate() {
+ for (offset, color, text) in row.iter() {
+ let styled = TextStyleBuilder::new(Font8x16)
+ .text_color(*color)
+ .background_color(Rgb565::BLACK)
+ .build();
+
+ Text::new(
+ text,
+ Point::new(*offset * 8, i as i32 * 16)
+ ).into_styled(styled)
+ .draw(&mut fbuffy)
+ .unwrap();
+ }
+ }
+
+ rprintln!("text2 buffered middle");
+
+ lcd.draw_raw(0, 0, 319, 239, fbuffy.inner()).unwrap();
+
+ rprintln!("text2 buffered done");
+
+ timer.delay_ms(3000u16);
+
+ continue;
+
+
+ // // SHOULD BE
+ // // rrrrr gggggg bbbbb
+ // buffy2.iter_mut().for_each(|px| *px = swap(0b11111_000000_00000));
+ // rprintln!("Start red");
+ // lcd.draw_raw(0, 0, 319, 239, &buffy2).unwrap();
+ // rprintln!("Done.\n");
+
+ // timer.delay_ms(250u16);
+
+ // buffy2.iter_mut().for_each(|px| *px = swap(0b00000_111111_00000));
+ // rprintln!("Start green");
+ // lcd.draw_raw(0, 0, 319, 239, &buffy2).unwrap();
+ // rprintln!("Done.\n");
+
+ // timer.delay_ms(250u16);
+
+ // buffy2.iter_mut().for_each(|px| *px = swap(0b00000_000000_11111));
+ // rprintln!("Start blue");
+ // lcd.draw_raw(0, 0, 319, 239, &buffy2).unwrap();
+ // rprintln!("Done.\n");
+
+ // buffy2.iter_mut().for_each(|px| *px = swap(0b00000_000000_00000));
+ // rprintln!("Start black");
+ // lcd.draw_raw(0, 0, 319, 239, &buffy2).unwrap();
+ // rprintln!("Done.\n");
+
+ // 240 / 16: 15
+ // 320 / 8: 40
+
+ let text = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
+
+ let mut textiter = text.chars().cycle();
+
+ for row in 0..15 {
+ for col in 0..40 {
+ let mut buf = [0u8; 4];
+ let txt = textiter.next().unwrap().encode_utf8(&mut buf);
+ Text::new(
+ txt,
+ Point::new(col * 8, row * 16)
+ ).into_styled(style)
+ .draw(&mut lcd)
+ .unwrap();
+ }
+ timer.delay_ms(500u16);
+ }
+
+ timer.delay_ms(1000u16);
+
+
+ // buffy2.iter_mut().for_each(|px| *px = swap(0b00000_000000_00000));
+ // rprintln!("Start black");
+ // lcd.draw_raw(0, 0, 319, 239, &buffy2).unwrap();
+ // rprintln!("Done.\n");
+
+ rprintln!("Starting Text Fill...");
+
+ let mut text = Text::new(
+ "1234567890123456789012345678901234567890",
+ Point::new(0, 0)
+ ).into_styled(style);
+
+ for _y in 0..15 {
+ text.draw(&mut lcd).unwrap();
+ text = text.translate(Point::new(0, 16));
+ }
+
+ rprintln!("Finished Text Fill.");
+
+
+ timer.delay_ms(1000u16);
+
+
+ }
+
+ Ok(())
+}
+
+const fn swap(inp: u16) -> u16 {
+ (inp & 0x00FF) << 8 |
+ (inp & 0xFF00) >> 8
+}