Used cargo clippy to fix a few bad coding styles
parent
4870b72336
commit
835e25d133
|
|
@ -29,9 +29,10 @@ impl Color {
|
||||||
/// remember: 1 is white, 0 is black
|
/// remember: 1 is white, 0 is black
|
||||||
/// Color is the color you want to draw with in the foreground
|
/// Color is the color you want to draw with in the foreground
|
||||||
pub(crate) fn get_color(input: u8, pos: u8, color: &Color) -> Color {
|
pub(crate) fn get_color(input: u8, pos: u8, color: &Color) -> Color {
|
||||||
match Color::is_drawable_pixel(input, pos) {
|
if Color::is_drawable_pixel(input, pos) {
|
||||||
true => Color::normal_color(color),
|
Color::normal_color(color)
|
||||||
false => Color::inverse_color(color)
|
} else {
|
||||||
|
Color::inverse_color(color)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -65,9 +66,10 @@ impl Color {
|
||||||
// - black for pixel to draw
|
// - black for pixel to draw
|
||||||
//
|
//
|
||||||
//foreground color is the color you want to have in the foreground
|
//foreground color is the color you want to have in the foreground
|
||||||
match Color::is_drawable_pixel(input, pos) {
|
if Color::is_drawable_pixel(input, pos) {
|
||||||
true => Color::normal_color(foreground_color),
|
Color::normal_color(foreground_color)
|
||||||
false => Color::inverse_color(foreground_color)
|
} else {
|
||||||
|
Color::inverse_color(foreground_color)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -141,7 +141,7 @@ impl<'a> Graphics<'a> {
|
||||||
let mut counter = 0;
|
let mut counter = 0;
|
||||||
for input_char in input.chars() {
|
for input_char in input.chars() {
|
||||||
self.draw_char(x0 + counter, y0, input_char, font, color);
|
self.draw_char(x0 + counter, y0, input_char, font, color);
|
||||||
counter += font.get_char_width(input_char) as u16;
|
counter += u16::from(font.get_char_width(input_char));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -163,7 +163,7 @@ impl<'a> Graphics<'a> {
|
||||||
for _ in 0..8 {
|
for _ in 0..8 {
|
||||||
|
|
||||||
self.draw_pixel(
|
self.draw_pixel(
|
||||||
x0 + width_counter as u16,
|
x0 + u16::from(width_counter),
|
||||||
y0 + row_counter,
|
y0 + row_counter,
|
||||||
&Color::get_color(elem, width_counter % 8, color));
|
&Color::get_color(elem, width_counter % 8, color));
|
||||||
|
|
||||||
|
|
@ -183,9 +183,9 @@ impl<'a> Graphics<'a> {
|
||||||
pub fn draw_char_8x8(&mut self, x0: u16, y0: u16, input: char, color: &Color) {
|
pub fn draw_char_8x8(&mut self, x0: u16, y0: u16, input: char, color: &Color) {
|
||||||
let mut counter = 0;
|
let mut counter = 0;
|
||||||
// includes special draw_char instructions as this one is ordered columnwise and not rowwise (first byte == first 8 pixel columnwise)
|
// includes special draw_char instructions as this one is ordered columnwise and not rowwise (first byte == first 8 pixel columnwise)
|
||||||
for &elem in font::bitmap_8x8(input).iter() {
|
for &elem in (&font::bitmap_8x8(input)).iter() {
|
||||||
for i in 0..8u8 {
|
for i in 0..8u8 {
|
||||||
self.draw_pixel(x0 + counter, y0 + 7 - i as u16, &Color::convert_color(elem, i, color))
|
self.draw_pixel(x0 + counter, y0 + 7 - u16::from(i), &Color::convert_color(elem, i, color))
|
||||||
}
|
}
|
||||||
counter += 1;
|
counter += 1;
|
||||||
}
|
}
|
||||||
|
|
@ -197,10 +197,8 @@ impl<'a> Graphics<'a> {
|
||||||
///
|
///
|
||||||
/// no autobreak line yet
|
/// no autobreak line yet
|
||||||
pub fn draw_string_8x8(&mut self, x0: u16, y0: u16, input: &str, color: &Color) {
|
pub fn draw_string_8x8(&mut self, x0: u16, y0: u16, input: &str, color: &Color) {
|
||||||
let mut counter = 0;
|
for (counter, input_char) in input.chars().enumerate() {
|
||||||
for input_char in input.chars() {
|
self.draw_char_8x8(x0 + counter as u16*8, y0, input_char, color);
|
||||||
self.draw_char_8x8(x0 + counter*8, y0, input_char, color);
|
|
||||||
counter += 1;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@
|
||||||
|
|
||||||
const WIDTH: u16 = 200;
|
const WIDTH: u16 = 200;
|
||||||
const HEIGHT: u16 = 200;
|
const HEIGHT: u16 = 200;
|
||||||
const DPI: u16 = 184;
|
//const DPI: u16 = 184;
|
||||||
const DEFAULT_BACKGROUND_COLOR: Color = Color::White;
|
const DEFAULT_BACKGROUND_COLOR: Color = Color::White;
|
||||||
|
|
||||||
use hal::{
|
use hal::{
|
||||||
|
|
@ -292,9 +292,9 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO: assert length for LUT is exactly 30
|
//TODO: assert length for LUT is exactly 30
|
||||||
fn set_lut_manual(&mut self, buffer: &[u8]) -> Result<(), E> {
|
//fn set_lut_manual(&mut self, buffer: &[u8]) -> Result<(), E> {
|
||||||
self.set_lut_helper(buffer)
|
// self.set_lut_helper(buffer)
|
||||||
}
|
//}
|
||||||
|
|
||||||
|
|
||||||
fn set_lut_helper(&mut self, buffer: &[u8]) -> Result<(), E> {
|
fn set_lut_helper(&mut self, buffer: &[u8]) -> Result<(), E> {
|
||||||
|
|
|
||||||
|
|
@ -295,9 +295,9 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO: assert length for LUT is exactly 30
|
//TODO: assert length for LUT is exactly 30
|
||||||
fn set_lut_manual(&mut self, buffer: &[u8]) -> Result<(), E> {
|
//fn set_lut_manual(&mut self, buffer: &[u8]) -> Result<(), E> {
|
||||||
self.set_lut_helper(buffer)
|
// self.set_lut_helper(buffer)
|
||||||
}
|
//}
|
||||||
|
|
||||||
|
|
||||||
fn set_lut_helper(&mut self, buffer: &[u8]) -> Result<(), E> {
|
fn set_lut_helper(&mut self, buffer: &[u8]) -> Result<(), E> {
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ use interface;
|
||||||
/// Should rarely (never?) be needed directly.
|
/// Should rarely (never?) be needed directly.
|
||||||
///
|
///
|
||||||
/// For more infos about the addresses and what they are doing look into the pdfs
|
/// For more infos about the addresses and what they are doing look into the pdfs
|
||||||
//#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
#[allow(non_camel_case_types)]
|
#[allow(non_camel_case_types)]
|
||||||
#[derive(Copy, Clone)]
|
#[derive(Copy, Clone)]
|
||||||
pub(crate) enum Command {
|
pub(crate) enum Command {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue