File: i_feel_today.py

package info (click to toggle)
firmware-microbit-micropython 1.0.1-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, sid
  • size: 25,448 kB
  • sloc: ansic: 83,496; cpp: 27,664; python: 2,475; asm: 274; makefile: 245; javascript: 41; sh: 25
file content (20 lines) | stat: -rwxr-xr-x 587 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
"""
Program that shows different emotions.
Push button "A" to become sadder and "B" to become happier.
"""

from microbit import *

horror = Image("09090:00000:09990:90009:99999")
better_meh = Image("00000:09090:00000:99999:00000")
joy = Image("09090:00000:99999:90009:09990")

emotions = [horror, Image.SAD, better_meh, Image.HAPPY, joy]
current_emotion = 2

while True:
    if button_a.get_presses():
        current_emotion = max(current_emotion - 1, 0)
    elif button_b.get_presses():
        current_emotion = min(current_emotion + 1, 4)
    display.show(emotions[current_emotion])