#![allow(clippy::doc_markdown)]
#![allow(clippy::match_same_arms)]
use display_interface::{DataFormat::U8, DisplayError, WriteOnlyDataCommand};
#[derive(Debug, Copy, Clone)]
pub enum Command {
SleepMode(Logical),
PartialMode,
NormalDisplayMode,
DisplayInversion(Logical),
DisplayState(Logical),
ColumnAddressSet(u16, u16),
RowAddressSet(u16, u16),
VertialScrollDef(u16, u16),
TearingEffectLine(Logical),
MemoryAccessControl(Logical, Logical, Logical, Logical, Logical, Logical),
VerticalScrollStartAddresss(u16),
IdleMode(Logical),
PixelFormatSet(Dbi, Dpi),
SetTearScanline(u16),
DisplayBrightness(u8),
CtrlDisplay(Logical, Logical, Logical),
RGBInterfaceSignalCtrl(DEPolarity, DOTClk, XSpl, XSpl, RCMMode),
BlankingPorchControl(u8, u8, u8),
DispalyFunctionControl(GSMode, SSMode, u8, u8),
TEControl(TEPolarity, u8),
Interface(DMMode, RMMode, RIMMode),
PowerCriterioControl(VCIRe),
VCoreVoltageControl(VddAd),
Vreg1aVoltageControl(u8),
Vreg1bVoltageControl(u8),
Vreg2aVoltageControl(u8),
FrameRate(DINVMode),
Spi2dataControl(Data2EN, DataFormatMDT),
ChargePumpFrequentControl(u8, u8, u8, u8, u8),
InnerRegisterEnable1,
InnerRegisterEnable2,
SetGamma1(Gamma1),
SetGamma2(Gamma2),
SetGamma3(Gamma3),
SetGamma4(Gamma4),
SetUndocumented0EBh(u8),
SetUndocumented084h(u8),
SetUndocumented085h(u8),
SetUndocumented086h(u8),
SetUndocumented087h(u8),
SetUndocumented088h(u8),
SetUndocumented089h(u8),
SetUndocumented08Ah(u8),
SetUndocumented08Bh(u8),
SetUndocumented08Ch(u8),
SetUndocumented08Dh(u8),
SetUndocumented08Eh(u8),
SetUndocumented08Fh(u8),
SetUndocumented090h,
SetUndocumented062h,
SetUndocumented063h,
SetUndocumented064h,
SetUndocumented066h,
SetUndocumented067h,
SetUndocumented074h,
SetUndocumented098h,
SetUndocumented0BEh,
SetUndocumented0BCh,
SetUndocumented0BDh,
SetUndocumented0E1h,
SetUndocumented0DFh,
SetUndocumented0EDh,
SetUndocumented0AEh,
SetUndocumented0CDh,
SetUndocumented070h,
SetUndocumented0FFh,
MemoryWrite,
MemoryWriteContinue,
}
impl Command {
#[allow(clippy::too_many_lines)]
pub fn send<DI>(self, iface: &mut DI) -> Result<(), DisplayError>
where
DI: WriteOnlyDataCommand,
{
let (data, len): ([u8; 13], usize) = match self {
Self::SleepMode(level) => (
[
match level {
Logical::Off => 0x11,
Logical::On => 0x10,
},
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
],
1,
),
Self::PartialMode => ([0x12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 1),
Self::NormalDisplayMode => ([0x13, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 1),
Self::DisplayInversion(level) => {
([0x20 | level as u8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 1)
}
Self::DisplayState(level) => {
([0x28 | level as u8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 1)
}
Self::ColumnAddressSet(sc, ec) => (
[
0x2A,
(sc >> 8) as u8,
(sc & 0xFF) as u8,
(ec >> 8) as u8,
(ec & 0xFF) as u8,
0,
0,
0,
0,
0,
0,
0,
0,
],
5,
),
Self::RowAddressSet(sp, ep) => (
[
0x2B,
(sp >> 8) as u8,
(sp & 0xFF) as u8,
(ep >> 8) as u8,
(ep & 0xFF) as u8,
0,
0,
0,
0,
0,
0,
0,
0,
],
5,
),
Self::VertialScrollDef(tfa, vsa) => (
[
0x33,
(tfa >> 8) as u8,
(tfa & 0xFF) as u8,
(vsa >> 8) as u8,
(vsa & 0xFF) as u8,
0,
0,
0,
0,
0,
0,
0,
0,
],
5,
),
Self::TearingEffectLine(mode) => {
([0x34 | mode as u8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 1)
}
Self::VerticalScrollStartAddresss(vsp) => (
[
0x37,
(vsp >> 8) as u8,
(vsp & 0xFF) as u8,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
],
3,
),
Self::IdleMode(mode) => ([0x38 | mode as u8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 1),
Self::PixelFormatSet(dbi, dpi) => (
[
0x3A,
((dpi as u8) << 4) | (dbi as u8),
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
],
2,
),
Self::SetTearScanline(sts) => (
[
0x44,
(((sts + 8) & 0x100) >> 8) as u8,
((sts + 8) & 0xFF) as u8,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
],
3,
),
Self::DisplayBrightness(dbv) => ([0x51, dbv, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 2),
Self::CtrlDisplay(bctrl, dd, bl) => (
[
0x53,
(bctrl as u8) << 5 | (dd as u8) << 3 | (bl as u8) << 2,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
],
2,
),
Self::RGBInterfaceSignalCtrl(epl, dpl, hsp, vsp, rcm) => (
[
0xB0,
(epl as u8 & 0b1)
| ((dpl as u8 & 0b1) << 1)
| ((hsp as u8 & 0b1) << 2)
| ((vsp as u8 & 0b1) << 3)
| ((rcm as u8 & 0b11) << 5),
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
],
2,
),
Self::BlankingPorchControl(vfp, vbp, hbp) => (
[
0xB5,
vfp,
vbp & 0b0111_1111,
hbp & 0b0001_1111,
0,
0,
0,
0,
0,
0,
0,
0,
0,
],
4,
),
Self::DispalyFunctionControl(gs, ss, sm, nl) => (
[
0xB6,
((gs as u8 & 0b1) << 6) | ((ss as u8 & 0b1) << 5) | ((sm & 0b1) << 4),
nl & 0b0001_1111,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
],
3,
),
Self::TEControl(te_pol, te_width) => (
[
0xBA,
((te_pol as u8) << 7) | (te_width & 0b0111_1111),
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
],
2,
),
Self::Interface(dm, rm, rim) => (
[
0xF6,
((dm as u8 & 0b11) << 2) | ((rm as u8 & 0b1) << 1) | (rim as u8 & 0b1),
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
],
2,
),
Self::PowerCriterioControl(vcire) => (
[
0xC1,
((vcire as u8 & 0b1) << 1),
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
],
2,
),
Self::VCoreVoltageControl(vddad) => (
[
0xA7,
0b0100_0000 | vddad as u8,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
],
2,
),
Self::Vreg1aVoltageControl(value) => {
([0xC3, value, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 2)
}
Self::Vreg1bVoltageControl(value) => {
([0xC4, value, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 2)
}
Self::Vreg2aVoltageControl(value) => {
([0xC9, value, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 2)
}
Self::FrameRate(divn_mode) => (
[
0xE8,
(divn_mode as u8 & 0b111) << 4,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
],
2,
),
Self::Spi2dataControl(data2_en, data_format) => (
[
0xE9,
(data2_en as u8 & 0b1) << 3 | (data_format as u8 & 0b111),
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
],
3,
),
Self::ChargePumpFrequentControl(
avdd_clk_ad,
avee_clk_ad,
vcl_clk_ad,
vgh_clk_ad,
vgl_clk_ad,
) => (
[
0xEC,
((avdd_clk_ad & 0b111) << 4) | avee_clk_ad & 0b111,
vcl_clk_ad & 0b111,
((vgh_clk_ad & 0b1111) << 4) | vgl_clk_ad & 0b1111,
0,
0,
0,
0,
0,
0,
0,
0,
0,
],
4,
),
Self::InnerRegisterEnable1 => ([0xFE, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 1),
Self::InnerRegisterEnable2 => ([0xEF, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 1),
Self::SetGamma1(gamma) => (
[
0xF0,
(gamma.dig2j0_n & 0b11) << 6 | (gamma.vr1_n & 0b0011_1111),
(gamma.dig2j1_n & 0b11) << 6 | (gamma.vr2_n & 0b0011_1111),
(gamma.vr4_n & 0b0001_1111),
(gamma.vr6_n & 0b0001_1111),
(gamma.vr0_n & 0b1111) << 4 | (gamma.vr13_n & 0b0000_1111),
(gamma.vr20_n & 0b0111_1111),
0,
0,
0,
0,
0,
0,
],
7,
),
Self::SetGamma2(gamma) => (
[
0xF1,
(gamma.vr43_n & 0b0111_1111),
(gamma.vr27_n & 0b111) << 5 | (gamma.vr57_n & 0b0001_1111),
(gamma.vr36_n & 0b111) << 5 | (gamma.vr59_n & 0b0001_1111),
(gamma.vr61_n & 0b0011_1111),
(gamma.vr62_n & 0b0011_1111),
(gamma.vr50_n & 0b1111) << 4 | (gamma.vr63_n & 0b0000_1111),
0,
0,
0,
0,
0,
0,
],
7,
),
Self::SetGamma3(gamma) => (
[
0xF2,
(gamma.dig2j0_p & 0b11) << 6 | (gamma.vr1_p & 0b0011_1111),
(gamma.dig2j1_p & 0b11) << 6 | (gamma.vr2_p & 0b0011_1111),
(gamma.vr4_p & 0b0001_1111),
(gamma.vr6_p & 0b0001_1111),
(gamma.vr0_p & 0b1111) << 4 | (gamma.vr13_p & 0b0000_1111),
(gamma.vr20_p & 0b0111_1111),
0,
0,
0,
0,
0,
0,
],
7,
),
Self::SetGamma4(gamma) => (
[
0xF3,
(gamma.vr43_p & 0b0111_1111),
(gamma.vr27_p & 0b111) << 5 | (gamma.vr57_p & 0b0001_1111),
(gamma.vr36_p & 0b111) << 5 | (gamma.vr59_p & 0b0001_1111),
(gamma.vr61_p & 0b0011_1111),
(gamma.vr62_p & 0b0011_1111),
(gamma.vr50_p & 0b1111) << 4 | (gamma.vr63_p & 0b0000_1111),
0,
0,
0,
0,
0,
0,
],
7,
),
Self::MemoryWrite => ([0x2c, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 1),
Self::MemoryWriteContinue => ([0x3c, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 1),
Self::SetUndocumented0BEh => ([0xBE, 0x11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 2),
Self::SetUndocumented0BCh => ([0xBC, 0x00, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 2),
Self::SetUndocumented0BDh => ([0xBD, 0x06, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 2),
Self::SetUndocumented0E1h => ([0xE1, 0x10, 0x0E, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 3),
Self::SetUndocumented0DFh => ([0xDF, 0x21, 0x0c, 0x02, 0, 0, 0, 0, 0, 0, 0, 0, 0], 4),
Self::SetUndocumented0EDh => ([0xED, 0x1B, 0x0B, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 3),
Self::SetUndocumented0AEh => ([0xAE, 0x77, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 2),
Self::SetUndocumented0CDh => ([0xCD, 0x63, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 2),
Self::SetUndocumented070h => (
[
0x70, 0x07, 0x07, 0x04, 0x0E, 0x0F, 0x09, 0x07, 0x08, 0x03, 0, 0, 0,
],
10,
),
Self::SetUndocumented0FFh => ([0xFF, 0x60, 0x01, 0x04, 0, 0, 0, 0, 0, 0, 0, 0, 0], 4),
Self::SetUndocumented0EBh(value) => ([0xEB, value, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 2),
Self::SetUndocumented084h(value) => ([0x84, value, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 2),
Self::SetUndocumented085h(value) => ([0x85, value, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 2),
Self::SetUndocumented086h(value) => ([0x86, value, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 2),
Self::SetUndocumented087h(value) => ([0x87, value, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 2),
Self::SetUndocumented088h(value) => ([0x88, value, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 2),
Self::SetUndocumented089h(value) => ([0x89, value, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 2),
Self::SetUndocumented08Ah(value) => ([0x8A, value, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 2),
Self::SetUndocumented08Bh(value) => ([0x8B, value, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 2),
Self::SetUndocumented08Ch(value) => ([0x8C, value, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 2),
Self::SetUndocumented08Dh(value) => ([0x8D, value, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 2),
Self::SetUndocumented08Eh(value) => ([0x8E, value, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 2),
Self::SetUndocumented08Fh(value) => ([0x8F, value, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 2),
Self::SetUndocumented090h => {
([0x90, 0x08, 0x08, 0x08, 0x08, 0, 0, 0, 0, 0, 0, 0, 0], 5)
}
Self::MemoryAccessControl(my, mx, mv, ml, bgr, mh) => (
[
0x36,
(my as u8) << 7
| (mx as u8) << 6
| (mv as u8) << 5
| (ml as u8) << 4
| (bgr as u8) << 3
| (mh as u8) << 2,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
],
2,
),
Self::SetUndocumented062h => (
[
0x62, 0x18, 0x0D, 0x71, 0xED, 0x70, 0x70, 0x18, 0x0F, 0x71, 0xEF, 0x70, 0x70,
],
13,
),
Self::SetUndocumented063h => (
[
0x63, 0x18, 0x11, 0x71, 0xF1, 0x70, 0x70, 0x18, 0x13, 0x71, 0xF3, 0x70, 0x70,
],
13,
),
Self::SetUndocumented064h => (
[
0x64, 0x28, 0x29, 0xF1, 0x01, 0xF1, 0x00, 0x07, 0, 0, 0, 0, 0,
],
8,
),
Self::SetUndocumented066h => (
[
0x66, 0x3C, 0x00, 0xCD, 0x67, 0x45, 0x45, 0x10, 0x00, 0x00, 0x00, 0, 0,
],
11,
),
Self::SetUndocumented067h => (
[
0x67, 0x00, 0x3C, 0x00, 0x00, 0x00, 0x01, 0x54, 0x10, 0x32, 0x98, 0, 0,
],
11,
),
Self::SetUndocumented074h => (
[
0x74, 0x10, 0x85, 0x80, 0x00, 0x00, 0x4E, 0x00, 0, 0, 0, 0, 0,
],
8,
),
Self::SetUndocumented098h => ([0x98, 0x3e, 0x07, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 3),
};
iface.send_commands(U8(&[data[0]]))?;
if len > 1 {
iface.send_data(U8(&data[1..len]))?;
}
Ok(())
}
}
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
#[repr(u8)]
pub enum Logical {
Off = 0,
On = 1,
}
impl From<bool> for Logical {
fn from(val: bool) -> Self {
if val {
Self::On
} else {
Self::Off
}
}
}
impl From<u8> for Logical {
fn from(val: u8) -> Self {
match val {
0 => Self::Off,
_ => Self::On,
}
}
}
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
#[repr(u8)]
pub enum DEPolarity {
HighEnableForRGB = 0,
LowEnableForRGB = 1,
}
impl From<bool> for DEPolarity {
fn from(val: bool) -> Self {
if val {
Self::HighEnableForRGB
} else {
Self::LowEnableForRGB
}
}
}
impl From<u8> for DEPolarity {
fn from(val: u8) -> Self {
match val {
0 => Self::HighEnableForRGB,
_ => Self::LowEnableForRGB,
}
}
}
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
#[repr(u8)]
pub enum TEPolarity {
PositivePulse = 0,
NegativePulse = 1,
}
impl From<bool> for TEPolarity {
fn from(val: bool) -> Self {
if val {
Self::PositivePulse
} else {
Self::NegativePulse
}
}
}
impl From<u8> for TEPolarity {
fn from(val: u8) -> Self {
match val {
0 => Self::PositivePulse,
_ => Self::NegativePulse,
}
}
}
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
#[repr(u8)]
pub enum DOTClk {
FetchOnRising = 0,
FetchOnFalling = 1,
}
impl From<bool> for DOTClk {
fn from(val: bool) -> Self {
if val {
Self::FetchOnRising
} else {
Self::FetchOnFalling
}
}
}
impl From<u8> for DOTClk {
fn from(val: u8) -> Self {
match val {
0 => Self::FetchOnRising,
_ => Self::FetchOnFalling,
}
}
}
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
#[repr(u8)]
pub enum XSpl {
LowSyncClock = 0,
HighSyncClock = 1,
}
impl From<bool> for XSpl {
fn from(val: bool) -> Self {
if val {
Self::LowSyncClock
} else {
Self::HighSyncClock
}
}
}
impl From<u8> for XSpl {
fn from(val: u8) -> Self {
match val {
0 => Self::LowSyncClock,
_ => Self::HighSyncClock,
}
}
}
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
#[repr(u8)]
pub enum RCMMode {
DEMode = 0b10,
SyncMode = 0b11,
}
impl From<u8> for RCMMode {
fn from(val: u8) -> Self {
match val {
0b10 => Self::DEMode,
_ => Self::SyncMode,
}
}
}
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
#[repr(u8)]
pub enum SSMode {
S1toS360 = 0,
S360toS1 = 1,
}
impl From<u8> for SSMode {
fn from(val: u8) -> Self {
match val {
0 => Self::S1toS360,
_ => Self::S1toS360,
}
}
}
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
#[repr(u8)]
pub enum DMMode {
InternalClockOperation = 0,
RGBInterfaceMode = 1,
VSYNCInterfaceMode = 2,
SettingDisabled = 3,
}
impl From<u8> for DMMode {
fn from(val: u8) -> Self {
match val {
0 => Self::InternalClockOperation,
1 => Self::RGBInterfaceMode,
2 => Self::VSYNCInterfaceMode,
_ => Self::SettingDisabled,
}
}
}
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
#[repr(u8)]
pub enum RMMode {
SystemOrVSyncInterface = 0,
RGBInterface = 1,
}
impl From<u8> for RMMode {
fn from(val: u8) -> Self {
match val {
0 => Self::SystemOrVSyncInterface,
1 => Self::RGBInterface,
_ => Self::RGBInterface,
}
}
}
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
#[repr(u8)]
pub enum RIMMode {
TransferPerPixel1 = 0,
TransferPerPixel3 = 1,
}
impl From<u8> for RIMMode {
fn from(val: u8) -> Self {
match val {
0 => Self::TransferPerPixel1,
1 => Self::TransferPerPixel3,
_ => Self::TransferPerPixel3,
}
}
}
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
#[repr(u8)]
pub enum DINVMode {
ColumnInversion = 0,
Inversion1Dot = 1,
Inversion2Dot = 2,
Inversion4Dot = 3,
Inversion8Dot = 4,
}
impl From<u8> for DINVMode {
fn from(val: u8) -> Self {
match val {
0 => Self::ColumnInversion,
1 => Self::Inversion1Dot,
2 => Self::Inversion2Dot,
3 => Self::Inversion4Dot,
4 => Self::Inversion8Dot,
_ => Self::Inversion8Dot,
}
}
}
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
#[repr(u8)]
pub enum Data2EN {
Data3Wire = 0,
Data4Wire = 1,
}
impl From<u8> for Data2EN {
fn from(val: u8) -> Self {
match val {
0 => Self::Data3Wire,
1 => Self::Data4Wire,
_ => Self::Data4Wire,
}
}
}
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
#[repr(u8)]
pub enum DataFormatMDT {
Color65k1PixelPerTransition = 0,
Color262k1PixelPerTransition = 1,
Color262k2Or3PixelPerTransition = 2,
Color4Mk1PixelPerTransition = 4,
Color4M2Or3PixelPerTransition = 5,
}
impl From<u8> for DataFormatMDT {
fn from(val: u8) -> Self {
match val {
0 => Self::Color65k1PixelPerTransition,
1 => Self::Color262k1PixelPerTransition,
2 => Self::Color262k2Or3PixelPerTransition,
3 => Self::Color4Mk1PixelPerTransition,
4 => Self::Color4M2Or3PixelPerTransition,
_ => Self::Color4M2Or3PixelPerTransition,
}
}
}
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
#[repr(u8)]
pub enum VCIRe {
Internal = 0,
External = 1,
}
impl From<u8> for VCIRe {
fn from(val: u8) -> Self {
match val {
0 => Self::Internal,
1 => Self::External,
_ => Self::External,
}
}
}
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
#[repr(u8)]
pub enum VddAd {
VCore1_483V = 0x00,
VCore1_545V = 0x01,
VCore1_590V = 0x02,
VCore1_638V = 0x03,
VCore1_714V = 0x04,
VCore1_279V = 0x05,
VCore1_859V = 0x06,
VCore1_925V = 0x07,
VCore1_994V = 0x08,
VCore2_109V = 0x09,
VCore2_193V = 0x0a,
VCore2_286V = 0x0b,
VCore2_385V = 0x0c,
VCore1_713V = 0x0d,
VCore1_713Ve = 0x0e,
VCore1_713Vf = 0x0f,
}
impl From<u8> for VddAd {
fn from(val: u8) -> Self {
match val {
0x00 => Self::VCore1_483V,
0x01 => Self::VCore1_545V,
0x02 => Self::VCore1_590V,
0x03 => Self::VCore1_638V,
0x04 => Self::VCore1_714V,
0x05 => Self::VCore1_279V,
0x06 => Self::VCore1_859V,
0x07 => Self::VCore1_925V,
0x08 => Self::VCore1_994V,
0x09 => Self::VCore2_109V,
0x0a => Self::VCore2_193V,
0x0b => Self::VCore2_286V,
0x0c => Self::VCore2_385V,
0x0d => Self::VCore1_713V,
0x0e => Self::VCore1_713Ve,
0x0f => Self::VCore1_713Vf,
_ => Self::VCore1_713Vf,
}
}
}
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
#[repr(u8)]
pub enum GSMode {
G1toG32 = 0,
G32toG1 = 1,
}
impl From<u8> for GSMode {
fn from(val: u8) -> Self {
match val {
0 => Self::G1toG32,
_ => Self::G32toG1,
}
}
}
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
#[repr(u8)]
pub enum Dpi {
Pixel16bits = 0b0000_0101,
Pixel18bits = 0b0000_0110,
}
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
#[repr(u8)]
pub enum Dbi {
Pixel12bits = 0b0000_0011,
Pixel16bits = 0b0000_0101,
Pixel18bits = 0b0000_0110,
}
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
pub struct Gamma1 {
pub dig2j0_n: u8,
pub vr1_n: u8,
pub dig2j1_n: u8,
pub vr2_n: u8,
pub vr4_n: u8,
pub vr6_n: u8,
pub vr0_n: u8,
pub vr13_n: u8,
pub vr20_n: u8,
}
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
pub struct Gamma2 {
pub vr43_n: u8,
pub vr27_n: u8,
pub vr57_n: u8,
pub vr36_n: u8,
pub vr59_n: u8,
pub vr61_n: u8,
pub vr62_n: u8,
pub vr50_n: u8,
pub vr63_n: u8,
}
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
pub struct Gamma3 {
pub dig2j0_p: u8,
pub vr1_p: u8,
pub dig2j1_p: u8,
pub vr2_p: u8,
pub vr4_p: u8,
pub vr6_p: u8,
pub vr0_p: u8,
pub vr13_p: u8,
pub vr20_p: u8,
}
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
pub struct Gamma4 {
pub vr43_p: u8,
pub vr27_p: u8,
pub vr57_p: u8,
pub vr36_p: u8,
pub vr59_p: u8,
pub vr61_p: u8,
pub vr62_p: u8,
pub vr50_p: u8,
pub vr63_p: u8,
}