Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit

EL648 – Real Time Embedded Systems

Exam 1, Fall 2023

Instructions:  This exam is completely open book and open notes.  You may use any coding techniques and may introduce any variables unless otherwise specified.

Motivation : The beginning of our class has focused on the basics of Embedded systems and both the C and Assembly languages that are used to program our microcontrollers.  I mentioned in class that the study of Embedded systems has many parallels to a Signals and Systems course, both including inputs that are operated on to produce outputs.  In Embedded systems, inputs are typically provided   by sensors and outputs are implemented as actuators.  One of the most common ways to provide this I/O capability to an operator is through the use of a TFT touch screen.

During a recent Embedded project, the primary human I/O utilized a wearable round TFT touch screen similar to a watch form factor.  The TFT I choose was a 240 x 240 pixel 1.28” display (reasonable due to its size and resolution). This exam focusses on the design and implementation considerations of this peripheral.  Start a PlatformIO project, select you STM32F429 microcontroller, and lets build the project.

Question 1:

One of the requirements of using a screen is often displaying an image. For this screen, The image is requires to be a single row oriented array of 16 bit “color” values.  So if your image is a square 20 x 20 image, you need to setup a 400 element array of 16 bit values (row by row). There are plent of tools available to convert images to RGB values, which is referred to 24 bit color: 8 bits for Red, followed by 8 bits for Green, followed by 8 bits for Blue (blue is the LSB). To save memory, the TFT screen does not use 24 bit color, but uses 16 bit color instead.  The format is called RGB 565 (5 bits of Red, 6 bits of Green, 5 bits of Blue; 16 total bits where Blue is least significant.  For each color, the new format takes the MSBits to make the new truncate bits.  Lets assume we have a 20 x 20 image that we already converted to RGB, meaning we have a uint8_t array called myImage[1200] which contains 3 bytes for each pixel (that’s why the array size is 400 x 3 = 1200).

Formats:

RGB = R7 RRRRRRR0                G7GGGGGGG0                                B7 BBBBBBB0  (3 BYTES)

RGB565= R7 RRRR3G7GG5                        G4GG2 B7 BBBB3  (2 BYTES)

Write an ARM assembly function called convImage that takes in three parameters. The first parameter is a pointer to myImage. The second parameter is a pointer to a uint16_t array that holds the converted 16 bit color values of the image. The third parameter is the number of pixels in the image. The function should be generic for any size image. Be sure to comment appropriately.

Question 2:

Question 1 will generate a uint_16 array of pixels to display that represent an image. The TFT screen actually provides a function called DrawImage(int x, int y, int w, int h, uint16_t *Image).

x = starting x coordinate on screen (0,0 is upper left hand corner of the screen)

y = starting y coordinate on screen

w = width of image

h = height of image

Image = pointer to array of uint16_t color elements of the image.

Assume the RGB information is provided as :

uint8_t RGBImage[] = {0xRR1, 0xGG1,  0xBB1, 0xRR2, 0xGG2, 0xBB2, 0xRR3………};

uint16_t imageSize = XX  //XX is the number of pixels in the array

Declare an array to hold the RGB565 array and write the code to populate this array by calling the ARM function convImage you developed in Question 1.

Question 3:

The geometry in this TFT unfortunately suffers from the “square peg in a round hole” problem.  That is, While the TFT is 240 x 240, not all pixels are displayed since the display is round. In fact the display is actually a circle inscribed within a 240 x 240 square.  Write two C functions called:

bool itFits(same parameters as DrawImage above)

and

void blackoutBackBits(int x, int y, int w, int h, uint16_t *Image)

itFits returns true if the image can be completely displayed on the round screen. blackoutBackBits sets any pixels in Image to 0 if they are not visible in the round display.  For example, if the image itself is 240 x 240, the first pixel would NOT be visible. In fact all four corners of the image would not be visible.

Submit your answers and code in a single PDF file.  Thank you and good luck!