From 0567da80c088d2c879f5541125fe34173176dde1 Mon Sep 17 00:00:00 2001 From: Caemor <11088935+caemor@users.noreply.github.com> Date: Sun, 11 Apr 2021 20:28:46 +0200 Subject: [PATCH 1/4] Small impros to changelog and readme --- CHANGELOG.md | 59 +++++++++++++++++++++++++++++++++------------------- README.md | 47 +++++++++++++++++++++-------------------- 2 files changed, 63 insertions(+), 43 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f3eeac2..9a4ae72 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,15 +8,17 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## [Unreleased] ### Added - - Added QuickRefresh Trait and implemented it for EPD4in2 in #62 (thanks to @David-OConnor) - - Added Epd 2in7 (B) support in #60 (thanks to @pjsier) + +- Added QuickRefresh Trait and implemented it for EPD4in2 in #62 (thanks to @David-OConnor) +- Added Epd 2in7 (B) support in #60 (thanks to @pjsier) ### Changed - - Use specific ParseColorError instead of () - - EPD4in2: Don't set the resolution (and some more) over and over again (#48) -### Fixed +- Use specific ParseColorError instead of () +- EPD4in2: Don't set the resolution (and some more) over and over again (#48) +- Removed `#[allow(non_camel_case_types)]` to fix various issues around it +### Fixed ## [v0.5.0] @@ -25,56 +27,65 @@ TODO! ## [v0.4.0] - 2020-04-06 ### Added - - New supported epds: epd7in5 (thanks to @str4d), epd7in5 v2 (thanks to @asaaki), epd1in54b (thanks to @jkristell) - - Added update_and_display_frame to WaveshareDisplay trait (fixes #38) - - also improve position of busy_wait (#30) once more - - More Documenation + +- New supported epds: epd7in5 (thanks to @str4d), epd7in5 v2 (thanks to @asaaki), epd1in54b (thanks to @jkristell) +- Added update_and_display_frame to WaveshareDisplay trait (fixes #38) +- also improve position of busy_wait (#30) once more +- More Documentation ### Changed - - Update embedded-graphics to 0.6 (changes Display Trait) (and to 0.5 before thanks to @dbr) - - Remove useless Featuregates (Doesn't change size) - - Update and integrate a few important examples and remove the others - - Use Embedded_hal:digital::v2 +- Update embedded-graphics to 0.6 (changes Display Trait) (and to 0.5 before thanks to @dbr) +- Remove useless feature gates (Doesn't change size) +- Update and integrate a few important examples and remove the others +- Use Embedded_hal:digital::v2 ### Fixed - - Doc Tests +- Doc Tests ## [v0.3.2] - 2019-06-17 ### Fixed - - Added some more missing wait_until_idle calls + +- Added some more missing wait_until_idle calls ## [v0.3.1] - 2019-04-06 ### Added - - Example for epd4in2 and BluePill-Board + +- Example for epd4in2 and BluePill-Board ### Changed - - Improved CI + +- Improved CI ### Fixed - - Timing issues in display_frame function: epd1in54 and epd2in9 were both missing a necessary wait_until_idle call at the end of their display_frame function which sometimes caused invalid/ignored commands/inputs afterwards - - Some CI Targets were not tested correctly before + +- Timing issues in display_frame function: epd1in54 and epd2in9 were both missing a necessary wait_until_idle call at + the end of their display_frame function which sometimes caused invalid/ignored commands/inputs afterwards +- Some CI Targets were not tested correctly before ## [v0.3.0] - 2019-04-04 ### Added + - added eink to keywords - added reference to previous crate-name - improved readme/docs e.g. added reference to a few great arduino display libs for these epds - Added is_busy to Waveshare_Interface - Added IS_BUSY_LOW const for all supported epds - Added is_busy to DisplayInterface -- Added VarDisplay (a variable buffersize display/graphic driver) +- Added VarDisplay (a variable buffer-size display/graphic driver) - Updated and added more examples - add a feature gated alternative full lut for type_a displays ### Removed + - Removed all Buffers (Buffer1in54,...) and instead made specialised Displays (Display1in54,...) with included Buffers ### Changed + - Switch to 2018 edition - "cargo fix --edition" for the library - Use cargo fix edition-idioms and remove the internal renaming from embedded_hal to hal @@ -87,19 +98,25 @@ TODO! Initial release with Changelog ### Added + - Uses embedded-graphics now - Tested and fixed 1.54 inch, 2.9 inch and 4.2 inch display ### Removed + - Old included Graphics Library ### Changed + - Lots of internal changes - Renamed to `epd-waveshare` - [Unreleased]: https://github.com/Caemor/eink-waveshare-rs/compare/v0.4.0...HEAD + [v0.4.0]: https://github.com/Caemor/eink-waveshare-rs/compare/v0.3.2...v0.4.0 + [v0.3.2]: https://github.com/Caemor/eink-waveshare-rs/compare/v0.3.1...v0.3.2 + [v0.3.1]: https://github.com/Caemor/eink-waveshare-rs/compare/v0.3.0...v0.3.1 + [v0.3.0]: https://github.com/Caemor/eink-waveshare-rs/compare/v0.2.0...v0.3.0 diff --git a/README.md b/README.md index 200e601..99fcb1b 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,14 @@ [![Build Status](https://travis-ci.com/caemor/epd-waveshare.svg?branch=master)](https://travis-ci.com/caemor/epd-waveshare) -This library contains a driver for E-Paper Modules from Waveshare (which are basically the same as the Dalian Good Display ones). +This library contains a driver for E-Paper Modules from Waveshare (which are basically the same as the Dalian Good +Display ones). It uses the [embedded graphics](https://crates.io/crates/embedded-graphics) library for the optional graphics support. A 2018-edition compatible version (Rust 1.31+) is needed. -Other similiar libraries with support for much more displays are [u8g2](https://github.com/olikraus/u8g2) and [GxEPD](https://github.com/ZinggJM/GxEPD) for arduino. +Other similar libraries with support for much more displays are [u8g2](https://github.com/olikraus/u8g2) +and [GxEPD](https://github.com/ZinggJM/GxEPD) for arduino. ## Examples @@ -14,24 +16,24 @@ There are multiple examples in the examples folder. Use `cargo run --example exa ```Rust // Setup the epd -let mut epd = EPD4in2::new(&mut spi, cs, busy, dc, rst, &mut delay)?; +let mut epd = EPD4in2::new( & mut spi, cs, busy, dc, rst, & mut delay) ?; // Setup the graphics -let mut display = Display4in2::default(); +let mut display = Display4in2::default (); // Draw some text display.draw( - let _ = Text::new("Hello Rust!", Point::new(x, y)) - .into_styled(text_style!( +let _ = Text::new("Hello Rust!", Point::new(x, y)) +.into_styled(text_style!( font = Font12x16, text_color = Black, background_color = White )) - .draw(display); +.draw(display); ); // Transfer the frame data to the epd and display it -epd.update_and_display_frame(&mut spi, &display.buffer())?; +epd.update_and_display_frame( & mut spi, & display.buffer()) ?; ``` ## (Supported) Devices @@ -50,11 +52,10 @@ epd.update_and_display_frame(&mut spi, &display.buffer())?; | [5.65 Inch 7 Color (F)](https://www.waveshare.com/5.65inch-e-paper-module-f.htm) | Black, White, Red, Green, Blue, Yellow, Orange | ✕ | ✕ | ✔ | ✔ | | [2.7 Inch 3 Color (B)](https://www.waveshare.com/2.7inch-e-paper-b.htm) | Black, White, Red | ✕ | ✔ | ✔ | ✔ | - ### [1]: 7.5 Inch B/W V2 (A) -Since November 2019 Waveshare sells their updated version of these displays. -They should have a "V2" marking sticker on the backside of the panel. +Since November 2019 Waveshare sells their updated version of these displays. They should have a "V2" marking sticker on +the backside of the panel. Use `epd7in5_v2` instead of `epd7in5`, because the protocol changed. @@ -69,21 +70,23 @@ It's possible with this driver but might lead to ghosting / burn-in effects ther | Interface | Description | | :---: | :--- | -| VCC | 3.3V | -| GND | GND | -| DIN | SPI MOSI | -| CLK | SPI SCK | -| CS | SPI chip select (Low active) | -| DC | Data/Command control pin (High for data, and low for command) | -| RST | External reset pin (Low for reset) | -| BUSY | Busy state output pin (Low for busy) | +| VCC | 3.3V | +| GND | GND | +| DIN | SPI MOSI | +| CLK | SPI SCK | +| CS | SPI chip select (Low active) | +| DC | Data/Command control pin (High for data, and low for command) | +| RST | External reset pin (Low for reset) | +| BUSY | Busy state output pin (Low for busy) | ### Display Configs -There are two types of Display Configurations used in Wavedshare EPDs, which also needs to be set on the "new" E-Paper Driver HAT. -They are also called A and B, but you shouldn't get confused and mix it with the Type A,B,C and D of the various Displays, which just describe different types (colored variants) or new versions. In the Display Config the seperation is most likely due to included fast partial refresh of the displays. In a Tabular form: +There are two types of Display Configurations used in Waveshare EPDs, which also needs to be set on the "new" E-Paper +Driver HAT. They are also called A and B, but you shouldn't get confused and mix it with the Type A,B,C and D of the +various Displays, which just describe different types (colored variants) or new versions. In the Display Config the +separation is most likely due to included fast partial refresh of the displays. In a Tabular form: -| Type A | Tybe B | +| Type A | Type B | | :---: | :---: | | 1.54in (A) | 1.54in (B) | | 2.13in (A) | 1.54in (C) | From ba1b90e2f3b32237d0cbe1f00d29289b1776c464 Mon Sep 17 00:00:00 2001 From: Caemor <11088935+caemor@users.noreply.github.com> Date: Sun, 11 Apr 2021 20:31:24 +0200 Subject: [PATCH 2/4] Removed #[allow(non_camel_case_types)] to fix issues --- src/epd1in54/mod.rs | 34 +++++------ src/epd1in54b/command.rs | 47 ++++++++------- src/epd1in54b/mod.rs | 54 +++++++++--------- src/epd1in54c/command.rs | 43 +++++++------- src/epd1in54c/mod.rs | 26 ++++----- src/epd2in13_v2/command.rs | 113 ++++++++++++++++++------------------- src/epd2in13_v2/mod.rs | 64 ++++++++++----------- src/epd2in7b/command.rs | 81 +++++++++++++------------- src/epd2in7b/mod.rs | 78 ++++++++++++------------- src/epd2in9/mod.rs | 34 +++++------ src/epd2in9bc/command.rs | 43 +++++++------- src/epd2in9bc/mod.rs | 36 ++++++------ src/epd4in2/command.rs | 83 ++++++++++++++------------- src/epd4in2/mod.rs | 84 +++++++++++++-------------- src/epd5in65f/command.rs | 77 +++++++++++++------------ src/epd5in65f/mod.rs | 34 +++++------ src/epd7in5/command.rs | 77 +++++++++++++------------ src/epd7in5/mod.rs | 34 +++++------ src/epd7in5_v2/command.rs | 79 +++++++++++++------------- src/epd7in5_v2/mod.rs | 36 ++++++------ src/type_a/command.rs | 47 ++++++++------- 21 files changed, 593 insertions(+), 611 deletions(-) diff --git a/src/epd1in54/mod.rs b/src/epd1in54/mod.rs index 66420ea..1edac11 100644 --- a/src/epd1in54/mod.rs +++ b/src/epd1in54/mod.rs @@ -103,7 +103,7 @@ where // Default Values: A = Height of Screen (0x127), B = 0x00 (GD, SM and TB=0?) self.interface.cmd_with_data( spi, - Command::DRIVER_OUTPUT_CONTROL, + Command::DriverOutputControl, &[HEIGHT as u8, (HEIGHT >> 8) as u8, 0x00], )?; @@ -114,26 +114,26 @@ where //TODO: test self.interface.cmd_with_data( spi, - Command::BOOSTER_SOFT_START_CONTROL, + Command::BoosterSoftStartControl, &[0xD7, 0xD6, 0x9D], )?; // One Databyte with value 0xA8 for 7V VCOM self.interface - .cmd_with_data(spi, Command::WRITE_VCOM_REGISTER, &[0xA8])?; + .cmd_with_data(spi, Command::WriteVcomRegister, &[0xA8])?; // One Databyte with default value 0x1A for 4 dummy lines per gate self.interface - .cmd_with_data(spi, Command::SET_DUMMY_LINE_PERIOD, &[0x1A])?; + .cmd_with_data(spi, Command::SetDummyLinePeriod, &[0x1A])?; // One Databyte with default value 0x08 for 2us per line self.interface - .cmd_with_data(spi, Command::SET_GATE_LINE_WIDTH, &[0x08])?; + .cmd_with_data(spi, Command::SetGateLineWidth, &[0x08])?; // One Databyte with default value 0x03 // -> address: x increment, y increment, address counter is updated in x direction self.interface - .cmd_with_data(spi, Command::DATA_ENTRY_MODE_SETTING, &[0x03])?; + .cmd_with_data(spi, Command::DataEntryModeSetting, &[0x03])?; self.set_lut(spi, None)?; @@ -194,7 +194,7 @@ where // 0x00 for Normal mode (Power on Reset), 0x01 for Deep Sleep Mode //TODO: is 0x00 needed here or would 0x01 be even more efficient? self.interface - .cmd_with_data(spi, Command::DEEP_SLEEP_MODE, &[0x00])?; + .cmd_with_data(spi, Command::DeepSleepMode, &[0x00])?; Ok(()) } @@ -202,7 +202,7 @@ where self.wait_until_idle(); self.use_full_frame(spi)?; self.interface - .cmd_with_data(spi, Command::WRITE_RAM, buffer)?; + .cmd_with_data(spi, Command::WriteRam, buffer)?; Ok(()) } @@ -221,7 +221,7 @@ where self.set_ram_counter(spi, x, y)?; self.interface - .cmd_with_data(spi, Command::WRITE_RAM, buffer)?; + .cmd_with_data(spi, Command::WriteRam, buffer)?; Ok(()) } @@ -230,9 +230,9 @@ where // enable clock signal, enable cp, display pattern -> 0xC4 (tested with the arduino version) //TODO: test control_1 or control_2 with default value 0xFF (from the datasheet) self.interface - .cmd_with_data(spi, Command::DISPLAY_UPDATE_CONTROL_2, &[0xC4])?; + .cmd_with_data(spi, Command::DisplayUpdateControl2, &[0xC4])?; - self.interface.cmd(spi, Command::MASTER_ACTIVATION)?; + self.interface.cmd(spi, Command::MasterActivation)?; // MASTER Activation should not be interupted to avoid currption of panel images // therefore a terminate command is send self.interface.cmd(spi, Command::NOP)?; @@ -252,7 +252,7 @@ where // clear the ram with the background color let color = self.background_color.get_byte_value(); - self.interface.cmd(spi, Command::WRITE_RAM)?; + self.interface.cmd(spi, Command::WriteRam)?; self.interface .data_x_times(spi, color, WIDTH / 8 * HEIGHT)?; Ok(()) @@ -321,14 +321,14 @@ where // aren't relevant self.interface.cmd_with_data( spi, - Command::SET_RAM_X_ADDRESS_START_END_POSITION, + Command::SetRamXAddressStartEndPosition, &[(start_x >> 3) as u8, (end_x >> 3) as u8], )?; // 2 Databytes: A[7:0] & 0..A[8] for each - start and end self.interface.cmd_with_data( spi, - Command::SET_RAM_Y_ADDRESS_START_END_POSITION, + Command::SetRamYAddressStartEndPosition, &[ start_y as u8, (start_y >> 8) as u8, @@ -349,12 +349,12 @@ where // x is positioned in bytes, so the last 3 bits which show the position inside a byte in the ram // aren't relevant self.interface - .cmd_with_data(spi, Command::SET_RAM_X_ADDRESS_COUNTER, &[(x >> 3) as u8])?; + .cmd_with_data(spi, Command::SetRamXAddressCounter, &[(x >> 3) as u8])?; // 2 Databytes: A[7:0] & 0..A[8] self.interface.cmd_with_data( spi, - Command::SET_RAM_Y_ADDRESS_COUNTER, + Command::SetRamYAddressCounter, &[y as u8, (y >> 8) as u8], )?; Ok(()) @@ -365,7 +365,7 @@ where assert!(buffer.len() == 30); self.interface - .cmd_with_data(spi, Command::WRITE_LUT_REGISTER, buffer)?; + .cmd_with_data(spi, Command::WriteLutRegister, buffer)?; Ok(()) } } diff --git a/src/epd1in54b/command.rs b/src/epd1in54b/command.rs index 6c150e0..392fd19 100644 --- a/src/epd1in54b/command.rs +++ b/src/epd1in54b/command.rs @@ -2,35 +2,34 @@ use crate::traits; #[allow(dead_code)] -#[allow(non_camel_case_types)] #[derive(Copy, Clone)] pub(crate) enum Command { - PANEL_SETTING = 0x00, + PanelSetting = 0x00, - POWER_SETTING = 0x01, - POWER_OFF = 0x02, - POWER_ON = 0x04, - BOOSTER_SOFT_START = 0x06, - DATA_START_TRANSMISSION_1 = 0x10, - DISPLAY_REFRESH = 0x12, - DATA_START_TRANSMISSION_2 = 0x13, + PowerSetting = 0x01, + PowerOff = 0x02, + PowerOn = 0x04, + BoosterSoftStart = 0x06, + DataStartTransmission1 = 0x10, + DisplayRefresh = 0x12, + DataStartTransmission2 = 0x13, - LUT_FOR_VCOM = 0x20, - LUT_WHITE_TO_WHITE = 0x21, - LUT_BLACK_TO_WHITE = 0x22, - LUT_G0 = 0x23, - LUT_G1 = 0x24, - LUT_RED_VCOM = 0x25, - LUT_RED0 = 0x26, - LUT_RED1 = 0x27, + LutForVcom = 0x20, + LutWhiteToWhite = 0x21, + LutBlackToWhite = 0x22, + LutG0 = 0x23, + LutG1 = 0x24, + LutRedVcom = 0x25, + LutRed0 = 0x26, + LutRed1 = 0x27, - PLL_CONTROL = 0x30, - TEMPERATURE_SENSOR_COMMAND = 0x40, - TEMPERATURE_SENSOR_SELECTION = 0x41, - VCOM_AND_DATA_INTERVAL_SETTING = 0x50, - RESOLUTION_SETTING = 0x61, - VCM_DC_SETTING = 0x82, - POWER_SAVING = 0xE3, + PllControl = 0x30, + TemperatureSensorCommand = 0x40, + TemperatureSensorSelection = 0x41, + VcomAndDataIntervalSetting = 0x50, + ResolutionSetting = 0x61, + VcmDcSetting = 0x82, + PowerSaving = 0xE3, } impl traits::Command for Command { diff --git a/src/epd1in54b/mod.rs b/src/epd1in54b/mod.rs index c14050e..8441508 100644 --- a/src/epd1in54b/mod.rs +++ b/src/epd1in54b/mod.rs @@ -56,29 +56,29 @@ where // set the power settings self.interface - .cmd_with_data(spi, Command::POWER_SETTING, &[0x07, 0x00, 0x08, 0x00])?; + .cmd_with_data(spi, Command::PowerSetting, &[0x07, 0x00, 0x08, 0x00])?; // start the booster self.interface - .cmd_with_data(spi, Command::BOOSTER_SOFT_START, &[0x07, 0x07, 0x07])?; + .cmd_with_data(spi, Command::BoosterSoftStart, &[0x07, 0x07, 0x07])?; // power on - self.command(spi, Command::POWER_ON)?; + self.command(spi, Command::PowerOn)?; delay.delay_ms(5); self.wait_until_idle(); // set the panel settings - self.cmd_with_data(spi, Command::PANEL_SETTING, &[0xCF])?; + self.cmd_with_data(spi, Command::PanelSetting, &[0xCF])?; - self.cmd_with_data(spi, Command::VCOM_AND_DATA_INTERVAL_SETTING, &[0x37])?; + self.cmd_with_data(spi, Command::VcomAndDataIntervalSetting, &[0x37])?; // PLL - self.cmd_with_data(spi, Command::PLL_CONTROL, &[0x39])?; + self.cmd_with_data(spi, Command::PllControl, &[0x39])?; // set resolution self.send_resolution(spi)?; - self.cmd_with_data(spi, Command::VCM_DC_SETTING, &[0x0E])?; + self.cmd_with_data(spi, Command::VcmDcSetting, &[0x0E])?; self.set_lut(spi, None)?; @@ -112,7 +112,7 @@ where self.send_resolution(spi)?; self.interface - .cmd(spi, Command::DATA_START_TRANSMISSION_1)?; + .cmd(spi, Command::DataStartTransmission1)?; for b in black { let expanded = expand_bits(*b); @@ -127,7 +127,7 @@ where chromatic: &[u8], ) -> Result<(), SPI::Error> { self.interface - .cmd(spi, Command::DATA_START_TRANSMISSION_2)?; + .cmd(spi, Command::DataStartTransmission2)?; self.interface.data(spi, chromatic)?; Ok(()) } @@ -164,19 +164,19 @@ where fn sleep(&mut self, spi: &mut SPI) -> Result<(), SPI::Error> { self.wait_until_idle(); self.interface - .cmd_with_data(spi, Command::VCOM_AND_DATA_INTERVAL_SETTING, &[0x17])?; //border floating + .cmd_with_data(spi, Command::VcomAndDataIntervalSetting, &[0x17])?; //border floating self.interface - .cmd_with_data(spi, Command::VCM_DC_SETTING, &[0x00])?; // VCOM to 0V + .cmd_with_data(spi, Command::VcmDcSetting, &[0x00])?; // VCOM to 0V self.interface - .cmd_with_data(spi, Command::POWER_SETTING, &[0x02, 0x00, 0x00, 0x00])?; //VG&VS to 0V fast + .cmd_with_data(spi, Command::PowerSetting, &[0x02, 0x00, 0x00, 0x00])?; //VG&VS to 0V fast self.wait_until_idle(); //NOTE: The example code has a 1s delay here - self.command(spi, Command::POWER_OFF)?; + self.command(spi, Command::PowerOff)?; Ok(()) } @@ -210,7 +210,7 @@ where self.send_resolution(spi)?; self.interface - .cmd(spi, Command::DATA_START_TRANSMISSION_1)?; + .cmd(spi, Command::DataStartTransmission1)?; for b in buffer { // Two bits per pixel @@ -225,7 +225,7 @@ where let nbits = WIDTH * (HEIGHT / 8); self.interface - .cmd(spi, Command::DATA_START_TRANSMISSION_2)?; + .cmd(spi, Command::DataStartTransmission2)?; self.interface.data_x_times(spi, color, nbits)?; //NOTE: Example code has a delay here @@ -247,7 +247,7 @@ where fn display_frame(&mut self, spi: &mut SPI) -> Result<(), SPI::Error> { self.wait_until_idle(); - self.command(spi, Command::DISPLAY_REFRESH)?; + self.command(spi, Command::DisplayRefresh)?; Ok(()) } @@ -265,7 +265,7 @@ where // Clear the black self.interface - .cmd(spi, Command::DATA_START_TRANSMISSION_1)?; + .cmd(spi, Command::DataStartTransmission1)?; // Uses 2 bits per pixel self.interface @@ -273,7 +273,7 @@ where // Clear the red self.interface - .cmd(spi, Command::DATA_START_TRANSMISSION_2)?; + .cmd(spi, Command::DataStartTransmission2)?; self.interface .data_x_times(spi, color, WIDTH * HEIGHT / 8)?; Ok(()) @@ -285,19 +285,19 @@ where _refresh_rate: Option, ) -> Result<(), SPI::Error> { self.interface - .cmd_with_data(spi, Command::LUT_FOR_VCOM, LUT_VCOM0)?; + .cmd_with_data(spi, Command::LutForVcom, LUT_VCOM0)?; self.interface - .cmd_with_data(spi, Command::LUT_WHITE_TO_WHITE, LUT_WHITE_TO_WHITE)?; + .cmd_with_data(spi, Command::LutWhiteToWhite, LUT_WHITE_TO_WHITE)?; self.interface - .cmd_with_data(spi, Command::LUT_BLACK_TO_WHITE, LUT_BLACK_TO_WHITE)?; - self.interface.cmd_with_data(spi, Command::LUT_G0, LUT_G1)?; - self.interface.cmd_with_data(spi, Command::LUT_G1, LUT_G2)?; + .cmd_with_data(spi, Command::LutBlackToWhite, LUT_BLACK_TO_WHITE)?; + self.interface.cmd_with_data(spi, Command::LutG0, LUT_G1)?; + self.interface.cmd_with_data(spi, Command::LutG1, LUT_G2)?; self.interface - .cmd_with_data(spi, Command::LUT_RED_VCOM, LUT_RED_VCOM)?; + .cmd_with_data(spi, Command::LutRedVcom, LUT_RED_VCOM)?; self.interface - .cmd_with_data(spi, Command::LUT_RED0, LUT_RED0)?; + .cmd_with_data(spi, Command::LutRed0, LUT_RED0)?; self.interface - .cmd_with_data(spi, Command::LUT_RED1, LUT_RED1)?; + .cmd_with_data(spi, Command::LutRed1, LUT_RED1)?; Ok(()) } @@ -340,7 +340,7 @@ where let w = self.width(); let h = self.height(); - self.command(spi, Command::RESOLUTION_SETTING)?; + self.command(spi, Command::ResolutionSetting)?; self.send_data(spi, &[w as u8])?; self.send_data(spi, &[(h >> 8) as u8])?; diff --git a/src/epd1in54c/command.rs b/src/epd1in54c/command.rs index e0ad2f2..eef7aec 100644 --- a/src/epd1in54c/command.rs +++ b/src/epd1in54c/command.rs @@ -2,33 +2,32 @@ use crate::traits; #[allow(dead_code)] -#[allow(non_camel_case_types)] #[derive(Copy, Clone)] pub(crate) enum Command { - PANEL_SETTING = 0x00, + PanelSetting = 0x00, - POWER_SETTING = 0x01, - POWER_OFF = 0x02, - POWER_ON = 0x04, - BOOSTER_SOFT_START = 0x06, - DEEP_SLEEP = 0x07, - DATA_START_TRANSMISSION_1 = 0x10, - DISPLAY_REFRESH = 0x12, - DATA_START_TRANSMISSION_2 = 0x13, + PowerSetting = 0x01, + PowerOff = 0x02, + PowerOn = 0x04, + BoosterSoftStart = 0x06, + DeepSleep = 0x07, + DataStartTransmission1 = 0x10, + DisplayRefresh = 0x12, + DataStartTransmission2 = 0x13, - LUT_FOR_VCOM = 0x20, - LUT_WHITE_TO_WHITE = 0x21, - LUT_BLACK_TO_WHITE = 0x22, - LUT_WHITE_TO_BLACK = 0x23, - LUT_BLACK_TO_BLACK = 0x24, + LutForVcom = 0x20, + LutWhiteToWhite = 0x21, + LutBlackToWhite = 0x22, + LutWhiteToBlack = 0x23, + LutBlackToBlack = 0x24, - PLL_CONTROL = 0x30, - TEMPERATURE_SENSOR_COMMAND = 0x40, - TEMPERATURE_SENSOR_SELECTION = 0x41, - VCOM_AND_DATA_INTERVAL_SETTING = 0x50, - RESOLUTION_SETTING = 0x61, - VCM_DC_SETTING = 0x82, - POWER_SAVING = 0xE3, + PllControl = 0x30, + TemperatureSensorCommand = 0x40, + TemperatureSensorSelection = 0x41, + VcomAndDataIntervalSetting = 0x50, + ResolutionSetting = 0x61, + VcmDcSetting = 0x82, + PowerSaving = 0xE3, } impl traits::Command for Command { diff --git a/src/epd1in54c/mod.rs b/src/epd1in54c/mod.rs index f8bd54d..77b5325 100644 --- a/src/epd1in54c/mod.rs +++ b/src/epd1in54c/mod.rs @@ -57,20 +57,20 @@ where self.interface.reset(delay, 2); // start the booster - self.cmd_with_data(spi, Command::BOOSTER_SOFT_START, &[0x17, 0x17, 0x17])?; + self.cmd_with_data(spi, Command::BoosterSoftStart, &[0x17, 0x17, 0x17])?; // power on - self.command(spi, Command::POWER_ON)?; + self.command(spi, Command::PowerOn)?; delay.delay_ms(5); self.wait_until_idle(); // set the panel settings - self.cmd_with_data(spi, Command::PANEL_SETTING, &[0x0f, 0x0d])?; + self.cmd_with_data(spi, Command::PanelSetting, &[0x0f, 0x0d])?; // set resolution self.send_resolution(spi)?; - self.cmd_with_data(spi, Command::VCOM_AND_DATA_INTERVAL_SETTING, &[0x77])?; + self.cmd_with_data(spi, Command::VcomAndDataIntervalSetting, &[0x77])?; Ok(()) } @@ -97,7 +97,7 @@ where fn update_achromatic_frame(&mut self, spi: &mut SPI, black: &[u8]) -> Result<(), SPI::Error> { self.wait_until_idle(); - self.cmd_with_data(spi, Command::DATA_START_TRANSMISSION_1, black)?; + self.cmd_with_data(spi, Command::DataStartTransmission1, black)?; Ok(()) } @@ -108,7 +108,7 @@ where chromatic: &[u8], ) -> Result<(), SPI::Error> { self.wait_until_idle(); - self.cmd_with_data(spi, Command::DATA_START_TRANSMISSION_2, chromatic)?; + self.cmd_with_data(spi, Command::DataStartTransmission2, chromatic)?; Ok(()) } @@ -145,9 +145,9 @@ where fn sleep(&mut self, spi: &mut SPI) -> Result<(), SPI::Error> { self.wait_until_idle(); - self.command(spi, Command::POWER_OFF)?; + self.command(spi, Command::PowerOff)?; self.wait_until_idle(); - self.cmd_with_data(spi, Command::DEEP_SLEEP, &[0xa5])?; + self.cmd_with_data(spi, Command::DeepSleep, &[0xa5])?; Ok(()) } @@ -182,7 +182,7 @@ where // Clear the chromatic layer let color = self.color.get_byte_value(); - self.command(spi, Command::DATA_START_TRANSMISSION_2)?; + self.command(spi, Command::DataStartTransmission2)?; self.interface.data_x_times(spi, color, NUM_DISPLAY_BITS)?; Ok(()) @@ -202,7 +202,7 @@ where } fn display_frame(&mut self, spi: &mut SPI) -> Result<(), SPI::Error> { - self.command(spi, Command::DISPLAY_REFRESH)?; + self.command(spi, Command::DisplayRefresh)?; self.wait_until_idle(); Ok(()) @@ -220,11 +220,11 @@ where let color = DEFAULT_BACKGROUND_COLOR.get_byte_value(); // Clear the black - self.command(spi, Command::DATA_START_TRANSMISSION_1)?; + self.command(spi, Command::DataStartTransmission1)?; self.interface.data_x_times(spi, color, NUM_DISPLAY_BITS)?; // Clear the chromatic - self.command(spi, Command::DATA_START_TRANSMISSION_2)?; + self.command(spi, Command::DataStartTransmission2)?; self.interface.data_x_times(spi, color, NUM_DISPLAY_BITS)?; Ok(()) @@ -276,7 +276,7 @@ where let w = self.width(); let h = self.height(); - self.command(spi, Command::RESOLUTION_SETTING)?; + self.command(spi, Command::ResolutionSetting)?; // | D7 | D6 | D5 | D4 | D3 | D2 | D1 | D0 | // | HRES[7:3] | 0 | 0 | 0 | diff --git a/src/epd2in13_v2/command.rs b/src/epd2in13_v2/command.rs index 9ab4ddd..e94c43e 100644 --- a/src/epd2in13_v2/command.rs +++ b/src/epd2in13_v2/command.rs @@ -9,51 +9,50 @@ use bit_field::BitField; /// /// For more infos about the addresses and what they are doing look into the pdfs #[allow(dead_code)] -#[allow(non_camel_case_types)] #[derive(Copy, Clone)] pub(crate) enum Command { - DRIVER_OUTPUT_CONTROL = 0x01, - GATE_DRIVING_VOLTAGE_CTRL = 0x03, - SOURCE_DRIVING_VOLTAGE_CTRL = 0x04, - BOOSTER_SOFT_START_CONTROL = 0x0C, - GATE_SCAN_START_POSITION = 0x0F, - DEEP_SLEEP_MODE = 0x10, - DATA_ENTRY_MODE_SETTING = 0x11, - SW_RESET = 0x12, - HV_READY_DETECTION = 0x14, - VCI_DETECTION = 0x15, - TEMPERATURE_SENSOR_CONTROL_WRITE = 0x1A, - TEMPERATURE_SENSOR_CONTROL_READ = 0x1B, - TEMPERATURE_SENSOR_EXT_CONTROL_WRITE = 0x1C, - MASTER_ACTIVATION = 0x20, - DISPLAY_UPDATE_CONTROL_1 = 0x21, - DISPLAY_UPDATE_CONTROL_2 = 0x22, - WRITE_RAM = 0x24, - WRITE_RAM_RED = 0x26, - READ_RAM = 0x27, - VCOM_SENSE = 0x28, - VCOM_SENSE_DURATION = 0x29, - PROGRAM_VCOM_OPT = 0x2A, - WRITE_VCOM_REGISTER = 0x2C, - OTP_REGISTER_READ = 0x2D, - STATUS_BIT_READ = 0x2F, - PROGRAM_WS_OTP = 0x30, - LOAD_WS_OTP = 0x31, - WRITE_LUT_REGISTER = 0x32, - PROGRAM_OTP_SELECTION = 0x36, - WRITE_OTP_SELECTION = 0x37, - SET_DUMMY_LINE_PERIOD = 0x3A, - SET_GATE_LINE_WIDTH = 0x3B, - BORDER_WAVEFORM_CONTROL = 0x3C, - READ_RAM_OPTION = 0x41, - SET_RAM_X_ADDRESS_START_END_POSITION = 0x44, - SET_RAM_Y_ADDRESS_START_END_POSITION = 0x45, - AUTO_WRITE_RED_RAM_REGULAR_PATTERN = 0x46, - AUTO_WRITE_BW_RAM_REGULAR_PATTERN = 0x47, - SET_RAM_X_ADDRESS_COUNTER = 0x4E, - SET_RAM_Y_ADDRESS_COUNTER = 0x4F, - SET_ANALOG_BLOCK_CONTROL = 0x74, - SET_DIGITAL_BLOCK_CONTROL = 0x7E, + DriverOutputControl = 0x01, + GateDrivingVoltageCtrl = 0x03, + SourceDrivingVoltageCtrl = 0x04, + BoosterSoftStartControl = 0x0C, + GateScanStartPosition = 0x0F, + DeepSleepMode = 0x10, + DataEntryModeSetting = 0x11, + SwReset = 0x12, + HvReadyDetection = 0x14, + VciDetection = 0x15, + TemperatureSensorControlWrite = 0x1A, + TemperatureSensorControlRead = 0x1B, + TemperatureSensorExtControlWrite = 0x1C, + MasterActivation = 0x20, + DisplayUpdateControl1 = 0x21, + DisplayUpdateControl2 = 0x22, + WriteRam = 0x24, + WriteRamRed = 0x26, + ReadRam = 0x27, + VcomSense = 0x28, + VcomSenseDuration = 0x29, + ProgramVcomOpt = 0x2A, + WriteVcomRegister = 0x2C, + OtpRegisterRead = 0x2D, + StatusBitRead = 0x2F, + ProgramWsOtp = 0x30, + LoadWsOtp = 0x31, + WriteLutRegister = 0x32, + ProgramOtpSelection = 0x36, + WriteOtpSelection = 0x37, + SetDummyLinePeriod = 0x3A, + SetGateLineWidth = 0x3B, + BorderWaveformControl = 0x3C, + ReadRamOption = 0x41, + SetRamXAddressStartEndPosition = 0x44, + SetRamYAddressStartEndPosition = 0x45, + AutoWriteRedRamRegularPattern = 0x46, + AutoWriteBwRamRegularPattern = 0x47, + SetRamXAddressCounter = 0x4E, + SetRamYAddressCounter = 0x4F, + SetAnalogBlockControl = 0x74, + SetDigitalBlockControl = 0x7E, NOP = 0x7F, } @@ -135,32 +134,30 @@ impl DisplayUpdateControl2 { } #[allow(dead_code)] -#[allow(non_camel_case_types)] + pub(crate) enum DataEntryModeIncr { - X_DECR_Y_DECR = 0x0, - X_INCR_Y_DECR = 0x1, - X_DECR_Y_INCR = 0x2, - X_INCR_Y_INCR = 0x3, + XDecrYDecr = 0x0, + XIncrYDecr = 0x1, + XDecrYIncr = 0x2, + XIncrYIncr = 0x3, } #[allow(dead_code)] -#[allow(non_camel_case_types)] + pub(crate) enum DataEntryModeDir { - X_DIR = 0x0, - Y_DIR = 0x4, + XDir = 0x0, + YDir = 0x4, } #[allow(dead_code)] -#[allow(non_camel_case_types)] #[derive(Copy, Clone)] pub(crate) enum BorderWaveFormVBD { GS = 0x0, - FIX_LEVEL = 0x1, + FixLevel = 0x1, VCOM = 0x2, } #[allow(dead_code)] -#[allow(non_camel_case_types)] #[derive(Copy, Clone)] pub(crate) enum BorderWaveFormFixLevel { VSS = 0x0, @@ -170,7 +167,6 @@ pub(crate) enum BorderWaveFormFixLevel { } #[allow(dead_code)] -#[allow(non_camel_case_types)] #[derive(Copy, Clone)] pub(crate) enum BorderWaveFormGS { LUT0 = 0x0, @@ -194,17 +190,16 @@ impl BorderWaveForm { } #[allow(dead_code)] -#[allow(non_camel_case_types)] #[derive(Copy, Clone)] pub enum DeepSleepMode { // Sleeps and keeps access to RAM and controller - NORMAL = 0x00, + Normal = 0x00, // Sleeps without access to RAM/controller but keeps RAM content - MODE_1 = 0x01, + Mode1 = 0x01, // Same as MODE_1 but RAM content is not kept - MODE_2 = 0x11, + Mode2 = 0x11, } pub(crate) struct GateDrivingVoltage(pub u8); diff --git a/src/epd2in13_v2/mod.rs b/src/epd2in13_v2/mod.rs index 704d262..cd5481d 100644 --- a/src/epd2in13_v2/mod.rs +++ b/src/epd2in13_v2/mod.rs @@ -80,7 +80,7 @@ where self.set_lut(spi, Some(self.refresh))?; // Python code does this, not sure why - // self.cmd_with_data(spi, Command::WRITE_OTP_SELECTION, &[0, 0, 0, 0, 0x40, 0, 0])?; + // self.cmd_with_data(spi, Command::WriteOtpSelection, &[0, 0, 0, 0, 0x40, 0, 0])?; // During partial update, clock/analog are not disabled between 2 // updates. @@ -88,7 +88,7 @@ where spi, DisplayUpdateControl2::new().enable_analog().enable_clock(), )?; - self.command(spi, Command::MASTER_ACTIVATION)?; + self.command(spi, Command::MasterActivation)?; self.wait_until_idle(); self.set_border_waveform( @@ -101,7 +101,7 @@ where )?; } else { self.wait_until_idle(); - self.command(spi, Command::SW_RESET)?; + self.command(spi, Command::SwReset)?; self.wait_until_idle(); self.set_driver_output( @@ -118,11 +118,7 @@ where self.set_dummy_line_period(spi, 0x30)?; self.set_gate_scan_start_position(spi, 0)?; - self.set_data_entry_mode( - spi, - DataEntryModeIncr::X_INCR_Y_INCR, - DataEntryModeDir::X_DIR, - )?; + self.set_data_entry_mode(spi, DataEntryModeIncr::XIncrYIncr, DataEntryModeDir::XDir)?; // Use simple X/Y auto increase self.set_ram_area(spi, 0, 0, WIDTH - 1, HEIGHT - 1)?; @@ -177,7 +173,7 @@ where ) -> Result { let mut epd = EPD2in13 { interface: DisplayInterface::new(cs, busy, dc, rst), - sleep_mode: DeepSleepMode::MODE_1, + sleep_mode: DeepSleepMode::Mode1, background_color: DEFAULT_BACKGROUND_COLOR, refresh: RefreshLUT::FULL, }; @@ -206,7 +202,7 @@ where .disable_analog() .disable_clock(), )?; - self.command(spi, Command::MASTER_ACTIVATION)?; + self.command(spi, Command::MasterActivation)?; self.set_sleep_mode(spi, self.sleep_mode)?; Ok(()) @@ -217,14 +213,14 @@ where self.set_ram_area(spi, 0, 0, WIDTH - 1, HEIGHT - 1)?; self.set_ram_address_counters(spi, 0, 0)?; - self.cmd_with_data(spi, Command::WRITE_RAM, buffer)?; + self.cmd_with_data(spi, Command::WriteRam, buffer)?; if self.refresh == RefreshLUT::FULL { // Always keep the base buffer equal to current if not doing partial refresh. self.set_ram_area(spi, 0, 0, WIDTH - 1, HEIGHT - 1)?; self.set_ram_address_counters(spi, 0, 0)?; - self.cmd_with_data(spi, Command::WRITE_RAM_RED, buffer)?; + self.cmd_with_data(spi, Command::WriteRamRed, buffer)?; } Ok(()) } @@ -254,14 +250,14 @@ where self.set_ram_area(spi, x, y, x + width, y + height)?; self.set_ram_address_counters(spi, x, y)?; - self.cmd_with_data(spi, Command::WRITE_RAM, buffer)?; + self.cmd_with_data(spi, Command::WriteRam, buffer)?; if self.refresh == RefreshLUT::FULL { // Always keep the base buffer equals to current if not doing partial refresh. self.set_ram_area(spi, x, y, x + width, y + height)?; self.set_ram_address_counters(spi, x, y)?; - self.cmd_with_data(spi, Command::WRITE_RAM_RED, buffer)?; + self.cmd_with_data(spi, Command::WriteRamRed, buffer)?; } Ok(()) @@ -283,7 +279,7 @@ where } else { self.set_display_update_control_2(spi, DisplayUpdateControl2::new().display())?; } - self.command(spi, Command::MASTER_ACTIVATION)?; + self.command(spi, Command::MasterActivation)?; self.wait_until_idle(); Ok(()) @@ -305,7 +301,7 @@ where self.set_ram_area(spi, 0, 0, WIDTH - 1, HEIGHT - 1)?; self.set_ram_address_counters(spi, 0, 0)?; - self.command(spi, Command::WRITE_RAM)?; + self.command(spi, Command::WriteRam)?; self.interface.data_x_times( spi, color, @@ -317,7 +313,7 @@ where self.set_ram_area(spi, 0, 0, WIDTH - 1, HEIGHT - 1)?; self.set_ram_address_counters(spi, 0, 0)?; - self.command(spi, Command::WRITE_RAM_RED)?; + self.command(spi, Command::WriteRamRed)?; self.interface.data_x_times( spi, color, @@ -353,7 +349,7 @@ where Some(RefreshLUT::QUICK) => &LUT_PARTIAL_UPDATE, }; - self.cmd_with_data(spi, Command::WRITE_LUT_REGISTER, buffer) + self.cmd_with_data(spi, Command::WriteLutRegister, buffer) } fn is_busy(&self) -> bool { @@ -380,7 +376,7 @@ where self.set_ram_area(spi, 0, 0, WIDTH - 1, HEIGHT - 1)?; self.set_ram_address_counters(spi, 0, 0)?; - self.cmd_with_data(spi, Command::WRITE_RAM_RED, buffer)?; + self.cmd_with_data(spi, Command::WriteRamRed, buffer)?; Ok(()) } @@ -412,7 +408,7 @@ where assert!(start <= 295); self.cmd_with_data( spi, - Command::GATE_SCAN_START_POSITION, + Command::GateScanStartPosition, &[(start & 0xFF) as u8, ((start >> 8) & 0x1) as u8], ) } @@ -424,13 +420,13 @@ where ) -> Result<(), SPI::Error> { self.cmd_with_data( spi, - Command::BORDER_WAVEFORM_CONTROL, + Command::BorderWaveformControl, &[borderwaveform.to_u8()], ) } fn set_vcom_register(&mut self, spi: &mut SPI, vcom: VCOM) -> Result<(), SPI::Error> { - self.cmd_with_data(spi, Command::WRITE_VCOM_REGISTER, &[vcom.0]) + self.cmd_with_data(spi, Command::WriteVcomRegister, &[vcom.0]) } fn set_gate_driving_voltage( @@ -438,7 +434,7 @@ where spi: &mut SPI, voltage: GateDrivingVoltage, ) -> Result<(), SPI::Error> { - self.cmd_with_data(spi, Command::GATE_DRIVING_VOLTAGE_CTRL, &[voltage.0]) + self.cmd_with_data(spi, Command::GateDrivingVoltageCtrl, &[voltage.0]) } fn set_dummy_line_period( @@ -447,11 +443,11 @@ where number_of_lines: u8, ) -> Result<(), SPI::Error> { assert!(number_of_lines <= 127); - self.cmd_with_data(spi, Command::SET_DUMMY_LINE_PERIOD, &[number_of_lines]) + self.cmd_with_data(spi, Command::SetDummyLinePeriod, &[number_of_lines]) } fn set_gate_line_width(&mut self, spi: &mut SPI, width: u8) -> Result<(), SPI::Error> { - self.cmd_with_data(spi, Command::SET_GATE_LINE_WIDTH, &[width & 0x0F]) + self.cmd_with_data(spi, Command::SetGateLineWidth, &[width & 0x0F]) } /// Sets the source driving voltage value @@ -464,7 +460,7 @@ where ) -> Result<(), SPI::Error> { self.cmd_with_data( spi, - Command::SOURCE_DRIVING_VOLTAGE_CTRL, + Command::SourceDrivingVoltageCtrl, &[vsh1.0, vsh2.0, vsl.0], ) } @@ -476,16 +472,16 @@ where spi: &mut SPI, value: DisplayUpdateControl2, ) -> Result<(), SPI::Error> { - self.cmd_with_data(spi, Command::DISPLAY_UPDATE_CONTROL_2, &[value.0]) + self.cmd_with_data(spi, Command::DisplayUpdateControl2, &[value.0]) } /// Triggers the deep sleep mode fn set_sleep_mode(&mut self, spi: &mut SPI, mode: DeepSleepMode) -> Result<(), SPI::Error> { - self.cmd_with_data(spi, Command::DEEP_SLEEP_MODE, &[mode as u8]) + self.cmd_with_data(spi, Command::DeepSleepMode, &[mode as u8]) } fn set_driver_output(&mut self, spi: &mut SPI, output: DriverOutput) -> Result<(), SPI::Error> { - self.cmd_with_data(spi, Command::DRIVER_OUTPUT_CONTROL, &output.to_bytes()) + self.cmd_with_data(spi, Command::DriverOutputControl, &output.to_bytes()) } /// Sets the data entry mode (ie. how X and Y positions changes when writing @@ -497,7 +493,7 @@ where counter_direction: DataEntryModeDir, ) -> Result<(), SPI::Error> { let mode = counter_incr_mode as u8 | counter_direction as u8; - self.cmd_with_data(spi, Command::DATA_ENTRY_MODE_SETTING, &[mode]) + self.cmd_with_data(spi, Command::DataEntryModeSetting, &[mode]) } /// Sets both X and Y pixels ranges @@ -511,13 +507,13 @@ where ) -> Result<(), SPI::Error> { self.cmd_with_data( spi, - Command::SET_RAM_X_ADDRESS_START_END_POSITION, + Command::SetRamXAddressStartEndPosition, &[(start_x >> 3) as u8, (end_x >> 3) as u8], )?; self.cmd_with_data( spi, - Command::SET_RAM_Y_ADDRESS_START_END_POSITION, + Command::SetRamYAddressStartEndPosition, &[ start_y as u8, (start_y >> 8) as u8, @@ -535,11 +531,11 @@ where y: u32, ) -> Result<(), SPI::Error> { self.wait_until_idle(); - self.cmd_with_data(spi, Command::SET_RAM_X_ADDRESS_COUNTER, &[(x >> 3) as u8])?; + self.cmd_with_data(spi, Command::SetRamXAddressCounter, &[(x >> 3) as u8])?; self.cmd_with_data( spi, - Command::SET_RAM_Y_ADDRESS_COUNTER, + Command::SetRamYAddressCounter, &[y as u8, (y >> 8) as u8], )?; Ok(()) diff --git a/src/epd2in7b/command.rs b/src/epd2in7b/command.rs index d478ce7..b228d22 100644 --- a/src/epd2in7b/command.rs +++ b/src/epd2in7b/command.rs @@ -5,117 +5,116 @@ use crate::traits; /// /// More information can be found in the [specification](https://www.waveshare.com/w/upload/d/d8/2.7inch-e-paper-b-specification.pdf) #[allow(dead_code)] -#[allow(non_camel_case_types)] #[derive(Copy, Clone)] pub(crate) enum Command { /// Set Resolution, LUT selection, BWR pixels, gate scan direction, source shift direction, booster switch, soft reset - PANEL_SETTING = 0x00, + PanelSetting = 0x00, /// Selecting internal and external power - POWER_SETTING = 0x01, - POWER_OFF = 0x02, + PowerSetting = 0x01, + PowerOff = 0x02, /// Setting Power OFF sequence - POWER_OFF_SEQUENCE_SETTING = 0x03, - POWER_ON = 0x04, + PowerOffSequenceSetting = 0x03, + PowerOn = 0x04, /// This command enables the internal bandgap, which will be cleared by the next POF. - POWER_ON_MEASURE = 0x05, + PowerOnMeasure = 0x05, /// Starting data transmission /// /// ```ignore /// self.send_data(&[0x07, 0x07, 0x17])?; /// ``` - BOOSTER_SOFT_START = 0x06, + BoosterSoftStart = 0x06, /// After this command is transmitted, the chip would enter the deep-sleep mode to save power. /// /// The deep sleep mode would return to standby by hardware reset. /// /// The only one parameter is a check code, the command would be excuted if check code = 0xA5. - DEEP_SLEEP = 0x07, + DeepSleep = 0x07, /// This command starts transmitting data and write them into SRAM. To complete data transmission, command DSP (Data /// transmission Stop) must be issued. Then the chip will start to send data/VCOM for panel. /// /// - In B/W mode, this command writes “OLD” data to SRAM. /// - In B/W/Red mode, this command writes “B/W” data to SRAM. - DATA_START_TRANSMISSION_1 = 0x10, + DataStartTransmission1 = 0x10, /// Stopping data transmission - DATA_STOP = 0x11, + DataStop = 0x11, /// After this command is issued, driver will refresh display (data/VCOM) according to SRAM data and LUT. - DISPLAY_REFRESH = 0x12, + DisplayRefresh = 0x12, /// This command starts transmitting data and write them into SRAM. To complete data transmission, command DSP (Data /// transmission Stop) must be issued. Then the chip will start to send data/VCOM for panel. /// - In B/W mode, this command writes “NEW” data to SRAM. /// - In B/W/Red mode, this command writes “RED” data to SRAM. - DATA_START_TRANSMISSION_2 = 0x13, + DataStartTransmission2 = 0x13, /// The command define as follows: The register is indicates that user start to transmit data, then write to SRAM. While data transmission /// complete, user must send command DSP (Data transmission Stop). Then chip will start to send data/VCOM for panel. /// /// - In B/W mode, this command writes “OLD” data to SRAM. /// - In B/W/Red mode, this command writes “B/W” data to SRAM. - PARTIAL_DATA_START_TRANSMISSION_1 = 0x14, + PartialDataStartTransmission1 = 0x14, /// The command define as follows: The register is indicates that user start to transmit data, then write to SRAM. While data transmission /// complete, user must send command DSP (Data transmission Stop). Then chip will start to send data/VCOM for panel. /// /// - In B/W mode, this command writes “NEW” data to SRAM. /// - In B/W/Red mode, this command writes “RED” data to SRAM. - PARTIAL_DATA_START_TRANSMISSION_2 = 0x15, + PartialDataStartTransmission2 = 0x15, /// While user sent this command, driver will refresh display (data/VCOM) base on SRAM data and LUT. /// /// Only the area (X,Y, W, L) would update, the others pixel output would follow VCOM LUT - PARTIAL_DISPLAY_REFRESH = 0x16, + PartialDisplayRefresh = 0x16, /// This command builds the Look-up table for VCOM - LUT_FOR_VCOM = 0x20, - LUT_WHITE_TO_WHITE = 0x21, - LUT_BLACK_TO_WHITE = 0x22, - LUT_WHITE_TO_BLACK = 0x23, - LUT_BLACK_TO_BLACK = 0x24, + LutForVcom = 0x20, + LutWhiteToWhite = 0x21, + LutBlackToWhite = 0x22, + LutWhiteToBlack = 0x23, + LutBlackToBlack = 0x24, /// The command controls the PLL clock frequency. - PLL_CONTROL = 0x30, + PllControl = 0x30, /// This command reads the temperature sensed by the temperature sensor. /// /// Doesn't work! Waveshare doesn't connect the read pin - TEMPERATURE_SENSOR_COMMAND = 0x40, + TemperatureSensorCommand = 0x40, /// This command selects Internal or External temperature sensor. - TEMPERATURE_SENSOR_CALIBRATION = 0x41, + TemperatureSensorCalibration = 0x41, /// Write External Temperature Sensor - TEMPERATURE_SENSOR_WRITE = 0x42, + TemperatureSensorWrite = 0x42, /// Read External Temperature Sensor /// /// Doesn't work! Waveshare doesn't connect the read pin - TEMPERATURE_SENSOR_READ = 0x43, + TemperatureSensorRead = 0x43, /// This command indicates the interval of Vcom and data output. When setting the vertical back porch, the total blanking will be kept (20 Hsync) - VCOM_AND_DATA_INTERVAL_SETTING = 0x50, + VcomAndDataIntervalSetting = 0x50, /// This command indicates the input power condition. Host can read this flag to learn the battery condition. - LOW_POWER_DETECTION = 0x51, + LowPowerDetection = 0x51, /// This command defines non-overlap period of Gate and Source. - TCON_SETTING = 0x60, + TconSetting = 0x60, /// This command defines alternative resolution and this setting is of higher priority than the RES\[1:0\] in R00H (PSR). - RESOLUTION_SETTING = 0x61, - SOURCE_AND_GATE_SETTING = 0x62, + ResolutionSetting = 0x61, + SourceAndGateSetting = 0x62, /// This command reads the IC status. /// /// Doesn't work! Waveshare doesn't connect the read pin - GET_STATUS = 0x71, + GetStatus = 0x71, /// Automatically measure VCOM. This command reads the IC status - AUTO_MEASUREMENT_VCOM = 0x80, + AutoMeasurementVcom = 0x80, /// This command gets the VCOM value /// /// Doesn't work! Waveshare doesn't connect the read pin - READ_VCOM_VALUE = 0x81, + ReadVcomValue = 0x81, /// This command sets VCOM_DC value. - VCM_DC_SETTING = 0x82, + VcmDcSetting = 0x82, /// After this command is issued, the chip would enter the program mode. /// /// After the programming procedure completed, a hardware reset is necessary for leaving program mode. /// /// The only one parameter is a check code, the command would be excuted if check code = 0xA5. - PROGRAM_MODE = 0xA0, + ProgramMode = 0xA0, /// After this command is issued, the chip would enter the program mode. - ACTIVE_PROGRAMMING = 0xA1, + ActiveProgramming = 0xA1, /// The command is used for reading the content of OTP for checking the data of programming. /// /// The value of (n) is depending on the amount of programmed data, tha max address = 0xFFF. - READ_OTP = 0xA2, + ReadOtp = 0xA2, /// Not shown in commands table, but used in init sequence - POWER_OPTIMIZATION = 0xf8, + PowerOptimization = 0xf8, } impl traits::Command for Command { @@ -132,7 +131,7 @@ mod tests { #[test] fn command_addr() { - assert_eq!(Command::PANEL_SETTING.address(), 0x00); - assert_eq!(Command::DISPLAY_REFRESH.address(), 0x12); + assert_eq!(Command::PanelSetting.address(), 0x00); + assert_eq!(Command::DisplayRefresh.address(), 0x12); } } diff --git a/src/epd2in7b/mod.rs b/src/epd2in7b/mod.rs index 666add7..fc85eab 100644 --- a/src/epd2in7b/mod.rs +++ b/src/epd2in7b/mod.rs @@ -60,51 +60,51 @@ where self.interface.reset(delay, 2); // power on - self.command(spi, Command::POWER_ON)?; + self.command(spi, Command::PowerOn)?; delay.delay_ms(5); self.wait_until_idle(); // set panel settings, 0xbf is bw, 0xaf is multi-color self.interface - .cmd_with_data(spi, Command::PANEL_SETTING, &[0xaf])?; + .cmd_with_data(spi, Command::PanelSetting, &[0xaf])?; // pll control self.interface - .cmd_with_data(spi, Command::PLL_CONTROL, &[0x3a])?; + .cmd_with_data(spi, Command::PllControl, &[0x3a])?; // set the power settings self.interface.cmd_with_data( spi, - Command::POWER_SETTING, + Command::PowerSetting, &[0x03, 0x00, 0x2b, 0x2b, 0x09], )?; // start the booster self.interface - .cmd_with_data(spi, Command::BOOSTER_SOFT_START, &[0x07, 0x07, 0x17])?; + .cmd_with_data(spi, Command::BoosterSoftStart, &[0x07, 0x07, 0x17])?; // power optimization self.interface - .cmd_with_data(spi, Command::POWER_OPTIMIZATION, &[0x60, 0xa5])?; + .cmd_with_data(spi, Command::PowerOptimization, &[0x60, 0xa5])?; self.interface - .cmd_with_data(spi, Command::POWER_OPTIMIZATION, &[0x89, 0xa5])?; + .cmd_with_data(spi, Command::PowerOptimization, &[0x89, 0xa5])?; self.interface - .cmd_with_data(spi, Command::POWER_OPTIMIZATION, &[0x90, 0x00])?; + .cmd_with_data(spi, Command::PowerOptimization, &[0x90, 0x00])?; self.interface - .cmd_with_data(spi, Command::POWER_OPTIMIZATION, &[0x93, 0x2a])?; + .cmd_with_data(spi, Command::PowerOptimization, &[0x93, 0x2a])?; self.interface - .cmd_with_data(spi, Command::POWER_OPTIMIZATION, &[0x73, 0x41])?; + .cmd_with_data(spi, Command::PowerOptimization, &[0x73, 0x41])?; self.interface - .cmd_with_data(spi, Command::VCM_DC_SETTING, &[0x12])?; + .cmd_with_data(spi, Command::VcmDcSetting, &[0x12])?; self.interface - .cmd_with_data(spi, Command::VCOM_AND_DATA_INTERVAL_SETTING, &[0x87])?; + .cmd_with_data(spi, Command::VcomAndDataIntervalSetting, &[0x87])?; self.set_lut(spi, None)?; self.interface - .cmd_with_data(spi, Command::PARTIAL_DISPLAY_REFRESH, &[0x00])?; + .cmd_with_data(spi, Command::PartialDisplayRefresh, &[0x00])?; self.wait_until_idle(); Ok(()) @@ -150,27 +150,27 @@ where fn sleep(&mut self, spi: &mut SPI) -> Result<(), SPI::Error> { self.wait_until_idle(); self.interface - .cmd_with_data(spi, Command::VCOM_AND_DATA_INTERVAL_SETTING, &[0xf7])?; + .cmd_with_data(spi, Command::VcomAndDataIntervalSetting, &[0xf7])?; - self.command(spi, Command::POWER_OFF)?; + self.command(spi, Command::PowerOff)?; self.wait_until_idle(); self.interface - .cmd_with_data(spi, Command::DEEP_SLEEP, &[0xA5])?; + .cmd_with_data(spi, Command::DeepSleep, &[0xA5])?; Ok(()) } fn update_frame(&mut self, spi: &mut SPI, buffer: &[u8]) -> Result<(), SPI::Error> { self.interface - .cmd(spi, Command::DATA_START_TRANSMISSION_1)?; + .cmd(spi, Command::DataStartTransmission1)?; self.send_buffer_helper(spi, buffer)?; // Clear chromatic layer since we won't be using it here self.interface - .cmd(spi, Command::DATA_START_TRANSMISSION_2)?; + .cmd(spi, Command::DataStartTransmission2)?; self.interface .data_x_times(spi, !self.color.get_byte_value(), WIDTH * HEIGHT / 8)?; - self.interface.cmd(spi, Command::DATA_STOP)?; + self.interface.cmd(spi, Command::DataStop)?; Ok(()) } @@ -184,7 +184,7 @@ where height: u32, ) -> Result<(), SPI::Error> { self.interface - .cmd(spi, Command::PARTIAL_DATA_START_TRANSMISSION_1)?; + .cmd(spi, Command::PartialDataStartTransmission1)?; self.send_data(spi, &[(x >> 8) as u8])?; self.send_data(spi, &[(x & 0xf8) as u8])?; @@ -198,18 +198,18 @@ where self.send_buffer_helper(spi, buffer)?; - self.interface.cmd(spi, Command::DATA_STOP) + self.interface.cmd(spi, Command::DataStop) } fn display_frame(&mut self, spi: &mut SPI) -> Result<(), SPI::Error> { - self.command(spi, Command::DISPLAY_REFRESH)?; + self.command(spi, Command::DisplayRefresh)?; self.wait_until_idle(); Ok(()) } fn update_and_display_frame(&mut self, spi: &mut SPI, buffer: &[u8]) -> Result<(), SPI::Error> { self.update_frame(spi, buffer)?; - self.command(spi, Command::DISPLAY_REFRESH)?; + self.command(spi, Command::DisplayRefresh)?; Ok(()) } @@ -218,17 +218,17 @@ where let color_value = self.color.get_byte_value(); self.interface - .cmd(spi, Command::DATA_START_TRANSMISSION_1)?; + .cmd(spi, Command::DataStartTransmission1)?; self.interface .data_x_times(spi, color_value, WIDTH * HEIGHT / 8)?; - self.interface.cmd(spi, Command::DATA_STOP)?; + self.interface.cmd(spi, Command::DataStop)?; self.interface - .cmd(spi, Command::DATA_START_TRANSMISSION_2)?; + .cmd(spi, Command::DataStartTransmission2)?; self.interface .data_x_times(spi, color_value, WIDTH * HEIGHT / 8)?; - self.interface.cmd(spi, Command::DATA_STOP)?; + self.interface.cmd(spi, Command::DataStop)?; Ok(()) } @@ -254,11 +254,11 @@ where _refresh_rate: Option, ) -> Result<(), SPI::Error> { self.wait_until_idle(); - self.cmd_with_data(spi, Command::LUT_FOR_VCOM, &LUT_VCOM_DC)?; - self.cmd_with_data(spi, Command::LUT_WHITE_TO_WHITE, &LUT_WW)?; - self.cmd_with_data(spi, Command::LUT_BLACK_TO_WHITE, &LUT_BW)?; - self.cmd_with_data(spi, Command::LUT_WHITE_TO_BLACK, &LUT_WB)?; - self.cmd_with_data(spi, Command::LUT_BLACK_TO_BLACK, &LUT_BB)?; + self.cmd_with_data(spi, Command::LutForVcom, &LUT_VCOM_DC)?; + self.cmd_with_data(spi, Command::LutWhiteToWhite, &LUT_WW)?; + self.cmd_with_data(spi, Command::LutBlackToWhite, &LUT_BW)?; + self.cmd_with_data(spi, Command::LutWhiteToBlack, &LUT_WB)?; + self.cmd_with_data(spi, Command::LutBlackToBlack, &LUT_BB)?; Ok(()) } @@ -295,11 +295,11 @@ where achromatic: &[u8], ) -> Result<(), SPI::Error> { self.interface - .cmd(spi, Command::DATA_START_TRANSMISSION_1)?; + .cmd(spi, Command::DataStartTransmission1)?; self.send_buffer_helper(spi, achromatic)?; - self.interface.cmd(spi, Command::DATA_STOP) + self.interface.cmd(spi, Command::DataStop) } /// Update only chromatic data of the display. @@ -311,11 +311,11 @@ where chromatic: &[u8], ) -> Result<(), SPI::Error> { self.interface - .cmd(spi, Command::DATA_START_TRANSMISSION_2)?; + .cmd(spi, Command::DataStartTransmission2)?; self.send_buffer_helper(spi, chromatic)?; - self.interface.cmd(spi, Command::DATA_STOP)?; + self.interface.cmd(spi, Command::DataStop)?; self.wait_until_idle(); Ok(()) @@ -369,7 +369,7 @@ where width: u32, height: u32, ) -> Result<(), SPI::Error> { - self.command(spi, Command::PARTIAL_DISPLAY_REFRESH)?; + self.command(spi, Command::PartialDisplayRefresh)?; self.send_data(spi, &[(x >> 8) as u8])?; self.send_data(spi, &[(x & 0xf8) as u8])?; self.send_data(spi, &[(y >> 8) as u8])?; @@ -393,7 +393,7 @@ where height: u32, ) -> Result<(), SPI::Error> { self.interface - .cmd(spi, Command::PARTIAL_DATA_START_TRANSMISSION_1)?; + .cmd(spi, Command::PartialDataStartTransmission1)?; self.send_data(spi, &[(x >> 8) as u8])?; self.send_data(spi, &[(x & 0xf8) as u8])?; self.send_data(spi, &[(y >> 8) as u8])?; @@ -423,7 +423,7 @@ where height: u32, ) -> Result<(), SPI::Error> { self.interface - .cmd(spi, Command::PARTIAL_DATA_START_TRANSMISSION_2)?; + .cmd(spi, Command::PartialDataStartTransmission2)?; self.send_data(spi, &[(x >> 8) as u8])?; self.send_data(spi, &[(x & 0xf8) as u8])?; self.send_data(spi, &[(y >> 8) as u8])?; diff --git a/src/epd2in9/mod.rs b/src/epd2in9/mod.rs index d2fbabb..0f25b7b 100644 --- a/src/epd2in9/mod.rs +++ b/src/epd2in9/mod.rs @@ -104,7 +104,7 @@ where // 0.. B[2:0] // Default Values: A = Height of Screen (0x127), B = 0x00 (GD, SM and TB=0?) self.interface - .cmd_with_data(spi, Command::DRIVER_OUTPUT_CONTROL, &[0x27, 0x01, 0x00])?; + .cmd_with_data(spi, Command::DriverOutputControl, &[0x27, 0x01, 0x00])?; // 3 Databytes: (and default values from datasheet and arduino) // 1 .. A[6:0] = 0xCF | 0xD7 @@ -113,26 +113,26 @@ where //TODO: test self.interface.cmd_with_data( spi, - Command::BOOSTER_SOFT_START_CONTROL, + Command::BoosterSoftStartControl, &[0xD7, 0xD6, 0x9D], )?; // One Databyte with value 0xA8 for 7V VCOM self.interface - .cmd_with_data(spi, Command::WRITE_VCOM_REGISTER, &[0xA8])?; + .cmd_with_data(spi, Command::WriteVcomRegister, &[0xA8])?; // One Databyte with default value 0x1A for 4 dummy lines per gate self.interface - .cmd_with_data(spi, Command::SET_DUMMY_LINE_PERIOD, &[0x1A])?; + .cmd_with_data(spi, Command::SetDummyLinePeriod, &[0x1A])?; // One Databyte with default value 0x08 for 2us per line self.interface - .cmd_with_data(spi, Command::SET_GATE_LINE_WIDTH, &[0x08])?; + .cmd_with_data(spi, Command::SetGateLineWidth, &[0x08])?; // One Databyte with default value 0x03 // -> address: x increment, y increment, address counter is updated in x direction self.interface - .cmd_with_data(spi, Command::DATA_ENTRY_MODE_SETTING, &[0x03])?; + .cmd_with_data(spi, Command::DataEntryModeSetting, &[0x03])?; self.set_lut(spi, None) } @@ -182,7 +182,7 @@ where // 0x00 for Normal mode (Power on Reset), 0x01 for Deep Sleep Mode //TODO: is 0x00 needed here? (see also epd1in54) self.interface - .cmd_with_data(spi, Command::DEEP_SLEEP_MODE, &[0x00])?; + .cmd_with_data(spi, Command::DeepSleepMode, &[0x00])?; Ok(()) } @@ -201,7 +201,7 @@ where self.use_full_frame(spi)?; self.interface - .cmd_with_data(spi, Command::WRITE_RAM, buffer)?; + .cmd_with_data(spi, Command::WriteRam, buffer)?; Ok(()) } @@ -220,7 +220,7 @@ where self.set_ram_counter(spi, x, y)?; self.interface - .cmd_with_data(spi, Command::WRITE_RAM, buffer)?; + .cmd_with_data(spi, Command::WriteRam, buffer)?; Ok(()) } @@ -229,9 +229,9 @@ where // enable clock signal, enable cp, display pattern -> 0xC4 (tested with the arduino version) //TODO: test control_1 or control_2 with default value 0xFF (from the datasheet) self.interface - .cmd_with_data(spi, Command::DISPLAY_UPDATE_CONTROL_2, &[0xC4])?; + .cmd_with_data(spi, Command::DisplayUpdateControl2, &[0xC4])?; - self.interface.cmd(spi, Command::MASTER_ACTIVATION)?; + self.interface.cmd(spi, Command::MasterActivation)?; // MASTER Activation should not be interupted to avoid currption of panel images // therefore a terminate command is send self.interface.cmd(spi, Command::NOP)?; @@ -251,7 +251,7 @@ where // clear the ram with the background color let color = self.background_color.get_byte_value(); - self.interface.cmd(spi, Command::WRITE_RAM)?; + self.interface.cmd(spi, Command::WriteRam)?; self.interface .data_x_times(spi, color, WIDTH / 8 * HEIGHT)?; Ok(()) @@ -319,14 +319,14 @@ where // aren't relevant self.interface.cmd_with_data( spi, - Command::SET_RAM_X_ADDRESS_START_END_POSITION, + Command::SetRamXAddressStartEndPosition, &[(start_x >> 3) as u8, (end_x >> 3) as u8], )?; // 2 Databytes: A[7:0] & 0..A[8] for each - start and end self.interface.cmd_with_data( spi, - Command::SET_RAM_Y_ADDRESS_START_END_POSITION, + Command::SetRamYAddressStartEndPosition, &[ start_y as u8, (start_y >> 8) as u8, @@ -341,12 +341,12 @@ where // x is positioned in bytes, so the last 3 bits which show the position inside a byte in the ram // aren't relevant self.interface - .cmd_with_data(spi, Command::SET_RAM_X_ADDRESS_COUNTER, &[(x >> 3) as u8])?; + .cmd_with_data(spi, Command::SetRamXAddressCounter, &[(x >> 3) as u8])?; // 2 Databytes: A[7:0] & 0..A[8] self.interface.cmd_with_data( spi, - Command::SET_RAM_Y_ADDRESS_COUNTER, + Command::SetRamYAddressCounter, &[y as u8, (y >> 8) as u8], )?; Ok(()) @@ -357,7 +357,7 @@ where self.wait_until_idle(); assert!(buffer.len() == 30); self.interface - .cmd_with_data(spi, Command::WRITE_LUT_REGISTER, buffer)?; + .cmd_with_data(spi, Command::WriteLutRegister, buffer)?; Ok(()) } } diff --git a/src/epd2in9bc/command.rs b/src/epd2in9bc/command.rs index a389a6f..9414c5a 100644 --- a/src/epd2in9bc/command.rs +++ b/src/epd2in9bc/command.rs @@ -2,33 +2,32 @@ use crate::traits; #[allow(dead_code)] -#[allow(non_camel_case_types)] #[derive(Copy, Clone)] pub(crate) enum Command { - PANEL_SETTING = 0x00, + PanelSetting = 0x00, - POWER_SETTING = 0x01, - POWER_OFF = 0x02, - POWER_ON = 0x04, - BOOSTER_SOFT_START = 0x06, - DEEP_SLEEP = 0x07, - DATA_START_TRANSMISSION_1 = 0x10, - DISPLAY_REFRESH = 0x12, - DATA_START_TRANSMISSION_2 = 0x13, + PowerSetting = 0x01, + PowerOff = 0x02, + PowerOn = 0x04, + BoosterSoftStart = 0x06, + DeepSleep = 0x07, + DataStartTransmission1 = 0x10, + DisplayRefresh = 0x12, + DataStartTransmission2 = 0x13, - LUT_FOR_VCOM = 0x20, - LUT_WHITE_TO_WHITE = 0x21, - LUT_BLACK_TO_WHITE = 0x22, - LUT_WHITE_TO_BLACK = 0x23, - LUT_BLACK_TO_BLACK = 0x24, + LutForVcom = 0x20, + LutWhiteToWhite = 0x21, + LutBlackToWhite = 0x22, + LutWhiteToBlack = 0x23, + LutBlackToBlack = 0x24, - PLL_CONTROL = 0x30, - TEMPERATURE_SENSOR_COMMAND = 0x40, - TEMPERATURE_SENSOR_SELECTION = 0x41, - VCOM_AND_DATA_INTERVAL_SETTING = 0x50, - RESOLUTION_SETTING = 0x61, - VCM_DC_SETTING = 0x82, - POWER_SAVING = 0xE3, + PllControl = 0x30, + TemperatureSensorCommand = 0x40, + TemperatureSensorSelection = 0x41, + VcomAndDataIntervalSetting = 0x50, + ResolutionSetting = 0x61, + VcmDcSetting = 0x82, + PowerSaving = 0xE3, } impl traits::Command for Command { diff --git a/src/epd2in9bc/mod.rs b/src/epd2in9bc/mod.rs index 300352c..5a81342 100644 --- a/src/epd2in9bc/mod.rs +++ b/src/epd2in9bc/mod.rs @@ -115,26 +115,26 @@ where // start the booster self.interface - .cmd_with_data(spi, Command::BOOSTER_SOFT_START, &[0x17, 0x17, 0x17])?; + .cmd_with_data(spi, Command::BoosterSoftStart, &[0x17, 0x17, 0x17])?; // power on - self.command(spi, Command::POWER_ON)?; + self.command(spi, Command::PowerOn)?; delay.delay_ms(5); self.wait_until_idle(); // set the panel settings - self.cmd_with_data(spi, Command::PANEL_SETTING, &[0x8F])?; + self.cmd_with_data(spi, Command::PanelSetting, &[0x8F])?; self.cmd_with_data( spi, - Command::VCOM_AND_DATA_INTERVAL_SETTING, + Command::VcomAndDataIntervalSetting, &[WHITE_BORDER | VCOM_DATA_INTERVAL], )?; // set resolution self.send_resolution(spi)?; - self.cmd_with_data(spi, Command::VCM_DC_SETTING, &[0x0A])?; + self.cmd_with_data(spi, Command::VcmDcSetting, &[0x0A])?; self.wait_until_idle(); @@ -166,7 +166,7 @@ where /// Finish by calling `update_chromatic_frame`. fn update_achromatic_frame(&mut self, spi: &mut SPI, black: &[u8]) -> Result<(), SPI::Error> { self.interface - .cmd(spi, Command::DATA_START_TRANSMISSION_1)?; + .cmd(spi, Command::DataStartTransmission1)?; self.interface.data(spi, black)?; Ok(()) } @@ -180,7 +180,7 @@ where chromatic: &[u8], ) -> Result<(), SPI::Error> { self.interface - .cmd(spi, Command::DATA_START_TRANSMISSION_2)?; + .cmd(spi, Command::DataStartTransmission2)?; self.interface.data(spi, chromatic)?; self.wait_until_idle(); @@ -220,15 +220,15 @@ where // Section 8.2 from datasheet self.interface.cmd_with_data( spi, - Command::VCOM_AND_DATA_INTERVAL_SETTING, + Command::VcomAndDataIntervalSetting, &[FLOATING_BORDER | VCOM_DATA_INTERVAL], )?; - self.command(spi, Command::POWER_OFF)?; - // The example STM code from Github has a wait after POWER_OFF + self.command(spi, Command::PowerOff)?; + // The example STM code from Github has a wait after PowerOff self.wait_until_idle(); - self.cmd_with_data(spi, Command::DEEP_SLEEP, &[0xA5])?; + self.cmd_with_data(spi, Command::DeepSleep, &[0xA5])?; Ok(()) } @@ -259,7 +259,7 @@ where fn update_frame(&mut self, spi: &mut SPI, buffer: &[u8]) -> Result<(), SPI::Error> { self.interface - .cmd(spi, Command::DATA_START_TRANSMISSION_1)?; + .cmd(spi, Command::DataStartTransmission1)?; self.interface.data(spi, &buffer)?; @@ -267,7 +267,7 @@ where let color = self.color.get_byte_value(); self.interface - .cmd(spi, Command::DATA_START_TRANSMISSION_2)?; + .cmd(spi, Command::DataStartTransmission2)?; self.interface.data_x_times(spi, color, NUM_DISPLAY_BITS)?; self.wait_until_idle(); @@ -288,7 +288,7 @@ where } fn display_frame(&mut self, spi: &mut SPI) -> Result<(), SPI::Error> { - self.command(spi, Command::DISPLAY_REFRESH)?; + self.command(spi, Command::DisplayRefresh)?; self.wait_until_idle(); Ok(()) @@ -307,13 +307,13 @@ where // Clear the black self.interface - .cmd(spi, Command::DATA_START_TRANSMISSION_1)?; + .cmd(spi, Command::DataStartTransmission1)?; self.interface.data_x_times(spi, color, NUM_DISPLAY_BITS)?; // Clear the chromatic self.interface - .cmd(spi, Command::DATA_START_TRANSMISSION_2)?; + .cmd(spi, Command::DataStartTransmission2)?; self.interface.data_x_times(spi, color, NUM_DISPLAY_BITS)?; self.wait_until_idle(); @@ -366,7 +366,7 @@ where let w = self.width(); let h = self.height(); - self.command(spi, Command::RESOLUTION_SETTING)?; + self.command(spi, Command::ResolutionSetting)?; self.send_data(spi, &[w as u8])?; self.send_data(spi, &[(h >> 8) as u8])?; @@ -382,7 +382,7 @@ where }; self.cmd_with_data( spi, - Command::VCOM_AND_DATA_INTERVAL_SETTING, + Command::VcomAndDataIntervalSetting, &[border | VCOM_DATA_INTERVAL], ) } diff --git a/src/epd4in2/command.rs b/src/epd4in2/command.rs index 0d220b1..3a31a69 100644 --- a/src/epd4in2/command.rs +++ b/src/epd4in2/command.rs @@ -8,7 +8,6 @@ use crate::traits; /// /// The description of the single commands is mostly taken from IL0398.pdf #[allow(dead_code)] -#[allow(non_camel_case_types)] #[derive(Copy, Clone)] pub(crate) enum Command { /// Set Resolution, LUT selection, BWR pixels, gate scan direction, source shift direction, booster switch, soft reset @@ -17,101 +16,101 @@ pub(crate) enum Command { /// 0x1F B/W Mode, LUT from OTP /// 0x2F Red Mode, LUT set by registers /// 0x3F B/W Mode, LUT set by registers - PANEL_SETTING = 0x00, + PanelSetting = 0x00, /// selecting internal and external power /// self.send_data(0x03)?; //VDS_EN, VDG_EN /// self.send_data(0x00)?; //VCOM_HV, VGHL_LV[1], VGHL_LV[0] /// self.send_data(0x2b)?; //VDH /// self.send_data(0x2b)?; //VDL /// self.send_data(0xff)?; //VDHR - POWER_SETTING = 0x01, + PowerSetting = 0x01, /// After the Power Off command, the driver will power off following the Power Off Sequence. This command will turn off charge /// pump, T-con, source driver, gate driver, VCOM, and temperature sensor, but register data will be kept until VDD becomes OFF. /// Source Driver output and Vcom will remain as previous condition, which may have 2 conditions: floating. - POWER_OFF = 0x02, + PowerOff = 0x02, /// Setting Power OFF sequence - POWER_OFF_SEQUENCE_SETTING = 0x03, + PowerOffSequenceSetting = 0x03, /// Turning On the Power - POWER_ON = 0x04, + PowerOn = 0x04, /// This command enables the internal bandgap, which will be cleared by the next POF. - POWER_ON_MEASURE = 0x05, + PowerOnMeasure = 0x05, /// Starting data transmission /// 3-times: self.send_data(0x17)?; //07 0f 17 1f 27 2F 37 2f - BOOSTER_SOFT_START = 0x06, + BoosterSoftStart = 0x06, /// After this command is transmitted, the chip would enter the deep-sleep mode to save power. /// /// The deep sleep mode would return to standby by hardware reset. /// /// The only one parameter is a check code, the command would be excuted if check code = 0xA5. - DEEP_SLEEP = 0x07, + DeepSleep = 0x07, /// This command starts transmitting data and write them into SRAM. To complete data transmission, command DSP (Data /// transmission Stop) must be issued. Then the chip will start to send data/VCOM for panel. /// /// - In B/W mode, this command writes “OLD” data to SRAM. /// - In B/W/Red mode, this command writes “B/W” data to SRAM. /// - In Program mode, this command writes “OTP” data to SRAM for programming. - DATA_START_TRANSMISSION_1 = 0x10, + DataStartTransmission1 = 0x10, /// Stopping data transmission - DATA_STOP = 0x11, + DataStop = 0x11, /// While user sent this command, driver will refresh display (data/VCOM) according to SRAM data and LUT. /// /// After Display Refresh command, BUSY_N signal will become “0” and the refreshing of panel starts. - DISPLAY_REFRESH = 0x12, + DisplayRefresh = 0x12, /// This command starts transmitting data and write them into SRAM. To complete data transmission, command DSP (Data /// transmission Stop) must be issued. Then the chip will start to send data/VCOM for panel. /// - In B/W mode, this command writes “NEW” data to SRAM. /// - In B/W/Red mode, this command writes “RED” data to SRAM. - DATA_START_TRANSMISSION_2 = 0x13, + DataStartTransmission2 = 0x13, /// This command stores VCOM Look-Up Table with 7 groups of data. Each group contains information for one state and is stored /// with 6 bytes, while the sixth byte indicates how many times that phase will repeat. /// /// from IL0373 - LUT_FOR_VCOM = 0x20, + LutForVcom = 0x20, /// This command stores White-to-White Look-Up Table with 7 groups of data. Each group contains information for one state and is /// stored with 6 bytes, while the sixth byte indicates how many times that phase will repeat. /// /// from IL0373 - LUT_WHITE_TO_WHITE = 0x21, + LutWhiteToWhite = 0x21, /// This command stores Black-to-White Look-Up Table with 7 groups of data. Each group contains information for one state and is /// stored with 6 bytes, while the sixth byte indicates how many times that phase will repeat. /// /// from IL0373 - LUT_BLACK_TO_WHITE = 0x22, + LutBlackToWhite = 0x22, /// This command stores White-to-Black Look-Up Table with 7 groups of data. Each group contains information for one state and is /// stored with 6 bytes, while the sixth byte indicates how many times that phase will repeat. /// /// from IL0373 - LUT_WHITE_TO_BLACK = 0x23, + LutWhiteToBlack = 0x23, /// This command stores Black-to-Black Look-Up Table with 7 groups of data. Each group contains information for one state and is /// stored with 6 bytes, while the sixth byte indicates how many times that phase will repeat. /// /// from IL0373 - LUT_BLACK_TO_BLACK = 0x24, + LutBlackToBlack = 0x24, /// The command controls the PLL clock frequency. - PLL_CONTROL = 0x30, + PllControl = 0x30, /// This command reads the temperature sensed by the temperature sensor. /// /// Doesn't work! Waveshare doesn't connect the read pin - TEMPERATURE_SENSOR_COMMAND = 0x40, + TemperatureSensorCommand = 0x40, /// Selects the Internal or External temperature sensor and offset - TEMPERATURE_SENSOR_SELECTION = 0x41, + TemperatureSensorSelection = 0x41, /// Write External Temperature Sensor - TEMPERATURE_SENSOR_WRITE = 0x42, + TemperatureSensorWrite = 0x42, /// Read External Temperature Sensor /// /// Doesn't work! Waveshare doesn't connect the read pin - TEMPERATURE_SENSOR_READ = 0x43, + TemperatureSensorRead = 0x43, /// This command indicates the interval of Vcom and data output. When setting the vertical back porch, the total blanking will be kept (20 Hsync) - VCOM_AND_DATA_INTERVAL_SETTING = 0x50, + VcomAndDataIntervalSetting = 0x50, /// This command indicates the input power condition. Host can read this flag to learn the battery condition. - LOW_POWER_DETECTION = 0x51, + LowPowerDetection = 0x51, /// This command defines non-overlap period of Gate and Source. - TCON_SETTING = 0x60, + TconSetting = 0x60, /// This command defines alternative resolution and this setting is of higher priority than the RES\[1:0\] in R00H (PSR). - RESOLUTION_SETTING = 0x61, + ResolutionSetting = 0x61, /// This command defines the Fist Active Gate and First Active Source of active channels. - GSST_SETTING = 0x65, + GsstSetting = 0x65, /// The LUT_REV / Chip Revision is read from OTP address = 0x001. /// /// Doesn't work! Waveshare doesn't connect the read pin @@ -120,39 +119,39 @@ pub(crate) enum Command { /// PTL, I2C_ERR, I2C_BUSY, DATA, PON, POF, BUSY /// /// Doesn't work! Waveshare doesn't connect the read pin - GET_STATUS = 0x71, + GetStatus = 0x71, /// Automatically measure VCOM. This command reads the IC status - AUTO_MEASUREMENT_VCOM = 0x80, + AutoMeasurementVcom = 0x80, /// This command gets the VCOM value /// /// Doesn't work! Waveshare doesn't connect the read pin - READ_VCOM_VALUE = 0x81, + ReadVcomValue = 0x81, /// Set VCM_DC - VCM_DC_SETTING = 0x82, + VcmDcSetting = 0x82, /// This command sets partial window - PARTIAL_WINDOW = 0x90, + PartialWindow = 0x90, /// This command makes the display enter partial mode - PARTIAL_IN = 0x91, + PartialIn = 0x91, /// This command makes the display exit partial mode and enter normal mode - PARTIAL_OUT = 0x92, + PartialOut = 0x92, /// After this command is issued, the chip would enter the program mode. /// /// After the programming procedure completed, a hardware reset is necessary for leaving program mode. /// /// The only one parameter is a check code, the command would be excuted if check code = 0xA5. - PROGRAM_MODE = 0xA0, + ProgramMode = 0xA0, /// After this command is transmitted, the programming state machine would be activated. /// /// The BUSY flag would fall to 0 until the programming is completed. - ACTIVE_PROGRAMMING = 0xA1, + ActiveProgramming = 0xA1, /// The command is used for reading the content of OTP for checking the data of programming. /// /// The value of (n) is depending on the amount of programmed data, tha max address = 0xFFF. - READ_OTP = 0xA2, + ReadOtp = 0xA2, /// This command is set for saving power during fresh period. If the output voltage of VCOM / Source is from negative to positive or /// from positive to negative, the power saving mechanism will be activated. The active period width is defined by the following two /// parameters. - POWER_SAVING = 0xE3, + PowerSaving = 0xE3, } impl traits::Command for Command { @@ -169,10 +168,10 @@ mod tests { #[test] fn command_addr() { - assert_eq!(Command::POWER_SAVING.address(), 0xE3); + assert_eq!(Command::PowerSaving.address(), 0xE3); - assert_eq!(Command::PANEL_SETTING.address(), 0x00); + assert_eq!(Command::PanelSetting.address(), 0x00); - assert_eq!(Command::DISPLAY_REFRESH.address(), 0x12); + assert_eq!(Command::DisplayRefresh.address(), 0x12); } } diff --git a/src/epd4in2/mod.rs b/src/epd4in2/mod.rs index 636b254..73e46e0 100644 --- a/src/epd4in2/mod.rs +++ b/src/epd4in2/mod.rs @@ -110,36 +110,36 @@ where // set the power settings self.interface.cmd_with_data( spi, - Command::POWER_SETTING, + Command::PowerSetting, &[0x03, 0x00, 0x2b, 0x2b, 0xff], )?; // start the booster self.interface - .cmd_with_data(spi, Command::BOOSTER_SOFT_START, &[0x17, 0x17, 0x17])?; + .cmd_with_data(spi, Command::BoosterSoftStart, &[0x17, 0x17, 0x17])?; // power on - self.command(spi, Command::POWER_ON)?; + self.command(spi, Command::PowerOn)?; delay.delay_ms(5); self.wait_until_idle(); // set the panel settings - self.cmd_with_data(spi, Command::PANEL_SETTING, &[0x3F])?; + self.cmd_with_data(spi, Command::PanelSetting, &[0x3F])?; // Set Frequency, 200 Hz didn't work on my board // 150Hz and 171Hz wasn't tested yet // TODO: Test these other frequencies // 3A 100HZ 29 150Hz 39 200HZ 31 171HZ DEFAULT: 3c 50Hz - self.cmd_with_data(spi, Command::PLL_CONTROL, &[0x3A])?; + self.cmd_with_data(spi, Command::PllControl, &[0x3A])?; self.send_resolution(spi)?; self.interface - .cmd_with_data(spi, Command::VCM_DC_SETTING, &[0x12])?; + .cmd_with_data(spi, Command::VcmDcSetting, &[0x12])?; //VBDF 17|D7 VBDW 97 VBDB 57 VBDF F7 VBDW 77 VBDB 37 VBDR B7 self.interface - .cmd_with_data(spi, Command::VCOM_AND_DATA_INTERVAL_SETTING, &[0x97])?; + .cmd_with_data(spi, Command::VcomAndDataIntervalSetting, &[0x97])?; self.set_lut(spi, None)?; @@ -191,19 +191,19 @@ where fn sleep(&mut self, spi: &mut SPI) -> Result<(), SPI::Error> { self.wait_until_idle(); self.interface - .cmd_with_data(spi, Command::VCOM_AND_DATA_INTERVAL_SETTING, &[0x17])?; //border floating - self.command(spi, Command::VCM_DC_SETTING)?; // VCOM to 0V - self.command(spi, Command::PANEL_SETTING)?; + .cmd_with_data(spi, Command::VcomAndDataIntervalSetting, &[0x17])?; //border floating + self.command(spi, Command::VcmDcSetting)?; // VCOM to 0V + self.command(spi, Command::PanelSetting)?; - self.command(spi, Command::POWER_SETTING)?; //VG&VS to 0V fast + self.command(spi, Command::PowerSetting)?; //VG&VS to 0V fast for _ in 0..4 { self.send_data(spi, &[0x00])?; } - self.command(spi, Command::POWER_OFF)?; + self.command(spi, Command::PowerOff)?; self.wait_until_idle(); self.interface - .cmd_with_data(spi, Command::DEEP_SLEEP, &[0xA5])?; + .cmd_with_data(spi, Command::DeepSleep, &[0xA5])?; Ok(()) } @@ -212,12 +212,12 @@ where let color_value = self.color.get_byte_value(); self.interface - .cmd(spi, Command::DATA_START_TRANSMISSION_1)?; + .cmd(spi, Command::DataStartTransmission1)?; self.interface .data_x_times(spi, color_value, WIDTH / 8 * HEIGHT)?; self.interface - .cmd_with_data(spi, Command::DATA_START_TRANSMISSION_2, buffer)?; + .cmd_with_data(spi, Command::DataStartTransmission2, buffer)?; Ok(()) } @@ -236,8 +236,8 @@ where //return Err("Wrong buffersize"); } - self.command(spi, Command::PARTIAL_IN)?; - self.command(spi, Command::PARTIAL_WINDOW)?; + self.command(spi, Command::PartialIn)?; + self.command(spi, Command::PartialWindow)?; self.send_data(spi, &[(x >> 8) as u8])?; let tmp = x & 0xf8; self.send_data(spi, &[tmp as u8])?; // x should be the multiple of 8, the last 3 bit will always be ignored @@ -256,26 +256,26 @@ where //TODO: handle dtm somehow let is_dtm1 = false; if is_dtm1 { - self.command(spi, Command::DATA_START_TRANSMISSION_1)? //TODO: check if data_start transmission 1 also needs "old"/background data here + self.command(spi, Command::DataStartTransmission1)? //TODO: check if data_start transmission 1 also needs "old"/background data here } else { - self.command(spi, Command::DATA_START_TRANSMISSION_2)? + self.command(spi, Command::DataStartTransmission2)? } self.send_data(spi, buffer)?; - self.command(spi, Command::PARTIAL_OUT)?; + self.command(spi, Command::PartialOut)?; Ok(()) } fn display_frame(&mut self, spi: &mut SPI) -> Result<(), SPI::Error> { self.wait_until_idle(); - self.command(spi, Command::DISPLAY_REFRESH)?; + self.command(spi, Command::DisplayRefresh)?; Ok(()) } fn update_and_display_frame(&mut self, spi: &mut SPI, buffer: &[u8]) -> Result<(), SPI::Error> { self.update_frame(spi, buffer)?; - self.command(spi, Command::DISPLAY_REFRESH)?; + self.command(spi, Command::DisplayRefresh)?; Ok(()) } @@ -286,12 +286,12 @@ where let color_value = self.color.get_byte_value(); self.interface - .cmd(spi, Command::DATA_START_TRANSMISSION_1)?; + .cmd(spi, Command::DataStartTransmission1)?; self.interface .data_x_times(spi, color_value, WIDTH / 8 * HEIGHT)?; self.interface - .cmd(spi, Command::DATA_START_TRANSMISSION_2)?; + .cmd(spi, Command::DataStartTransmission2)?; self.interface .data_x_times(spi, color_value, WIDTH / 8 * HEIGHT)?; Ok(()) @@ -374,7 +374,7 @@ where let w = self.width(); let h = self.height(); - self.command(spi, Command::RESOLUTION_SETTING)?; + self.command(spi, Command::ResolutionSetting)?; self.send_data(spi, &[(w >> 8) as u8])?; self.send_data(spi, &[w as u8])?; self.send_data(spi, &[(h >> 8) as u8])?; @@ -392,19 +392,19 @@ where ) -> Result<(), SPI::Error> { self.wait_until_idle(); // LUT VCOM - self.cmd_with_data(spi, Command::LUT_FOR_VCOM, lut_vcom)?; + self.cmd_with_data(spi, Command::LutForVcom, lut_vcom)?; // LUT WHITE to WHITE - self.cmd_with_data(spi, Command::LUT_WHITE_TO_WHITE, lut_ww)?; + self.cmd_with_data(spi, Command::LutWhiteToWhite, lut_ww)?; // LUT BLACK to WHITE - self.cmd_with_data(spi, Command::LUT_BLACK_TO_WHITE, lut_bw)?; + self.cmd_with_data(spi, Command::LutBlackToWhite, lut_bw)?; // LUT WHITE to BLACK - self.cmd_with_data(spi, Command::LUT_WHITE_TO_BLACK, lut_wb)?; + self.cmd_with_data(spi, Command::LutWhiteToBlack, lut_wb)?; // LUT BLACK to BLACK - self.cmd_with_data(spi, Command::LUT_BLACK_TO_BLACK, lut_bb)?; + self.cmd_with_data(spi, Command::LutBlackToBlack, lut_bb)?; Ok(()) } @@ -451,7 +451,7 @@ where self.wait_until_idle(); self.interface - .cmd(spi, Command::DATA_START_TRANSMISSION_1)?; + .cmd(spi, Command::DataStartTransmission1)?; self.interface.data(spi, buffer)?; @@ -464,7 +464,7 @@ where // self.send_resolution(spi)?; self.interface - .cmd(spi, Command::DATA_START_TRANSMISSION_2)?; + .cmd(spi, Command::DataStartTransmission2)?; self.interface.data(spi, buffer)?; @@ -487,13 +487,13 @@ where //return Err("Wrong buffersize"); } - self.interface.cmd(spi, Command::PARTIAL_IN)?; - self.interface.cmd(spi, Command::PARTIAL_WINDOW)?; + self.interface.cmd(spi, Command::PartialIn)?; + self.interface.cmd(spi, Command::PartialWindow)?; self.shift_display(spi, x, y, width, height)?; self.interface - .cmd(spi, Command::DATA_START_TRANSMISSION_1)?; + .cmd(spi, Command::DataStartTransmission1)?; self.interface.data(spi, buffer)?; @@ -520,11 +520,11 @@ where self.shift_display(spi, x, y, width, height)?; self.interface - .cmd(spi, Command::DATA_START_TRANSMISSION_2)?; + .cmd(spi, Command::DataStartTransmission2)?; self.interface.data(spi, buffer)?; - self.interface.cmd(spi, Command::PARTIAL_OUT)?; + self.interface.cmd(spi, Command::PartialOut)?; Ok(()) } @@ -541,22 +541,22 @@ where let color_value = self.color.get_byte_value(); - self.interface.cmd(spi, Command::PARTIAL_IN)?; - self.interface.cmd(spi, Command::PARTIAL_WINDOW)?; + self.interface.cmd(spi, Command::PartialIn)?; + self.interface.cmd(spi, Command::PartialWindow)?; self.shift_display(spi, x, y, width, height)?; self.interface - .cmd(spi, Command::DATA_START_TRANSMISSION_1)?; + .cmd(spi, Command::DataStartTransmission1)?; self.interface .data_x_times(spi, color_value, width / 8 * height)?; self.interface - .cmd(spi, Command::DATA_START_TRANSMISSION_2)?; + .cmd(spi, Command::DataStartTransmission2)?; self.interface .data_x_times(spi, color_value, width / 8 * height)?; - self.interface.cmd(spi, Command::PARTIAL_OUT)?; + self.interface.cmd(spi, Command::PartialOut)?; Ok(()) } } diff --git a/src/epd5in65f/command.rs b/src/epd5in65f/command.rs index 5035bb8..89af89e 100644 --- a/src/epd5in65f/command.rs +++ b/src/epd5in65f/command.rs @@ -8,127 +8,126 @@ use crate::traits; /// /// For more infos about the addresses and what they are doing look into the PDFs. #[allow(dead_code)] -#[allow(non_camel_case_types)] #[derive(Copy, Clone)] pub(crate) enum Command { /// Set Resolution, LUT selection, BWR pixels, gate scan direction, source shift /// direction, booster switch, soft reset. - PANEL_SETTING = 0x00, + PanelSetting = 0x00, /// Selecting internal and external power - POWER_SETTING = 0x01, + PowerSetting = 0x01, /// After the Power Off command, the driver will power off following the Power Off /// Sequence; BUSY signal will become "0". This command will turn off charge pump, /// T-con, source driver, gate driver, VCOM, and temperature sensor, but register /// data will be kept until VDD becomes OFF. Source Driver output and Vcom will remain /// as previous condition, which may have 2 conditions: 0V or floating. - POWER_OFF = 0x02, + PowerOff = 0x02, /// Setting Power OFF sequence - POWER_OFF_SEQUENCE_SETTING = 0x03, + PowerOffSequenceSetting = 0x03, /// Turning On the Power /// /// After the Power ON command, the driver will power on following the Power ON /// sequence. Once complete, the BUSY signal will become "1". - POWER_ON = 0x04, + PowerOn = 0x04, /// Starting data transmission - BOOSTER_SOFT_START = 0x06, + BoosterSoftStart = 0x06, /// This command makes the chip enter the deep-sleep mode to save power. /// /// The deep sleep mode would return to stand-by by hardware reset. /// /// The only one parameter is a check code, the command would be excuted if check code = 0xA5. - DEEP_SLEEP = 0x07, + DeepSleep = 0x07, /// This command starts transmitting data and write them into SRAM. To complete data /// transmission, command DSP (Data Stop) must be issued. Then the chip will start to /// send data/VCOM for panel. /// /// BLACK/WHITE or OLD_DATA - DATA_START_TRANSMISSION_1 = 0x10, + DataStartTransmission1 = 0x10, /// To stop data transmission, this command must be issued to check the `data_flag`. /// /// After this command, BUSY signal will become "0" until the display update is /// finished. - DATA_STOP = 0x11, + DataStop = 0x11, /// After this command is issued, driver will refresh display (data/VCOM) according to /// SRAM data and LUT. /// /// After Display Refresh command, BUSY signal will become "0" until the display /// update is finished. - DISPLAY_REFRESH = 0x12, + DisplayRefresh = 0x12, /// Image Process Command - IMAGE_PROCESS_COMMAND = 0x13, + ImageProcessCommand = 0x13, /// This command builds the VCOM Look-Up Table (LUTC). - LUT_FOR_VCOM = 0x20, + LutForVcom = 0x20, /// This command builds the Black Look-Up Table (LUTB). - LUT_BLACK = 0x21, + LutBlack = 0x21, /// This command builds the White Look-Up Table (LUTW). - LUT_WHITE = 0x22, + LutWhite = 0x22, /// This command builds the Gray1 Look-Up Table (LUTG1). - LUT_GRAY_1 = 0x23, + LutGray1 = 0x23, /// This command builds the Gray2 Look-Up Table (LUTG2). - LUT_GRAY_2 = 0x24, + LutGray2 = 0x24, /// This command builds the Red0 Look-Up Table (LUTR0). - LUT_RED_0 = 0x25, + LutRed0 = 0x25, /// This command builds the Red1 Look-Up Table (LUTR1). - LUT_RED_1 = 0x26, + LutRed1 = 0x26, /// This command builds the Red2 Look-Up Table (LUTR2). - LUT_RED_2 = 0x27, + LutRed2 = 0x27, /// This command builds the Red3 Look-Up Table (LUTR3). - LUT_RED_3 = 0x28, + LutRed3 = 0x28, /// This command builds the XON Look-Up Table (LUTXON). - LUT_XON = 0x29, + LutXon = 0x29, /// The command controls the PLL clock frequency. - PLL_CONTROL = 0x30, + PllControl = 0x30, /// This command reads the temperature sensed by the temperature sensor. - TEMPERATURE_SENSOR_COMMAND = 0x40, + TemperatureSensorCommand = 0x40, /// This command selects the Internal or External temperature sensor. - TEMPERATURE_CALIBRATION = 0x41, + TemperatureCalibration = 0x41, /// This command could write data to the external temperature sensor. - TEMPERATURE_SENSOR_WRITE = 0x42, + TemperatureSensorWrite = 0x42, /// This command could read data from the external temperature sensor. - TEMPERATURE_SENSOR_READ = 0x43, + TemperatureSensorRead = 0x43, /// This command indicates the interval of Vcom and data output. When setting the /// vertical back porch, the total blanking will be kept (20 Hsync). - VCOM_AND_DATA_INTERVAL_SETTING = 0x50, + VcomAndDataIntervalSetting = 0x50, /// This command indicates the input power condition. Host can read this flag to learn /// the battery condition. - LOW_POWER_DETECTION = 0x51, + LowPowerDetection = 0x51, /// This command defines non-overlap period of Gate and Source. - TCON_SETTING = 0x60, + TconSetting = 0x60, /// This command defines alternative resolution and this setting is of higher priority /// than the RES\[1:0\] in R00H (PSR). - TCON_RESOLUTION = 0x61, + TconResolution = 0x61, /// This command defines MCU host direct access external memory mode. - //SPI_FLASH_CONTROL = 0x65, + //SpiFlashControl = 0x65, /// The LUT_REV / Chip Revision is read from OTP address = 25001 and 25000. //REVISION = 0x70, /// This command reads the IC status. - GET_STATUS = 0x71, + GetStatus = 0x71, /// This command implements related VCOM sensing setting. - //AUTO_MEASUREMENT_VCOM = 0x80, + //AutoMeasurementVcom = 0x80, /// This command gets the VCOM value. - READ_VCOM_VALUE = 0x81, + ReadVcomValue = 0x81, /// This command sets `VCOM_DC` value. - VCM_DC_SETTING = 0x82, + VcmDcSetting = 0x82, // /// This is in all the Waveshare controllers for EPD6in65f, but it's not documented // /// anywhere in the datasheet `¯\_(ツ)_/¯` - FLASH_MODE = 0xE3, + FlashMode = 0xE3, } impl traits::Command for Command { @@ -145,7 +144,7 @@ mod tests { #[test] fn command_addr() { - assert_eq!(Command::PANEL_SETTING.address(), 0x00); - assert_eq!(Command::DISPLAY_REFRESH.address(), 0x12); + assert_eq!(Command::PanelSetting.address(), 0x00); + assert_eq!(Command::DisplayRefresh.address(), 0x12); } } diff --git a/src/epd5in65f/mod.rs b/src/epd5in65f/mod.rs index d10dddc..6e8e7b4 100644 --- a/src/epd5in65f/mod.rs +++ b/src/epd5in65f/mod.rs @@ -57,21 +57,21 @@ where // Reset the device self.interface.reset(delay, 2); - self.cmd_with_data(spi, Command::PANEL_SETTING, &[0xEF, 0x08])?; - self.cmd_with_data(spi, Command::POWER_SETTING, &[0x37, 0x00, 0x23, 0x23])?; - self.cmd_with_data(spi, Command::POWER_OFF_SEQUENCE_SETTING, &[0x00])?; - self.cmd_with_data(spi, Command::BOOSTER_SOFT_START, &[0xC7, 0xC7, 0x1D])?; - self.cmd_with_data(spi, Command::PLL_CONTROL, &[0x3C])?; - self.cmd_with_data(spi, Command::TEMPERATURE_SENSOR_COMMAND, &[0x00])?; - self.cmd_with_data(spi, Command::VCOM_AND_DATA_INTERVAL_SETTING, &[0x37])?; - self.cmd_with_data(spi, Command::TCON_SETTING, &[0x22])?; + self.cmd_with_data(spi, Command::PanelSetting, &[0xEF, 0x08])?; + self.cmd_with_data(spi, Command::PowerSetting, &[0x37, 0x00, 0x23, 0x23])?; + self.cmd_with_data(spi, Command::PowerOffSequenceSetting, &[0x00])?; + self.cmd_with_data(spi, Command::BoosterSoftStart, &[0xC7, 0xC7, 0x1D])?; + self.cmd_with_data(spi, Command::PllControl, &[0x3C])?; + self.cmd_with_data(spi, Command::TemperatureSensorCommand, &[0x00])?; + self.cmd_with_data(spi, Command::VcomAndDataIntervalSetting, &[0x37])?; + self.cmd_with_data(spi, Command::TconSetting, &[0x22])?; self.send_resolution(spi)?; - self.cmd_with_data(spi, Command::FLASH_MODE, &[0xAA])?; + self.cmd_with_data(spi, Command::FlashMode, &[0xAA])?; delay.delay_ms(100); - self.cmd_with_data(spi, Command::VCOM_AND_DATA_INTERVAL_SETTING, &[0x37])?; + self.cmd_with_data(spi, Command::VcomAndDataIntervalSetting, &[0x37])?; Ok(()) } } @@ -113,14 +113,14 @@ where } fn sleep(&mut self, spi: &mut SPI) -> Result<(), SPI::Error> { - self.cmd_with_data(spi, Command::DEEP_SLEEP, &[0xA5])?; + self.cmd_with_data(spi, Command::DeepSleep, &[0xA5])?; Ok(()) } fn update_frame(&mut self, spi: &mut SPI, buffer: &[u8]) -> Result<(), SPI::Error> { self.wait_busy_high(); self.send_resolution(spi)?; - self.cmd_with_data(spi, Command::DATA_START_TRANSMISSION_1, buffer)?; + self.cmd_with_data(spi, Command::DataStartTransmission1, buffer)?; Ok(()) } @@ -138,11 +138,11 @@ where fn display_frame(&mut self, spi: &mut SPI) -> Result<(), SPI::Error> { self.wait_busy_high(); - self.command(spi, Command::POWER_ON)?; + self.command(spi, Command::PowerOn)?; self.wait_busy_high(); - self.command(spi, Command::DISPLAY_REFRESH)?; + self.command(spi, Command::DisplayRefresh)?; self.wait_busy_high(); - self.command(spi, Command::POWER_OFF)?; + self.command(spi, Command::PowerOff)?; self.wait_busy_low(); Ok(()) } @@ -157,7 +157,7 @@ where let bg = OctColor::colors_byte(self.color, self.color); self.wait_busy_high(); self.send_resolution(spi)?; - self.command(spi, Command::DATA_START_TRANSMISSION_1)?; + self.command(spi, Command::DataStartTransmission1)?; self.interface.data_x_times(spi, bg, WIDTH * HEIGHT / 2)?; self.display_frame(spi)?; Ok(()) @@ -227,7 +227,7 @@ where let w = self.width(); let h = self.height(); - self.command(spi, Command::TCON_RESOLUTION)?; + self.command(spi, Command::TconResolution)?; self.send_data(spi, &[(w >> 8) as u8])?; self.send_data(spi, &[w as u8])?; self.send_data(spi, &[(h >> 8) as u8])?; diff --git a/src/epd7in5/command.rs b/src/epd7in5/command.rs index 064a5ee..cb1aa1c 100644 --- a/src/epd7in5/command.rs +++ b/src/epd7in5/command.rs @@ -8,130 +8,129 @@ use crate::traits; /// /// For more infos about the addresses and what they are doing look into the PDFs. #[allow(dead_code)] -#[allow(non_camel_case_types)] #[derive(Copy, Clone)] pub(crate) enum Command { /// Set Resolution, LUT selection, BWR pixels, gate scan direction, source shift /// direction, booster switch, soft reset. - PANEL_SETTING = 0x00, + PanelSetting = 0x00, /// Selecting internal and external power - POWER_SETTING = 0x01, + PowerSetting = 0x01, /// After the Power Off command, the driver will power off following the Power Off /// Sequence; BUSY signal will become "0". This command will turn off charge pump, /// T-con, source driver, gate driver, VCOM, and temperature sensor, but register /// data will be kept until VDD becomes OFF. Source Driver output and Vcom will remain /// as previous condition, which may have 2 conditions: 0V or floating. - POWER_OFF = 0x02, + PowerOff = 0x02, /// Setting Power OFF sequence - POWER_OFF_SEQUENCE_SETTING = 0x03, + PowerOffSequenceSetting = 0x03, /// Turning On the Power /// /// After the Power ON command, the driver will power on following the Power ON /// sequence. Once complete, the BUSY signal will become "1". - POWER_ON = 0x04, + PowerOn = 0x04, /// Starting data transmission - BOOSTER_SOFT_START = 0x06, + BoosterSoftStart = 0x06, /// This command makes the chip enter the deep-sleep mode to save power. /// /// The deep sleep mode would return to stand-by by hardware reset. /// /// The only one parameter is a check code, the command would be excuted if check code = 0xA5. - DEEP_SLEEP = 0x07, + DeepSleep = 0x07, /// This command starts transmitting data and write them into SRAM. To complete data /// transmission, command DSP (Data Stop) must be issued. Then the chip will start to /// send data/VCOM for panel. - DATA_START_TRANSMISSION_1 = 0x10, + DataStartTransmission1 = 0x10, /// To stop data transmission, this command must be issued to check the `data_flag`. /// /// After this command, BUSY signal will become "0" until the display update is /// finished. - DATA_STOP = 0x11, + DataStop = 0x11, /// After this command is issued, driver will refresh display (data/VCOM) according to /// SRAM data and LUT. /// /// After Display Refresh command, BUSY signal will become "0" until the display /// update is finished. - DISPLAY_REFRESH = 0x12, + DisplayRefresh = 0x12, /// After this command is issued, image process engine will find thin lines/pixels /// from frame SRAM and update the frame SRAM for applying new gray level waveform. /// /// After "Image Process Command", BUSY_N signal will become "0" until image process /// is finished. - IMAGE_PROCESS = 0x13, + ImageProcess = 0x13, /// This command builds the VCOM Look-Up Table (LUTC). - LUT_FOR_VCOM = 0x20, + LutForVcom = 0x20, /// This command builds the Black Look-Up Table (LUTB). - LUT_BLACK = 0x21, + LutBlack = 0x21, /// This command builds the White Look-Up Table (LUTW). - LUT_WHITE = 0x22, + LutWhite = 0x22, /// This command builds the Gray1 Look-Up Table (LUTG1). - LUT_GRAY_1 = 0x23, + LutGray1 = 0x23, /// This command builds the Gray2 Look-Up Table (LUTG2). - LUT_GRAY_2 = 0x24, + LutGray2 = 0x24, /// This command builds the Red0 Look-Up Table (LUTR0). - LUT_RED_0 = 0x25, + LutRed0 = 0x25, /// This command builds the Red1 Look-Up Table (LUTR1). - LUT_RED_1 = 0x26, + LutRed1 = 0x26, /// This command builds the Red2 Look-Up Table (LUTR2). - LUT_RED_2 = 0x27, + LutRed2 = 0x27, /// This command builds the Red3 Look-Up Table (LUTR3). - LUT_RED_3 = 0x28, + LutRed3 = 0x28, /// This command builds the XON Look-Up Table (LUTXON). - LUT_XON = 0x29, + LutXon = 0x29, /// The command controls the PLL clock frequency. - PLL_CONTROL = 0x30, + PllControl = 0x30, /// This command reads the temperature sensed by the temperature sensor. - TEMPERATURE_SENSOR_COMMAND = 0x40, + TemperatureSensorCommand = 0x40, /// This command selects the Internal or External temperature sensor. - TEMPERATURE_CALIBRATION = 0x41, + TemperatureCalibration = 0x41, /// This command could write data to the external temperature sensor. - TEMPERATURE_SENSOR_WRITE = 0x42, + TemperatureSensorWrite = 0x42, /// This command could read data from the external temperature sensor. - TEMPERATURE_SENSOR_READ = 0x43, + TemperatureSensorRead = 0x43, /// This command indicates the interval of Vcom and data output. When setting the /// vertical back porch, the total blanking will be kept (20 Hsync). - VCOM_AND_DATA_INTERVAL_SETTING = 0x50, + VcomAndDataIntervalSetting = 0x50, /// This command indicates the input power condition. Host can read this flag to learn /// the battery condition. - LOW_POWER_DETECTION = 0x51, + LowPowerDetection = 0x51, /// This command defines non-overlap period of Gate and Source. - TCON_SETTING = 0x60, + TconSetting = 0x60, /// This command defines alternative resolution and this setting is of higher priority /// than the RES\[1:0\] in R00H (PSR). - TCON_RESOLUTION = 0x61, + TconResolution = 0x61, /// This command defines MCU host direct access external memory mode. - SPI_FLASH_CONTROL = 0x65, + SpiFlashControl = 0x65, /// The LUT_REV / Chip Revision is read from OTP address = 25001 and 25000. REVISION = 0x70, /// This command reads the IC status. - GET_STATUS = 0x71, + GetStatus = 0x71, /// This command implements related VCOM sensing setting. - AUTO_MEASUREMENT_VCOM = 0x80, + AutoMeasurementVcom = 0x80, /// This command gets the VCOM value. - READ_VCOM_VALUE = 0x81, + ReadVcomValue = 0x81, /// This command sets `VCOM_DC` value. - VCM_DC_SETTING = 0x82, + VcmDcSetting = 0x82, /// This is in all the Waveshare controllers for EPD7in5, but it's not documented /// anywhere in the datasheet `¯\_(ツ)_/¯` - FLASH_MODE = 0xE5, + FlashMode = 0xE5, } impl traits::Command for Command { @@ -148,7 +147,7 @@ mod tests { #[test] fn command_addr() { - assert_eq!(Command::PANEL_SETTING.address(), 0x00); - assert_eq!(Command::DISPLAY_REFRESH.address(), 0x12); + assert_eq!(Command::PanelSetting.address(), 0x00); + assert_eq!(Command::DisplayRefresh.address(), 0x12); } } diff --git a/src/epd7in5/mod.rs b/src/epd7in5/mod.rs index 883deb3..16d902a 100644 --- a/src/epd7in5/mod.rs +++ b/src/epd7in5/mod.rs @@ -58,41 +58,41 @@ where self.interface.reset(delay, 10); // Set the power settings - self.cmd_with_data(spi, Command::POWER_SETTING, &[0x37, 0x00])?; + self.cmd_with_data(spi, Command::PowerSetting, &[0x37, 0x00])?; // Set the panel settings: // - 600 x 448 // - Using LUT from external flash - self.cmd_with_data(spi, Command::PANEL_SETTING, &[0xCF, 0x08])?; + self.cmd_with_data(spi, Command::PanelSetting, &[0xCF, 0x08])?; // Start the booster - self.cmd_with_data(spi, Command::BOOSTER_SOFT_START, &[0xC7, 0xCC, 0x28])?; + self.cmd_with_data(spi, Command::BoosterSoftStart, &[0xC7, 0xCC, 0x28])?; // Power on - self.command(spi, Command::POWER_ON)?; + self.command(spi, Command::PowerOn)?; delay.delay_ms(5); self.wait_until_idle(); // Set the clock frequency to 50Hz (default) - self.cmd_with_data(spi, Command::PLL_CONTROL, &[0x3C])?; + self.cmd_with_data(spi, Command::PllControl, &[0x3C])?; // Select internal temperature sensor (default) - self.cmd_with_data(spi, Command::TEMPERATURE_CALIBRATION, &[0x00])?; + self.cmd_with_data(spi, Command::TemperatureCalibration, &[0x00])?; // Set Vcom and data interval to 10 (default), border output to white - self.cmd_with_data(spi, Command::VCOM_AND_DATA_INTERVAL_SETTING, &[0x77])?; + self.cmd_with_data(spi, Command::VcomAndDataIntervalSetting, &[0x77])?; // Set S2G and G2S non-overlap periods to 12 (default) - self.cmd_with_data(spi, Command::TCON_SETTING, &[0x22])?; + self.cmd_with_data(spi, Command::TconSetting, &[0x22])?; // Set the real resolution self.send_resolution(spi)?; // Set VCOM_DC to -1.5V - self.cmd_with_data(spi, Command::VCM_DC_SETTING, &[0x1E])?; + self.cmd_with_data(spi, Command::VcmDcSetting, &[0x1E])?; // This is in all the Waveshare controllers for EPD7in5 - self.cmd_with_data(spi, Command::FLASH_MODE, &[0x03])?; + self.cmd_with_data(spi, Command::FlashMode, &[0x03])?; self.wait_until_idle(); Ok(()) @@ -137,15 +137,15 @@ where fn sleep(&mut self, spi: &mut SPI) -> Result<(), SPI::Error> { self.wait_until_idle(); - self.command(spi, Command::POWER_OFF)?; + self.command(spi, Command::PowerOff)?; self.wait_until_idle(); - self.cmd_with_data(spi, Command::DEEP_SLEEP, &[0xA5])?; + self.cmd_with_data(spi, Command::DeepSleep, &[0xA5])?; Ok(()) } fn update_frame(&mut self, spi: &mut SPI, buffer: &[u8]) -> Result<(), SPI::Error> { self.wait_until_idle(); - self.command(spi, Command::DATA_START_TRANSMISSION_1)?; + self.command(spi, Command::DataStartTransmission1)?; for byte in buffer { let mut temp = *byte; for _ in 0..4 { @@ -174,13 +174,13 @@ where fn display_frame(&mut self, spi: &mut SPI) -> Result<(), SPI::Error> { self.wait_until_idle(); - self.command(spi, Command::DISPLAY_REFRESH)?; + self.command(spi, Command::DisplayRefresh)?; Ok(()) } fn update_and_display_frame(&mut self, spi: &mut SPI, buffer: &[u8]) -> Result<(), SPI::Error> { self.update_frame(spi, buffer)?; - self.command(spi, Command::DISPLAY_REFRESH)?; + self.command(spi, Command::DisplayRefresh)?; Ok(()) } @@ -189,7 +189,7 @@ where self.send_resolution(spi)?; // The Waveshare controllers all implement clear using 0x33 - self.command(spi, Command::DATA_START_TRANSMISSION_1)?; + self.command(spi, Command::DataStartTransmission1)?; self.interface .data_x_times(spi, 0x33, WIDTH / 8 * HEIGHT * 4)?; Ok(()) @@ -257,7 +257,7 @@ where let w = self.width(); let h = self.height(); - self.command(spi, Command::TCON_RESOLUTION)?; + self.command(spi, Command::TconResolution)?; self.send_data(spi, &[(w >> 8) as u8])?; self.send_data(spi, &[w as u8])?; self.send_data(spi, &[(h >> 8) as u8])?; diff --git a/src/epd7in5_v2/command.rs b/src/epd7in5_v2/command.rs index c239eda..599c080 100644 --- a/src/epd7in5_v2/command.rs +++ b/src/epd7in5_v2/command.rs @@ -8,130 +8,129 @@ use crate::traits; /// /// For more infos about the addresses and what they are doing look into the PDFs. #[allow(dead_code)] -#[allow(non_camel_case_types)] #[derive(Copy, Clone)] pub(crate) enum Command { /// Set Resolution, LUT selection, BWR pixels, gate scan direction, source shift /// direction, booster switch, soft reset. - PANEL_SETTING = 0x00, + PanelSetting = 0x00, /// Selecting internal and external power - POWER_SETTING = 0x01, + PowerSetting = 0x01, /// After the Power Off command, the driver will power off following the Power Off /// Sequence; BUSY signal will become "0". This command will turn off charge pump, /// T-con, source driver, gate driver, VCOM, and temperature sensor, but register /// data will be kept until VDD becomes OFF. Source Driver output and Vcom will remain /// as previous condition, which may have 2 conditions: 0V or floating. - POWER_OFF = 0x02, + PowerOff = 0x02, /// Setting Power OFF sequence - POWER_OFF_SEQUENCE_SETTING = 0x03, + PowerOffSequenceSetting = 0x03, /// Turning On the Power /// /// After the Power ON command, the driver will power on following the Power ON /// sequence. Once complete, the BUSY signal will become "1". - POWER_ON = 0x04, + PowerOn = 0x04, /// Starting data transmission - BOOSTER_SOFT_START = 0x06, + BoosterSoftStart = 0x06, /// This command makes the chip enter the deep-sleep mode to save power. /// /// The deep sleep mode would return to stand-by by hardware reset. /// /// The only one parameter is a check code, the command would be excuted if check code = 0xA5. - DEEP_SLEEP = 0x07, + DeepSleep = 0x07, /// This command starts transmitting data and write them into SRAM. To complete data /// transmission, command DSP (Data Stop) must be issued. Then the chip will start to /// send data/VCOM for panel. /// /// BLACK/WHITE or OLD_DATA - DATA_START_TRANSMISSION_1 = 0x10, + DataStartTransmission1 = 0x10, /// To stop data transmission, this command must be issued to check the `data_flag`. /// /// After this command, BUSY signal will become "0" until the display update is /// finished. - DATA_STOP = 0x11, + DataStop = 0x11, /// After this command is issued, driver will refresh display (data/VCOM) according to /// SRAM data and LUT. /// /// After Display Refresh command, BUSY signal will become "0" until the display /// update is finished. - DISPLAY_REFRESH = 0x12, + DisplayRefresh = 0x12, /// RED or NEW_DATA - DATA_START_TRANSMISSION_2 = 0x13, + DataStartTransmission2 = 0x13, /// Dual SPI - what for? - DUAL_SPI = 0x15, + DualSpi = 0x15, /// This command builds the VCOM Look-Up Table (LUTC). - LUT_FOR_VCOM = 0x20, + LutForVcom = 0x20, /// This command builds the Black Look-Up Table (LUTB). - LUT_BLACK = 0x21, + LutBlack = 0x21, /// This command builds the White Look-Up Table (LUTW). - LUT_WHITE = 0x22, + LutWhite = 0x22, /// This command builds the Gray1 Look-Up Table (LUTG1). - LUT_GRAY_1 = 0x23, + LutGray1 = 0x23, /// This command builds the Gray2 Look-Up Table (LUTG2). - LUT_GRAY_2 = 0x24, + LutGray2 = 0x24, /// This command builds the Red0 Look-Up Table (LUTR0). - LUT_RED_0 = 0x25, + LutRed0 = 0x25, /// This command builds the Red1 Look-Up Table (LUTR1). - LUT_RED_1 = 0x26, + LutRed1 = 0x26, /// This command builds the Red2 Look-Up Table (LUTR2). - LUT_RED_2 = 0x27, + LutRed2 = 0x27, /// This command builds the Red3 Look-Up Table (LUTR3). - LUT_RED_3 = 0x28, + LutRed3 = 0x28, /// This command builds the XON Look-Up Table (LUTXON). - LUT_XON = 0x29, + LutXon = 0x29, /// The command controls the PLL clock frequency. - PLL_CONTROL = 0x30, + PllControl = 0x30, /// This command reads the temperature sensed by the temperature sensor. - TEMPERATURE_SENSOR_COMMAND = 0x40, + TemperatureSensorCommand = 0x40, /// This command selects the Internal or External temperature sensor. - TEMPERATURE_CALIBRATION = 0x41, + TemperatureCalibration = 0x41, /// This command could write data to the external temperature sensor. - TEMPERATURE_SENSOR_WRITE = 0x42, + TemperatureSensorWrite = 0x42, /// This command could read data from the external temperature sensor. - TEMPERATURE_SENSOR_READ = 0x43, + TemperatureSensorRead = 0x43, /// This command indicates the interval of Vcom and data output. When setting the /// vertical back porch, the total blanking will be kept (20 Hsync). - VCOM_AND_DATA_INTERVAL_SETTING = 0x50, + VcomAndDataIntervalSetting = 0x50, /// This command indicates the input power condition. Host can read this flag to learn /// the battery condition. - LOW_POWER_DETECTION = 0x51, + LowPowerDetection = 0x51, /// This command defines non-overlap period of Gate and Source. - TCON_SETTING = 0x60, + TconSetting = 0x60, /// This command defines alternative resolution and this setting is of higher priority /// than the RES\[1:0\] in R00H (PSR). - TCON_RESOLUTION = 0x61, + TconResolution = 0x61, /// This command defines MCU host direct access external memory mode. - SPI_FLASH_CONTROL = 0x65, + SpiFlashControl = 0x65, /// The LUT_REV / Chip Revision is read from OTP address = 25001 and 25000. REVISION = 0x70, /// This command reads the IC status. - GET_STATUS = 0x71, + GetStatus = 0x71, /// This command implements related VCOM sensing setting. - AUTO_MEASUREMENT_VCOM = 0x80, + AutoMeasurementVcom = 0x80, /// This command gets the VCOM value. - READ_VCOM_VALUE = 0x81, + ReadVcomValue = 0x81, /// This command sets `VCOM_DC` value. - VCM_DC_SETTING = 0x82, + VcmDcSetting = 0x82, // /// This is in all the Waveshare controllers for EPD7in5, but it's not documented // /// anywhere in the datasheet `¯\_(ツ)_/¯` - // FLASH_MODE = 0xE5, + // FlashMode = 0xE5, } impl traits::Command for Command { @@ -148,7 +147,7 @@ mod tests { #[test] fn command_addr() { - assert_eq!(Command::PANEL_SETTING.address(), 0x00); - assert_eq!(Command::DISPLAY_REFRESH.address(), 0x12); + assert_eq!(Command::PanelSetting.address(), 0x00); + assert_eq!(Command::DisplayRefresh.address(), 0x12); } } diff --git a/src/epd7in5_v2/mod.rs b/src/epd7in5_v2/mod.rs index 67f9dab..e4c60e0 100644 --- a/src/epd7in5_v2/mod.rs +++ b/src/epd7in5_v2/mod.rs @@ -66,16 +66,16 @@ where // and as per specs: // https://www.waveshare.com/w/upload/6/60/7.5inch_e-Paper_V2_Specification.pdf - self.cmd_with_data(spi, Command::BOOSTER_SOFT_START, &[0x17, 0x17, 0x27, 0x17])?; - self.cmd_with_data(spi, Command::POWER_SETTING, &[0x07, 0x17, 0x3F, 0x3F])?; - self.command(spi, Command::POWER_ON)?; + self.cmd_with_data(spi, Command::BoosterSoftStart, &[0x17, 0x17, 0x27, 0x17])?; + self.cmd_with_data(spi, Command::PowerSetting, &[0x07, 0x17, 0x3F, 0x3F])?; + self.command(spi, Command::PowerOn)?; self.wait_until_idle(); - self.cmd_with_data(spi, Command::PANEL_SETTING, &[0x1F])?; - self.cmd_with_data(spi, Command::PLL_CONTROL, &[0x06])?; - self.cmd_with_data(spi, Command::TCON_RESOLUTION, &[0x03, 0x20, 0x01, 0xE0])?; - self.cmd_with_data(spi, Command::DUAL_SPI, &[0x00])?; - self.cmd_with_data(spi, Command::TCON_SETTING, &[0x22])?; - self.cmd_with_data(spi, Command::VCOM_AND_DATA_INTERVAL_SETTING, &[0x10, 0x07])?; + self.cmd_with_data(spi, Command::PanelSetting, &[0x1F])?; + self.cmd_with_data(spi, Command::PllControl, &[0x06])?; + self.cmd_with_data(spi, Command::TconResolution, &[0x03, 0x20, 0x01, 0xE0])?; + self.cmd_with_data(spi, Command::DualSpi, &[0x00])?; + self.cmd_with_data(spi, Command::TconSetting, &[0x22])?; + self.cmd_with_data(spi, Command::VcomAndDataIntervalSetting, &[0x10, 0x07])?; self.wait_until_idle(); Ok(()) } @@ -119,15 +119,15 @@ where fn sleep(&mut self, spi: &mut SPI) -> Result<(), SPI::Error> { self.wait_until_idle(); - self.command(spi, Command::POWER_OFF)?; + self.command(spi, Command::PowerOff)?; self.wait_until_idle(); - self.cmd_with_data(spi, Command::DEEP_SLEEP, &[0xA5])?; + self.cmd_with_data(spi, Command::DeepSleep, &[0xA5])?; Ok(()) } fn update_frame(&mut self, spi: &mut SPI, buffer: &[u8]) -> Result<(), SPI::Error> { self.wait_until_idle(); - self.cmd_with_data(spi, Command::DATA_START_TRANSMISSION_2, buffer)?; + self.cmd_with_data(spi, Command::DataStartTransmission2, buffer)?; Ok(()) } @@ -145,13 +145,13 @@ where fn display_frame(&mut self, spi: &mut SPI) -> Result<(), SPI::Error> { self.wait_until_idle(); - self.command(spi, Command::DISPLAY_REFRESH)?; + self.command(spi, Command::DisplayRefresh)?; Ok(()) } fn update_and_display_frame(&mut self, spi: &mut SPI, buffer: &[u8]) -> Result<(), SPI::Error> { self.update_frame(spi, buffer)?; - self.command(spi, Command::DISPLAY_REFRESH)?; + self.command(spi, Command::DisplayRefresh)?; Ok(()) } @@ -159,13 +159,13 @@ where self.wait_until_idle(); self.send_resolution(spi)?; - self.command(spi, Command::DATA_START_TRANSMISSION_1)?; + self.command(spi, Command::DataStartTransmission1)?; self.interface.data_x_times(spi, 0x00, WIDTH * HEIGHT / 8)?; - self.command(spi, Command::DATA_START_TRANSMISSION_2)?; + self.command(spi, Command::DataStartTransmission2)?; self.interface.data_x_times(spi, 0x00, WIDTH * HEIGHT / 8)?; - self.command(spi, Command::DISPLAY_REFRESH)?; + self.command(spi, Command::DisplayRefresh)?; Ok(()) } @@ -231,7 +231,7 @@ where let w = self.width(); let h = self.height(); - self.command(spi, Command::TCON_RESOLUTION)?; + self.command(spi, Command::TconResolution)?; self.send_data(spi, &[(w >> 8) as u8])?; self.send_data(spi, &[w as u8])?; self.send_data(spi, &[(h >> 8) as u8])?; diff --git a/src/type_a/command.rs b/src/type_a/command.rs index e966aa9..d12dd2c 100644 --- a/src/type_a/command.rs +++ b/src/type_a/command.rs @@ -8,7 +8,6 @@ use crate::traits; /// /// For more infos about the addresses and what they are doing look into the pdfs #[allow(dead_code)] -#[allow(non_camel_case_types)] #[derive(Copy, Clone)] pub(crate) enum Command { /// Driver Output control @@ -17,56 +16,56 @@ pub(crate) enum Command { /// 0.. A[8] /// 0.. B[2:0] /// Default: Set A[8:0] = 0x127 and B[2:0] = 0x0 - DRIVER_OUTPUT_CONTROL = 0x01, + DriverOutputControl = 0x01, /// Booster Soft start control /// 3 Databytes: /// 1.. A[6:0] /// 1.. B[6:0] /// 1.. C[6:0] /// Default: A[7:0] = 0xCF, B[7:0] = 0xCE, C[7:0] = 0x8D - BOOSTER_SOFT_START_CONTROL = 0x0C, - GATE_SCAN_START_POSITION = 0x0F, + BoosterSoftStartControl = 0x0C, + GateScanStartPosition = 0x0F, //TODO: useful? - // GATE_SCAN_START_POSITION = 0x0F, + // GateScanStartPosition = 0x0F, /// Deep Sleep Mode Control /// 1 Databyte: /// 0.. A[0] /// Values: /// A[0] = 0: Normal Mode (POR) /// A[0] = 1: Enter Deep Sleep Mode - DEEP_SLEEP_MODE = 0x10, + DeepSleepMode = 0x10, // /// Data Entry mode setting - DATA_ENTRY_MODE_SETTING = 0x11, + DataEntryModeSetting = 0x11, - SW_RESET = 0x12, + SwReset = 0x12, - TEMPERATURE_SENSOR_CONTROL = 0x1A, + TemperatureSensorControl = 0x1A, - MASTER_ACTIVATION = 0x20, + MasterActivation = 0x20, - DISPLAY_UPDATE_CONTROL_1 = 0x21, + DisplayUpdateControl1 = 0x21, - DISPLAY_UPDATE_CONTROL_2 = 0x22, + DisplayUpdateControl2 = 0x22, - WRITE_RAM = 0x24, + WriteRam = 0x24, - WRITE_VCOM_REGISTER = 0x2C, + WriteVcomRegister = 0x2C, - WRITE_LUT_REGISTER = 0x32, + WriteLutRegister = 0x32, - SET_DUMMY_LINE_PERIOD = 0x3A, + SetDummyLinePeriod = 0x3A, - SET_GATE_LINE_WIDTH = 0x3B, + SetGateLineWidth = 0x3B, - BORDER_WAVEFORM_CONTROL = 0x3C, + BorderWaveformControl = 0x3C, - SET_RAM_X_ADDRESS_START_END_POSITION = 0x44, + SetRamXAddressStartEndPosition = 0x44, - SET_RAM_Y_ADDRESS_START_END_POSITION = 0x45, + SetRamYAddressStartEndPosition = 0x45, - SET_RAM_X_ADDRESS_COUNTER = 0x4E, + SetRamXAddressCounter = 0x4E, - SET_RAM_Y_ADDRESS_COUNTER = 0x4F, + SetRamYAddressCounter = 0x4F, NOP = 0xFF, } @@ -85,9 +84,9 @@ mod tests { #[test] fn command_addr() { - assert_eq!(Command::DRIVER_OUTPUT_CONTROL.address(), 0x01); + assert_eq!(Command::DriverOutputControl.address(), 0x01); - assert_eq!(Command::SET_RAM_X_ADDRESS_COUNTER.address(), 0x4E); + assert_eq!(Command::SetRamXAddressCounter.address(), 0x4E); assert_eq!(Command::NOP.address(), 0xFF); } From 9d95eeb64b6bbff747b2583e21362d76489a0ef3 Mon Sep 17 00:00:00 2001 From: Caemor <11088935+caemor@users.noreply.github.com> Date: Sun, 11 Apr 2021 20:38:03 +0200 Subject: [PATCH 3/4] cargo fmt --- src/epd1in54/mod.rs | 7 ++----- src/epd1in54b/mod.rs | 18 ++++++------------ src/epd2in7b/mod.rs | 18 ++++++------------ src/epd2in9/mod.rs | 7 ++----- src/epd2in9bc/mod.rs | 18 ++++++------------ src/epd4in2/mod.rs | 27 +++++++++------------------ 6 files changed, 31 insertions(+), 64 deletions(-) diff --git a/src/epd1in54/mod.rs b/src/epd1in54/mod.rs index 1edac11..99f0d4c 100644 --- a/src/epd1in54/mod.rs +++ b/src/epd1in54/mod.rs @@ -112,11 +112,8 @@ where // 1 .. B[6:0] = 0xCE | 0xD6 // 1 .. C[6:0] = 0x8D | 0x9D //TODO: test - self.interface.cmd_with_data( - spi, - Command::BoosterSoftStartControl, - &[0xD7, 0xD6, 0x9D], - )?; + self.interface + .cmd_with_data(spi, Command::BoosterSoftStartControl, &[0xD7, 0xD6, 0x9D])?; // One Databyte with value 0xA8 for 7V VCOM self.interface diff --git a/src/epd1in54b/mod.rs b/src/epd1in54b/mod.rs index 8441508..25a5b48 100644 --- a/src/epd1in54b/mod.rs +++ b/src/epd1in54b/mod.rs @@ -111,8 +111,7 @@ where self.wait_until_idle(); self.send_resolution(spi)?; - self.interface - .cmd(spi, Command::DataStartTransmission1)?; + self.interface.cmd(spi, Command::DataStartTransmission1)?; for b in black { let expanded = expand_bits(*b); @@ -126,8 +125,7 @@ where spi: &mut SPI, chromatic: &[u8], ) -> Result<(), SPI::Error> { - self.interface - .cmd(spi, Command::DataStartTransmission2)?; + self.interface.cmd(spi, Command::DataStartTransmission2)?; self.interface.data(spi, chromatic)?; Ok(()) } @@ -209,8 +207,7 @@ where self.wait_until_idle(); self.send_resolution(spi)?; - self.interface - .cmd(spi, Command::DataStartTransmission1)?; + self.interface.cmd(spi, Command::DataStartTransmission1)?; for b in buffer { // Two bits per pixel @@ -224,8 +221,7 @@ where let color = self.color.get_byte_value(); let nbits = WIDTH * (HEIGHT / 8); - self.interface - .cmd(spi, Command::DataStartTransmission2)?; + self.interface.cmd(spi, Command::DataStartTransmission2)?; self.interface.data_x_times(spi, color, nbits)?; //NOTE: Example code has a delay here @@ -264,16 +260,14 @@ where let color = DEFAULT_BACKGROUND_COLOR.get_byte_value(); // Clear the black - self.interface - .cmd(spi, Command::DataStartTransmission1)?; + self.interface.cmd(spi, Command::DataStartTransmission1)?; // Uses 2 bits per pixel self.interface .data_x_times(spi, color, 2 * (WIDTH * HEIGHT / 8))?; // Clear the red - self.interface - .cmd(spi, Command::DataStartTransmission2)?; + self.interface.cmd(spi, Command::DataStartTransmission2)?; self.interface .data_x_times(spi, color, WIDTH * HEIGHT / 8)?; Ok(()) diff --git a/src/epd2in7b/mod.rs b/src/epd2in7b/mod.rs index fc85eab..37ae3b5 100644 --- a/src/epd2in7b/mod.rs +++ b/src/epd2in7b/mod.rs @@ -160,13 +160,11 @@ where } fn update_frame(&mut self, spi: &mut SPI, buffer: &[u8]) -> Result<(), SPI::Error> { - self.interface - .cmd(spi, Command::DataStartTransmission1)?; + self.interface.cmd(spi, Command::DataStartTransmission1)?; self.send_buffer_helper(spi, buffer)?; // Clear chromatic layer since we won't be using it here - self.interface - .cmd(spi, Command::DataStartTransmission2)?; + self.interface.cmd(spi, Command::DataStartTransmission2)?; self.interface .data_x_times(spi, !self.color.get_byte_value(), WIDTH * HEIGHT / 8)?; @@ -217,15 +215,13 @@ where self.wait_until_idle(); let color_value = self.color.get_byte_value(); - self.interface - .cmd(spi, Command::DataStartTransmission1)?; + self.interface.cmd(spi, Command::DataStartTransmission1)?; self.interface .data_x_times(spi, color_value, WIDTH * HEIGHT / 8)?; self.interface.cmd(spi, Command::DataStop)?; - self.interface - .cmd(spi, Command::DataStartTransmission2)?; + self.interface.cmd(spi, Command::DataStartTransmission2)?; self.interface .data_x_times(spi, color_value, WIDTH * HEIGHT / 8)?; self.interface.cmd(spi, Command::DataStop)?; @@ -294,8 +290,7 @@ where spi: &mut SPI, achromatic: &[u8], ) -> Result<(), SPI::Error> { - self.interface - .cmd(spi, Command::DataStartTransmission1)?; + self.interface.cmd(spi, Command::DataStartTransmission1)?; self.send_buffer_helper(spi, achromatic)?; @@ -310,8 +305,7 @@ where spi: &mut SPI, chromatic: &[u8], ) -> Result<(), SPI::Error> { - self.interface - .cmd(spi, Command::DataStartTransmission2)?; + self.interface.cmd(spi, Command::DataStartTransmission2)?; self.send_buffer_helper(spi, chromatic)?; diff --git a/src/epd2in9/mod.rs b/src/epd2in9/mod.rs index 0f25b7b..99d003c 100644 --- a/src/epd2in9/mod.rs +++ b/src/epd2in9/mod.rs @@ -111,11 +111,8 @@ where // 1 .. B[6:0] = 0xCE | 0xD6 // 1 .. C[6:0] = 0x8D | 0x9D //TODO: test - self.interface.cmd_with_data( - spi, - Command::BoosterSoftStartControl, - &[0xD7, 0xD6, 0x9D], - )?; + self.interface + .cmd_with_data(spi, Command::BoosterSoftStartControl, &[0xD7, 0xD6, 0x9D])?; // One Databyte with value 0xA8 for 7V VCOM self.interface diff --git a/src/epd2in9bc/mod.rs b/src/epd2in9bc/mod.rs index 5a81342..6f76602 100644 --- a/src/epd2in9bc/mod.rs +++ b/src/epd2in9bc/mod.rs @@ -165,8 +165,7 @@ where /// /// Finish by calling `update_chromatic_frame`. fn update_achromatic_frame(&mut self, spi: &mut SPI, black: &[u8]) -> Result<(), SPI::Error> { - self.interface - .cmd(spi, Command::DataStartTransmission1)?; + self.interface.cmd(spi, Command::DataStartTransmission1)?; self.interface.data(spi, black)?; Ok(()) } @@ -179,8 +178,7 @@ where spi: &mut SPI, chromatic: &[u8], ) -> Result<(), SPI::Error> { - self.interface - .cmd(spi, Command::DataStartTransmission2)?; + self.interface.cmd(spi, Command::DataStartTransmission2)?; self.interface.data(spi, chromatic)?; self.wait_until_idle(); @@ -258,16 +256,14 @@ where } fn update_frame(&mut self, spi: &mut SPI, buffer: &[u8]) -> Result<(), SPI::Error> { - self.interface - .cmd(spi, Command::DataStartTransmission1)?; + self.interface.cmd(spi, Command::DataStartTransmission1)?; self.interface.data(spi, &buffer)?; // Clear the chromatic layer let color = self.color.get_byte_value(); - self.interface - .cmd(spi, Command::DataStartTransmission2)?; + self.interface.cmd(spi, Command::DataStartTransmission2)?; self.interface.data_x_times(spi, color, NUM_DISPLAY_BITS)?; self.wait_until_idle(); @@ -306,14 +302,12 @@ where let color = DEFAULT_BACKGROUND_COLOR.get_byte_value(); // Clear the black - self.interface - .cmd(spi, Command::DataStartTransmission1)?; + self.interface.cmd(spi, Command::DataStartTransmission1)?; self.interface.data_x_times(spi, color, NUM_DISPLAY_BITS)?; // Clear the chromatic - self.interface - .cmd(spi, Command::DataStartTransmission2)?; + self.interface.cmd(spi, Command::DataStartTransmission2)?; self.interface.data_x_times(spi, color, NUM_DISPLAY_BITS)?; self.wait_until_idle(); diff --git a/src/epd4in2/mod.rs b/src/epd4in2/mod.rs index 73e46e0..4e155a5 100644 --- a/src/epd4in2/mod.rs +++ b/src/epd4in2/mod.rs @@ -211,8 +211,7 @@ where self.wait_until_idle(); let color_value = self.color.get_byte_value(); - self.interface - .cmd(spi, Command::DataStartTransmission1)?; + self.interface.cmd(spi, Command::DataStartTransmission1)?; self.interface .data_x_times(spi, color_value, WIDTH / 8 * HEIGHT)?; @@ -285,13 +284,11 @@ where let color_value = self.color.get_byte_value(); - self.interface - .cmd(spi, Command::DataStartTransmission1)?; + self.interface.cmd(spi, Command::DataStartTransmission1)?; self.interface .data_x_times(spi, color_value, WIDTH / 8 * HEIGHT)?; - self.interface - .cmd(spi, Command::DataStartTransmission2)?; + self.interface.cmd(spi, Command::DataStartTransmission2)?; self.interface .data_x_times(spi, color_value, WIDTH / 8 * HEIGHT)?; Ok(()) @@ -450,8 +447,7 @@ where fn update_old_frame(&mut self, spi: &mut SPI, buffer: &[u8]) -> Result<(), SPI::Error> { self.wait_until_idle(); - self.interface - .cmd(spi, Command::DataStartTransmission1)?; + self.interface.cmd(spi, Command::DataStartTransmission1)?; self.interface.data(spi, buffer)?; @@ -463,8 +459,7 @@ where self.wait_until_idle(); // self.send_resolution(spi)?; - self.interface - .cmd(spi, Command::DataStartTransmission2)?; + self.interface.cmd(spi, Command::DataStartTransmission2)?; self.interface.data(spi, buffer)?; @@ -492,8 +487,7 @@ where self.shift_display(spi, x, y, width, height)?; - self.interface - .cmd(spi, Command::DataStartTransmission1)?; + self.interface.cmd(spi, Command::DataStartTransmission1)?; self.interface.data(spi, buffer)?; @@ -519,8 +513,7 @@ where self.shift_display(spi, x, y, width, height)?; - self.interface - .cmd(spi, Command::DataStartTransmission2)?; + self.interface.cmd(spi, Command::DataStartTransmission2)?; self.interface.data(spi, buffer)?; @@ -546,13 +539,11 @@ where self.shift_display(spi, x, y, width, height)?; - self.interface - .cmd(spi, Command::DataStartTransmission1)?; + self.interface.cmd(spi, Command::DataStartTransmission1)?; self.interface .data_x_times(spi, color_value, width / 8 * height)?; - self.interface - .cmd(spi, Command::DataStartTransmission2)?; + self.interface.cmd(spi, Command::DataStartTransmission2)?; self.interface .data_x_times(spi, color_value, width / 8 * height)?; From 15e557951f09d3e0eab186643b7d1603645432f5 Mon Sep 17 00:00:00 2001 From: Caemor <11088935+caemor@users.noreply.github.com> Date: Sun, 11 Apr 2021 21:21:39 +0200 Subject: [PATCH 4/4] Further improvements around acronym lowercases,... --- CHANGELOG.md | 4 +-- README.md | 2 +- examples/epd1in54_no_graphics.rs | 6 ++-- examples/epd2in13_v2.rs | 6 ++-- examples/epd4in2.rs | 6 ++-- examples/epd4in2_variable_size.rs | 4 +-- src/epd1in54/mod.rs | 28 +++++++-------- src/epd1in54b/command.rs | 2 +- src/epd1in54b/mod.rs | 20 +++++------ src/epd1in54c/command.rs | 2 +- src/epd1in54c/mod.rs | 18 +++++----- src/epd2in13_v2/command.rs | 40 ++++++++++----------- src/epd2in13_v2/mod.rs | 58 +++++++++++++++---------------- src/epd2in7b/command.rs | 2 +- src/epd2in7b/mod.rs | 18 +++++----- src/epd2in9/mod.rs | 26 +++++++------- src/epd2in9bc/command.rs | 2 +- src/epd2in9bc/mod.rs | 20 +++++------ src/epd4in2/command.rs | 4 +-- src/epd4in2/mod.rs | 28 +++++++-------- src/epd5in65f/command.rs | 6 ++-- src/epd5in65f/mod.rs | 18 +++++----- src/epd7in5/command.rs | 8 ++--- src/epd7in5/mod.rs | 18 +++++----- src/epd7in5_v2/command.rs | 8 ++--- src/epd7in5_v2/mod.rs | 16 ++++----- src/interface.rs | 4 +-- src/lib.rs | 4 +-- src/traits.rs | 16 ++++----- src/type_a/command.rs | 6 ++-- 30 files changed, 200 insertions(+), 200 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9a4ae72..37fbb31 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,13 +9,13 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ### Added -- Added QuickRefresh Trait and implemented it for EPD4in2 in #62 (thanks to @David-OConnor) +- Added QuickRefresh Trait and implemented it for Epd4in2 in #62 (thanks to @David-OConnor) - Added Epd 2in7 (B) support in #60 (thanks to @pjsier) ### Changed - Use specific ParseColorError instead of () -- EPD4in2: Don't set the resolution (and some more) over and over again (#48) +- Epd4in2: Don't set the resolution (and some more) over and over again (#48) - Removed `#[allow(non_camel_case_types)]` to fix various issues around it ### Fixed diff --git a/README.md b/README.md index 99fcb1b..1b72247 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ There are multiple examples in the examples folder. Use `cargo run --example exa ```Rust // Setup the epd -let mut epd = EPD4in2::new( & mut spi, cs, busy, dc, rst, & mut delay) ?; +let mut epd = Epd4in2::new( & mut spi, cs, busy, dc, rst, & mut delay) ?; // Setup the graphics let mut display = Display4in2::default (); diff --git a/examples/epd1in54_no_graphics.rs b/examples/epd1in54_no_graphics.rs index 7fd30ae..4782622 100644 --- a/examples/epd1in54_no_graphics.rs +++ b/examples/epd1in54_no_graphics.rs @@ -1,7 +1,7 @@ #![deny(warnings)] use embedded_hal::prelude::*; -use epd_waveshare::{epd1in54::EPD1in54, prelude::*}; +use epd_waveshare::{epd1in54::Epd1in54, prelude::*}; use linux_embedded_hal::{ spidev::{self, SpidevOptions}, sysfs_gpio::Direction, @@ -58,14 +58,14 @@ fn main() -> Result<(), std::io::Error> { // Setup of the needed pins is finished here // Now the "real" usage of the eink-waveshare-rs crate begins - let mut epd = EPD1in54::new(&mut spi, cs_pin, busy, dc, rst, &mut delay)?; + let mut epd = Epd1in54::new(&mut spi, cs_pin, busy, dc, rst, &mut delay)?; // Clear the full screen epd.clear_frame(&mut spi)?; epd.display_frame(&mut spi)?; // Speeddemo - epd.set_lut(&mut spi, Some(RefreshLUT::QUICK))?; + epd.set_lut(&mut spi, Some(RefreshLut::Quick))?; let small_buffer = [Color::Black.get_byte_value(); 32]; //16x16 let number_of_runs = 1; for i in 0..number_of_runs { diff --git a/examples/epd2in13_v2.rs b/examples/epd2in13_v2.rs index ac509c3..3fc7472 100644 --- a/examples/epd2in13_v2.rs +++ b/examples/epd2in13_v2.rs @@ -10,7 +10,7 @@ use embedded_graphics::{ use embedded_hal::prelude::*; use epd_waveshare::{ color::*, - epd2in13_v2::{Display2in13, EPD2in13}, + epd2in13_v2::{Display2in13, Epd2in13}, graphics::{Display, DisplayRotation}, prelude::*, }; @@ -63,7 +63,7 @@ fn main() -> Result<(), std::io::Error> { let mut delay = Delay {}; let mut epd2in13 = - EPD2in13::new(&mut spi, cs, busy, dc, rst, &mut delay).expect("eink initalize error"); + Epd2in13::new(&mut spi, cs, busy, dc, rst, &mut delay).expect("eink initalize error"); //println!("Test all the rotations"); let mut display = Display2in13::default(); @@ -121,7 +121,7 @@ fn main() -> Result<(), std::io::Error> { // Demonstrating how to use the partial refresh feature of the screen. // Real animations can be used. epd2in13 - .set_refresh(&mut spi, &mut delay, RefreshLUT::QUICK) + .set_refresh(&mut spi, &mut delay, RefreshLut::Quick) .unwrap(); epd2in13.clear_frame(&mut spi).unwrap(); diff --git a/examples/epd4in2.rs b/examples/epd4in2.rs index 04730ed..b986828 100644 --- a/examples/epd4in2.rs +++ b/examples/epd4in2.rs @@ -10,7 +10,7 @@ use embedded_graphics::{ use embedded_hal::prelude::*; use epd_waveshare::{ color::*, - epd4in2::{Display4in2, EPD4in2}, + epd4in2::{Display4in2, Epd4in2}, graphics::{Display, DisplayRotation}, prelude::*, }; @@ -63,7 +63,7 @@ fn main() -> Result<(), std::io::Error> { let mut delay = Delay {}; let mut epd4in2 = - EPD4in2::new(&mut spi, cs, busy, dc, rst, &mut delay).expect("eink initalize error"); + Epd4in2::new(&mut spi, cs, busy, dc, rst, &mut delay).expect("eink initalize error"); //println!("Test all the rotations"); let mut display = Display4in2::default(); @@ -120,7 +120,7 @@ fn main() -> Result<(), std::io::Error> { // a moving `Hello World!` let limit = 10; - epd4in2.set_lut(&mut spi, Some(RefreshLUT::QUICK)).unwrap(); + epd4in2.set_lut(&mut spi, Some(RefreshLut::Quick)).unwrap(); epd4in2.clear_frame(&mut spi).unwrap(); for i in 0..limit { //println!("Moving Hello World. Loop {} from {}", (i + 1), limit); diff --git a/examples/epd4in2_variable_size.rs b/examples/epd4in2_variable_size.rs index 6c03851..554c707 100644 --- a/examples/epd4in2_variable_size.rs +++ b/examples/epd4in2_variable_size.rs @@ -11,7 +11,7 @@ use embedded_graphics::{ use embedded_hal::prelude::*; use epd_waveshare::{ color::*, - epd4in2::{self, EPD4in2}, + epd4in2::{self, Epd4in2}, graphics::{Display, DisplayRotation, VarDisplay}, prelude::*, }; @@ -64,7 +64,7 @@ fn main() -> Result<(), std::io::Error> { let mut delay = Delay {}; let mut epd4in2 = - EPD4in2::new(&mut spi, cs, busy, dc, rst, &mut delay).expect("eink initalize error"); + Epd4in2::new(&mut spi, cs, busy, dc, rst, &mut delay).expect("eink initalize error"); println!("Test all the rotations"); diff --git a/src/epd1in54/mod.rs b/src/epd1in54/mod.rs index 99f0d4c..315899b 100644 --- a/src/epd1in54/mod.rs +++ b/src/epd1in54/mod.rs @@ -20,7 +20,7 @@ //!# let mut delay = delay::MockNoop::new(); //! //!// Setup EPD -//!let mut epd = EPD1in54::new(&mut spi, cs_pin, busy_in, dc, rst, &mut delay)?; +//!let mut epd = Epd1in54::new(&mut spi, cs_pin, busy_in, dc, rst, &mut delay)?; //! //!// Use display graphics from embedded-graphics //!let mut display = Display1in54::default(); @@ -61,7 +61,7 @@ use crate::type_a::{ use crate::color::Color; -use crate::traits::{RefreshLUT, WaveshareDisplay}; +use crate::traits::{RefreshLut, WaveshareDisplay}; use crate::interface::DisplayInterface; @@ -70,18 +70,18 @@ mod graphics; #[cfg(feature = "graphics")] pub use crate::epd1in54::graphics::Display1in54; -/// EPD1in54 driver +/// Epd1in54 driver /// -pub struct EPD1in54 { +pub struct Epd1in54 { /// SPI interface: DisplayInterface, /// Color background_color: Color, /// Refresh LUT - refresh: RefreshLUT, + refresh: RefreshLut, } -impl EPD1in54 +impl Epd1in54 where SPI: Write, CS: OutputPin, @@ -140,7 +140,7 @@ where } impl WaveshareDisplay - for EPD1in54 + for Epd1in54 where SPI: Write, CS: OutputPin, @@ -167,10 +167,10 @@ where ) -> Result { let interface = DisplayInterface::new(cs, busy, dc, rst); - let mut epd = EPD1in54 { + let mut epd = Epd1in54 { interface, background_color: DEFAULT_BACKGROUND_COLOR, - refresh: RefreshLUT::FULL, + refresh: RefreshLut::Full, }; epd.init(spi, delay)?; @@ -232,7 +232,7 @@ where self.interface.cmd(spi, Command::MasterActivation)?; // MASTER Activation should not be interupted to avoid currption of panel images // therefore a terminate command is send - self.interface.cmd(spi, Command::NOP)?; + self.interface.cmd(spi, Command::Nop)?; Ok(()) } @@ -266,14 +266,14 @@ where fn set_lut( &mut self, spi: &mut SPI, - refresh_rate: Option, + refresh_rate: Option, ) -> Result<(), SPI::Error> { if let Some(refresh_lut) = refresh_rate { self.refresh = refresh_lut; } match self.refresh { - RefreshLUT::FULL => self.set_lut_helper(spi, &LUT_FULL_UPDATE), - RefreshLUT::QUICK => self.set_lut_helper(spi, &LUT_PARTIAL_UPDATE), + RefreshLut::Full => self.set_lut_helper(spi, &LUT_FULL_UPDATE), + RefreshLut::Quick => self.set_lut_helper(spi, &LUT_PARTIAL_UPDATE), } } @@ -282,7 +282,7 @@ where } } -impl EPD1in54 +impl Epd1in54 where SPI: Write, CS: OutputPin, diff --git a/src/epd1in54b/command.rs b/src/epd1in54b/command.rs index 392fd19..fd1e35d 100644 --- a/src/epd1in54b/command.rs +++ b/src/epd1in54b/command.rs @@ -24,7 +24,7 @@ pub(crate) enum Command { LutRed1 = 0x27, PllControl = 0x30, - TemperatureSensorCommand = 0x40, + TemperatureSensor = 0x40, TemperatureSensorSelection = 0x41, VcomAndDataIntervalSetting = 0x50, ResolutionSetting = 0x61, diff --git a/src/epd1in54b/mod.rs b/src/epd1in54b/mod.rs index 25a5b48..0f871ba 100644 --- a/src/epd1in54b/mod.rs +++ b/src/epd1in54b/mod.rs @@ -7,7 +7,7 @@ use embedded_hal::{ use crate::interface::DisplayInterface; use crate::traits::{ - InternalWiAdditions, RefreshLUT, WaveshareDisplay, WaveshareThreeColorDisplay, + InternalWiAdditions, RefreshLut, WaveshareDisplay, WaveshareThreeColorDisplay, }; //The Lookup Tables for the Display @@ -32,14 +32,14 @@ mod graphics; #[cfg(feature = "graphics")] pub use self::graphics::Display1in54b; -/// EPD1in54b driver -pub struct EPD1in54b { +/// Epd1in54b driver +pub struct Epd1in54b { interface: DisplayInterface, color: Color, } impl InternalWiAdditions - for EPD1in54b + for Epd1in54b where SPI: Write, CS: OutputPin, @@ -89,7 +89,7 @@ where } impl WaveshareThreeColorDisplay - for EPD1in54b + for Epd1in54b where SPI: Write, CS: OutputPin, @@ -132,7 +132,7 @@ where } impl WaveshareDisplay - for EPD1in54b + for Epd1in54b where SPI: Write, CS: OutputPin, @@ -152,7 +152,7 @@ where let interface = DisplayInterface::new(cs, busy, dc, rst); let color = DEFAULT_BACKGROUND_COLOR; - let mut epd = EPD1in54b { interface, color }; + let mut epd = Epd1in54b { interface, color }; epd.init(spi, delay)?; @@ -165,7 +165,7 @@ where .cmd_with_data(spi, Command::VcomAndDataIntervalSetting, &[0x17])?; //border floating self.interface - .cmd_with_data(spi, Command::VcmDcSetting, &[0x00])?; // VCOM to 0V + .cmd_with_data(spi, Command::VcmDcSetting, &[0x00])?; // Vcom to 0V self.interface .cmd_with_data(spi, Command::PowerSetting, &[0x02, 0x00, 0x00, 0x00])?; //VG&VS to 0V fast @@ -276,7 +276,7 @@ where fn set_lut( &mut self, spi: &mut SPI, - _refresh_rate: Option, + _refresh_rate: Option, ) -> Result<(), SPI::Error> { self.interface .cmd_with_data(spi, Command::LutForVcom, LUT_VCOM0)?; @@ -301,7 +301,7 @@ where } } -impl EPD1in54b +impl Epd1in54b where SPI: Write, CS: OutputPin, diff --git a/src/epd1in54c/command.rs b/src/epd1in54c/command.rs index eef7aec..5913986 100644 --- a/src/epd1in54c/command.rs +++ b/src/epd1in54c/command.rs @@ -22,7 +22,7 @@ pub(crate) enum Command { LutBlackToBlack = 0x24, PllControl = 0x30, - TemperatureSensorCommand = 0x40, + TemperatureSensor = 0x40, TemperatureSensorSelection = 0x41, VcomAndDataIntervalSetting = 0x50, ResolutionSetting = 0x61, diff --git a/src/epd1in54c/mod.rs b/src/epd1in54c/mod.rs index 77b5325..6ff0508 100644 --- a/src/epd1in54c/mod.rs +++ b/src/epd1in54c/mod.rs @@ -7,7 +7,7 @@ use embedded_hal::{ use crate::interface::DisplayInterface; use crate::traits::{ - InternalWiAdditions, RefreshLUT, WaveshareDisplay, WaveshareThreeColorDisplay, + InternalWiAdditions, RefreshLut, WaveshareDisplay, WaveshareThreeColorDisplay, }; /// Width of epd1in54 in pixels @@ -30,14 +30,14 @@ mod graphics; #[cfg(feature = "graphics")] pub use self::graphics::Display1in54c; -/// EPD1in54c driver -pub struct EPD1in54c { +/// Epd1in54c driver +pub struct Epd1in54c { interface: DisplayInterface, color: Color, } impl InternalWiAdditions - for EPD1in54c + for Epd1in54c where SPI: Write, CS: OutputPin, @@ -77,7 +77,7 @@ where } impl WaveshareThreeColorDisplay - for EPD1in54c + for Epd1in54c where SPI: Write, CS: OutputPin, @@ -115,7 +115,7 @@ where } impl WaveshareDisplay - for EPD1in54c + for Epd1in54c where SPI: Write, CS: OutputPin, @@ -135,7 +135,7 @@ where let interface = DisplayInterface::new(cs, busy, dc, rst); let color = DEFAULT_BACKGROUND_COLOR; - let mut epd = EPD1in54c { interface, color }; + let mut epd = Epd1in54c { interface, color }; epd.init(spi, delay)?; @@ -233,7 +233,7 @@ where fn set_lut( &mut self, _spi: &mut SPI, - _refresh_rate: Option, + _refresh_rate: Option, ) -> Result<(), SPI::Error> { Ok(()) } @@ -243,7 +243,7 @@ where } } -impl EPD1in54c +impl Epd1in54c where SPI: Write, CS: OutputPin, diff --git a/src/epd2in13_v2/command.rs b/src/epd2in13_v2/command.rs index e94c43e..850fd16 100644 --- a/src/epd2in13_v2/command.rs +++ b/src/epd2in13_v2/command.rs @@ -5,7 +5,7 @@ use crate::traits; extern crate bit_field; use bit_field::BitField; -/// EPD2in13 v2 +/// Epd2in13 v2 /// /// For more infos about the addresses and what they are doing look into the pdfs #[allow(dead_code)] @@ -54,7 +54,7 @@ pub(crate) enum Command { SetAnalogBlockControl = 0x74, SetDigitalBlockControl = 0x7E, - NOP = 0x7F, + Nop = 0x7F, } pub(crate) struct DriverOutput { @@ -151,34 +151,34 @@ pub(crate) enum DataEntryModeDir { #[allow(dead_code)] #[derive(Copy, Clone)] -pub(crate) enum BorderWaveFormVBD { - GS = 0x0, +pub(crate) enum BorderWaveFormVbd { + Gs = 0x0, FixLevel = 0x1, - VCOM = 0x2, + Vcom = 0x2, } #[allow(dead_code)] #[derive(Copy, Clone)] pub(crate) enum BorderWaveFormFixLevel { - VSS = 0x0, - VSH1 = 0x1, - VSL = 0x2, - VSH2 = 0x3, + Vss = 0x0, + Vsh1 = 0x1, + Vsl = 0x2, + Vsh2 = 0x3, } #[allow(dead_code)] #[derive(Copy, Clone)] -pub(crate) enum BorderWaveFormGS { - LUT0 = 0x0, - LUT1 = 0x1, - LUT2 = 0x2, - LUT3 = 0x3, +pub(crate) enum BorderWaveFormGs { + Lut0 = 0x0, + Lut1 = 0x1, + Lut2 = 0x2, + Lut3 = 0x3, } pub(crate) struct BorderWaveForm { - pub vbd: BorderWaveFormVBD, + pub vbd: BorderWaveFormVbd, pub fix_level: BorderWaveFormFixLevel, - pub gs_trans: BorderWaveFormGS, + pub gs_trans: BorderWaveFormGs, } impl BorderWaveForm { @@ -204,10 +204,10 @@ pub enum DeepSleepMode { pub(crate) struct GateDrivingVoltage(pub u8); pub(crate) struct SourceDrivingVoltage(pub u8); -pub(crate) struct VCOM(pub u8); +pub(crate) struct Vcom(pub u8); pub(crate) trait I32Ext { - fn vcom(self) -> VCOM; + fn vcom(self) -> Vcom; fn gate_driving_decivolt(self) -> GateDrivingVoltage; fn source_driving_decivolt(self) -> SourceDrivingVoltage; } @@ -215,7 +215,7 @@ pub(crate) trait I32Ext { impl I32Ext for i32 { // This is really not very nice. Until I find something better, this will be // a placeholder. - fn vcom(self) -> VCOM { + fn vcom(self) -> Vcom { assert!((-30..=-2).contains(&self)); let u = match -self { 2 => 0x08, @@ -249,7 +249,7 @@ impl I32Ext for i32 { 30 => 0x78, _ => 0, }; - VCOM(u) + Vcom(u) } fn gate_driving_decivolt(self) -> GateDrivingVoltage { diff --git a/src/epd2in13_v2/mod.rs b/src/epd2in13_v2/mod.rs index cd5481d..4705c1f 100644 --- a/src/epd2in13_v2/mod.rs +++ b/src/epd2in13_v2/mod.rs @@ -16,13 +16,13 @@ use embedded_hal::{ use crate::buffer_len; use crate::color::Color; use crate::interface::DisplayInterface; -use crate::traits::{InternalWiAdditions, RefreshLUT, WaveshareDisplay}; +use crate::traits::{InternalWiAdditions, RefreshLut, WaveshareDisplay}; pub(crate) mod command; use self::command::{ - BorderWaveForm, BorderWaveFormFixLevel, BorderWaveFormGS, BorderWaveFormVBD, Command, + BorderWaveForm, BorderWaveFormFixLevel, BorderWaveFormGs, BorderWaveFormVbd, Command, DataEntryModeDir, DataEntryModeIncr, DeepSleepMode, DisplayUpdateControl2, DriverOutput, - GateDrivingVoltage, I32Ext, SourceDrivingVoltage, VCOM, + GateDrivingVoltage, I32Ext, SourceDrivingVoltage, Vcom, }; pub(crate) mod constants; @@ -43,9 +43,9 @@ pub const HEIGHT: u32 = 250; pub const DEFAULT_BACKGROUND_COLOR: Color = Color::White; const IS_BUSY_LOW: bool = false; -/// EPD2in13 (V2) driver +/// Epd2in13 (V2) driver /// -pub struct EPD2in13 { +pub struct Epd2in13 { /// Connection Interface interface: DisplayInterface, @@ -53,11 +53,11 @@ pub struct EPD2in13 { /// Background Color background_color: Color, - refresh: RefreshLUT, + refresh: RefreshLut, } impl InternalWiAdditions - for EPD2in13 + for Epd2in13 where SPI: Write, CS: OutputPin, @@ -73,7 +73,7 @@ where // HW reset self.interface.reset(delay, 10); - if self.refresh == RefreshLUT::QUICK { + if self.refresh == RefreshLut::Quick { self.set_vcom_register(spi, (-9).vcom())?; self.wait_until_idle(); @@ -94,9 +94,9 @@ where self.set_border_waveform( spi, BorderWaveForm { - vbd: BorderWaveFormVBD::GS, - fix_level: BorderWaveFormFixLevel::VSS, - gs_trans: BorderWaveFormGS::LUT1, + vbd: BorderWaveFormVbd::Gs, + fix_level: BorderWaveFormFixLevel::Vss, + gs_trans: BorderWaveFormGs::Lut1, }, )?; } else { @@ -127,9 +127,9 @@ where self.set_border_waveform( spi, BorderWaveForm { - vbd: BorderWaveFormVBD::GS, - fix_level: BorderWaveFormFixLevel::VSS, - gs_trans: BorderWaveFormGS::LUT3, + vbd: BorderWaveFormVbd::Gs, + fix_level: BorderWaveFormFixLevel::Vss, + gs_trans: BorderWaveFormGs::Lut3, }, )?; @@ -154,7 +154,7 @@ where } impl WaveshareDisplay - for EPD2in13 + for Epd2in13 where SPI: Write, CS: OutputPin, @@ -171,11 +171,11 @@ where rst: RST, delay: &mut DELAY, ) -> Result { - let mut epd = EPD2in13 { + let mut epd = Epd2in13 { interface: DisplayInterface::new(cs, busy, dc, rst), sleep_mode: DeepSleepMode::Mode1, background_color: DEFAULT_BACKGROUND_COLOR, - refresh: RefreshLUT::FULL, + refresh: RefreshLut::Full, }; epd.init(spi, delay)?; @@ -215,7 +215,7 @@ where self.cmd_with_data(spi, Command::WriteRam, buffer)?; - if self.refresh == RefreshLUT::FULL { + if self.refresh == RefreshLut::Full { // Always keep the base buffer equal to current if not doing partial refresh. self.set_ram_area(spi, 0, 0, WIDTH - 1, HEIGHT - 1)?; self.set_ram_address_counters(spi, 0, 0)?; @@ -245,14 +245,14 @@ where // RAM content). Using this function will most probably make the actual // display incorrect as the controler will compare with something // incorrect. - assert!(self.refresh == RefreshLUT::FULL); + assert!(self.refresh == RefreshLut::Full); self.set_ram_area(spi, x, y, x + width, y + height)?; self.set_ram_address_counters(spi, x, y)?; self.cmd_with_data(spi, Command::WriteRam, buffer)?; - if self.refresh == RefreshLUT::FULL { + if self.refresh == RefreshLut::Full { // Always keep the base buffer equals to current if not doing partial refresh. self.set_ram_area(spi, x, y, x + width, y + height)?; self.set_ram_address_counters(spi, x, y)?; @@ -266,7 +266,7 @@ where /// Never use directly this function when using partial refresh, or also /// keep the base buffer in syncd using `set_partial_base_buffer` function. fn display_frame(&mut self, spi: &mut SPI) -> Result<(), SPI::Error> { - if self.refresh == RefreshLUT::FULL { + if self.refresh == RefreshLut::Full { self.set_display_update_control_2( spi, DisplayUpdateControl2::new() @@ -289,7 +289,7 @@ where self.update_frame(spi, buffer)?; self.display_frame(spi)?; - if self.refresh == RefreshLUT::QUICK { + if self.refresh == RefreshLut::Quick { self.set_partial_base_buffer(spi, buffer)?; } Ok(()) @@ -309,7 +309,7 @@ where )?; // Always keep the base buffer equals to current if not doing partial refresh. - if self.refresh == RefreshLUT::FULL { + if self.refresh == RefreshLut::Full { self.set_ram_area(spi, 0, 0, WIDTH - 1, HEIGHT - 1)?; self.set_ram_address_counters(spi, 0, 0)?; @@ -342,11 +342,11 @@ where fn set_lut( &mut self, spi: &mut SPI, - refresh_rate: Option, + refresh_rate: Option, ) -> Result<(), SPI::Error> { let buffer = match refresh_rate { - Some(RefreshLUT::FULL) | None => &LUT_FULL_UPDATE, - Some(RefreshLUT::QUICK) => &LUT_PARTIAL_UPDATE, + Some(RefreshLut::Full) | None => &LUT_FULL_UPDATE, + Some(RefreshLut::Quick) => &LUT_PARTIAL_UPDATE, }; self.cmd_with_data(spi, Command::WriteLutRegister, buffer) @@ -357,7 +357,7 @@ where } } -impl EPD2in13 +impl Epd2in13 where SPI: Write, CS: OutputPin, @@ -391,7 +391,7 @@ where &mut self, spi: &mut SPI, delay: &mut DELAY, - refresh: RefreshLUT, + refresh: RefreshLut, ) -> Result<(), SPI::Error> { if self.refresh != refresh { self.refresh = refresh; @@ -425,7 +425,7 @@ where ) } - fn set_vcom_register(&mut self, spi: &mut SPI, vcom: VCOM) -> Result<(), SPI::Error> { + fn set_vcom_register(&mut self, spi: &mut SPI, vcom: Vcom) -> Result<(), SPI::Error> { self.cmd_with_data(spi, Command::WriteVcomRegister, &[vcom.0]) } diff --git a/src/epd2in7b/command.rs b/src/epd2in7b/command.rs index b228d22..e32365c 100644 --- a/src/epd2in7b/command.rs +++ b/src/epd2in7b/command.rs @@ -71,7 +71,7 @@ pub(crate) enum Command { /// This command reads the temperature sensed by the temperature sensor. /// /// Doesn't work! Waveshare doesn't connect the read pin - TemperatureSensorCommand = 0x40, + TemperatureSensor = 0x40, /// This command selects Internal or External temperature sensor. TemperatureSensorCalibration = 0x41, /// Write External Temperature Sensor diff --git a/src/epd2in7b/mod.rs b/src/epd2in7b/mod.rs index 37ae3b5..cbe07fe 100644 --- a/src/epd2in7b/mod.rs +++ b/src/epd2in7b/mod.rs @@ -9,7 +9,7 @@ use embedded_hal::{ use crate::interface::DisplayInterface; use crate::traits::{ - InternalWiAdditions, RefreshLUT, WaveshareDisplay, WaveshareThreeColorDisplay, + InternalWiAdditions, RefreshLut, WaveshareDisplay, WaveshareThreeColorDisplay, }; // The Lookup Tables for the Display @@ -34,8 +34,8 @@ mod graphics; #[cfg(feature = "graphics")] pub use self::graphics::Display2in7b; -/// EPD2in7b driver -pub struct EPD2in7b { +/// Epd2in7b driver +pub struct Epd2in7b { /// Connection Interface interface: DisplayInterface, /// Background Color @@ -43,7 +43,7 @@ pub struct EPD2in7b { } impl InternalWiAdditions - for EPD2in7b + for Epd2in7b where SPI: Write, CS: OutputPin, @@ -112,7 +112,7 @@ where } impl WaveshareDisplay - for EPD2in7b + for Epd2in7b where SPI: Write, CS: OutputPin, @@ -132,7 +132,7 @@ where let interface = DisplayInterface::new(cs, busy, dc, rst); let color = DEFAULT_BACKGROUND_COLOR; - let mut epd = EPD2in7b { interface, color }; + let mut epd = Epd2in7b { interface, color }; epd.init(spi, delay)?; @@ -247,7 +247,7 @@ where fn set_lut( &mut self, spi: &mut SPI, - _refresh_rate: Option, + _refresh_rate: Option, ) -> Result<(), SPI::Error> { self.wait_until_idle(); self.cmd_with_data(spi, Command::LutForVcom, &LUT_VCOM_DC)?; @@ -264,7 +264,7 @@ where } impl WaveshareThreeColorDisplay - for EPD2in7b + for Epd2in7b where SPI: Write, CS: OutputPin, @@ -316,7 +316,7 @@ where } } -impl EPD2in7b +impl Epd2in7b where SPI: Write, CS: OutputPin, diff --git a/src/epd2in9/mod.rs b/src/epd2in9/mod.rs index 99d003c..8658789 100644 --- a/src/epd2in9/mod.rs +++ b/src/epd2in9/mod.rs @@ -21,7 +21,7 @@ //!# let mut delay = delay::MockNoop::new(); //! //!// Setup EPD -//!let mut epd = EPD2in9::new(&mut spi, cs_pin, busy_in, dc, rst, &mut delay)?; +//!let mut epd = Epd2in9::new(&mut spi, cs_pin, busy_in, dc, rst, &mut delay)?; //! //!// Use display graphics from embedded-graphics //!let mut display = Display2in9::default(); @@ -70,18 +70,18 @@ mod graphics; #[cfg(feature = "graphics")] pub use crate::epd2in9::graphics::Display2in9; -/// EPD2in9 driver +/// Epd2in9 driver /// -pub struct EPD2in9 { +pub struct Epd2in9 { /// SPI interface: DisplayInterface, /// Color background_color: Color, /// Refresh LUT - refresh: RefreshLUT, + refresh: RefreshLut, } -impl EPD2in9 +impl Epd2in9 where SPI: Write, CS: OutputPin, @@ -136,7 +136,7 @@ where } impl WaveshareDisplay - for EPD2in9 + for Epd2in9 where SPI: Write, CS: OutputPin, @@ -163,10 +163,10 @@ where ) -> Result { let interface = DisplayInterface::new(cs, busy, dc, rst); - let mut epd = EPD2in9 { + let mut epd = Epd2in9 { interface, background_color: DEFAULT_BACKGROUND_COLOR, - refresh: RefreshLUT::FULL, + refresh: RefreshLut::Full, }; epd.init(spi, delay)?; @@ -231,7 +231,7 @@ where self.interface.cmd(spi, Command::MasterActivation)?; // MASTER Activation should not be interupted to avoid currption of panel images // therefore a terminate command is send - self.interface.cmd(spi, Command::NOP)?; + self.interface.cmd(spi, Command::Nop)?; Ok(()) } @@ -265,14 +265,14 @@ where fn set_lut( &mut self, spi: &mut SPI, - refresh_rate: Option, + refresh_rate: Option, ) -> Result<(), SPI::Error> { if let Some(refresh_lut) = refresh_rate { self.refresh = refresh_lut; } match self.refresh { - RefreshLUT::FULL => self.set_lut_helper(spi, &LUT_FULL_UPDATE), - RefreshLUT::QUICK => self.set_lut_helper(spi, &LUT_PARTIAL_UPDATE), + RefreshLut::Full => self.set_lut_helper(spi, &LUT_FULL_UPDATE), + RefreshLut::Quick => self.set_lut_helper(spi, &LUT_PARTIAL_UPDATE), } } @@ -281,7 +281,7 @@ where } } -impl EPD2in9 +impl Epd2in9 where SPI: Write, CS: OutputPin, diff --git a/src/epd2in9bc/command.rs b/src/epd2in9bc/command.rs index 9414c5a..7121c50 100644 --- a/src/epd2in9bc/command.rs +++ b/src/epd2in9bc/command.rs @@ -22,7 +22,7 @@ pub(crate) enum Command { LutBlackToBlack = 0x24, PllControl = 0x30, - TemperatureSensorCommand = 0x40, + TemperatureSensor = 0x40, TemperatureSensorSelection = 0x41, VcomAndDataIntervalSetting = 0x50, ResolutionSetting = 0x61, diff --git a/src/epd2in9bc/mod.rs b/src/epd2in9bc/mod.rs index 6f76602..ff8face 100644 --- a/src/epd2in9bc/mod.rs +++ b/src/epd2in9bc/mod.rs @@ -20,7 +20,7 @@ //!# let mut delay = delay::MockNoop::new(); //! //!// Setup EPD -//!let mut epd = EPD2in9bc::new(&mut spi, cs_pin, busy_in, dc, rst, &mut delay)?; +//!let mut epd = Epd2in9bc::new(&mut spi, cs_pin, busy_in, dc, rst, &mut delay)?; //! //!// Use display graphics from embedded-graphics //!// This display is for the black/white pixels @@ -60,7 +60,7 @@ use embedded_hal::{ use crate::interface::DisplayInterface; use crate::traits::{ - InternalWiAdditions, RefreshLUT, WaveshareDisplay, WaveshareThreeColorDisplay, + InternalWiAdditions, RefreshLut, WaveshareDisplay, WaveshareThreeColorDisplay, }; /// Width of epd2in9bc in pixels @@ -89,14 +89,14 @@ mod graphics; #[cfg(feature = "graphics")] pub use self::graphics::Display2in9bc; -/// EPD2in9bc driver -pub struct EPD2in9bc { +/// Epd2in9bc driver +pub struct Epd2in9bc { interface: DisplayInterface, color: Color, } impl InternalWiAdditions - for EPD2in9bc + for Epd2in9bc where SPI: Write, CS: OutputPin, @@ -143,7 +143,7 @@ where } impl WaveshareThreeColorDisplay - for EPD2in9bc + for Epd2in9bc where SPI: Write, CS: OutputPin, @@ -187,7 +187,7 @@ where } impl WaveshareDisplay - for EPD2in9bc + for Epd2in9bc where SPI: Write, CS: OutputPin, @@ -207,7 +207,7 @@ where let interface = DisplayInterface::new(cs, busy, dc, rst); let color = DEFAULT_BACKGROUND_COLOR; - let mut epd = EPD2in9bc { interface, color }; + let mut epd = Epd2in9bc { interface, color }; epd.init(spi, delay)?; @@ -317,7 +317,7 @@ where fn set_lut( &mut self, _spi: &mut SPI, - _refresh_rate: Option, + _refresh_rate: Option, ) -> Result<(), SPI::Error> { Ok(()) } @@ -327,7 +327,7 @@ where } } -impl EPD2in9bc +impl Epd2in9bc where SPI: Write, CS: OutputPin, diff --git a/src/epd4in2/command.rs b/src/epd4in2/command.rs index 3a31a69..4d3a9fe 100644 --- a/src/epd4in2/command.rs +++ b/src/epd4in2/command.rs @@ -92,7 +92,7 @@ pub(crate) enum Command { /// This command reads the temperature sensed by the temperature sensor. /// /// Doesn't work! Waveshare doesn't connect the read pin - TemperatureSensorCommand = 0x40, + TemperatureSensor = 0x40, /// Selects the Internal or External temperature sensor and offset TemperatureSensorSelection = 0x41, /// Write External Temperature Sensor @@ -114,7 +114,7 @@ pub(crate) enum Command { /// The LUT_REV / Chip Revision is read from OTP address = 0x001. /// /// Doesn't work! Waveshare doesn't connect the read pin - REVISION = 0x70, + Revision = 0x70, /// Read Flags. This command reads the IC status /// PTL, I2C_ERR, I2C_BUSY, DATA, PON, POF, BUSY /// diff --git a/src/epd4in2/mod.rs b/src/epd4in2/mod.rs index 4e155a5..2f75539 100644 --- a/src/epd4in2/mod.rs +++ b/src/epd4in2/mod.rs @@ -25,7 +25,7 @@ //!# let mut delay = delay::MockNoop::new(); //! //!// Setup EPD -//!let mut epd = EPD4in2::new(&mut spi, cs_pin, busy_in, dc, rst, &mut delay)?; +//!let mut epd = Epd4in2::new(&mut spi, cs_pin, busy_in, dc, rst, &mut delay)?; //! //!// Use display graphics from embedded-graphics //!let mut display = Display4in2::default(); @@ -55,7 +55,7 @@ use embedded_hal::{ }; use crate::interface::DisplayInterface; -use crate::traits::{InternalWiAdditions, QuickRefresh, RefreshLUT, WaveshareDisplay}; +use crate::traits::{InternalWiAdditions, QuickRefresh, RefreshLut, WaveshareDisplay}; //The Lookup Tables for the Display mod constants; @@ -79,19 +79,19 @@ mod graphics; #[cfg(feature = "graphics")] pub use self::graphics::Display4in2; -/// EPD4in2 driver +/// Epd4in2 driver /// -pub struct EPD4in2 { +pub struct Epd4in2 { /// Connection Interface interface: DisplayInterface, /// Background Color color: Color, /// Refresh LUT - refresh: RefreshLUT, + refresh: RefreshLut, } impl InternalWiAdditions - for EPD4in2 + for Epd4in2 where SPI: Write, CS: OutputPin, @@ -149,7 +149,7 @@ where } impl WaveshareDisplay - for EPD4in2 + for Epd4in2 where SPI: Write, CS: OutputPin, @@ -169,10 +169,10 @@ where let interface = DisplayInterface::new(cs, busy, dc, rst); let color = DEFAULT_BACKGROUND_COLOR; - let mut epd = EPD4in2 { + let mut epd = Epd4in2 { interface, color, - refresh: RefreshLUT::FULL, + refresh: RefreshLut::Full, }; epd.init(spi, delay)?; @@ -313,16 +313,16 @@ where fn set_lut( &mut self, spi: &mut SPI, - refresh_rate: Option, + refresh_rate: Option, ) -> Result<(), SPI::Error> { if let Some(refresh_lut) = refresh_rate { self.refresh = refresh_lut; } match self.refresh { - RefreshLUT::FULL => { + RefreshLut::Full => { self.set_lut_helper(spi, &LUT_VCOM0, &LUT_WW, &LUT_BW, &LUT_WB, &LUT_BB) } - RefreshLUT::QUICK => self.set_lut_helper( + RefreshLut::Quick => self.set_lut_helper( spi, &LUT_VCOM0_QUICK, &LUT_WW_QUICK, @@ -338,7 +338,7 @@ where } } -impl EPD4in2 +impl Epd4in2 where SPI: Write, CS: OutputPin, @@ -435,7 +435,7 @@ where } impl QuickRefresh - for EPD4in2 + for Epd4in2 where SPI: Write, CS: OutputPin, diff --git a/src/epd5in65f/command.rs b/src/epd5in65f/command.rs index 89af89e..23d2246 100644 --- a/src/epd5in65f/command.rs +++ b/src/epd5in65f/command.rs @@ -64,7 +64,7 @@ pub(crate) enum Command { DisplayRefresh = 0x12, /// Image Process Command - ImageProcessCommand = 0x13, + ImageProcess = 0x13, /// This command builds the VCOM Look-Up Table (LUTC). LutForVcom = 0x20, @@ -91,7 +91,7 @@ pub(crate) enum Command { PllControl = 0x30, /// This command reads the temperature sensed by the temperature sensor. - TemperatureSensorCommand = 0x40, + TemperatureSensor = 0x40, /// This command selects the Internal or External temperature sensor. TemperatureCalibration = 0x41, /// This command could write data to the external temperature sensor. @@ -115,7 +115,7 @@ pub(crate) enum Command { //SpiFlashControl = 0x65, /// The LUT_REV / Chip Revision is read from OTP address = 25001 and 25000. - //REVISION = 0x70, + //Revision = 0x70, /// This command reads the IC status. GetStatus = 0x71, diff --git a/src/epd5in65f/mod.rs b/src/epd5in65f/mod.rs index 6e8e7b4..9f94930 100644 --- a/src/epd5in65f/mod.rs +++ b/src/epd5in65f/mod.rs @@ -13,7 +13,7 @@ use embedded_hal::{ use crate::color::OctColor; use crate::interface::DisplayInterface; -use crate::traits::{InternalWiAdditions, RefreshLUT, WaveshareDisplay}; +use crate::traits::{InternalWiAdditions, RefreshLut, WaveshareDisplay}; pub(crate) mod command; use self::command::Command; @@ -31,9 +31,9 @@ pub const HEIGHT: u32 = 448; pub const DEFAULT_BACKGROUND_COLOR: OctColor = OctColor::White; const IS_BUSY_LOW: bool = true; -/// EPD5in65f driver +/// Epd5in65f driver /// -pub struct EPD5in65f { +pub struct Epd5in65f { /// Connection Interface interface: DisplayInterface, /// Background Color @@ -41,7 +41,7 @@ pub struct EPD5in65f { } impl InternalWiAdditions - for EPD5in65f + for Epd5in65f where SPI: Write, CS: OutputPin, @@ -62,7 +62,7 @@ where self.cmd_with_data(spi, Command::PowerOffSequenceSetting, &[0x00])?; self.cmd_with_data(spi, Command::BoosterSoftStart, &[0xC7, 0xC7, 0x1D])?; self.cmd_with_data(spi, Command::PllControl, &[0x3C])?; - self.cmd_with_data(spi, Command::TemperatureSensorCommand, &[0x00])?; + self.cmd_with_data(spi, Command::TemperatureSensor, &[0x00])?; self.cmd_with_data(spi, Command::VcomAndDataIntervalSetting, &[0x37])?; self.cmd_with_data(spi, Command::TconSetting, &[0x22])?; self.send_resolution(spi)?; @@ -77,7 +77,7 @@ where } impl WaveshareDisplay - for EPD5in65f + for Epd5in65f where SPI: Write, CS: OutputPin, @@ -97,7 +97,7 @@ where let interface = DisplayInterface::new(cs, busy, dc, rst); let color = DEFAULT_BACKGROUND_COLOR; - let mut epd = EPD5in65f { interface, color }; + let mut epd = Epd5in65f { interface, color }; epd.init(spi, delay)?; @@ -182,7 +182,7 @@ where fn set_lut( &mut self, _spi: &mut SPI, - _refresh_rate: Option, + _refresh_rate: Option, ) -> Result<(), SPI::Error> { unimplemented!(); } @@ -192,7 +192,7 @@ where } } -impl EPD5in65f +impl Epd5in65f where SPI: Write, CS: OutputPin, diff --git a/src/epd7in5/command.rs b/src/epd7in5/command.rs index cb1aa1c..8615269 100644 --- a/src/epd7in5/command.rs +++ b/src/epd7in5/command.rs @@ -2,7 +2,7 @@ use crate::traits; -/// EPD7in5 commands +/// Epd7in5 commands /// /// Should rarely (never?) be needed directly. /// @@ -93,7 +93,7 @@ pub(crate) enum Command { PllControl = 0x30, /// This command reads the temperature sensed by the temperature sensor. - TemperatureSensorCommand = 0x40, + TemperatureSensor = 0x40, /// This command selects the Internal or External temperature sensor. TemperatureCalibration = 0x41, /// This command could write data to the external temperature sensor. @@ -117,7 +117,7 @@ pub(crate) enum Command { SpiFlashControl = 0x65, /// The LUT_REV / Chip Revision is read from OTP address = 25001 and 25000. - REVISION = 0x70, + Revision = 0x70, /// This command reads the IC status. GetStatus = 0x71, @@ -128,7 +128,7 @@ pub(crate) enum Command { /// This command sets `VCOM_DC` value. VcmDcSetting = 0x82, - /// This is in all the Waveshare controllers for EPD7in5, but it's not documented + /// This is in all the Waveshare controllers for Epd7in5, but it's not documented /// anywhere in the datasheet `¯\_(ツ)_/¯` FlashMode = 0xE5, } diff --git a/src/epd7in5/mod.rs b/src/epd7in5/mod.rs index 16d902a..c93bf1e 100644 --- a/src/epd7in5/mod.rs +++ b/src/epd7in5/mod.rs @@ -13,7 +13,7 @@ use embedded_hal::{ use crate::color::Color; use crate::interface::DisplayInterface; -use crate::traits::{InternalWiAdditions, RefreshLUT, WaveshareDisplay}; +use crate::traits::{InternalWiAdditions, RefreshLut, WaveshareDisplay}; pub(crate) mod command; use self::command::Command; @@ -31,9 +31,9 @@ pub const HEIGHT: u32 = 384; pub const DEFAULT_BACKGROUND_COLOR: Color = Color::White; const IS_BUSY_LOW: bool = true; -/// EPD7in5 driver +/// Epd7in5 driver /// -pub struct EPD7in5 { +pub struct Epd7in5 { /// Connection Interface interface: DisplayInterface, /// Background Color @@ -41,7 +41,7 @@ pub struct EPD7in5 { } impl InternalWiAdditions - for EPD7in5 + for Epd7in5 where SPI: Write, CS: OutputPin, @@ -91,7 +91,7 @@ where // Set VCOM_DC to -1.5V self.cmd_with_data(spi, Command::VcmDcSetting, &[0x1E])?; - // This is in all the Waveshare controllers for EPD7in5 + // This is in all the Waveshare controllers for Epd7in5 self.cmd_with_data(spi, Command::FlashMode, &[0x03])?; self.wait_until_idle(); @@ -100,7 +100,7 @@ where } impl WaveshareDisplay - for EPD7in5 + for Epd7in5 where SPI: Write, CS: OutputPin, @@ -120,7 +120,7 @@ where let interface = DisplayInterface::new(cs, busy, dc, rst); let color = DEFAULT_BACKGROUND_COLOR; - let mut epd = EPD7in5 { interface, color }; + let mut epd = Epd7in5 { interface, color }; epd.init(spi, delay)?; @@ -214,7 +214,7 @@ where fn set_lut( &mut self, _spi: &mut SPI, - _refresh_rate: Option, + _refresh_rate: Option, ) -> Result<(), SPI::Error> { unimplemented!(); } @@ -224,7 +224,7 @@ where } } -impl EPD7in5 +impl Epd7in5 where SPI: Write, CS: OutputPin, diff --git a/src/epd7in5_v2/command.rs b/src/epd7in5_v2/command.rs index 599c080..95292d3 100644 --- a/src/epd7in5_v2/command.rs +++ b/src/epd7in5_v2/command.rs @@ -2,7 +2,7 @@ use crate::traits; -/// EPD7in5 commands +/// Epd7in5 commands /// /// Should rarely (never?) be needed directly. /// @@ -94,7 +94,7 @@ pub(crate) enum Command { PllControl = 0x30, /// This command reads the temperature sensed by the temperature sensor. - TemperatureSensorCommand = 0x40, + TemperatureSensor = 0x40, /// This command selects the Internal or External temperature sensor. TemperatureCalibration = 0x41, /// This command could write data to the external temperature sensor. @@ -118,7 +118,7 @@ pub(crate) enum Command { SpiFlashControl = 0x65, /// The LUT_REV / Chip Revision is read from OTP address = 25001 and 25000. - REVISION = 0x70, + Revision = 0x70, /// This command reads the IC status. GetStatus = 0x71, @@ -128,7 +128,7 @@ pub(crate) enum Command { ReadVcomValue = 0x81, /// This command sets `VCOM_DC` value. VcmDcSetting = 0x82, - // /// This is in all the Waveshare controllers for EPD7in5, but it's not documented + // /// This is in all the Waveshare controllers for Epd7in5, but it's not documented // /// anywhere in the datasheet `¯\_(ツ)_/¯` // FlashMode = 0xE5, } diff --git a/src/epd7in5_v2/mod.rs b/src/epd7in5_v2/mod.rs index e4c60e0..b3ab5de 100644 --- a/src/epd7in5_v2/mod.rs +++ b/src/epd7in5_v2/mod.rs @@ -17,7 +17,7 @@ use embedded_hal::{ use crate::color::Color; use crate::interface::DisplayInterface; -use crate::traits::{InternalWiAdditions, RefreshLUT, WaveshareDisplay}; +use crate::traits::{InternalWiAdditions, RefreshLut, WaveshareDisplay}; pub(crate) mod command; use self::command::Command; @@ -35,9 +35,9 @@ pub const HEIGHT: u32 = 480; pub const DEFAULT_BACKGROUND_COLOR: Color = Color::White; const IS_BUSY_LOW: bool = true; -/// EPD7in5 (V2) driver +/// Epd7in5 (V2) driver /// -pub struct EPD7in5 { +pub struct Epd7in5 { /// Connection Interface interface: DisplayInterface, /// Background Color @@ -45,7 +45,7 @@ pub struct EPD7in5 { } impl InternalWiAdditions - for EPD7in5 + for Epd7in5 where SPI: Write, CS: OutputPin, @@ -82,7 +82,7 @@ where } impl WaveshareDisplay - for EPD7in5 + for Epd7in5 where SPI: Write, CS: OutputPin, @@ -102,7 +102,7 @@ where let interface = DisplayInterface::new(cs, busy, dc, rst); let color = DEFAULT_BACKGROUND_COLOR; - let mut epd = EPD7in5 { interface, color }; + let mut epd = Epd7in5 { interface, color }; epd.init(spi, delay)?; @@ -188,7 +188,7 @@ where fn set_lut( &mut self, _spi: &mut SPI, - _refresh_rate: Option, + _refresh_rate: Option, ) -> Result<(), SPI::Error> { unimplemented!(); } @@ -198,7 +198,7 @@ where } } -impl EPD7in5 +impl Epd7in5 where SPI: Write, CS: OutputPin, diff --git a/src/interface.rs b/src/interface.rs index 58fbebb..4ba1eb3 100644 --- a/src/interface.rs +++ b/src/interface.rs @@ -51,7 +51,7 @@ where /// Basic function for sending an array of u8-values of data over spi /// - /// Enables direct interaction with the device with the help of [command()](EPD4in2::command()) + /// Enables direct interaction with the device with the help of [command()](Epd4in2::command()) pub(crate) fn data(&mut self, spi: &mut SPI, data: &[u8]) -> Result<(), SPI::Error> { // high for data let _ = self.dc.set_high(); @@ -157,7 +157,7 @@ where /// Resets the device. /// - /// Often used to awake the module from deep sleep. See [EPD4in2::sleep()](EPD4in2::sleep()) + /// Often used to awake the module from deep sleep. See [Epd4in2::sleep()](Epd4in2::sleep()) /// /// The timing of keeping the reset pin low seems to be important and different per device. /// Most displays seem to require keeping it low for 10ms, but the 7in5_v2 only seems to reset diff --git a/src/lib.rs b/src/lib.rs index 60a816e..b96e6fe 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -28,7 +28,7 @@ //!# let mut delay = delay::MockNoop::new(); //! //!// Setup EPD -//!let mut epd = EPD1in54::new(&mut spi, cs_pin, busy_in, dc, rst, &mut delay)?; +//!let mut epd = Epd1in54::new(&mut spi, cs_pin, busy_in, dc, rst, &mut delay)?; //! //!// Use display graphics from embedded-graphics //!let mut display = Display1in54::default(); @@ -90,7 +90,7 @@ pub(crate) mod type_a; pub mod prelude { pub use crate::color::{Color, OctColor, TriColor}; pub use crate::traits::{ - QuickRefresh, RefreshLUT, WaveshareDisplay, WaveshareThreeColorDisplay, + QuickRefresh, RefreshLut, WaveshareDisplay, WaveshareThreeColorDisplay, }; pub use crate::SPI_MODE; diff --git a/src/traits.rs b/src/traits.rs index d4877b5..7c21c10 100644 --- a/src/traits.rs +++ b/src/traits.rs @@ -12,17 +12,17 @@ pub(crate) trait Command { /// Seperates the different LUT for the Display Refresh process #[derive(Debug, Clone, PartialEq, Eq, Copy)] -pub enum RefreshLUT { +pub enum RefreshLut { /// The "normal" full Lookuptable for the Refresh-Sequence - FULL, + Full, /// The quick LUT where not the full refresh sequence is followed. /// This might lead to some - QUICK, + Quick, } -impl Default for RefreshLUT { +impl Default for RefreshLut { fn default() -> Self { - RefreshLUT::FULL + RefreshLut::Full } } @@ -108,7 +108,7 @@ where ///# let mut delay = delay::MockNoop::new(); /// ///// Setup EPD -///let mut epd = EPD4in2::new(&mut spi, cs_pin, busy_in, dc, rst, &mut delay)?; +///let mut epd = Epd4in2::new(&mut spi, cs_pin, busy_in, dc, rst, &mut delay)?; /// ///// Use display graphics from embedded-graphics ///let mut display = Display4in2::default(); @@ -219,7 +219,7 @@ where fn set_lut( &mut self, spi: &mut SPI, - refresh_rate: Option, + refresh_rate: Option, ) -> Result<(), SPI::Error>; /// Checks if the display is busy transmitting data @@ -258,7 +258,7 @@ where ///# let mut delay = delay::MockNoop::new(); ///# ///# // Setup EPD -///# let mut epd = EPD4in2::new(&mut spi, cs_pin, busy_in, dc, rst, &mut delay)?; +///# let mut epd = Epd4in2::new(&mut spi, cs_pin, busy_in, dc, rst, &mut delay)?; ///let (x, y, frame_width, frame_height) = (20, 40, 80,80); /// ///let mut buffer = [DEFAULT_BACKGROUND_COLOR.get_byte_value(); 80 / 8 * 80]; diff --git a/src/type_a/command.rs b/src/type_a/command.rs index d12dd2c..71a106b 100644 --- a/src/type_a/command.rs +++ b/src/type_a/command.rs @@ -2,7 +2,7 @@ use crate::traits; -/// EPD1in54 and EPD2IN9 commands +/// Epd1in54 and EPD2IN9 commands /// /// Should rarely (never?) be needed directly. /// @@ -67,7 +67,7 @@ pub(crate) enum Command { SetRamYAddressCounter = 0x4F, - NOP = 0xFF, + Nop = 0xFF, } impl traits::Command for Command { @@ -88,6 +88,6 @@ mod tests { assert_eq!(Command::SetRamXAddressCounter.address(), 0x4E); - assert_eq!(Command::NOP.address(), 0xFF); + assert_eq!(Command::Nop.address(), 0xFF); } }