Keypad try

This commit is contained in:
Adrian Woźniak 2024-09-20 17:48:30 +02:00
parent aad0ccef4e
commit cb5633c0c4
4 changed files with 268 additions and 134 deletions

290
Cargo.lock generated
View File

@ -9,12 +9,52 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "512761e0bb2578dd7380c6baaa0f4ce03e84f95e960231d1dec8bf4d7d6e2627" checksum = "512761e0bb2578dd7380c6baaa0f4ce03e84f95e960231d1dec8bf4d7d6e2627"
[[package]] [[package]]
name = "aho-corasick" name = "anstream"
version = "1.1.3" version = "0.6.15"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" checksum = "64e15c1ab1f89faffbf04a634d5e1962e9074f2741eef6d97f3c4e322426d526"
dependencies = [ dependencies = [
"memchr", "anstyle",
"anstyle-parse",
"anstyle-query",
"anstyle-wincon",
"colorchoice",
"is_terminal_polyfill",
"utf8parse",
]
[[package]]
name = "anstyle"
version = "1.0.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1bec1de6f59aedf83baf9ff929c98f2ad654b97c9510f4e70cf6f661d49fd5b1"
[[package]]
name = "anstyle-parse"
version = "0.2.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "eb47de1e80c2b463c735db5b217a0ddc39d612e7ac9e2e96a5aed1f57616c1cb"
dependencies = [
"utf8parse",
]
[[package]]
name = "anstyle-query"
version = "1.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6d36fc52c7f6c869915e99412912f22093507da8d9e942ceaf66fe4b7c14422a"
dependencies = [
"windows-sys 0.52.0",
]
[[package]]
name = "anstyle-wincon"
version = "3.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5bf74e1b6e971609db8ca7a9ce79fd5768ab6ae46441c572e46cf596f59e57f8"
dependencies = [
"anstyle",
"windows-sys 0.52.0",
] ]
[[package]] [[package]]
@ -52,9 +92,9 @@ dependencies = [
[[package]] [[package]]
name = "bitfield" name = "bitfield"
version = "0.15.0" version = "0.16.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c821a6e124197eb56d907ccc2188eab1038fb919c914f47976e64dd8dbc855d1" checksum = "d5acf59e2452f0c4b968b15ce4b9468f57b45f7733b919d68b19fcc39264bfb8"
[[package]] [[package]]
name = "bitflags" name = "bitflags"
@ -86,6 +126,52 @@ version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]]
name = "clap"
version = "4.5.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3e5a21b8495e732f1b3c364c9949b201ca7bae518c502c80256c96ad79eaf6ac"
dependencies = [
"clap_builder",
"clap_derive",
]
[[package]]
name = "clap_builder"
version = "4.5.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8cf2dd12af7a047ad9d6da2b6b249759a22a7abc0f474c1dae1777afa4b21a73"
dependencies = [
"anstream",
"anstyle",
"clap_lex",
"strsim",
]
[[package]]
name = "clap_derive"
version = "4.5.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "501d359d5f3dcaf6ecdeee48833ae73ec6e42723a1e52419c79abf9507eec0a0"
dependencies = [
"heck 0.5.0",
"proc-macro2",
"quote",
"syn 2.0.77",
]
[[package]]
name = "clap_lex"
version = "0.7.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1462739cb27611015575c0c11df5df7601141071f07518d56fcc1be504cbec97"
[[package]]
name = "colorchoice"
version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d3fd119d74b830634cea2a0f58bbd0d54540518a14397557951e79340abc28c0"
[[package]] [[package]]
name = "convert_case" name = "convert_case"
version = "0.6.0" version = "0.6.0"
@ -95,19 +181,6 @@ dependencies = [
"unicode-segmentation", "unicode-segmentation",
] ]
[[package]]
name = "core-isa-parser"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "23ec98e54b735872e54b2335c2e5a5c7fa7d9c3bfd45500f75280f84089a0083"
dependencies = [
"anyhow",
"enum-as-inner",
"regex",
"strum 0.24.1",
"strum_macros 0.24.3",
]
[[package]] [[package]]
name = "crc32fast" name = "crc32fast"
version = "1.4.2" version = "1.4.2"
@ -205,15 +278,6 @@ dependencies = [
"nb 1.1.0", "nb 1.1.0",
] ]
[[package]]
name = "embedded-dma"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "994f7e5b5cb23521c22304927195f236813053eb9c065dd2226a32ba64695446"
dependencies = [
"stable_deref_trait",
]
[[package]] [[package]]
name = "embedded-graphics" name = "embedded-graphics"
version = "0.8.1" version = "0.8.1"
@ -285,14 +349,14 @@ dependencies = [
[[package]] [[package]]
name = "enum-as-inner" name = "enum-as-inner"
version = "0.4.0" version = "0.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "21cdad81446a7f7dc43f6a77409efeb9733d2fa65553efef6018ef257c959b73" checksum = "a1e6a265c649f3f5979b601d26f1d05ada116434c87741c9493cb56218f76cbc"
dependencies = [ dependencies = [
"heck 0.4.1", "heck 0.5.0",
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 1.0.109", "syn 2.0.77",
] ]
[[package]] [[package]]
@ -345,9 +409,9 @@ dependencies = [
[[package]] [[package]]
name = "esp-hal" name = "esp-hal"
version = "0.19.0" version = "0.20.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fe4f8cb6a9dcf0fd4506a856fbb4a0622b92042978c601a23c840c28f621a59f" checksum = "64f5393b8f7e7f055455d9f86706ddb675f943c12f12a7b80b8a79c3a94233ff"
dependencies = [ dependencies = [
"basic-toml", "basic-toml",
"bitfield", "bitfield",
@ -358,7 +422,6 @@ dependencies = [
"delegate", "delegate",
"document-features", "document-features",
"embedded-can", "embedded-can",
"embedded-dma",
"embedded-hal 1.0.0", "embedded-hal 1.0.0",
"embedded-hal-nb", "embedded-hal-nb",
"enumset", "enumset",
@ -374,16 +437,16 @@ dependencies = [
"rand_core", "rand_core",
"riscv", "riscv",
"serde", "serde",
"strum 0.26.3", "strum",
"void", "void",
"xtensa-lx-rt", "xtensa-lx-rt",
] ]
[[package]] [[package]]
name = "esp-hal-procmacros" name = "esp-hal-procmacros"
version = "0.12.0" version = "0.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9569ccb286c5a0c39292dbaaa0995bbb2a2a9d671ef3ce807b8b5b3d9a589d35" checksum = "6eac531546027909a355fc9c2449f22c839955fa4b7f1976b64ddd04b2f22f83"
dependencies = [ dependencies = [
"darling", "darling",
"document-features", "document-features",
@ -398,14 +461,16 @@ dependencies = [
[[package]] [[package]]
name = "esp-metadata" name = "esp-metadata"
version = "0.2.0" version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6013420eb303c3087d82c2d2a38944427662b0b07a9ae79e5b1636fc1442e0ba" checksum = "b471bc61fa817ca4ae41a31d5d453258328b31e5ad82db72b473621d36cc4cb6"
dependencies = [ dependencies = [
"anyhow",
"basic-toml", "basic-toml",
"clap",
"lazy_static", "lazy_static",
"serde", "serde",
"strum 0.26.3", "strum",
] ]
[[package]] [[package]]
@ -432,9 +497,9 @@ dependencies = [
[[package]] [[package]]
name = "esp32c6" name = "esp32c6"
version = "0.15.0" version = "0.16.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d5824acf92f8536c997e673113ce704c004f77e154fd550dc511b92d61bb34f6" checksum = "f0c05e230022cf5a8d10e9bcdc4878c0886a3a5701a96d6763cb42562e42ecd7"
dependencies = [ dependencies = [
"critical-section", "critical-section",
"vcell", "vcell",
@ -533,6 +598,12 @@ dependencies = [
"hashbrown", "hashbrown",
] ]
[[package]]
name = "is_terminal_polyfill"
version = "1.70.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf"
[[package]] [[package]]
name = "keypad" name = "keypad"
version = "0.2.2" version = "0.2.2"
@ -622,9 +693,9 @@ checksum = "c3c8dda44ff03a2f238717214da50f65d5a53b45cd213a7370424ffdb6fae815"
[[package]] [[package]]
name = "minijinja" name = "minijinja"
version = "1.0.21" version = "2.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "55e877d961d4f96ce13615862322df7c0b6d169d40cab71a7ef3f9b9e594451e" checksum = "1028b628753a7e1a88fc59c9ba4b02ecc3bc0bd3c7af23df667bc28df9b3310e"
dependencies = [ dependencies = [
"serde", "serde",
] ]
@ -638,6 +709,12 @@ dependencies = [
"adler2", "adler2",
] ]
[[package]]
name = "mutex-trait"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b4bb1638d419e12f8b1c43d9e639abd0d1424285bdea2f76aa231e233c63cd3a"
[[package]] [[package]]
name = "nb" name = "nb"
version = "0.1.3" version = "0.1.3"
@ -818,39 +895,10 @@ dependencies = [
"profont", "profont",
"rand", "rand",
"shared", "shared",
"strum 0.26.3", "strum",
"weact-studio-epd", "weact-studio-epd",
] ]
[[package]]
name = "regex"
version = "1.10.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4219d74c6b67a3654a9fbebc4b419e22126d13d2f3c4a07ee0cb61ff79a79619"
dependencies = [
"aho-corasick",
"memchr",
"regex-automata",
"regex-syntax",
]
[[package]]
name = "regex-automata"
version = "0.4.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "38caf58cc5ef2fed281f89292ef23f6365465ed9a41b7a7754eb4e26496c92df"
dependencies = [
"aho-corasick",
"memchr",
"regex-syntax",
]
[[package]]
name = "regex-syntax"
version = "0.8.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b"
[[package]] [[package]]
name = "riscv" name = "riscv"
version = "0.11.1" version = "0.11.1"
@ -919,6 +967,15 @@ dependencies = [
"syn 2.0.77", "syn 2.0.77",
] ]
[[package]]
name = "serde_spanned"
version = "0.6.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "eb5b1b31579f3811bf615c144393417496f152e12ac8b7663bf664f4a815306d"
dependencies = [
"serde",
]
[[package]] [[package]]
name = "shared" name = "shared"
version = "0.1.0" version = "0.1.0"
@ -945,32 +1002,13 @@ version = "0.11.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f"
[[package]]
name = "strum"
version = "0.24.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "063e6045c0e62079840579a7e47a355ae92f60eb74daaf156fb1e84ba164e63f"
[[package]] [[package]]
name = "strum" name = "strum"
version = "0.26.3" version = "0.26.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8fec0f0aef304996cf250b31b5a10dee7980c85da9d759361292b8bca5a18f06" checksum = "8fec0f0aef304996cf250b31b5a10dee7980c85da9d759361292b8bca5a18f06"
dependencies = [ dependencies = [
"strum_macros 0.26.4", "strum_macros",
]
[[package]]
name = "strum_macros"
version = "0.24.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1e385be0d24f186b4ce2f9982191e7101bb737312ad61c1f2f984f34bcf85d59"
dependencies = [
"heck 0.4.1",
"proc-macro2",
"quote",
"rustversion",
"syn 1.0.109",
] ]
[[package]] [[package]]
@ -1017,11 +1055,26 @@ dependencies = [
"winapi-util", "winapi-util",
] ]
[[package]]
name = "toml"
version = "0.8.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a1ed1f98e3fdc28d6d910e6737ae6ab1a93bf1985935a1193e68f93eeb68d24e"
dependencies = [
"serde",
"serde_spanned",
"toml_datetime",
"toml_edit",
]
[[package]] [[package]]
name = "toml_datetime" name = "toml_datetime"
version = "0.6.8" version = "0.6.8"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0dd7358ecb8fc2f8d014bf86f6f638ce72ba252a2c3a2572f2a795f1d23efb41" checksum = "0dd7358ecb8fc2f8d014bf86f6f638ce72ba252a2c3a2572f2a795f1d23efb41"
dependencies = [
"serde",
]
[[package]] [[package]]
name = "toml_edit" name = "toml_edit"
@ -1030,6 +1083,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "583c44c02ad26b0c3f3066fe629275e50627026c51ac2e595cca4c230ce1ce1d" checksum = "583c44c02ad26b0c3f3066fe629275e50627026c51ac2e595cca4c230ce1ce1d"
dependencies = [ dependencies = [
"indexmap", "indexmap",
"serde",
"serde_spanned",
"toml_datetime", "toml_datetime",
"winnow", "winnow",
] ]
@ -1071,6 +1126,12 @@ version = "2.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "daf8dba3b7eb870caf1ddeed7bc9d2a049f3cfdfae7cb521b087cc33ae4c49da" checksum = "daf8dba3b7eb870caf1ddeed7bc9d2a049f3cfdfae7cb521b087cc33ae4c49da"
[[package]]
name = "utf8parse"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821"
[[package]] [[package]]
name = "vcell" name = "vcell"
version = "0.1.3" version = "0.1.3"
@ -1109,7 +1170,16 @@ version = "0.1.9"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb" checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb"
dependencies = [ dependencies = [
"windows-sys", "windows-sys 0.59.0",
]
[[package]]
name = "windows-sys"
version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d"
dependencies = [
"windows-targets",
] ]
[[package]] [[package]]
@ -1195,23 +1265,39 @@ dependencies = [
] ]
[[package]] [[package]]
name = "xtensa-lx-rt" name = "xtensa-lx"
version = "0.16.0" version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "904102108b780c9a5e3275c5f3c63dc348ec43ae5da5237868515498b447d51a" checksum = "e758f94e1a1f71758f94052a2766dcb12604998eb372b8b2e30576e3ab1ba1e6"
dependencies = [ dependencies = [
"bare-metal", "bare-metal",
"core-isa-parser", "mutex-trait",
]
[[package]]
name = "xtensa-lx-rt"
version = "0.17.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2ceb69c1487b78d83531c5d94fb81d0dceef1ccb0affba29f29420b1f72d3ddb"
dependencies = [
"anyhow",
"bare-metal",
"document-features",
"enum-as-inner",
"minijinja", "minijinja",
"r0", "r0",
"serde",
"strum",
"toml",
"xtensa-lx",
"xtensa-lx-rt-proc-macros", "xtensa-lx-rt-proc-macros",
] ]
[[package]] [[package]]
name = "xtensa-lx-rt-proc-macros" name = "xtensa-lx-rt-proc-macros"
version = "0.2.1" version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "082cdede098bbec9af15b0e74085e5f3d16f2923597de7aed7b8112003af2da7" checksum = "11277b1e4cbb7ffe44678c668518b249c843c81df249b8f096701757bc50d7ee"
dependencies = [ dependencies = [
"darling", "darling",
"proc-macro2", "proc-macro2",

View File

@ -8,7 +8,7 @@ display-interface-spi = "0.5.0"
embedded-graphics = "0.8.1" embedded-graphics = "0.8.1"
embedded-hal-bus = "0.2.0" embedded-hal-bus = "0.2.0"
esp-backtrace = { version = "0.13.0", features = ["esp32c6", "exception-handler", "panic-handler", "println"] } esp-backtrace = { version = "0.13.0", features = ["esp32c6", "exception-handler", "panic-handler", "println"] }
esp-hal = { version = "0.19.0", features = ["esp32c6", "embedded-hal"] } esp-hal = { version = "0.20", features = ["esp32c6", "embedded-hal"] }
esp-println = { version = "0.10.0", default-features = false, features = ["esp32c6", "log", "auto"] } esp-println = { version = "0.10.0", default-features = false, features = ["esp32c6", "log", "auto"] }
heapless = "0.8.0" heapless = "0.8.0"
log = { version = "0.4.21" } log = { version = "0.4.21" }

View File

@ -10,5 +10,5 @@ full-rand = [ 'rand' ]
[dependencies] [dependencies]
nutype = { version = "0.5.0", default-features = false } nutype = { version = "0.5.0", default-features = false }
esp-hal = { version = "0.19.0", features = ["esp32c6", "embedded-hal"], optional = true } esp-hal = { version = "0.20", features = ["esp32c6", "embedded-hal"], optional = true }
rand = { version = "0.8.5", features = ["getrandom", "small_rng", "std", "std_rng"], optional = true } rand = { version = "0.8.5", features = ["getrandom", "small_rng", "std", "std_rng"], optional = true }

View File

@ -15,8 +15,8 @@ use esp_hal::{
clock::ClockControl, clock::ClockControl,
delay::Delay, delay::Delay,
gpio::{ gpio::{
Gpio10, Gpio2, Gpio3, Gpio4, Gpio5, Gpio6, Gpio7, Gpio8, Input, Io, Level, Output, Pull, Gpio10, Gpio2, Gpio3, Gpio4, Gpio5, Gpio6, Gpio7, Gpio8, Input, InputPin, Io, Level,
NO_PIN, Output, OutputPin, Pull, NO_PIN,
}, },
peripherals::Peripherals, peripherals::Peripherals,
prelude::*, prelude::*,
@ -102,7 +102,7 @@ fn main() -> ! {
log::info!("Sleeping for 0.5s..."); log::info!("Sleeping for 0.5s...");
delay.delay(500.millis()); delay.delay(500.millis());
let kbd = Keyboard { let mut kbd = Keyboard {
rows: Rows { rows: Rows {
gpio2: Input::new(io.pins.gpio2, Pull::Up), gpio2: Input::new(io.pins.gpio2, Pull::Up),
gpio3: Input::new(io.pins.gpio3, Pull::Up), gpio3: Input::new(io.pins.gpio3, Pull::Up),
@ -187,45 +187,93 @@ struct Rows<'d> {
gpio4: Input<'d, Gpio4>, // gpio4: Input<'d, Gpio4>, //
gpio5: Input<'d, Gpio5>, // gpio5: Input<'d, Gpio5>, //
} }
impl<'d> Rows<'d> {
pub fn states(&self) -> [bool; 4] {
[
self.gpio2.is_low(),
self.gpio3.is_low(),
self.gpio4.is_low(),
self.gpio5.is_low(),
]
}
}
struct Cols<'d> { struct Cols<'d> {
gpio6: Output<'d, Gpio6>, // gpio6: Output<'d, Gpio6>, //
gpio7: Output<'d, Gpio7>, // gpio7: Output<'d, Gpio7>, //
gpio8: Output<'d, Gpio8>, // gpio8: Output<'d, Gpio8>, //
gpio10: Output<'d, Gpio10>, // gpio10: Output<'d, Gpio10>, //
} }
impl<'d> Cols<'d> {
pub fn states(&self) -> [bool; 4] {
[
self.gpio6.is_set_low(),
self.gpio7.is_set_low(),
self.gpio8.is_set_low(),
self.gpio10.is_set_low(),
]
}
}
struct Keyboard<'d> { struct Keyboard<'d> {
rows: Rows<'d>, rows: Rows<'d>,
cols: Cols<'d>, cols: Cols<'d>,
} }
impl<'d> Keyboard<'d> { impl<'d> Keyboard<'d> {
pub fn pressed(&self) -> Option<Button> { pub fn pressed(&mut self) -> Option<Button> {
self.cols.gpio6.set_high();
let col1 = [
self.rows.gpio2.is_high(),
self.rows.gpio3.is_high(),
self.rows.gpio4.is_high(),
self.rows.gpio5.is_high(),
];
self.cols.gpio6.set_high();
self.cols.gpio7.set_high();
let col2 = [
self.rows.gpio2.is_high(),
self.rows.gpio3.is_high(),
self.rows.gpio4.is_high(),
self.rows.gpio5.is_high(),
];
self.cols.gpio7.set_low();
self.cols.gpio8.set_high();
let col3 = [
self.rows.gpio2.is_high(),
self.rows.gpio3.is_high(),
self.rows.gpio4.is_high(),
self.rows.gpio5.is_high(),
];
self.cols.gpio8.set_low();
self.cols.gpio10.set_high();
let col4 = [
self.rows.gpio2.is_high(),
self.rows.gpio3.is_high(),
self.rows.gpio4.is_high(),
self.rows.gpio5.is_high(),
];
self.cols.gpio10.set_low();
println!("***************************************"); println!("***************************************");
println!("rows lows: {:?}", self.rows.states()); println!("col1 {col1:?}");
println!("cols lows: {:?}", self.cols.states()); println!("col2 {col2:?}");
println!("col3 {col3:?}");
println!("col4 {col4:?}");
None None
} }
} }
/*
struct Keyboard<'d>(
[(
core::cell::RefCell<dyn InputPin + 'd>,
core::cell::RefCell<dyn OutputPin + 'd>,
); 16],
);
impl<'d> Keyboard<'d> {
pub fn new(cols: [impl InputPin; 4], rows: [impl OutputPin; 4]) {
core::array::from_fn(|x| )
for (x, c) in cols.into_iter().enumerate() {
for (y, r) in rows.into_iter().enumerate() {
;
}
}
}
}
trait KeyboardInput<'d> {
fn is_low(&mut self) -> bool;
fn is_high(&mut self) -> bool {
!self.is_low()
}
}
impl<'d, C: InputPin, R: OutputPin> KeyboardInput<'d> for (Input<'d, C>, Output<'d, R>) {
fn is_low(&mut self) -> bool {
self.1.set_low();
let s = self.0.is_low();
self.1.set_high();
s
}
}*/