Table of Contents

Lab10 - Project

The final application of the CPL course is a project composed from:

In summary, the PC application will open a text file that has the commands inside. Then it will wait for the joystick state. If the user pushes the joystick down, NUCLEO will send info to the PC informing that the joystick has been pushed down. Then PC will send the next command from a command text file. If the user pushes the joystick up, the PC will send the command in the previous line of the command text file. Meanwhile, in another thread, the user should be able to send commands to NUCLEO by typing into the terminal (use scanf() function the receive user input and send it to NUCLEO). It is highly recommended to use the template project of eclipse IDE for NUCLEO new LCDs: hw05_new_boards.zip, old LCDs:hw05_old_boards.zip . For the PC side, codes from lab04 lab04_x.zip are recommended to use.

Nucleo board

You need a NUCLEO F446RE board and Adafruit 802 shield LCD. The embedded software allows for standardized communication over RS232 which is part of the StLink debugger. The communication is based on text commands which are sent to the device and the device responds appropriately.

The description of the command interface implemented in NUCLEO is as follows.

The communication protocol will be based on text commands/strings which are ended by ';' character. There are two types of commands: with and without question mark '?'. The commands with question marks require a reply. When a reply is not provided a timeout of 5 sec. shall be detected.

An unimplemented command is indicated in the response as UNKNOWN. An error, e.g. parameter, is indicated as ERROR, “an unresolved command”.

*IDN?

The *IDN?; is a request for identification.

Response: Text string with device name and author identification.

DRAW:SETTEXTCOLOR

The SETTEXTCOLOR has one parameter - the number of colors. The color-coding is as follows:

  1. Black
  2. Grey
  3. Blue
  4. Red
  5. Green
  6. Cyan
  7. Magenta
  8. Yellow
  9. White

Example (BSP_LCD_SetTextColor):

Response: No response is requested.

DRAW:CLEAR

The CLEAR redraws the whole display in one collor (color coding is above).

Example (BSP_LCD_Clear):

Response: No response is requested.

DRAW:PIXEL

The PIXEL controls one image element at [iX, iY] on the display (color coding as above).

Example (BSP_LCD_DrawPixel):

Response: No response is requested.

DRAW:LINE

The LINE draws a line in between a start point [iXs, iYs] and endpoint [iXe, iYe].

Example (BSP_LCD_DrawLine):

Response: No response is requested.

DRAW:CIRCLE

The CIRCLE draws a circle with center at [iXs, iYs] and with radius iR.

Example (BSP_LCD_DrawCircle):

Response: No response is requested.

DRAW:SETFONT

The SETFONT selects from available fonts. The available fonts are:

Example (BSP_LCD_SetFont):

Response: No response is requested.

DRAW:TEXT

The TEXT prints the string at the selected location [iX, iY] with specific alignment. The alignment is following:

  1. Center
  2. Right
  3. Left

Example (BSP_LCD_DisplayStringAt):

Response: No response is requested.

PC application

The application has to be able to send the device commands and accept responses.

The basic functionality

The Full functionality:

Please note: These parameters of the program will be evaluated:

An example for commands.txt file

*IDN?;

DRAW:CLEAR 2;

DRAW:SETTEXTCOLOR 3;

DRAW:CIRCLE 49,20;

DRAW:CIRCLE 79,20,10;

DRAW:SETTEXTCOLOR 2;

DRAW:LINE 55,40,60,45;

DRAW:LINE 68,45,73,40;

DRAW:LINE 60,45,68,45;

DRAW:SETFONT 12;

DRAW:TEXT 64,120,Nucleo RULEZ!,1;