diff options
author | Philipp Gesang <phg@phi-gamma.net> | 2021-12-12 01:30:31 +0100 |
---|---|---|
committer | Philipp Gesang <phg@phi-gamma.net> | 2021-12-12 01:30:31 +0100 |
commit | f86892c2639f0256a99d66bd34f40a572acc070c (patch) | |
tree | 06c02a62024198c40ad2fab12b6733d1dd695c74 /src/lib.rs | |
parent | 11156b67778ce87a24611b918b60fe970b979755 (diff) | |
download | vtcol-f86892c2639f0256a99d66bd34f40a572acc070c.tar.gz |
bin: lib: implement setting state of individual LEDs
Diffstat (limited to 'src/lib.rs')
-rw-r--r-- | src/lib.rs | 26 |
1 files changed, 25 insertions, 1 deletions
@@ -186,7 +186,10 @@ impl KbLedState } #[inline] - pub fn revert(con: &Console) -> io::Result<()> { ioctl::kdsetled(con, None) } + pub fn revert(con: &Console) -> io::Result<()> + { + ioctl::kdsetled(con, None) + } #[inline] pub fn cap(&self) -> bool { (self.0 & 0x4) != 0 } @@ -196,6 +199,27 @@ impl KbLedState #[inline] pub fn scr(&self) -> bool { (self.0 & 0x1) != 0 } + + #[inline] + pub fn set_cap(&mut self, set: bool) + { + let bit = (set as u8) << 2; + self.0 = (self.0 & !bit) | bit; + } + + #[inline] + pub fn set_num(&mut self, set: bool) + { + let bit = (set as u8) << 1; + self.0 = (self.0 & !bit) | bit; + } + + #[inline] + pub fn set_scr(&mut self, set: bool) + { + let bit = set as u8; + self.0 = (self.0 & !bit) | bit; + } } impl fmt::Display for KbLedState |