diff --git a/mipidsi/src/dcs/set_address_mode.rs b/mipidsi/src/dcs/set_address_mode.rs index 1a48a78..b2ceb1f 100644 --- a/mipidsi/src/dcs/set_address_mode.rs +++ b/mipidsi/src/dcs/set_address_mode.rs @@ -13,12 +13,12 @@ pub struct SetAddressMode(u8); impl SetAddressMode { /// Creates a new Set Address Mode command. - pub fn new( + pub const fn new( color_order: ColorOrder, orientation: Orientation, refresh_order: RefreshOrder, ) -> Self { - Self::default() + Self(0) .with_color_order(color_order) .with_orientation(orientation) .with_refresh_order(refresh_order) @@ -26,7 +26,7 @@ impl SetAddressMode { /// Returns this Madctl with [ColorOrder] set to new value #[must_use] - pub fn with_color_order(self, color_order: ColorOrder) -> Self { + pub const fn with_color_order(self, color_order: ColorOrder) -> Self { let mut result = self; match color_order { ColorOrder::Rgb => result.0 &= 0b1111_0111, @@ -38,7 +38,7 @@ impl SetAddressMode { /// Returns this Madctl with [Orientation] set to new value #[must_use] - pub fn with_orientation(self, orientation: Orientation) -> Self { + pub const fn with_orientation(self, orientation: Orientation) -> Self { let mut result = self; let value = match orientation { Orientation::Portrait(false) => 0b0000_0000, @@ -57,7 +57,7 @@ impl SetAddressMode { /// Returns this Madctl with [RefreshOrder] set to new value #[must_use] - pub fn with_refresh_order(self, refresh_order: RefreshOrder) -> Self { + pub const fn with_refresh_order(self, refresh_order: RefreshOrder) -> Self { let mut result = self; let value = match (refresh_order.vertical, refresh_order.horizontal) { (VerticalRefreshOrder::TopToBottom, HorizontalRefreshOrder::LeftToRight) => 0b0000_0000, diff --git a/mipidsi/src/dcs/set_column_address.rs b/mipidsi/src/dcs/set_column_address.rs index 7d59633..2cba1a5 100644 --- a/mipidsi/src/dcs/set_column_address.rs +++ b/mipidsi/src/dcs/set_column_address.rs @@ -13,7 +13,7 @@ pub struct SetColumnAddress { impl SetColumnAddress { /// Creates a new Set Column Address command. - pub fn new(start_column: u16, end_column: u16) -> Self { + pub const fn new(start_column: u16, end_column: u16) -> Self { Self { start_column, end_column, diff --git a/mipidsi/src/dcs/set_page_address.rs b/mipidsi/src/dcs/set_page_address.rs index 81eaff2..cd44527 100644 --- a/mipidsi/src/dcs/set_page_address.rs +++ b/mipidsi/src/dcs/set_page_address.rs @@ -13,7 +13,7 @@ pub struct SetPageAddress { impl SetPageAddress { /// Creates a new Set Page Address command. - pub fn new(start_row: u16, end_row: u16) -> Self { + pub const fn new(start_row: u16, end_row: u16) -> Self { Self { start_row, end_row } } } diff --git a/mipidsi/src/dcs/set_pixel_format.rs b/mipidsi/src/dcs/set_pixel_format.rs index e3cc4e7..dd9e16a 100644 --- a/mipidsi/src/dcs/set_pixel_format.rs +++ b/mipidsi/src/dcs/set_pixel_format.rs @@ -10,7 +10,7 @@ pub struct SetPixelFormat(PixelFormat); impl SetPixelFormat { /// Creates a new Set Pixel Format command. - pub fn new(pixel_format: PixelFormat) -> Self { + pub const fn new(pixel_format: PixelFormat) -> Self { Self(pixel_format) } } diff --git a/mipidsi/src/dcs/set_scroll_area.rs b/mipidsi/src/dcs/set_scroll_area.rs index de0cbb5..66b6790 100644 --- a/mipidsi/src/dcs/set_scroll_area.rs +++ b/mipidsi/src/dcs/set_scroll_area.rs @@ -16,7 +16,7 @@ impl SetScrollArea { /// Creates a new Set Scroll Area command. /// /// VSA should default to the display's height (or width) framebuffer size. - pub fn new(tfa: u16, vsa: u16, bfa: u16) -> Self { + pub const fn new(tfa: u16, vsa: u16, bfa: u16) -> Self { Self { tfa, vsa, bfa } } } diff --git a/mipidsi/src/dcs/set_scroll_start.rs b/mipidsi/src/dcs/set_scroll_start.rs index cea111e..ad03703 100644 --- a/mipidsi/src/dcs/set_scroll_start.rs +++ b/mipidsi/src/dcs/set_scroll_start.rs @@ -10,7 +10,7 @@ pub struct SetScrollStart(u16); impl SetScrollStart { /// Creates a new Set Scroll Start command. - pub fn new(offset: u16) -> Self { + pub const fn new(offset: u16) -> Self { Self(offset) } }