mirror of
https://gitlab1.ptb.de/waltem01/Matrix
synced 2024-12-25 03:31:44 +00:00
populate API data
This commit is contained in:
parent
4d15cefdbd
commit
68cbd7fd6b
32
src/cell.rs
32
src/cell.rs
@ -118,10 +118,42 @@ pub async fn display_grid(client: &reqwest::Client, grid: &Vec<Vec<Cell>>) -> Re
|
||||
// Print cell to console
|
||||
let index = map_num(state, 0, Q as usize, 0, BRIGHTNESS.len());
|
||||
print!("{}", BRIGHTNESS.chars().nth(index).unwrap());
|
||||
|
||||
// Add object to json
|
||||
let scale = map_num(state, 0, Q as usize, 0, 256);
|
||||
let xw = ((x as u32) * w).to_string();
|
||||
let yh = ((y as u32) * h).to_string();
|
||||
|
||||
// Additional string copies
|
||||
let ss = scale.to_string();
|
||||
let ws = w.to_string();
|
||||
let hs = h.to_string();
|
||||
|
||||
// Insert data into hashmap
|
||||
let mut color = HashMap::new();
|
||||
color.insert("endpoint", "color".to_string());
|
||||
color.insert("r", ss.clone());
|
||||
color.insert("g", ss.clone());
|
||||
color.insert("b", ss);
|
||||
let mut rect = HashMap::new();
|
||||
rect.insert("endpoint", "rectangle".to_string());
|
||||
rect.insert("x", xw);
|
||||
rect.insert("y", yh);
|
||||
rect.insert("w", ws);
|
||||
rect.insert("h", hs);
|
||||
|
||||
// Add data to list
|
||||
map_list.push(color);
|
||||
map_list.push(rect);
|
||||
}
|
||||
println!();
|
||||
}
|
||||
|
||||
// Create UPDATE instruction
|
||||
let mut update = HashMap::new();
|
||||
update.insert("endpoint", "update".to_string());
|
||||
map_list.push(update);
|
||||
|
||||
// Create formdata serializable object
|
||||
let mut fdata = HashMap::new();
|
||||
fdata.insert("instructions", serde_json::to_string(&map_list).unwrap());
|
||||
|
Loading…
Reference in New Issue
Block a user