STM32F401 Shape-Drawing Firmware

Job ID: 40025860

Budget: £20 – £45 GBP

1. Core Goal
Build an STM32 program that uses joystick, LCD, RGB LED, and two potentiometers to draw shapes on the screen, controlled via a finite state machine.

2. Required Classes
• Use Potentiometer and LED classes unchanged.
• Create SamplingPotentiometer (inherits Potentiometer) using a Ticker to auto-sample at a given frequency.
• No extra members beyond the given spec.

3. State Machine
• Implement inside main() using an enum.
• States handle everything: selecting start point, menus, shape choice, drawing shapes, showing options, etc.
• Use RGB LED to indicate state (red initial, white menu, blue circle, yellow square, green rectangle).

4. Inputs & Interrupts
• Joystick buttons must use InterruptIn with efficient ISR callbacks.
• ISRs only change state or update tiny variables (no LCD calls, no waits).
• Potentiometers move the on-screen cursor (x via left pot, y via right pot).

5. GUI Requirements
• LCD must show cursor in real time (never off-screen).
• Implement a simple shape menu and options GUI.
• Shapes must be drawn smoothly with no flicker.
• After drawing: display area, circumference, aspect ratio for 2 seconds.

6. Objects Required
• C12832 LCD object
• LED objects (RGB)
• InterruptIn objects
• SamplingPotentiometer objects
• Minimal globals (ideally just the program state)

7. Marking Essentials
To get full marks your program MUST include:
• Working SamplingPotentiometer class
• Correct state machine with default safety state
• Accurate shape calculations (2dp)
• Clean ISRs + proper interrupt use
• Smooth GUI + correct LED colours
• Compiling code + ability to explain how it works

8. Workflow Advice
• Build in stages: test SamplingPot → test LCD drawing → test state machine → integrate everything.
• Use a flowchart/plan for all states.
• Do not try to build the whole thing at once.