updated padcontrol
This commit is contained in:
parent
355643ecdd
commit
c2482fa257
@ -4,6 +4,8 @@ use crate::zabbix::problems::ZabbixLayout;
|
|||||||
use launchy::Color;
|
use launchy::Color;
|
||||||
use launchy::{self, Canvas, CanvasLayout, CanvasLayoutPoller, MsgPollingWrapper, Pad};
|
use launchy::{self, Canvas, CanvasLayout, CanvasLayoutPoller, MsgPollingWrapper, Pad};
|
||||||
|
|
||||||
|
pub const MATRIX_SIZE: i32 = 8;
|
||||||
|
|
||||||
pub fn initpad() -> (CanvasLayout<'static>, CanvasLayoutPoller) {
|
pub fn initpad() -> (CanvasLayout<'static>, CanvasLayoutPoller) {
|
||||||
let (mut canvas, poller) = launchy::CanvasLayout::new_polling();
|
let (mut canvas, poller) = launchy::CanvasLayout::new_polling();
|
||||||
match canvas.add_by_guess_rotated::<launchy::mini::Canvas>(0, 0, launchy::Rotation::None) {
|
match canvas.add_by_guess_rotated::<launchy::mini::Canvas>(0, 0, launchy::Rotation::None) {
|
||||||
@ -33,19 +35,22 @@ pub fn draw(canvas: &mut CanvasLayout, datamatrix: &mut ZabbixLayout, cfg: &mut
|
|||||||
loop {
|
loop {
|
||||||
let zabbix_data = get_zabbix_problems(cfg);
|
let zabbix_data = get_zabbix_problems(cfg);
|
||||||
datamatrix.compute(&zabbix_data);
|
datamatrix.compute(&zabbix_data);
|
||||||
|
let mut x = 0i32;
|
||||||
let mut y = 1i32;
|
let mut y = 1i32;
|
||||||
for (x, j) in datamatrix.layout.iter().enumerate() {
|
for j in datamatrix.layout.iter() {
|
||||||
if y % 8 == 0 {
|
let p = Pad { x: x, y: y };
|
||||||
y += 1;
|
|
||||||
};
|
|
||||||
let p = Pad { x: x as i32, y: y };
|
|
||||||
let c = match j.status {
|
let c = match j.status {
|
||||||
4 => Color::RED,
|
4 => Color::RED,
|
||||||
3 => Color::YELLOW,
|
3 => Color::from_hue(0.05),
|
||||||
2 => Color::WHITE,
|
2 => Color::from_hue(1.24),
|
||||||
_ => Color::GREEN,
|
_ => Color::GREEN,
|
||||||
};
|
};
|
||||||
canvas[p] = c;
|
canvas[p] = c;
|
||||||
|
x += 1;
|
||||||
|
if x % MATRIX_SIZE == 0 {
|
||||||
|
y += 1;
|
||||||
|
x = 0;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
let _a = canvas.flush();
|
let _a = canvas.flush();
|
||||||
std::thread::sleep(std::time::Duration::from_secs(cfg.refresh.unwrap_or(5)));
|
std::thread::sleep(std::time::Duration::from_secs(cfg.refresh.unwrap_or(5)));
|
||||||
|
Loading…
Reference in New Issue
Block a user