Sun, 04 Apr 2021 16:54:03 +0200
Updated BBC micro:bit APIs for V2.
--- a/Microbit/microbit/__init__.py Wed Apr 29 18:26:18 2020 +0200 +++ b/Microbit/microbit/__init__.py Sun Apr 04 16:54:03 2021 +0200 @@ -22,9 +22,12 @@ def temperature(): pass +def set_volume(volume): + pass + ###################################################################### -class MicroBitButton(): +class Button(): def is_pressed(self): pass @@ -34,11 +37,21 @@ def get_presses(self): pass -button_a = MicroBitButton() -button_b = MicroBitButton() +button_a = Button() +button_b = Button() ###################################################################### +class MicroBitTouchOnlyPin(): + RESISTIVE = 0 + CAPACITIVE = 1 + + def is_touched(self): + pass + + def set_touch_mode(self, mode): + pass + class MicroBitDigitalPin(): PULL_UP = 0 PULL_DOWN = 1 @@ -94,6 +107,9 @@ def set_analog_period_microseconds(self, period): pass + def get_analog_period_microseconds(self): + pass + def set_pull(self, mode): pass @@ -108,6 +124,9 @@ PULL_DOWN = 1 NO_PULL = 2 + RESISTIVE = 0 + CAPACITIVE = 1 + def read_digital(self): pass @@ -126,7 +145,7 @@ def set_analog_period_microseconds(self, period): pass - def is_touched(self): + def get_analog_period_microseconds(self): pass def set_pull(self, mode): @@ -137,6 +156,12 @@ def get_mode(self): pass + + def is_touched(self): + pass + + def set_touch_mode(self, mode): + pass pin0 = MicroBitTouchPin() # Pad 0 pin1 = MicroBitTouchPin() # Pad 1 @@ -158,6 +183,9 @@ pin19 = MicroBitDigitalPin() # I2C SCL pin20 = MicroBitDigitalPin() # I2C SDA +pin_logo = MicroBitTouchOnlyPin() # V2: Touch Logo +pin_speaker = MicroBitDigitalPin() # V2: Speaker + ###################################################################### class Image(): @@ -266,3 +294,23 @@ def blit(self, src, x, y, width, height, xdest=0, ydest=0): pass + +###################################################################### + +class Sound(): + GIGGLE = Sound() + HAPPY = Sound() + HELLO = Sound() + MYSTERIOUS = Sound() + SAD = Sound() + SLIDE = Sound() + SOARING = Sound() + SPRING = Sound() + TWINKLE = Sound() + YAWN = Sound() + +###################################################################### + +class SoundEvent(): + LOUD = SoundEvent('loud') + QUIET = SoundEvent('quiet')
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Microbit/microbit/microphone.py Sun Apr 04 16:54:03 2021 +0200 @@ -0,0 +1,27 @@ +# -*- coding: utf-8 -*- + +# Copyright (c) 2021 Detlev Offenbach <detlev@die-offenbachs.de> +# + +""" +Module containing stubs for API generation of the 'microbit.microphone' +module. +""" + +def current_event(): + pass + +def was_event(event): + pass + +def is_event(event): + pass + +def get_events(): + pass + +def set_threshold(event, value): + pass + +def sound_level(): + pass
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Microbit/microbit/speaker.py Sun Apr 04 16:54:03 2021 +0200 @@ -0,0 +1,15 @@ +# -*- coding: utf-8 -*- + +# Copyright (c) 2021 Detlev Offenbach <detlev@die-offenbachs.de> +# + +""" +Module containing stubs for API generation of the 'microbit.speaker' +module. +""" + +def off(): + pass + +def on(): + pass
--- a/Microbit/neopixel.py Wed Apr 29 18:26:18 2020 +0200 +++ b/Microbit/neopixel.py Sun Apr 04 16:54:03 2021 +0200 @@ -8,7 +8,7 @@ """ class NeoPixel(): - def __init__(self, pin, n): + def __init__(self, pin, n, bpp=3): pass def clear(self): @@ -16,3 +16,9 @@ def show(self): pass + + def write(self): + pass + + def fill(self, color): + pass
--- a/Microbit/speech.py Wed Apr 29 18:26:18 2020 +0200 +++ b/Microbit/speech.py Sun Apr 04 16:54:03 2021 +0200 @@ -7,14 +7,17 @@ Module containing stubs for API generation of the 'speech' module. """ +from microbit import pin0 + def translate(words): pass -def pronounce(phonemes, *, pitch=64, speed=72, mouth=128, throat=128): +def pronounce(phonemes, *, pitch=64, speed=72, mouth=128, throat=128, + pin=pin0): pass -def say(words, *, pitch=64, speed=72, mouth=128, throat=128): +def say(words, *, pitch=64, speed=72, mouth=128, throat=128, pin=pin0): pass -def sing(phonemes, *, pitch=64, speed=72, mouth=128, throat=128): +def sing(phonemes, *, pitch=64, speed=72, mouth=128, throat=128, pin=pin0): pass
--- a/microbit.api Wed Apr 29 18:26:18 2020 +0200 +++ b/microbit.api Sun Apr 04 16:54:03 2021 +0200 @@ -8,6 +8,9 @@ machine.reset?4() machine.time_pulse_us?4(pin, pulse_level, timeout_us=1000000) machine.unique_id?4() +microbit.Button.get_presses?4() +microbit.Button.is_pressed?4() +microbit.Button.was_pressed?4() microbit.Image.ANGRY?7 microbit.Image.ARROW_E?7 microbit.Image.ARROW_N?7 @@ -88,6 +91,7 @@ microbit.MicroBitAnalogDigitalPin.NO_PULL?7 microbit.MicroBitAnalogDigitalPin.PULL_DOWN?7 microbit.MicroBitAnalogDigitalPin.PULL_UP?7 +microbit.MicroBitAnalogDigitalPin.get_analog_period_microseconds?4() microbit.MicroBitAnalogDigitalPin.get_mode?4() microbit.MicroBitAnalogDigitalPin.get_pull?4() microbit.MicroBitAnalogDigitalPin.read_analog?4() @@ -97,9 +101,6 @@ microbit.MicroBitAnalogDigitalPin.set_pull?4(mode) microbit.MicroBitAnalogDigitalPin.write_analog?4(value) microbit.MicroBitAnalogDigitalPin.write_digital?4(value) -microbit.MicroBitButton.get_presses?4() -microbit.MicroBitButton.is_pressed?4() -microbit.MicroBitButton.was_pressed?4() microbit.MicroBitDigitalPin.NO_PULL?7 microbit.MicroBitDigitalPin.PULL_DOWN?7 microbit.MicroBitDigitalPin.PULL_UP?7 @@ -112,9 +113,16 @@ microbit.MicroBitDigitalPin.set_pull?4(mode) microbit.MicroBitDigitalPin.write_analog?4(value) microbit.MicroBitDigitalPin.write_digital?4(value) +microbit.MicroBitTouchOnlyPin.CAPACITIVE?7 +microbit.MicroBitTouchOnlyPin.RESISTIVE?7 +microbit.MicroBitTouchOnlyPin.is_touched?4() +microbit.MicroBitTouchOnlyPin.set_touch_mode?4(mode) +microbit.MicroBitTouchPin.CAPACITIVE?7 microbit.MicroBitTouchPin.NO_PULL?7 microbit.MicroBitTouchPin.PULL_DOWN?7 microbit.MicroBitTouchPin.PULL_UP?7 +microbit.MicroBitTouchPin.RESISTIVE?7 +microbit.MicroBitTouchPin.get_analog_period_microseconds?4() microbit.MicroBitTouchPin.get_mode?4() microbit.MicroBitTouchPin.get_pull?4() microbit.MicroBitTouchPin.is_touched?4() @@ -123,8 +131,21 @@ microbit.MicroBitTouchPin.set_analog_period?4(period) microbit.MicroBitTouchPin.set_analog_period_microseconds?4(period) microbit.MicroBitTouchPin.set_pull?4(mode) +microbit.MicroBitTouchPin.set_touch_mode?4(mode) microbit.MicroBitTouchPin.write_analog?4(value) microbit.MicroBitTouchPin.write_digital?4(value) +microbit.Sound.GIGGLE?7 +microbit.Sound.HAPPY?7 +microbit.Sound.HELLO?7 +microbit.Sound.MYSTERIOUS?7 +microbit.Sound.SAD?7 +microbit.Sound.SLIDE?7 +microbit.Sound.SOARING?7 +microbit.Sound.SPRING?7 +microbit.Sound.TWINKLE?7 +microbit.Sound.YAWN?7 +microbit.SoundEvent.LOUD?7 +microbit.SoundEvent.QUIET?7 microbit.accelerometer.current_gesture?4() microbit.accelerometer.get_gestures?4() microbit.accelerometer.get_values?4() @@ -157,6 +178,12 @@ microbit.i2c.read?4(addr, n, repeat=False) microbit.i2c.scan?4() microbit.i2c.write?4(addr, buf, repeat=False) +microbit.microphone.current_event?4() +microbit.microphone.get_events?4() +microbit.microphone.is_event?4(event) +microbit.microphone.set_threshold?4(event, value) +microbit.microphone.sound_level?4() +microbit.microphone.was_event?4(event) microbit.panic?4(code) microbit.pin0?7 microbit.pin10?7 @@ -177,9 +204,14 @@ microbit.pin7?7 microbit.pin8?7 microbit.pin9?7 +microbit.pin_logo?7 +microbit.pin_speaker?7 microbit.reset?4() microbit.running_time?4() +microbit.set_volume?4(volume) microbit.sleep?4(ms) +microbit.speaker.off?4() +microbit.speaker.on?4() microbit.spi.init?4(baudrate=1000000, bits=8, mode=0, sclk=pin13, mosi=pin15, miso=pin14) microbit.spi.read?4(nbytes) microbit.spi.write?4(buffer) @@ -234,8 +266,10 @@ music.set_tempo?4(ticks=4, bpm=120) music.stop?4(pin=microbit.pin0) neopixel.NeoPixel.clear?4() +neopixel.NeoPixel.fill?4(color) neopixel.NeoPixel.show?4() -neopixel.NeoPixel?1(pin, n) +neopixel.NeoPixel.write?4() +neopixel.NeoPixel?1(pin, n, bpp=3) os.listdir?4() os.remove?4(filename) os.size?4(filename) @@ -262,9 +296,9 @@ random.randrange?4(stop) random.seed?4(n) random.uniform?4(a, b) -speech.pronounce?4(phonemes, *, pitch=64, speed=72, mouth=128, throat=128) -speech.say?4(words, *, pitch=64, speed=72, mouth=128, throat=128) -speech.sing?4(phonemes, *, pitch=64, speed=72, mouth=128, throat=128) +speech.pronounce?4(phonemes, *, pitch=64, speed=72, mouth=128, throat=128, pin=pin0) +speech.say?4(words, *, pitch=64, speed=72, mouth=128, throat=128, pin=pin0) +speech.sing?4(phonemes, *, pitch=64, speed=72, mouth=128, throat=128, pin=pin0) speech.translate?4(words) utime.sleep?4(seconds) utime.sleep_ms?4(ms)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/micropython.epj Sun Apr 04 16:54:03 2021 +0200 @@ -0,0 +1,267 @@ +{ + "header": { + "comment": "eric project file for project micropython", + "copyright": "Copyright (C) 2021 Detlev Offenbach, detlev@die-offenbachs.de" + }, + "project": { + "AUTHOR": "Detlev Offenbach", + "CHECKERSPARMS": {}, + "DESCRIPTION": "This projects contains stub files needed to generate API files for various MicroPython dialects.", + "DOCSTRING": "", + "DOCUMENTATIONPARMS": {}, + "EMAIL": "detlev@die-offenbachs.de", + "EOL": 1, + "FILETYPES": { + "*.api": "OTHERS", + "*.bas": "OTHERS", + "*.e4p": "OTHERS", + "*.idl": "INTERFACES", + "*.md": "OTHERS", + "*.proto": "PROTOCOLS", + "*.py": "SOURCES", + "*.rst": "OTHERS", + "*.sh": "OTHERS", + "*.txt": "OTHERS", + "GNUmakefile": "OTHERS", + "Makefile": "OTHERS", + "README": "OTHERS", + "README.*": "OTHERS", + "makefile": "OTHERS" + }, + "FORMS": [], + "HASH": "3b18ba9ef9e1e4f08a68d0c3116f144b99821e0c", + "IDLPARAMS": { + "DefinedNames": [], + "IncludeDirs": [], + "UndefinedNames": [] + }, + "INTERFACES": [], + "LEXERASSOCS": { + "*.py": "MicroPython" + }, + "MAINSCRIPT": "", + "MAKEPARAMS": { + "MakeEnabled": false, + "MakeExecutable": "", + "MakeFile": "", + "MakeParameters": "", + "MakeTarget": "", + "MakeTestOnly": true + }, + "MIXEDLANGUAGE": 0, + "OTHERS": [ + ".hgignore", + "calliope.api", + "calliope.bas", + "circuitpython.api", + "circuitpython.bas", + "create_api.sh", + "microbit.api", + "microbit.bas", + "micropython.api", + "micropython.bas", + "micropython.e4p", + "micropython.epj" + ], + "OTHERTOOLSPARMS": {}, + "PACKAGERSPARMS": {}, + "PROGLANGUAGE": "MicroPython", + "PROJECTTYPE": "Console", + "PROJECTTYPESPECIFICDATA": {}, + "PROTOCOLS": [], + "RCCPARAMS": { + "CompressLevel": 0, + "CompressionDisable": false, + "CompressionThreshold": 70, + "PathPrefix": "" + }, + "RESOURCES": [], + "SOURCES": [ + "Calliope/audio.py", + "Calliope/calliope_mini/__init__.py", + "Calliope/calliope_mini/accelerometer.py", + "Calliope/calliope_mini/display.py", + "Calliope/calliope_mini/gyrometer.py", + "Calliope/calliope_mini/i2c.py", + "Calliope/calliope_mini/led.py", + "Calliope/calliope_mini/magnetometer.py", + "Calliope/calliope_mini/sensor.py", + "Calliope/calliope_mini/spi.py", + "Calliope/calliope_mini/uart.py", + "Calliope/machine.py", + "Calliope/micropython.py", + "Calliope/music.py", + "Calliope/neopixel.py", + "Calliope/os.py", + "Calliope/radio.py", + "Calliope/random.py", + "Calliope/speech.py", + "Calliope/utime.py", + "CircuitPython/analogio.py", + "CircuitPython/array.py", + "CircuitPython/audiobusio.py", + "CircuitPython/audiocore.py", + "CircuitPython/audioio.py", + "CircuitPython/audiopwmio.py", + "CircuitPython/binascii.py", + "CircuitPython/bitbangio.py", + "CircuitPython/bleio.py", + "CircuitPython/board.py", + "CircuitPython/btree.py", + "CircuitPython/busio.py", + "CircuitPython/collections.py", + "CircuitPython/digitalio.py", + "CircuitPython/displayio.py", + "CircuitPython/esp.py", + "CircuitPython/fontio.py", + "CircuitPython/framebuf.py", + "CircuitPython/frequencyio.py", + "CircuitPython/gamepad.py", + "CircuitPython/gamepadshift.py", + "CircuitPython/gc.py", + "CircuitPython/hashlib.py", + "CircuitPython/i2cslave.py", + "CircuitPython/math.py", + "CircuitPython/microcontroller.py", + "CircuitPython/micropython.py", + "CircuitPython/multiterminal.py", + "CircuitPython/neopixel_write.py", + "CircuitPython/network.py", + "CircuitPython/nvm.py", + "CircuitPython/os.py", + "CircuitPython/ps2io.py", + "CircuitPython/pulseio.py", + "CircuitPython/random.py", + "CircuitPython/rotaryio.py", + "CircuitPython/rtc.py", + "CircuitPython/samd.py", + "CircuitPython/socket.py", + "CircuitPython/storage.py", + "CircuitPython/struct.py", + "CircuitPython/supervisor.py", + "CircuitPython/sys.py", + "CircuitPython/terminalio.py", + "CircuitPython/time.py", + "CircuitPython/touchio.py", + "CircuitPython/uctypes.py", + "CircuitPython/uerrno.py", + "CircuitPython/uheap.py", + "CircuitPython/uheapq.py", + "CircuitPython/uio.py", + "CircuitPython/ujson.py", + "CircuitPython/ure.py", + "CircuitPython/usb_hid.py", + "CircuitPython/usb_midi.py", + "CircuitPython/uselect.py", + "CircuitPython/usocket.py", + "CircuitPython/ussl.py", + "CircuitPython/ustack.py", + "CircuitPython/uzlib.py", + "CircuitPython/wiznet.py", + "MicroPython/array.py", + "MicroPython/btree.py", + "MicroPython/cmath.py", + "MicroPython/esp.py", + "MicroPython/esp32.py", + "MicroPython/framebuf.py", + "MicroPython/gc.py", + "MicroPython/lcd160cr.py", + "MicroPython/machine.py", + "MicroPython/math.py", + "MicroPython/micropython.py", + "MicroPython/network.py", + "MicroPython/pyb.py", + "MicroPython/sys.py", + "MicroPython/ubinascii.py", + "MicroPython/ucollections.py", + "MicroPython/ucryptolib.py", + "MicroPython/uctypes.py", + "MicroPython/uerrno.py", + "MicroPython/uhashlib.py", + "MicroPython/uheapq.py", + "MicroPython/uio.py", + "MicroPython/ujson.py", + "MicroPython/uos.py", + "MicroPython/ure.py", + "MicroPython/uselect.py", + "MicroPython/usocket.py", + "MicroPython/ussl.py", + "MicroPython/ustruct.py", + "MicroPython/utime.py", + "MicroPython/uzlib.py", + "MicroPython/wipy.py", + "Microbit/audio.py", + "Microbit/machine.py", + "Microbit/microbit/__init__.py", + "Microbit/microbit/accelerometer.py", + "Microbit/microbit/compass.py", + "Microbit/microbit/display.py", + "Microbit/microbit/i2c.py", + "Microbit/microbit/spi.py", + "Microbit/microbit/uart.py", + "Microbit/micropython.py", + "Microbit/music.py", + "Microbit/neopixel.py", + "Microbit/os.py", + "Microbit/radio.py", + "Microbit/random.py", + "Microbit/speech.py", + "Microbit/utime.py", + "Microbit/microbit/microphone.py", + "Microbit/microbit/speaker.py" + ], + "SPELLEXCLUDES": "", + "SPELLLANGUAGE": "en", + "SPELLWORDS": "", + "TRANSLATIONEXCEPTIONS": [], + "TRANSLATIONPATTERN": "", + "TRANSLATIONS": [], + "TRANSLATIONSBINPATH": "", + "UICPARAMS": { + "Package": "", + "PackagesRoot": "", + "RcSuffix": "" + }, + "VCS": "Mercurial", + "VCSOPTIONS": { + "add": [ + "" + ], + "checkout": [ + "" + ], + "commit": [ + "" + ], + "diff": [ + "" + ], + "export": [ + "" + ], + "global": [ + "" + ], + "history": [ + "" + ], + "log": [ + "" + ], + "remove": [ + "" + ], + "status": [ + "" + ], + "tag": [ + "" + ], + "update": [ + "" + ] + }, + "VCSOTHERDATA": {}, + "VERSION": "1.x" + } +} \ No newline at end of file