Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need assistance with my lab. The language we are using is C and the application this is all on is Code Composer Studio. Thank

image text in transcribed

image text in transcribed

image text in transcribedimage text in transcribedimage text in transcribed

I need assistance with my lab. The language we are using is C and the application this is all on is Code Composer Studio. Thank you in advance. We are using the MSP432 LaunchPad and the Booster Pack MKII

Page of 7 ZOOM + #include #include #include "LcdDriver/Crystalfontz128x128_ST7735.h" /* Graphic library context */ Graphics_Context g_sContext; void LCD_Init() { /* Initializes display Crystalfontz128x128_Init(); * Set default screen orientation */ Crystalfontz128x128_SetOrientation(LCD_ORIENTATION_UP); /* Initializes graphics context Graphics_initContext(&g_sContext, &g_sCrystalfontz128x128, &g_sCrystalfontz128x128_funcs); Graphics_setForegroundColor(&g_sContext, GRAPHICS_COLOR_RED): Graphics setBackgroundColor(&g_sContext, GRAPHICS_COLOR_WHITE); GrContextFontSet(&g_sContext, &g_sFontFixed6x8); Graphics_clear Display(&g_sContext); int main(void) { int32_tx=50, y=70; int32_t vx=1, vy=-1; const int32_t radius=3; uint32_t count=0; WDT_A_holdTimer(); LCD_init(); Example 1: Initialization code for the EDUMKII BoosterPack's LCD screen. The code to initialize the LCD screen is provided above in Example 1. Do not copy and Paste this code from a pdf. You should create an LCD_init() function as shown in Example 1 to keep your main function more readable. Don't forget to call the function after stopping the watchdog timer Page of 7 ZOOM + c The circle should have a radius of 3 or 4 pixels. The circle or ball should start somewhere near the center of the screen. The screen is 128x128 pixels so both x and y pixel coordinates range from 0 to 127. The origin, point(0,0), is in the upper-left corner. . The circle should start with an initial velocity of: o vx = 1 pixel/time-step o vy = -1 pixel/time-step If adding the x-velocity to the current x-coordinate will push the radius of the circle up to the screen's left or right boundaries, then the x-velocity should be negated. (aka vx = -vx). An alternate method is to use a flag to indicate if the ball is moving in the positive or negative x direction. Similarly, for the y-velocity, if adding the y-velocity to the current y-coordinates will push the radius of the circle up to the screen's top or bottom boundaries then the y-velocity should be negated. An alternate method is to use a flag to indicate if the ball is moving in the positive or negative y direction. A simple flowchart is shown in Figure 3. This flowchart shows the update of x, y, vx and vy being done before the circle is erased and redrawn. This ordering is not required. However, by keeping the delay small between the erasure of the old circle and the drawing of the new circle, it will make the movement of the circle appear smoother. This program sequence implies that the old x and old y values are still available for erasing the old circle after x and y are updated. You can easily keep track of the previous x and y values in variables, such as oldx and oldy. You don't have to follow this flowchart exactly, but you do need to do all the calculations and drawing and erasing the ball within the main function. You should try to make the motion of the ball as smooth as possible. Page of 7 ZOOM + #include #include #include "LcdDriver/Crystalfontz128x128_ST7735.h" /* Graphic library context */ Graphics_Context g_sContext; void LCD_Init() { /* Initializes display Crystalfontz128x128_Init(); * Set default screen orientation */ Crystalfontz128x128_SetOrientation(LCD_ORIENTATION_UP); /* Initializes graphics context Graphics_initContext(&g_sContext, &g_sCrystalfontz128x128, &g_sCrystalfontz128x128_funcs); Graphics_setForegroundColor(&g_sContext, GRAPHICS_COLOR_RED): Graphics setBackgroundColor(&g_sContext, GRAPHICS_COLOR_WHITE); GrContextFontSet(&g_sContext, &g_sFontFixed6x8); Graphics_clear Display(&g_sContext); int main(void) { int32_tx=50, y=70; int32_t vx=1, vy=-1; const int32_t radius=3; uint32_t count=0; WDT_A_holdTimer(); LCD_init(); Example 1: Initialization code for the EDUMKII BoosterPack's LCD screen. The code to initialize the LCD screen is provided above in Example 1. Do not copy and Paste this code from a pdf. You should create an LCD_init() function as shown in Example 1 to keep your main function more readable. Don't forget to call the function after stopping the watchdog timer Page of 7 ZOOM + c The circle should have a radius of 3 or 4 pixels. The circle or ball should start somewhere near the center of the screen. The screen is 128x128 pixels so both x and y pixel coordinates range from 0 to 127. The origin, point(0,0), is in the upper-left corner. . The circle should start with an initial velocity of: o vx = 1 pixel/time-step o vy = -1 pixel/time-step If adding the x-velocity to the current x-coordinate will push the radius of the circle up to the screen's left or right boundaries, then the x-velocity should be negated. (aka vx = -vx). An alternate method is to use a flag to indicate if the ball is moving in the positive or negative x direction. Similarly, for the y-velocity, if adding the y-velocity to the current y-coordinates will push the radius of the circle up to the screen's top or bottom boundaries then the y-velocity should be negated. An alternate method is to use a flag to indicate if the ball is moving in the positive or negative y direction. A simple flowchart is shown in Figure 3. This flowchart shows the update of x, y, vx and vy being done before the circle is erased and redrawn. This ordering is not required. However, by keeping the delay small between the erasure of the old circle and the drawing of the new circle, it will make the movement of the circle appear smoother. This program sequence implies that the old x and old y values are still available for erasing the old circle after x and y are updated. You can easily keep track of the previous x and y values in variables, such as oldx and oldy. You don't have to follow this flowchart exactly, but you do need to do all the calculations and drawing and erasing the ball within the main function. You should try to make the motion of the ball as smooth as possible. Page

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2016 Riva Del Garda Italy September 19 23 2016 Proceedings Part 3 Lnai 9853

Authors: Bettina Berendt ,Bjorn Bringmann ,Elisa Fromont ,Gemma Garriga ,Pauli Miettinen ,Nikolaj Tatti ,Volker Tresp

1st Edition

3319461303, 978-3319461304

More Books

Students also viewed these Databases questions

Question

What is meant by Career Planning and development ?

Answered: 1 week ago

Question

What are Fringe Benefits ? List out some.

Answered: 1 week ago