kd1889 / Internet-Radio-for-Kids

0 stars 0 forks source link

Writing stub functions #3

Closed kd1889 closed 3 years ago

kd1889 commented 3 years ago

Create stub functions

kd1889 commented 3 years ago

Added the function

toggle_display(state)

to turn on and off the LCD Screen, based on the given state, 1 and 0, respectively. Test results are shown below:

>>> import radio
>>> radio.toggle_display(0)
Screen is Off
>>> radio.toggle_display(1)
Screen is On
sboahen commented 3 years ago

Added function is_len_on in commit 4884b7ed6020004a4948dc917573b285b9c3270e Test available in commit

sboahen commented 3 years ago

Added function is_button_pressed and tested in fe1490376dc5a3cc7a163ef5cee45d49cb7be0e9

sboahen commented 3 years ago

Preview of test:

Installed /usr/local/lib/python3.8/dist-packages/radio-1.0-py3.8.egg
Processing dependencies for radio==1.0
Finished processing dependencies for radio==1.0
sboahen@SKABB:~/code/Internet-Radio-for-Kids$ python3
Python 3.8.2 (default, Jul 16 2020, 14:00:26)
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import radio
>>> radio.is_button_pressed(9)
True
kd1889 commented 3 years ago

Added the function:

send_data_to_screen(text)

The test results are shown below:

>>> import radio
>>> text = "Quick brown fox jumps over the lazy dog"
>>> radio.send_data_to_screen(text)
The following has been sent to the screen: Quick brown fox jumps over the lazy dog
kd1889 commented 3 years ago

Added the function:

play_sound(sound_file)

The test results are shown below:

>>> import radio
>>> sound_file = "'Hello' By Lionel Richie"
>>> radio.play_sound(sound_file)
Now playing: 'Hello' By Lionel Richie
kd1889 commented 3 years ago

Added demo.py to run all functions.

The results:

pi@raspberrypi:~/Internet-Radio-for-Kids $ python3 demo.py 
Testing is_led_on                                          
True                                                       
Testing is_button_pressed                                  
True                                                       
Testing toggle_display with both possible inputs           
Screen is Off                                              
Screen is On                                               
Testing send_data_to_screen                                
The following has been sent to the screen: My name is Kunj 
Testing play_sound                                         
Now playing: 'Hello' by Lionel Richie