-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Post to printer when button is pressed #8
Conversation
src/main.rs
Outdated
@@ -64,6 +70,11 @@ async fn amain(mut leds: Leds, mut wifi: AsyncWifi<EspWifi<'static>>) { | |||
log::error!("ZAP: Printer error: {e}"); | |||
} | |||
} | |||
if matches!(button_switch.get_level(), Level::High) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should have a state variable here that doesnt block but doesnt print multiple times when the button is pressed. i.e., if you press the button it should only print once, then wait for the button to not be pressed instead of being able to send another receipt request.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Err I thought we were magically protected by that by the fact that the code in this loop only seems to run once every second? My understanding was that every second it's checking the state of the pins, if the button is pressed then it sends a print command, then blocks and checks again after 1 second. If this is how it works, why would it be possible to send multiple print commands? Other than holding the button for 2+ seconds
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I completely forgot about that, but that actually presents a different problem: If the user pushes the button while this is sleeping, it will be ignored. You should decrease the sleep delay and also add my suggestion since it will then become necessary.
src/main.rs
Outdated
let peripherals = Peripherals::take().unwrap(); | ||
|
||
// The buttonled and button switch pins are reversed from the original board schematic since pin 36 is input only (oops) | ||
let _button_led = PinDriver::output(peripherals.pins.gpio15).unwrap(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be cool if the button flashed on 1 sec/off 1 sec
This PR posts to the awestruck printer at BURST ✷ when the button is pressed. I think