MicroPython Tutorial VII

We have charged ahead in the last few tutorials and I thought this might be a good place to take stock. As I said in last tutorial you covered buttons, LEDs, sounds and images.

Lets take a few moments to review. The buttons we already named in the first tutorial. Here is reminder. You got 10 choices.

LEFT_DOWN
DOWN
RIGHT_DOWN
LEFT
CENTER
RIGHT
LEFT_UP

UP
BEACON
RIGHT_UP

Moving ahead beyond buttons, we talked about color, now in LEDs we have just four colors, although in honestly there are very few defined in MicroPython anyway. Here is a complete list for future reference, you can use all the colours with the colour sensor.

Color.BLACK, 
Color.BLUE,
Color.GREEN,
Color.YELLOW,
Color.RED,
Color.WHITE,
Color.BROWN or
None

We picked sounds from a collection that downloads with the ev3dev brickman image. You can find the complete list by using the command “ls -lR /usr/share/sounds” obviously when you logged into the brick. At the time of writing I find these files.

robot@lima:~$ ls -lR /usr/share/sounds
/usr/share/sounds:
total 8
drwxr-xr-x 2 root root 4096 Mar 4 03:42 alsa
drwxr-xr-x 11 root root 4096 Mar 4 03:51 ev3dev
/usr/share/sounds/alsa:
total 1212
-rw-r--r-- 1 root root 137134 Jan 23 2017 Front_Center.wav
-rw-r--r-- 1 root root 142128 Jan 23 2017 Front_Left.wav
-rw-r--r-- 1 root root 146990 Jan 23 2017 Front_Right.wav
-rw-r--r-- 1 root root 135202 Jan 23 2017 Noise.wav
-rw-r--r-- 1 root root 130096 Jan 23 2017 Rear_Center.wav
-rw-r--r-- 1 root root 126064 Jan 23 2017 Rear_Left.wav
-rw-r--r-- 1 root root 146480 Jan 23 2017 Rear_Right.wav
-rw-r--r-- 1 root root 134868 Jan 23 2017 Side_Left.wav
-rw-r--r-- 1 root root 129966 Jan 23 2017 Side_Right.wav
/usr/share/sounds/ev3dev:
total 36
drwxr-xr-x 2 root root 4096 Mar 4 03:51 animals
drwxr-xr-x 2 root root 4096 Mar 4 03:51 colors
drwxr-xr-x 2 root root 4096 Mar 4 03:51 communication
drwxr-xr-x 2 root root 4096 Mar 4 03:51 expressions
drwxr-xr-x 2 root root 4096 Mar 4 03:51 information
drwxr-xr-x 2 root root 4096 Mar 4 03:51 mechanical
drwxr-xr-x 2 root root 4096 Mar 4 03:51 movements
drwxr-xr-x 2 root root 4096 Mar 4 03:51 numbers
drwxr-xr-x 2 root root 4096 Mar 4 03:51 system
/usr/share/sounds/ev3dev/animals:
total 1172
-rw-r--r-- 1 root root 151088 Sep 28 2017 cat_purr.wav
-rw-r--r-- 1 root root 127856 Sep 28 2017 dog_bark_1.wav
-rw-r--r-- 1 root root 28268 Sep 28 2017 dog_bark_2.wav
-rw-r--r-- 1 root root 89894 Sep 28 2017 dog_growl.wav
-rw-r--r-- 1 root root 55854 Sep 28 2017 dog_sniff.wav
-rw-r--r-- 1 root root 79964 Sep 28 2017 dog_whine.wav
-rw-r--r-- 1 root root 61710 Sep 28 2017 elephant_call.wav
-rw-r--r-- 1 root root 127168 Sep 28 2017 insect_buzz_1.wav
-rw-r--r-- 1 root root 114870 Sep 28 2017 insect_buzz_2.wav
-rw-r--r-- 1 root root 125758 Sep 28 2017 insect_chirp.wav
-rw-r--r-- 1 root root 63108 Sep 28 2017 snake_hiss.wav
-rw-r--r-- 1 root root 63990 Sep 28 2017 snake_rattle.wav
-rw-r--r-- 1 root root 85598 Sep 28 2017 t-rex_roar.wav
/usr/share/sounds/ev3dev/colors:
total 308
-rw-r--r-- 1 root root 45026 Dec 8 2018 black.wav
-rw-r--r-- 1 root root 39910 Dec 8 2018 blue.wav
-rw-r--r-- 1 root root 47848 Dec 8 2018 brown.wav
-rw-r--r-- 1 root root 42204 Dec 8 2018 green.wav
-rw-r--r-- 1 root root 39382 Dec 8 2018 red.wav
-rw-r--r-- 1 root root 42732 Dec 8 2018 white.wav
-rw-r--r-- 1 root root 46438 Dec 8 2018 yellow.wav
/usr/share/sounds/ev3dev/communication:
total 932
-rw-r--r-- 1 root root 51552 Dec 8 2018 bravo.wav
-rw-r--r-- 1 root root 58256 Dec 8 2018 ev3.wav
-rw-r--r-- 1 root root 60372 Dec 8 2018 fantastic.wav
-rw-r--r-- 1 root root 55962 Dec 8 2018 game_over.wav
-rw-r--r-- 1 root root 38500 Dec 8 2018 go.wav
-rw-r--r-- 1 root root 36030 Dec 8 2018 good.wav
-rw-r--r-- 1 root root 48024 Dec 8 2018 good_job.wav
-rw-r--r-- 1 root root 44674 Dec 8 2018 goodbye.wav
-rw-r--r-- 1 root root 43792 Dec 8 2018 hello.wav
-rw-r--r-- 1 root root 38146 Dec 8 2018 hi.wav
-rw-r--r-- 1 root root 46966 Dec 8 2018 lego.wav
-rw-r--r-- 1 root root 64782 Dec 8 2018 mindstorms.wav
-rw-r--r-- 1 root root 47672 Dec 8 2018 morning.wav
-rw-r--r-- 1 root root 39204 Dec 8 2018 no.wav
-rw-r--r-- 1 root root 48202 Dec 8 2018 okay.wav
-rw-r--r-- 1 root root 57374 Dec 8 2018 okey-dokey.wav
-rw-r--r-- 1 root root 45732 Dec 8 2018 sorry.wav
-rw-r--r-- 1 root root 51024 Dec 8 2018 thank_you.wav
-rw-r--r-- 1 root root 44320 Dec 8 2018 yes.wav
/usr/share/sounds/ev3dev/expressions:
total 896
-rw-r--r-- 1 root root 34652 Sep 28 2017 boing.wav
-rw-r--r-- 1 root root 45186 Sep 28 2017 boo.wav
-rw-r--r-- 1 root root 136788 Sep 28 2017 cheering.wav
-rw-r--r-- 1 root root 127492 Sep 28 2017 crunching.wav
-rw-r--r-- 1 root root 62048 Sep 28 2017 crying.wav
-rw-r--r-- 1 root root 94606 Sep 28 2017 fanfare.wav
-rw-r--r-- 1 root root 41272 Sep 28 2017 kung_fu.wav
-rw-r--r-- 1 root root 41938 Sep 28 2017 laughing_1.wav
-rw-r--r-- 1 root root 31818 Sep 28 2017 laughing_2.wav
-rw-r--r-- 1 root root 87214 Sep 28 2017 magic_wand.wav
-rw-r--r-- 1 root root 26068 Sep 28 2017 ouch.wav
-rw-r--r-- 1 root root 16610 Sep 28 2017 shouting.wav
-rw-r--r-- 1 root root 5182 Sep 28 2017 smack.wav
-rw-r--r-- 1 root root 17960 Sep 28 2017 sneezing.wav
-rw-r--r-- 1 root root 80306 Sep 28 2017 snoring.wav
-rw-r--r-- 1 root root 21968 Sep 28 2017 uh-oh.wav
/usr/share/sounds/ev3dev/information:
total 924
-rw-r--r-- 1 root root 57374 Dec 8 2018 activate.wav
-rw-r--r-- 1 root root 56844 Dec 8 2018 analyze.wav
-rw-r--r-- 1 root root 55258 Dec 8 2018 backwards.wav
-rw-r--r-- 1 root root 44674 Dec 8 2018 color.wav
-rw-r--r-- 1 root root 50318 Dec 8 2018 detected.wav
-rw-r--r-- 1 root root 42556 Dec 8 2018 down.wav
-rw-r--r-- 1 root root 44144 Dec 8 2018 error.wav
-rw-r--r-- 1 root root 53686 Dec 8 2018 error_alarm.wav
-rw-r--r-- 1 root root 54376 Dec 8 2018 flashing.wav
-rw-r--r-- 1 root root 51906 Dec 8 2018 forward.wav
-rw-r--r-- 1 root root 44496 Dec 8 2018 left.wav
-rw-r--r-- 1 root root 48554 Dec 8 2018 object.wav
-rw-r--r-- 1 root root 42732 Dec 8 2018 right.wav
-rw-r--r-- 1 root root 49966 Dec 8 2018 searching.wav
-rw-r--r-- 1 root root 46790 Dec 8 2018 start.wav
-rw-r--r-- 1 root root 43792 Dec 8 2018 stop.wav
-rw-r--r-- 1 root root 44496 Dec 8 2018 touch.wav
-rw-r--r-- 1 root root 39910 Dec 8 2018 turn.wav
-rw-r--r-- 1 root root 39382 Dec 8 2018 up.wav
/usr/share/sounds/ev3dev/mechanical:
total 644
-rw-r--r-- 1 root root 45908 Sep 29 2017 air_release.wav
-rw-r--r-- 1 root root 37530 Sep 29 2017 airbrake.wav
-rw-r--r-- 1 root root 93536 Sep 29 2017 backing_alert.wav
-rw-r--r-- 1 root root 39266 Sep 30 2017 horn_1.wav
-rw-r--r-- 1 root root 50318 Sep 30 2017 horn_2.wav
-rw-r--r-- 1 root root 42380 Sep 30 2017 laser.wav
-rw-r--r-- 1 root root 39370 Sep 30 2017 motor_idle.wav
-rw-r--r-- 1 root root 63476 Sep 30 2017 motor_start.wav
-rw-r--r-- 1 root root 41624 Sep 30 2017 motor_stop.wav
-rw-r--r-- 1 root root 31304 Sep 30 2017 ratchet.wav
-rw-r--r-- 1 root root 88360 Sep 30 2017 sonar.wav
-rw-r--r-- 1 root root 58844 Sep 30 2017 tick_tack.wav
/usr/share/sounds/ev3dev/movements:
total 136
-rw-r--r-- 1 root root 66194 Sep 30 2017 speed_down.wav
-rw-r--r-- 1 root root 15342 Sep 30 2017 speed_idle.wav
-rw-r--r-- 1 root root 52022 Sep 30 2017 speed_up.wav
/usr/share/sounds/ev3dev/numbers:
total 484
-rw-r--r-- 1 root root 40792 Dec 8 2018 eight.wav
-rw-r--r-- 1 root root 44674 Dec 8 2018 five.wav
-rw-r--r-- 1 root root 42732 Dec 8 2018 four.wav
-rw-r--r-- 1 root root 42380 Dec 8 2018 nine.wav
-rw-r--r-- 1 root root 42732 Dec 8 2018 one.wav
-rw-r--r-- 1 root root 45732 Dec 8 2018 seven.wav
-rw-r--r-- 1 root root 44144 Dec 8 2018 six.wav
-rw-r--r-- 1 root root 40968 Dec 8 2018 ten.wav
-rw-r--r-- 1 root root 42732 Dec 8 2018 three.wav
-rw-r--r-- 1 root root 39028 Dec 8 2018 two.wav
-rw-r--r-- 1 root root 47320 Dec 8 2018 zero.wav
/usr/share/sounds/ev3dev/system:
total 160
-rw-r--r-- 1 root root 932 Sep 28 2017 click.wav
-rw-r--r-- 1 root root 49128 Sep 28 2017 confirm.wav
-rw-r--r-- 1 root root 40236 Dec 8 2018 general_alert.wav
-rw-r--r-- 1 root root 47148 Sep 28 2017 overpower.wav
-rw-r--r-- 1 root root 17138 Dec 8 2018 ready.wav

Images can be found in almost the same place, with the same command. Try logging into the brick and typing “ls -lR /usr/share/images”. Again I find these files at the time of writing. The resolution of the great majority if not all of them is 160 pixels x 120 pixels. According to the wikipage the maximum resolution is 178 x 128, you find a good deal of other useful info there too, take a look, here is the link.

robot@lima:~$ ls -lR /usr/share/images
/usr/share/images:
total 4
drwxr-xr-x 3 root root 4096 Mar 4 03:51 ev3dev
/usr/share/images/ev3dev:
total 4
drwxr-xr-x 6 root root 4096 Mar 4 03:51 mono
/usr/share/images/ev3dev/mono:
total 16
drwxr-xr-x 2 root root 4096 Mar 4 03:51 eyes
drwxr-xr-x 2 root root 4096 Mar 4 03:51 information
drwxr-xr-x 2 root root 4096 Mar 4 03:51 lego
drwxr-xr-x 2 root root 4096 Mar 4 03:51 objects
/usr/share/images/ev3dev/mono/eyes:
total 88
-rw-r--r-- 1 root root 600 Dec 8 2018 angry.png
-rw-r--r-- 1 root root 701 Dec 8 2018 awake.png
-rw-r--r-- 1 root root 687 Dec 8 2018 bottom_left.png
-rw-r--r-- 1 root root 692 Dec 8 2018 bottom_right.png
-rw-r--r-- 1 root root 698 Dec 8 2018 crazy_1.png
-rw-r--r-- 1 root root 702 Dec 8 2018 crazy_2.png
-rw-r--r-- 1 root root 885 Dec 8 2018 dizzy.png
-rw-r--r-- 1 root root 694 Dec 8 2018 down.png
-rw-r--r-- 1 root root 773 Dec 8 2018 evil.png
-rw-r--r-- 1 root root 677 Dec 8 2018 knocked_out.png
-rw-r--r-- 1 root root 646 Dec 8 2018 middle_left.png
-rw-r--r-- 1 root root 647 Dec 8 2018 middle_right.png
-rw-r--r-- 1 root root 649 Dec 8 2018 neutral.png
-rw-r--r-- 1 root root 617 Dec 8 2018 pinched_left.png
-rw-r--r-- 1 root root 616 Dec 8 2018 pinched_middle.png
-rw-r--r-- 1 root root 612 Dec 8 2018 pinched_right.png
-rw-r--r-- 1 root root 663 Dec 8 2018 sleeping.png
-rw-r--r-- 1 root root 700 Dec 8 2018 tired_left.png
-rw-r--r-- 1 root root 722 Dec 8 2018 tired_middle.png
-rw-r--r-- 1 root root 717 Dec 8 2018 tired_right.png
-rw-r--r-- 1 root root 684 Dec 8 2018 up.png
-rw-r--r-- 1 root root 637 Dec 8 2018 winking.png
/usr/share/images/ev3dev/mono/information:
total 52
-rw-r--r-- 1 root root 539 Dec 8 2018 accept.png
-rw-r--r-- 1 root root 350 Dec 8 2018 backward.png
-rw-r--r-- 1 root root 649 Dec 8 2018 decline.png
-rw-r--r-- 1 root root 344 Dec 8 2018 forward.png
-rw-r--r-- 1 root root 322 Dec 8 2018 left.png
-rw-r--r-- 1 root root 679 Dec 8 2018 no_go.png
-rw-r--r-- 1 root root 372 Dec 8 2018 question_mark.png
-rw-r--r-- 1 root root 327 Dec 8 2018 right.png
-rw-r--r-- 1 root root 595 Dec 8 2018 stop_1.png
-rw-r--r-- 1 root root 652 Dec 8 2018 stop_2.png
-rw-r--r-- 1 root root 387 Dec 8 2018 thumbs_down.png
-rw-r--r-- 1 root root 376 Dec 8 2018 thumbs_up.png
-rw-r--r-- 1 root root 651 Dec 8 2018 warning.png
/usr/share/images/ev3dev/mono/lego:
total 8
-rw-r--r-- 1 root root 374 Dec 8 2018 ev3.png
-rw-r--r-- 1 root root 515 Dec 8 2018 ev3_icon.png
/usr/share/images/ev3dev/mono/objects:
total 4
-rw-r--r-- 1 root root 685 Dec 8 2018 target.png

The options for alignment don’t really make sense unless you start using your own custom images. Most if not all of the images downloaded are full screen versions at the maximum resolution. The alignment options as I write this are as follows.

    BOTTOM_LEFT
BOTTOM
BOTTOM_RIGHT
LEFT
CENTER
RIGHT
TOP_LEFT
TOP
TOP_RIGHT

The best place to find the definative answers on this of course the manual that you can download from the LEGO website which you find on this link.

https://education.lego.com/en-us/support/mindstorms-ev3/python-for-ev3

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store