| File | Description |
|---|---|
| README.md | Project overview, hardware, clock features, controls, and objects. |
| docs/01-guide-coding-rules.md | Naming conventions, code style and clang-format setup, commit messages, and document naming. |
| docs/02-design-sequence-object.md | Owned state and signal sequences of RTC, Time, Stopwatch, Timer, Alarm, World Clock, Calendar, and Ringing. |
| docs/03-design-sequence-runtime.md | Clock start, running and ringing flows, task ownership, button processing, and scheduling notes. |
Mini Clock is a digital desk clock built on the AK Embedded Base Kit. It shows the time in digital and analog form, keeps alarms and calendar reminders, runs a stopwatch and a countdown timer, and converts the time to 32 world cities. Time is kept by an external RTC, and settings, alarms, and events survive a power cycle. Through this project, I practiced several embedded concepts:
- System design: Splitting the clock into objects with clear responsibilities.
- Task management: Running each object as an AK task, cooperatively and without blocking delays.
- Communication: Using signals, timers, and messages to carry button input, one-second ticks, and ringing requests.
- State machine: Managing screens and modes such as list, edit, running, and ringing.
![]() |
Figure 1: AK Embedded Base Kit - STM32L151
AK Embedded Base Kit is a development kit for people who already have some experience with embedded programming and want to learn more through practice.
The board includes a 1.54-inch OLED display, 3 push buttons, and a buzzer that can play simple sounds or short melodies. With these built-in parts, you can create small games, menu systems, clocks, and other interactive projects. It is also a good way to learn how event-driven programming works in a real embedded system.
The kit also supports RS485, Qwiic, and Grove connections. This makes it easy to connect sensors, modules, and other devices when testing or building embedded projects.
MCU Overview:
SoC Name : STM32L151CBT6
RAM : 16 KB
Flash Partitions Layout
----------------------
[ 0x08000000 - 0x08001FFF ] : Bootloader Partition (8 KB)
=> AK Bootloader
[ 0x08002000 - 0x08002FFF ] : BSF Shared Partition (4 KB)
=> Used for data sharing between Bootloader and Application
[ 0x08003000 - 0x0801FFFF ] : Application Partition (116 KB)
=> Mini Clock firmware
MCU Naming Convention:
| Part | Meaning |
|---|---|
STM32 |
STMicroelectronics 32-bit MCU family. |
L |
Low-power series. |
151 |
STM32L151 product line. |
C |
48-pin package. |
B |
128 KB Flash memory. |
T |
LQFP package. |
6 |
Industrial temperature grade. |
![]() |
Figure 2: Board view Top + Bottom
External RTC: time is kept by a PCF85063A module on the Qwiic/Grove I2C port (I2C1: SCL PB6, SDA PB7, address 0x51). The RTC holds Vietnam local time (UTC+7); other time zones are derived from it.
This section describes the screens and objects of Mini Clock.
![]() |
Figure 3: Digital screen
After the boot logo, the clock opens on the Digital screen. Press [Mode] to open the Menu:
![]() |
Figure 4: Menu screen
The menu offers:
- Digital: Large
HH:MM:SS, weekday bar, and date, in 12h or 24h format. - Analog: Clock face with hour, minute, and second hands, the date, and the UTC offset.
- Alarm: Up to 10 daily alarms, each with a time and an on/off switch.
- Stopwatch: 0.1 s resolution with up to 10 laps.
- Timer: Countdown up to 23:59:59.
- World Clock: 32 cities. The selected city is also the time zone shown on every other screen.
- Calendar: Month grid, day list, and up to 10 events with a category, start and end time, and an optional reminder.
- Setting: Time and date, display (12/24h, colour invert, brightness), sound (mute, hourly chime, alarm melody), and reset.
- Exit: Idle animation of bouncing balls.
![]() |
Figure 5: Analog screen
![]() |
Figure 6: Setting screen
Note: For detailed object flows, see Clock Object Sequences.
The kit has three buttons: [Mode], [Up], and [Down]. Long means hold the button; [Mode]+[Up] and [Mode]+[Down] mean press [Up] or [Down] while holding [Mode].
- Digital / Analog: [Mode] opens the menu.
- Menu: [Up] / [Down] choose an item, [Mode] opens it.
- Alarm list: [Up] / [Down] move, [Mode] edits an alarm or selects Add New / Back, long [Up] switches the alarm on or off, long [Down] deletes it, [Mode]+[Up] adds and edits a new alarm, [Mode]+[Down] returns to the menu.
- Alarm edit: [Up] / [Down] change the value, [Mode] moves to the next field. On Delete? it deletes the alarm, and on Save? it saves it.
- Stopwatch: [Mode] starts or pauses, long [Mode] resets, [Up] records a lap, [Down] scrolls the laps, long [Up] or long [Down] returns.
- Timer: [Mode] starts or pauses, [Up] / [Down] change the selected field, [Mode]+[Up] / [Mode]+[Down] select the next or previous field, long [Up] resets, long [Down] returns.
- World Clock: [Up] / [Down] change the city, [Mode] returns.
- Calendar (month): [Up] / [Down] select the previous or next day, long [Up] / long [Down] change the month, [Mode] opens the day, long [Mode] adds an event, [Mode]+[Up] returns to the menu.
- Calendar (day): [Up] / [Down] select the next or previous event ([Down] on an empty day adds one), [Mode] edits, long [Mode] deletes, long [Up] or long [Down] returns to the month.
- Calendar (edit): [Up] / [Down] change the value, [Mode] moves to the next field and saves on the last one, long [Mode] saves (or cancels a new event), long [Down] cancels.
- Setting: [Up] / [Down] move, [Mode] selects. In Time, [Up] / [Down] change a field and [Mode] moves on until OK.
- Ringing: any button dismisses it.
- Time zone: The RTC keeps Vietnam time (UTC+7). The city selected in World Clock sets the time zone of every screen, and alarms and reminders use that local time.
- Background counting: The timer, the stopwatch, and calendar reminders keep running when you leave their screens.
- Ringing: An alarm, a finished timer, or a reminder opens an ALARM, TIMER, or EVENT page on top of any screen. The selected alarm melody repeats every 5 seconds. Any button dismisses it, and it stops by itself after 60 seconds. A source that fires while another one is ringing replaces it.
- Persistence: Settings, alarms, and events are stored in EEPROM with a magic number and a checksum. An invalid record falls back to the defaults.
- Sound: Mute silences every sound, including the boot melody. The hourly chime plays at the start of each hour.
![]() |
Figure 7: Ringing screen
Note: For the complete signal flow, see Runtime Signal Processing.
![]() |
Figure 8: Clock sequence logic
Cao Trong Phuoc - Software Engineer - Embedded Systems
Thank you for visiting this repository.
If you have any questions, suggestions, or feedback about this project or firmware development, feel free to contact me directly.
Josef Tan - Software Engineer - Embedded Systems
For questions related to this project, embedded systems, or firmware development, please feel free to reach out through GitHub or LinkedIn.
















