EMBSYS110 Assignment 2-LED Pattern Solved

30.00 $

Category:
Click Category Button to View Your Next Assignment | Homework

You'll get a download link with a: zip solution files instantly, after Payment

Securely Powered by: Secure Checkout

Description

Rate this product

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.

2         Setup

  1. 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.
  2. 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.

  1. Backup your existing project folder, e.g. mv platform-stm32f401-nucleo platform-stm32f401-nucleo.bak
  2. Decompress the tgz file with:

tar xvzf platform-stm32f401-nucleo_assignment2.tgz

The project folder will be expanded to ~/Projects/stm32/platform-stm32f401-nucleo.

  1. Launch Eclipse. Hit F5 to refresh the project content.

Or you can right-click on the project in Project Explorer and then click “Refresh”.

  1. 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).

3         Tasks

  1. Most to-do tasks are marked with “// UW 2019” in the source code.
  2. Complete the implementation of the LedPattern and LedPatternSet classes in

Copyright (C) 2020 Lawrence Lo. All rights reserved.

src/UserLed/LedPattern.h.

Note – These member functions are inline, and therefore implemented in the header file.

  1. 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.

  1. 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.

  1. 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.)

  • hw02-y4krfd.zip