mirror of
https://github.com/Anshorei/epd-waveshare.git
synced 2026-10-03 22:06:43 +00:00
Removed #[allow(non_camel_case_types)] to fix issues
This commit is contained in:
+23
-24
@@ -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 {
|
||||
|
||||
+27
-27
@@ -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<RefreshLUT>,
|
||||
) -> 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])?;
|
||||
|
||||
Reference in New Issue
Block a user