0% found this document useful (0 votes)
2 views1 page

GUI Interface Reflection

The Tkinter Robot Control Panel is structured in two layers: a lower layer with GPIO functions for motor control and an upper layer with a GUI built using Tkinter. It features speed control via a Tkinter Scale widget, a status label for direction and speed, and ensures safe GPIO cleanup on exit. Optional enhancements include simulation mode, hover feedback, an event log, and a hardware badge indicating the current mode.

Uploaded by

Omkar Deshpande
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views1 page

GUI Interface Reflection

The Tkinter Robot Control Panel is structured in two layers: a lower layer with GPIO functions for motor control and an upper layer with a GUI built using Tkinter. It features speed control via a Tkinter Scale widget, a status label for direction and speed, and ensures safe GPIO cleanup on exit. Optional enhancements include simulation mode, hover feedback, an event log, and a hardware badge indicating the current mode.

Uploaded by

Omkar Deshpande
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Tkinter Robot Control Panel

1. Design Choices and Logic


The program is divided into two layers. The lower layer contains six standalone GPIO functions
(motor_forward, motor_backward, motor_left, motor_right, motor_stop, gpio_cleanup) with no dependency
on Tkinter, so they can be tested from the terminal independently. The upper layer is the RobotControlPanel
class, which builds the GUI and calls these functions from button callbacks.
Five direction buttons are placed in a D-pad cross using Tkinter's grid() geometry manager. Forward
occupies row 1 column 1; Left, Stop, and Right share row 2 columns 0-2; Backward sits at row 3 column 1. A
factory method _btn() creates each button with consistent styling and hover bindings, avoiding repetition.

2. Speed Control with Tkinter Scale


A Tkinter Scale widget provides speed control from 0 % to 100 %. The widget stores its value in a
[Link]() called speed_var so any button callback reads it with a simple speed_var.get() call. The command=
parameter fires _on_speed() on every slider movement, not just on mouse release.

Speed is applied to the motors via Hardware PWM on ENA (GPIO 12) and ENB (GPIO 13) at 1 kHz.
When the slider moves while the robot is already driving, _apply_speed() immediately updates
ChangeDutyCycle() on both PWM objects so the speed change is felt in real time without pressing any button
again.

3. Status Label Widget


A single [Link] widget called lbl_status shows the current direction and speed. The helper method
_update_status(direction, speed) is the only code path that writes to this label, keeping the display always
consistent. It is called after every button press and every slider movement.
The label foreground colour changes with direction: green for Forward, red for Backward, blue for Left
and Right, and grey for Stopped, providing an instant visual cue alongside the text.

4. Safe GPIO Cleanup on Exit


The window close button (X) is intercepted using Tkinter's protocol mechanism so GPIO is always
released cleanly, even if the user closes the window without pressing Stop.
The handler calls motor_stop() to brake both motors, then gpio_cleanup() which stops both PWM objects
and calls [Link]() to reset all pins to safe input state. This prevents motors from running after the
program ends.

5. Optional Enhancements
• Simulation mode: A try/except import guard sets GPIO_AVAILABLE = False when [Link] is
absent. All GPIO calls are silently skipped, so the full GUI runs on any laptop for testing and
demonstration.
• Hover feedback: Buttons lighten on mouse-over using <Enter> / <Leave> event bindings, giving
tactile visual feedback without image assets.
• Event log: A scrollable, read-only Text widget records every command with a timestamp, colour-
coded by action type (green forward, red backward, blue turn, grey stop, orange speed).
• Hardware badge: The header displays 'Hardware Active' in green or 'Simulation Mode' in red so the
operator immediately sees which mode is running.

You might also like