Skip to content
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

Merged
merged 4 commits into from
Dec 7, 2024
Merged

Conversation

MatthewStanciu
Copy link
Member

This PR posts to the awestruck printer at BURST ✷ when the button is pressed. I think

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) {
Copy link
Member

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.

Copy link
Member Author

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

Copy link
Member

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();
Copy link
Member

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

@ImTheSquid ImTheSquid merged commit cc8ecba into main Dec 7, 2024
3 checks passed
@ImTheSquid ImTheSquid deleted the matthew/button-pressed branch December 7, 2024 21:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants