@@ -23,6 +23,7 @@ use crate::displayrotation::DisplayRotation;
23
23
use crate :: interface:: DisplayInterface ;
24
24
use crate :: mode:: displaymode:: DisplayModeTrait ;
25
25
use crate :: properties:: DisplayProperties ;
26
+ use crate :: { DISPLAY_HEIGHT , DISPLAY_WIDTH } ;
26
27
27
28
/// 96px x 64px screen with 16 bits (2 bytes) per pixel
28
29
const BUF_SIZE : usize = 12288 ;
@@ -83,32 +84,30 @@ where
83
84
pub fn flush ( & mut self ) -> Result < ( ) , ( ) > {
84
85
// Ensure the display buffer is at the origin of the display before we send the full frame
85
86
// to prevent accidental offsets
86
- // let (display_width, display_height) = self.properties.get_dimensions();
87
- self . properties . set_draw_area ( ( 0 , 0 ) , ( 96 , 64 ) ) ?;
87
+ self . properties
88
+ . set_draw_area ( ( 0 , 0 ) , ( DISPLAY_WIDTH , DISPLAY_HEIGHT ) ) ?;
88
89
89
90
self . properties . draw ( & self . buffer )
90
91
}
91
92
92
93
/// Turn a pixel on or off. A non-zero `value` is treated as on, `0` as off. If the X and Y
93
94
/// coordinates are out of the bounds of the display, this method call is a noop.
94
95
pub fn set_pixel ( & mut self , x : u32 , y : u32 , value : u16 ) {
95
- let display_width = 96 ;
96
- let display_height = 64 ;
97
96
let display_rotation = self . properties . get_rotation ( ) ;
98
97
99
98
let idx = match display_rotation {
100
99
DisplayRotation :: Rotate0 | DisplayRotation :: Rotate180 => {
101
- if x >= display_width as u32 {
100
+ if x >= DISPLAY_WIDTH as u32 {
102
101
return ;
103
102
}
104
- ( ( y as usize ) * display_width as usize ) + ( x as usize )
103
+ ( ( y as usize ) * DISPLAY_WIDTH as usize ) + ( x as usize )
105
104
}
106
105
107
106
DisplayRotation :: Rotate90 | DisplayRotation :: Rotate270 => {
108
- if y >= display_width as u32 {
107
+ if y >= DISPLAY_WIDTH as u32 {
109
108
return ;
110
109
}
111
- ( ( y as usize ) * display_height as usize ) + ( x as usize )
110
+ ( ( y as usize ) * DISPLAY_HEIGHT as usize ) + ( x as usize )
112
111
}
113
112
} * 2 ;
114
113
0 commit comments