mirror of
https://github.com/laanwj/k210-sdk-stuff.git
synced 2024-11-22 01:16:20 +04:00
weather: Repeat query every 10 minutes
This commit is contained in:
parent
838067dcb0
commit
0f15e5f85d
@ -123,6 +123,7 @@ fn main() -> ! {
|
||||
let mut ofs: usize = 0;
|
||||
|
||||
let mut cur_link = 0;
|
||||
let mut finished = false;
|
||||
loop {
|
||||
if console.dirty {
|
||||
let mut image: ScreenImage = [0; DISP_WIDTH * DISP_HEIGHT / 2];
|
||||
@ -131,6 +132,16 @@ fn main() -> ! {
|
||||
console.dirty = false;
|
||||
}
|
||||
|
||||
// When finished, wait around a bit and re-do request
|
||||
// do this after updating the console, to be sure the last result is visible before
|
||||
// sleeping
|
||||
if finished {
|
||||
finished = false;
|
||||
usleep(10 * 60 * 1_000_000);
|
||||
cur_link = sh.connect(ConnectionType::TCP, b"wttr.in", 80).unwrap();
|
||||
writeln!(console, "∙ \x1b[38;5;141m[{}]\x1b[0m Opening TCP conn", cur_link).unwrap();
|
||||
}
|
||||
|
||||
// Receive into buffer
|
||||
let mut lastrecv = mcycle::read();
|
||||
while ofs < serial_buf.len() {
|
||||
@ -187,6 +198,7 @@ fn main() -> ! {
|
||||
}
|
||||
NetworkEvent::ConnectionClosed(link) => {
|
||||
writeln!(console, "∙ \x1b[38;5;141m[{}]\x1b[0m \x1b[38;2;100;100;100m[closed]\x1b[0m", link).unwrap();
|
||||
finished = true;
|
||||
}
|
||||
_ => { }
|
||||
}
|
||||
@ -231,11 +243,5 @@ fn main() -> ! {
|
||||
writeln!(debug, "Error: buffer was unparseable, dropping buffer").unwrap();
|
||||
ofs = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
if let Ok(ch) = rx.read() {
|
||||
let _res = block!(wtx.write(ch));
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user