Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please complete the To Do portions of the code using Python. Thank You EE 2450 Module 3 Practice Assignment 3 you will practice using the

Please complete the "To Do" portions of the code using Python. Thank You

EE 2450 Module 3 Practice Assignment 3

you will practice using the List data structure in Python.

We will use the List data structure to "memorize" keypresses the keypresses that

a user presses on the LCD's keypad, and "play" those keypresses on the LCD

once the Select button is pressed.

"""

def return_print_debounce_adc_value(adc_object: ADC, debounce_delay: int=10) ->

int:

"""

return_print_debounce_adc_value(adc_object, debounce_delay=20) will call

the read_u16() function on the input parameter adc_object thrice, with

a default 10 ms debounce spacing between ADC reads.

The values are averaged before printing/returning.

:param: adc_object: the ADC object to read

:returns: the int value of the current signal connected to the ADC

"""

# TODO: fill in function definition here from Practice Assignment 2

def return_and_print_current_button_pressed(adc_value: int) -> str:

"""

return_and_print_current_button_pressed(adc_value) will return the

button pressed (as a string) based on the integer value given.

:param: adc_value: the value of the signal input to the adc

:returns: the string of the button that was pressed

"""

# TODO: fill in function definition here from Practice Assignment 2

def display_list_on_lcd(lcd: GpioLcd, list_of_strs: list) -> None:

"""

display_list_on_lcd(lcd, list_of_strs) will print all strings inside

list_of_strs to the lcd, with a 500 ms wait in between each string.

:param: lcd: the lcd object

:param: list_of_strs: the list of strings to display on the lcd

"""

# TODO: fill in function definition here

def display_string_on_lcd(lcd: GpioLcd, to_display: str) -> None:

"""

display_string_on_lcd(lcd, to_display) will display the string to_display

on the lcd object.

NOTE: Do NOT edit this function, but you can call it to display strings to the

LCD.

:param: lcd: the lcd object

:param: to_display: the string to display on the lcd

"""

lcd.clear()

lcd.putstr(to_display)

def main() -> None:

"""

TODO: setup your Pin, ADC, and List objects.

Then, in an infinite loop:

1. check if a button was pressed

2. if the select button was pressed, display "Printing N",

where N is the length of list_presses, on the LCD, wait 400 ms,

then display all button presses stored in the List on the LCD

display, pausing 500 ms wait in between each print.

Then, display "DONE" on the LCD and clear the List.

3. if a normal directional button was pressed (left, up,

down, right), then store the button pressed in the List,

display the button pressed on the LCD, and then wait for 250 ms.

4. otherwise, sleep for 20 ms.

"""

""" Do NOT edit the lcd variable, which is the LCD's object """

lcd = GpioLcd(rs_pin=Pin("D8"),

enable_pin=Pin("D9"),

d4_pin=Pin("D4"),

d5_pin=Pin("D5"),

d6_pin=Pin("D6"),

d7_pin=Pin("D7"))

""" Edit code after this line. """

pin_analog_button = Pin()

adc_analog_button = ADC()

while True:

# TODO: add code here

main()

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

Unity From Zero To Proficiency Beginner A Step By Step Guide To Coding Your First Game

Authors: Patrick Felicia

1st Edition

1091872023, 978-1091872028

Students also viewed these Programming questions

Question

How are companies and marketers responding to the new challenges?

Answered: 1 week ago

Question

How many multiples of 4 are there between 10 and 250?

Answered: 1 week ago

Question

How many three-digit numbers are divisible by 7?

Answered: 1 week ago