Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Complete the implementation of the setup and process functions. Download and use this SDK which contains functions that will be used throughout this exercise: https://www.dropbox.com/s/5dgvvu4siezucx9/sdk.zip?dl=0

Complete the implementation of the setup and process functions.

Download and use this SDK which contains functions that will be used throughout this exercise: https://www.dropbox.com/s/5dgvvu4siezucx9/sdk.zip?dl=0

image text in transcribed

Complete using the code below, I've already completed b, c & d. I need a, e, f, g & h completed.

#include

#include

#include

#include

#include

#include

#include "lcd_model.h"

void setup( void ) {

set_clock_speed(CPU_8MHz);

// (a) Enable input from the joystick-left switch and joystick-right switch.

// (b) Initialise the LCD display using the default contrast setting.

lcd_init(LCD_DEFAULT_CONTRAST);

// (c) Use one of the functions declared in "graphics.h" to display

// your number, "j29847563", using the foreground colour,

// positioning the left edge of the text at 11 and the nominal top

// of the text at 20.

draw_string(11, 20, "j29847563", FG_COLOUR);

// (d) Use one of the functions declared in "graphics.h" to copy the contents

// of the screen buffer to the LCD.

show_screen();

}

// (e) Declare a global variable of type int named Contrast and

// initialise it to the default LCD contrast.

void process(void) {

// (f) Test pin corresponding to joystick-right switch. If closed,

// decrement Contrast by 4. If the result is less than zero,

// set Contrast to the maximum permitted LCD contrast value.

// (g) Test pin corresponding to joystick-left switch. If closed,

// increment Contrast by 4. If the result is greater

// then the maximum permitted LCD contrast value, set Contrast

// to zero.

// (h) Send a sequence of commands to the LCD to enable extended

// instructions, set contrast to the current value of Contrast,

// and finally retore the LCD to basic instruction mode.

}

int main(void) {

setup();

for ( ;; ) {

process();

_delay_ms(100);

}

return 0;

}

In this exercise you will get further practice getting user input by reading the state of a pair of switches, and use direct write to the LCD display to adjust the contrast of the display. These operations are directly relevant to microcontroller programming in a wide range of fields Briefly, the programming task is as follows: In setup: Set your Teensy up to receive input from the joystick-left switch and joystick-right switch Turn on the LCD display using the default contrast level. o o Create a global variable called Contrast as indicated in the code skeleton .In process If the joystick-left switch is closed. Cont rast should increase by 4 wrapping to zero if it exceeds the maximum permitted contrast value. If the joystick-right switch is closed, cont rast should decrease by 4, wrapping to the maximum value if it becomes less than 0 Regardless of whether the value of Contrast has changed, before leaving process the LCD contrast should be updated to reflect the current value of contrast. To complete the program, follow the instructions detailed in the in-line comments in the skeleton code below. In this exercise you will get further practice getting user input by reading the state of a pair of switches, and use direct write to the LCD display to adjust the contrast of the display. These operations are directly relevant to microcontroller programming in a wide range of fields Briefly, the programming task is as follows: In setup: Set your Teensy up to receive input from the joystick-left switch and joystick-right switch Turn on the LCD display using the default contrast level. o o Create a global variable called Contrast as indicated in the code skeleton .In process If the joystick-left switch is closed. Cont rast should increase by 4 wrapping to zero if it exceeds the maximum permitted contrast value. If the joystick-right switch is closed, cont rast should decrease by 4, wrapping to the maximum value if it becomes less than 0 Regardless of whether the value of Contrast has changed, before leaving process the LCD contrast should be updated to reflect the current value of contrast. To complete the program, follow the instructions detailed in the in-line comments in the skeleton code below

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

More Books

Students also viewed these Databases questions