Removed #[allow(non_camel_case_types)] to fix issues

This commit is contained in:
Caemor
2021-04-11 20:31:24 +02:00
parent 0567da80c0
commit ba1b90e2f3
21 changed files with 593 additions and 611 deletions
+39 -40
View File
@@ -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);
}
}
+18 -18
View File
@@ -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])?;