diff --git a/README.md b/README.md index 609e52c..d783e81 100644 --- a/README.md +++ b/README.md @@ -14,8 +14,9 @@ zabbixlaunch is a application that take control over a launchpad mini, and draw "server": "https://zabbix.acme.com/api_jsonrpc.php", "username": "bob", "password": "password", - "authtoken": "token", - "limit": 20 + "sloweffect": true, + "refresh": 2, + "limit": 100 } ``` @@ -48,7 +49,7 @@ cargo build --release ## License ```text -Copyright (c) 2021 PaulBSD +Copyright (c) 2021, 2022 PaulBSD All rights reserved. Redistribution and use in source and binary forms, with or without diff --git a/config.json.sample b/config.json.sample new file mode 100644 index 0000000..28cbeb0 --- /dev/null +++ b/config.json.sample @@ -0,0 +1,8 @@ +{ + "server": "https://zabbix.acme.com/api_jsonrpc.php", + "username": "bob", + "password": "password", + "sloweffect": true, + "refresh": 2, + "limit": 100 +} \ No newline at end of file diff --git a/src/padcontrol/mod.rs b/src/padcontrol/mod.rs index 9d5cd58..d050458 100644 --- a/src/padcontrol/mod.rs +++ b/src/padcontrol/mod.rs @@ -81,7 +81,7 @@ fn test(ctx: &mut Context) { pub fn draw(canvas: &mut CanvasLayout, ctx: &mut Context) { println!("Refresh rate is {} seconds", ctx.cfg.refresh.unwrap()); loop { - ctx.hotreload(); + let mut max = 0; let zabbix_data = match get_zabbix_problems(&ctx.cfg) { Ok(zabbix_data) => zabbix_data, Err(_) => { @@ -92,7 +92,7 @@ pub fn draw(canvas: &mut CanvasLayout, ctx: &mut Context) { }; ctx.datamatrix.compute(&zabbix_data); clear(canvas); - let mut max = 0; + for (i, j) in ctx.datamatrix.layout.iter().enumerate() { let p = Pad { x: ((i as i32) % MATRIX_WIDTH), @@ -106,15 +106,16 @@ pub fn draw(canvas: &mut CanvasLayout, ctx: &mut Context) { _ => Color::GREEN, }; canvas[p] = c; - max += 1; - if max >= MATRIX_SIZE { - break; - } if ctx.cfg.sloweffect.unwrap() { sleep(Duration::from_millis(15)); } canvas.flush().unwrap(); + max += 1; + if max >= MATRIX_SIZE { + break; + } } + ctx.hotreload(); } } @@ -141,8 +142,8 @@ fn effect(canvas: &mut CanvasLayout, poller: &mut CanvasLayoutPoller) { } fn clear(canvas: &mut CanvasLayout) { - for a in 0..8 { - for b in 0..9 { + for a in 0..MATRIX_WIDTH { + for b in 0..MATRIX_WIDTH+1 { canvas[Pad { x: a, y: b }] = Color { r: ZERO_COLOR, g: ZERO_COLOR, diff --git a/src/zabbix/problems.rs b/src/zabbix/problems.rs index 27d44c3..3ae11d5 100644 --- a/src/zabbix/problems.rs +++ b/src/zabbix/problems.rs @@ -26,6 +26,10 @@ impl DataMatrix { let severity = res["priority"].as_str().unwrap().parse::().unwrap(); self.layout.push(ZabbixProblems { status: severity }); } + // test + /*for i in 0..1000 { + self.layout.push(ZabbixProblems { status: 5 }); + }*/ } }