Merge branch 'master' of github.com:Caemor/eink-waveshare-rs
commit
3fa576732c
|
|
@ -1,5 +1,109 @@
|
||||||
|
//width must be multiple of 8
|
||||||
|
//
|
||||||
|
//chars are build in the bitmap like this example of a width 16, height 2 font:
|
||||||
|
//12
|
||||||
|
//34
|
||||||
|
// first char is the first ascii letter you want
|
||||||
|
#[allow(dead_code)]
|
||||||
|
pub struct Font<'a> {
|
||||||
|
width: u8,
|
||||||
|
height: u8,
|
||||||
|
first_char: u8,
|
||||||
|
last_char: u8,
|
||||||
|
bitmap: &'a [u8],
|
||||||
|
widthmap: &'a [u8]
|
||||||
|
}
|
||||||
|
|
||||||
pub(crate) fn to_bitmap(input: char) -> [u8; 8] {
|
impl<'a> Font<'a> {
|
||||||
|
/// Panics if either Bitmap or Widthmap of the Font are to small for the amount and size of chars
|
||||||
|
pub fn new(width: u8, height: u8, first_char: u8, last_char: u8, bitmap: &'a [u8], widthmap: &'a [u8]) -> Font<'a> {
|
||||||
|
//Assertion so it shouldn't be able to panic later
|
||||||
|
let length_of_char = width as usize / 8 * height as usize;
|
||||||
|
let amount_of_chars = last_char as usize - first_char as usize + 1;
|
||||||
|
assert!(bitmap.len() >= amount_of_chars * length_of_char);
|
||||||
|
assert!(widthmap.len() >= amount_of_chars);
|
||||||
|
|
||||||
|
Font {width, height, first_char, last_char, bitmap, widthmap }
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
fn get_length_of_char(&self) -> usize {
|
||||||
|
self.width as usize / 8 * self.height as usize
|
||||||
|
}
|
||||||
|
|
||||||
|
fn get_char_pos(&self, input: char) -> usize {
|
||||||
|
(input as usize - self.first_char as usize)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Can panic, when end_pos > bitmap.len, should be caught in Font::new already
|
||||||
|
pub(crate) fn get_char(&'a self, input: char) -> &'a [u8] {
|
||||||
|
let start_pos = self.get_char_pos(input) * self.get_length_of_char();
|
||||||
|
let end_pos = start_pos + self.get_length_of_char();
|
||||||
|
|
||||||
|
&self.bitmap[start_pos .. end_pos]
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Can panic, when get_char_pos > widthmap.len(), should be caught in Font::new already
|
||||||
|
pub(crate) fn get_char_width(&self, input: char) -> u8 {
|
||||||
|
self.widthmap[self.get_char_pos(input)]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn fonts_test() {
|
||||||
|
let bitmap = [
|
||||||
|
0x00, 0x00, 0x5F, 0x00, 0x00, 0x00, 0x00, 0x00, // '!'
|
||||||
|
0x00, 0x07, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, // '"'
|
||||||
|
0x14, 0x7F, 0x14, 0x7F, 0x14, 0x00, 0x00, 0x00, // '#'
|
||||||
|
0x14, 0x7F, 0x14, 0x7F, 0x14, 0x00, 0x00, 0x00]; // '$'
|
||||||
|
|
||||||
|
let widthmap = [8,8,8,8];
|
||||||
|
|
||||||
|
let font = Font::new(8, 8, '!' as u8, '$' as u8, &bitmap, &widthmap);
|
||||||
|
|
||||||
|
let hashtag = [0x14, 0x7F, 0x14, 0x7F, 0x14, 0x00, 0x00, 0x00];
|
||||||
|
|
||||||
|
assert_eq!(font.get_char('#'), hashtag);
|
||||||
|
|
||||||
|
assert_eq!(font.get_char('$')[7], 0x00);
|
||||||
|
|
||||||
|
assert_eq!(font.get_char_width('#'), widthmap[2]);
|
||||||
|
assert_eq!(font.get_char_width('$'), widthmap[3]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn bitmap_8x8_test() {
|
||||||
|
let and = [0x36, 0x49, 0x55, 0x22, 0x50, 0x00, 0x00, 0x00];
|
||||||
|
let zero = [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00];
|
||||||
|
let first_value = [0x00, 0x00, 0x5F, 0x00, 0x00, 0x00, 0x00, 0x00];
|
||||||
|
let last_value = [0x00, 0x41, 0x36, 0x08, 0x00, 0x00, 0x00, 0x00];
|
||||||
|
|
||||||
|
assert_eq!(bitmap_8x8('&'), and);
|
||||||
|
|
||||||
|
assert_eq!(bitmap_8x8('ß'), zero);
|
||||||
|
assert_eq!(bitmap_8x8('°'), zero);
|
||||||
|
|
||||||
|
assert_eq!(bitmap_8x8('!'), first_value);
|
||||||
|
assert_eq!(bitmap_8x8('}'), last_value);
|
||||||
|
|
||||||
|
assert_eq!(bitmap_8x8('0')[1], 0x3E);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//bad font as the order is not the one we want to use
|
||||||
|
//goes from bottom left -> up -> right
|
||||||
|
pub(crate) fn bitmap_8x8(input: char) -> [u8; 8] {
|
||||||
// Populate the array with the data from the character array at the right index
|
// Populate the array with the data from the character array at the right index
|
||||||
match input {
|
match input {
|
||||||
'!' => [0x00, 0x00, 0x5F, 0x00, 0x00, 0x00, 0x00, 0x00],
|
'!' => [0x00, 0x00, 0x5F, 0x00, 0x00, 0x00, 0x00, 0x00],
|
||||||
|
|
@ -100,10 +204,10 @@
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
pub(crate) const VCR_OSD_MONO_Bitmap = [
|
pub(crate) const VCR_OSD_MONO_Bitmap = [
|
||||||
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00,
|
af afa 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00,
|
||||||
0xFF, 0xFF, 0xFC, 0x3F, 0xFC, 0x3F, 0xFC, 0x3F, 0xFC, 0x3F, 0xFC, 0x3F,
|
0xFF, 0xFF, 0xFC, 0x3F, 0xFC, 0x3F, 0xFC, 0x3F, 0xFC, 0x3F, 0xFC, 0x3F,
|
||||||
0xFC, 0x3F, 0x30, 0x0C, 0x30, 0x0C, 0x00, 0x0F, 0x00, 0x00, 0xF0, 0x0F,
|
0xFC, 0x3F, 0x30, 0x0C, 0x30, 0x0C, 0x00, 0x0F, 0x00, 0x00, 0xF0, 0x0F,
|
||||||
0x0F, 0x00, 0xF0, 0xF0, 0x0F, 0x0F, 0xF0, 0xF0, 0xFF, 0x0F, 0xFF, 0xF0,
|
aaa 0x0F, 0x00, 0xF0, 0xF0, 0x0F, 0x0F, 0xF0, 0xF0, 0xFF, 0x0F, 0xFF, 0xF0,
|
||||||
0xFF, 0xFF, 0xFF, 0xFF, 0x0F, 0xFF, 0xF0, 0xFF, 0x0F, 0x0F, 0xF0, 0xF0,
|
0xFF, 0xFF, 0xFF, 0xFF, 0x0F, 0xFF, 0xF0, 0xFF, 0x0F, 0x0F, 0xF0, 0xF0,
|
||||||
0x0F, 0x0F, 0x00, 0xF0, 0xF0, 0x0F, 0x0F, 0xF0, 0xF0, 0xFF, 0x0F, 0xFF,
|
0x0F, 0x0F, 0x00, 0xF0, 0xF0, 0x0F, 0x0F, 0xF0, 0xF0, 0xFF, 0x0F, 0xFF,
|
||||||
0xF0, 0xFF, 0xFF, 0xFF, 0xFF, 0x0F, 0xFF, 0xF0, 0xFF, 0x0F, 0x0F, 0xF0,
|
0xF0, 0xFF, 0xFF, 0xFF, 0xFF, 0x0F, 0xFF, 0xF0, 0xFF, 0x0F, 0x0F, 0xF0,
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
|
|
||||||
mod font;
|
mod font;
|
||||||
|
use self::font::Font;
|
||||||
|
|
||||||
|
|
||||||
#[derive(Clone, Copy)]
|
#[derive(Clone, Copy)]
|
||||||
|
|
@ -15,11 +16,11 @@ pub enum Displayorientation {
|
||||||
}
|
}
|
||||||
|
|
||||||
//WARNING: Adapt for bigger sized displays!
|
//WARNING: Adapt for bigger sized displays!
|
||||||
pub struct DisplayDescription {
|
// pub struct DisplayDescription {
|
||||||
width: u16,
|
// width: u16,
|
||||||
height: u16,
|
// height: u16,
|
||||||
buffer_size: u16
|
// buffer_size: u16
|
||||||
}
|
// }
|
||||||
|
|
||||||
// impl Display_Description {
|
// impl Display_Description {
|
||||||
// pub fn new(width: u16, height: u16, buffer_size: u16) -> Display_Description {
|
// pub fn new(width: u16, height: u16, buffer_size: u16) -> Display_Description {
|
||||||
|
|
@ -43,12 +44,7 @@ impl Display {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct Graphics {
|
|
||||||
width: u16,
|
|
||||||
height: u16,
|
|
||||||
rotation: Displayorientation,
|
|
||||||
//buffer: Box<u8>//[u8; 15000],
|
|
||||||
}
|
|
||||||
|
|
||||||
pub enum Color {
|
pub enum Color {
|
||||||
Black,
|
Black,
|
||||||
|
|
@ -56,24 +52,71 @@ pub enum Color {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Color {
|
impl Color {
|
||||||
fn get_bit_value(&self) -> u8 {
|
pub(crate) fn _get_bit_value(&self) -> u8 {
|
||||||
match self {
|
match self {
|
||||||
Color::White => 1u8,
|
Color::White => 1u8,
|
||||||
Color::Black => 0u8,
|
Color::Black => 0u8,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_full_byte(&self) -> u8 {
|
pub(crate) fn get_full_byte(&self) -> u8 {
|
||||||
match self {
|
match self {
|
||||||
Color::White => 0xff,
|
Color::White => 0xff,
|
||||||
Color::Black => 0x00,
|
Color::Black => 0x00,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//position counted from the left (highest value) from 0 to 7
|
||||||
|
//remember: 1 is white, 0 is black
|
||||||
|
pub(crate) fn get_color(input: u8, pos: u8) -> Color {
|
||||||
|
match ((input >> (7 - pos)) & 1u8) > 0u8 {
|
||||||
|
true => Color::White,
|
||||||
|
false => Color::Black
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn inverse_color(color: &Color) -> Color {
|
||||||
|
match color {
|
||||||
|
Color::White => Color::Black,
|
||||||
|
Color::Black => Color::White,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn normal_color(color: &Color) -> Color {
|
||||||
|
match color {
|
||||||
|
Color::White => Color::White,
|
||||||
|
Color::Black => Color::Black,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//position counted from the left (highest value) from 0 to 7
|
||||||
|
//remember: 1 is white, 0 is black
|
||||||
|
pub(crate) fn _is_drawable_pixel(input: u8, pos: u8) -> bool {
|
||||||
|
((input >> (7 - pos)) & 1u8) > 0u8
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
pub(crate) fn convert_color(input: u8, pos: u8, foreground_color: &Color) -> Color {
|
||||||
|
//match color:
|
||||||
|
// - white for "nothing to draw"/background drawing
|
||||||
|
// - black for pixel to draw
|
||||||
|
//
|
||||||
|
//foreground color is the color you want to have in the foreground
|
||||||
|
match Color::get_color(input, pos) {
|
||||||
|
Color::White => Color::normal_color(foreground_color),
|
||||||
|
Color::Black => Color::inverse_color(foreground_color)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
|
pub struct Graphics {
|
||||||
|
width: u16,
|
||||||
|
height: u16,
|
||||||
|
rotation: Displayorientation,
|
||||||
|
//buffer: Box<u8>//[u8; 15000],
|
||||||
|
}
|
||||||
|
|
||||||
impl Graphics {
|
impl Graphics {
|
||||||
/// width needs to be a multiple of 8!
|
/// width needs to be a multiple of 8!
|
||||||
|
|
@ -142,9 +185,11 @@ impl Graphics {
|
||||||
|
|
||||||
/// font map doesn't work as expected, so everything with chars and string is broken atm
|
/// font map doesn't work as expected, so everything with chars and string is broken atm
|
||||||
///TODO: implement!
|
///TODO: implement!
|
||||||
pub fn draw_char(&self, buffer: &mut[u8], x0: u16, y0: u16, input: char, color: &Color) {
|
/// TODO: use Fonts
|
||||||
|
pub fn draw_char(&self, buffer: &mut[u8], x0: u16, y0: u16, input: char, font: &Font, color: &Color) {
|
||||||
let mut counter = 0;
|
let mut counter = 0;
|
||||||
for &elem in font::to_bitmap(input).iter() {
|
let _a = font.get_char(input);
|
||||||
|
for &elem in font::bitmap_8x8(input).iter() {
|
||||||
self.draw_byte(buffer, x0, y0 + counter * self.width, elem, color);
|
self.draw_byte(buffer, x0, y0 + counter * self.width, elem, color);
|
||||||
counter += 1;
|
counter += 1;
|
||||||
}
|
}
|
||||||
|
|
@ -152,10 +197,31 @@ impl Graphics {
|
||||||
|
|
||||||
///TODO: implement!
|
///TODO: implement!
|
||||||
/// no autobreak line yet
|
/// no autobreak line yet
|
||||||
pub fn draw_string(&self, buffer: &mut[u8], x0: u16, y0: u16, input: &str, color: &Color) {
|
pub fn draw_string(&self, buffer: &mut[u8], x0: u16, y0: u16, input: &str, font: &Font, color: &Color) {
|
||||||
let mut counter = 0;
|
let mut counter = 0;
|
||||||
for input_char in input.chars() {
|
for input_char in input.chars() {
|
||||||
self.draw_char(buffer, x0 + counter, y0, input_char, color);
|
self.draw_char(buffer, x0 + counter, y0, input_char, font, color);
|
||||||
|
counter += font.get_char_width(input_char) as u16;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
///TODO: test!
|
||||||
|
pub fn draw_char_8x8(&self, buffer: &mut[u8], x0: u16, y0: u16, input: char, color: &Color) {
|
||||||
|
let mut counter = 0;
|
||||||
|
for &elem in font::bitmap_8x8(input).iter() {
|
||||||
|
for i in 0..8u8 {
|
||||||
|
self.draw_pixel(buffer, x0 + counter, y0 + 7 - i as u16, &Color::convert_color(elem, i, color))
|
||||||
|
}
|
||||||
|
counter += 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
///TODO: test!
|
||||||
|
/// no autobreak line yet
|
||||||
|
pub fn draw_string_8x8(&self, buffer: &mut[u8], x0: u16, y0: u16, input: &str, color: &Color) {
|
||||||
|
let mut counter = 0;
|
||||||
|
for input_char in input.chars() {
|
||||||
|
self.draw_char_8x8(buffer, x0 + counter*8, y0, input_char, color);
|
||||||
counter += 1;
|
counter += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -308,7 +374,7 @@ impl Graphics {
|
||||||
// }
|
// }
|
||||||
|
|
||||||
///TODO: implement!
|
///TODO: implement!
|
||||||
pub fn draw_filled_circle(&self, buffer: &mut[u8]) {
|
pub fn draw_filled_circle(&self, _buffer: &mut[u8]) {
|
||||||
unimplemented!();
|
unimplemented!();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -452,11 +518,6 @@ mod graphics {
|
||||||
graphics.draw_pixel(&mut buffer, 9, 0, &Color::Black);
|
graphics.draw_pixel(&mut buffer, 9, 0, &Color::Black);
|
||||||
assert_eq!(buffer[0], Color::White.get_full_byte());
|
assert_eq!(buffer[0], Color::White.get_full_byte());
|
||||||
assert_eq!(buffer[1], !0x40);
|
assert_eq!(buffer[1], !0x40);
|
||||||
|
|
||||||
for &elem in buffer.iter() {
|
|
||||||
|
|
||||||
//assert_eq!(elem, 0x00u8);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
@ -466,30 +527,69 @@ mod graphics {
|
||||||
graphics.draw_byte(&mut buffer, 0, 0, 0xff, &Color::Black);
|
graphics.draw_byte(&mut buffer, 0, 0, 0xff, &Color::Black);
|
||||||
|
|
||||||
assert_eq!(buffer[0], Color::Black.get_full_byte());
|
assert_eq!(buffer[0], Color::Black.get_full_byte());
|
||||||
assert_eq!(buffer[1], Color::White.get_full_byte());
|
|
||||||
|
for i in 1..buffer.len() {
|
||||||
|
assert_eq!(buffer[i], Color::White.get_full_byte());
|
||||||
|
}
|
||||||
|
|
||||||
|
graphics.draw_byte(&mut buffer, 0, 0, 0x5A, &Color::Black) ;
|
||||||
|
assert_eq!(buffer[0], !0x5A);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_char_with_8x8_font() {
|
||||||
|
|
||||||
|
// Test !
|
||||||
|
let mut buffer = [Color::White.get_full_byte(); 8];
|
||||||
|
let graphics = Graphics::new(8, 8);
|
||||||
|
graphics.draw_char_8x8(&mut buffer, 0, 0, '!', &Color::Black);
|
||||||
|
|
||||||
|
for i in 0..5 {
|
||||||
|
assert_eq!(buffer[i], !0x20);
|
||||||
|
}
|
||||||
|
assert_eq!(buffer[5], Color::White.get_full_byte());
|
||||||
|
assert_eq!(buffer[6], !0x20);
|
||||||
|
assert_eq!(buffer[7], Color::White.get_full_byte());
|
||||||
|
|
||||||
|
|
||||||
|
// Test H
|
||||||
|
let mut buffer = [Color::White.get_full_byte(); 8];
|
||||||
|
let graphics = Graphics::new(8, 8);
|
||||||
|
graphics.draw_char_8x8(&mut buffer, 0, 0, 'H', &Color::Black);
|
||||||
|
|
||||||
|
for i in 0..3 {
|
||||||
|
assert_eq!(buffer[i], !0x88);
|
||||||
|
}
|
||||||
|
assert_eq!(buffer[3], !0xF8);
|
||||||
|
for i in 4..7 {
|
||||||
|
assert_eq!(buffer[i], !0x88);
|
||||||
|
}
|
||||||
|
assert_eq!(buffer[7], Color::White.get_full_byte());
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_string_with_8x8_font() {
|
||||||
|
|
||||||
|
// Test !H
|
||||||
let mut buffer = [Color::White.get_full_byte(); 16];
|
let mut buffer = [Color::White.get_full_byte(); 16];
|
||||||
let graphics = Graphics::new(16, 8);
|
let graphics = Graphics::new(16, 8);
|
||||||
graphics.draw_pixel(&mut buffer, 9, 0, &Color::Black);
|
graphics.draw_string_8x8(&mut buffer, 0, 0, "!H", &Color::Black);
|
||||||
assert_eq!(buffer[0], Color::White.get_full_byte());
|
|
||||||
assert_eq!(buffer[1], !0x40);
|
|
||||||
|
|
||||||
for &elem in buffer.iter() {
|
for i in 0..5 {
|
||||||
|
assert_eq!(buffer[i*2], !0x20);
|
||||||
//assert_eq!(elem, 0x00u8);
|
|
||||||
}
|
}
|
||||||
|
assert_eq!(buffer[5*2], Color::White.get_full_byte());
|
||||||
|
assert_eq!(buffer[6*2], !0x20);
|
||||||
|
assert_eq!(buffer[7*2], Color::White.get_full_byte());
|
||||||
|
|
||||||
|
|
||||||
|
for i in 0..3 {
|
||||||
|
assert_eq!(buffer[i*2 + 1], !0x88);
|
||||||
|
}
|
||||||
|
assert_eq!(buffer[3*2 + 1], !0xF8);
|
||||||
|
for i in 4..7 {
|
||||||
|
assert_eq!(buffer[i*2 + 1], !0x88);
|
||||||
|
}
|
||||||
|
assert_eq!(buffer[7*2 + 1], Color::White.get_full_byte());
|
||||||
}
|
}
|
||||||
|
|
||||||
// #[test]
|
|
||||||
// #[should_panic]
|
|
||||||
// fn test_any_panic() {
|
|
||||||
// divide_non_zero_result(1, 0);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// #[test]
|
|
||||||
// #[should_panic(expected = "Divide result is zero")]
|
|
||||||
// fn test_specific_panic() {
|
|
||||||
// divide_non_zero_result(1, 10);
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
@ -152,3 +152,18 @@ impl Command {
|
||||||
self as u8
|
self as u8
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn command_addr() {
|
||||||
|
assert_eq!(Command::POWER_SAVING.addr(), 0xE3);
|
||||||
|
|
||||||
|
assert_eq!(Command::PANEL_SETTING.addr(), 0x00);
|
||||||
|
|
||||||
|
assert_eq!(Command::DISPLAY_REFRESH.addr(), 0x12);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -61,6 +61,8 @@ use hal::{
|
||||||
mod lut;
|
mod lut;
|
||||||
use self::lut::*;
|
use self::lut::*;
|
||||||
|
|
||||||
|
use drawing::Color;
|
||||||
|
|
||||||
pub mod command;
|
pub mod command;
|
||||||
pub use command::Command as Command;
|
pub use command::Command as Command;
|
||||||
|
|
||||||
|
|
@ -338,8 +340,8 @@ where
|
||||||
///
|
///
|
||||||
/// TODO: should that option be removed? E.g. the struct contains an additional default background value
|
/// TODO: should that option be removed? E.g. the struct contains an additional default background value
|
||||||
/// which is settable?
|
/// which is settable?
|
||||||
pub fn clear_frame(&mut self, reset_color: Option<u8>) -> Result<(), E> {
|
pub fn clear_frame(&mut self, reset_color: Option<Color>) -> Result<(), E> {
|
||||||
let reset_color: u8 = reset_color.unwrap_or(0xff);
|
let reset_color: Color = reset_color.unwrap_or(Color::White);
|
||||||
|
|
||||||
self.send_resolution()?;
|
self.send_resolution()?;
|
||||||
|
|
||||||
|
|
@ -348,7 +350,7 @@ where
|
||||||
self.send_command(Command::DATA_START_TRANSMISSION_1)?;
|
self.send_command(Command::DATA_START_TRANSMISSION_1)?;
|
||||||
self.delay_ms(2);
|
self.delay_ms(2);
|
||||||
for _ in 0..size {
|
for _ in 0..size {
|
||||||
self.send_data(reset_color)?;
|
self.send_data(reset_color.get_full_byte())?;
|
||||||
}
|
}
|
||||||
|
|
||||||
self.delay_ms(2);
|
self.delay_ms(2);
|
||||||
|
|
@ -356,7 +358,7 @@ where
|
||||||
self.send_command(Command::DATA_START_TRANSMISSION_2)?;
|
self.send_command(Command::DATA_START_TRANSMISSION_2)?;
|
||||||
self.delay_ms(2);
|
self.delay_ms(2);
|
||||||
for _ in 0..size {
|
for _ in 0..size {
|
||||||
self.send_data(reset_color)?;
|
self.send_data(reset_color.get_full_byte())?;
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue