Warning
This page is located in archive. Go to the latest version of this course pages. Go the latest version of this page.

Lab10 - Project

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

  • A PC application
  • Nucleo board

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):

  • DRAW:SETTEXTCOLOR BLACK;

Response: No response is requested.

DRAW:CLEAR

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

Example (BSP_LCD_Clear):

  • DRAW:CLEAR 9;

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):

  • DRAW:PIXEL 30,40,4;

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):

  • DRAW:LINE 10,10,30,30;

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):

  • DRAW:CIRCLE 64,80,30;

Response: No response is requested.

DRAW:SETFONT

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

  • 24 poits
  • 20 points
  • 16 points
  • 12 points
  • 8 points

Example (BSP_LCD_SetFont):

  • DRAW:SETFONT 20;

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):

  • DRAW:TEXT 64,80,Nucleo RULEZ!,1;

Response: No response is requested.

PC application

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

The basic functionality

  • Send and receive command *IDN?
  • The application is able to send basic commands entered on request.
  • The app is capable to open a text file and send the commands stored in the file to the device.

The Full functionality:

  • The application uses two threads: main thread reads command.txt and waits for joystick info to send a command to the NUCLEO. Thread1 captures user input and sends them to the NUCLEO.

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

  • The Nucleo sends the asynchronous data based on the joystick events.
  • The Nucleo is capable to process all the commands described.
  • The PC application is capable to send “DRAW:TEXT 64,80,Nucleo RULEZ!,1” commands with space and Nucleo is capable to show the correct strings on the display.
  • Display the sent command on display. If the length of the command exceeds display width, wrap it into two (or three if necessary) lines.
  • The final homework is presented before the end of the term.

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;

courses/be5b99cpl/labs/lab10.txt · Last modified: 2022/01/03 12:01 by amjadara