← Back to Main Portfolio

task_start_button.py

Purpose

This file implements the physical start-button task. It debounces the user pushbutton, toggles the course-enable Share, and can clear bump events when beginning a new run.

Main Role

It provides a clean hardware-based interface for starting or stopping the autonomous course without needing the serial console.

Key Responsibilities

Important Attributes / Shares / Variables

NameDescription
_btnInput pin object for the hardware pushbutton.
_courseEnableShare that enables or disables the obstacle-course routine.
_bumpEventOptional Share cleared when starting a new run.
_prevPrevious button state used for edge detection.
_t_lastTimestamp of the last accepted button event.
_debounceDebounce interval in milliseconds.
_hb_tHeartbeat timer used for periodic debug printouts.

Why This File Matters

This file improves usability and repeatability by allowing the robot to be started from a physical button in a clean, debounced way. It also prevents stale bump events from affecting the next run.

Open raw task_start_button.py file