The goal of this assignment is to represent a set of LED patterns using object-based techniques. Students will learn how to encapsulate an abstract idea, i.e. an LED pattern, with C++ classes. Students will implement a typical “hello-world” program to display those patterns with a physical LED.
- Carefully unplug any extension modules from your Nucleo board. They are not required and may hinder your view of the USER LED. Besides, the USER LED pin (PA.5) is shared with the SPI CLK pin of the LCD module, and therefore they cannot be used together.
- Download the compressed project file (platform-stm32f401-nucleo_assignment2.tgz) from the Assignment 2 course site.
Place the downloaded tgz file in your VM under ~/Projects/stm32.
- Backup your existing project folder, e.g. mv platform-stm32f401-nucleo platform-stm32f401-nucleo.bak
- Decompress the tgz file with:
tar xvzf platform-stm32f401-nucleo_assignment2.tgz
The project folder will be expanded to ~/Projects/stm32/platform-stm32f401-nucleo.
- Launch Eclipse. Hit F5 to refresh the project content.
Or you can right-click on the project in Project Explorer and then click “Refresh”.
- Clean and rebuild the project. Download it to the board and make sure it runs.
In minicom, type the command “led on 0” and verify the USER LED blinks twice (with the first one brighter than the second one).
- Most to-do tasks are marked with “// UW 2019” in the source code.
- Complete the implementation of the LedPattern and LedPatternSet classes in
Copyright (C) 2020 Lawrence Lo. All rights reserved.
Note – These member functions are inline, and therefore implemented in the header file.
- Add two new LED patterns to the structure named TEST_LED_PATTERN_SET in src/UserLed/LedPattern.cpp.
Two samples, patterns 0 and 1, are provided for reference. Do not remove them, and append yours as patterns 2 and 3.
- Implement the handlers for the command “led on <index> <repeat>” in src/UserLed/UserLedCmd.cpp.
This command displays the indexed pattern. If repeat is “0”, it is shown once; otherwise it is shown 5 times. Handle the case when the index is out of range. As a reminder, the set of LED patterns is defined in the structure TEST_LED_PATTERN_SET.
Please remove or comment the sample code when adding your own code.
- Test your code with the console command:
led on <pattern index from 0 to 3 > <0 for non-repeating; 1 for repeating>
For example, “led on 3 1” shows pattern 3 for 5 times.)