目录

  • RNG 随机数
  • OS 文件系统
  • SYS 系统
  • System state objects. 系统状态
  • Accelerometer 3D orientation 三轴加速度
  • Pushbutton 按键
  • Compass 3D direction heading 三轴磁场传感器
  • Display 5x5 LED grid LED点阵
  • Pins GPIO功能
  • I2C
  • Image
  • uart 串口通讯
  • SPI
  • Music module 音乐
  • Antigravity 反重力 彩蛋
  • This module 彩蛋
  • Love module 彩蛋
  • NeoPixel module
  • Radio 无线传输
  • Audio 声音
  • Speech 语句发声
  • Math functions

RNG 随机数

random.getrandbits(n) \nReturn an integer with n random bits.
random.seed(n) \nInitialise the random number generator with a known integer 'n'.
random.randint(a, b) \nReturn a random whole number between a and b (inclusive).
random.randrange(stop) \nReturn a random whole number between 0 and up to (but not including) stop.
random.choice(seq) \nReturn a randomly selected element from a sequence of objects (such as a list).
random.random() \nReturn a random floating point number between 0.0 and 1.0.
random.uniform(a, b) \nReturn a random floating point number between a and b (inclusive).

OS 文件系统

os.listdir() \nReturn a list of the names of all the files contained within the local\non-device file system.
os.remove(filename) \nRemove (delete) the file named filename.
os.size(filename) \nReturn the size, in bytes, of the file named filename.
os.uname() \nReturn information about MicroPython and the device.

SYS 系统

sys.version
sys.version_info
sys.implementation
sys.platform
sys.byteorder
sys.print_exception(ex) \nPrint to the REPL information about the exception 'ex'.

System state objects. 系统状态

microbit.panic() \nPut micro:bit in panic() mode and display an unhappy face.\nPress the reset button to exit panic() mode.
microbit.sleep(time) \nPut micro:bit to sleep for some milliseconds (1 second = 1000 ms) of time.\nsleep(2000) gives micro:bit a 2 second nap.
microbit.running_time() \nReturn running_time() in milliseconds since micro:bit's last reset.
microbit.temperature() \nReturn micro:bit's temperature in degrees Celcius.

Accelerometer 3D orientation 三轴加速度

microbit.accelerometer.get_x() \nReturn micro:bit's tilt (X acceleration) in milli-g's.
microbit.accelerometer.get_y() \nReturn micro:bit's tilt (Y acceleration) in milli-g's.
microbit.accelerometer.get_z() \nReturn micro:bit's up-down motion (Z acceleration) in milli-g's.\nZ is a positive number when moving up. Moving down, Z is a negative number.
microbit.accelerometer.is_gesture(name) \nReturn True or False to indicate if the named gesture is currently active.\nMicroPython understands the following gestures: 'up', 'down', 'left', 'right',\n'face up', 'face down', 'freefall', '3g', '6g', '8g' and 'shake'.
microbit.accelerometer.was_gesture(name) \nReturn True or False to indicate if the named gesture was active since the\nlast call.\nMicroPython understands the following gestures: 'up', 'down', 'left', 'right',\n'face up', 'face down', 'freefall', '3g', '6g', '8g' and 'shake'.
microbit.accelerometer.get_gestures() \nReturn a list indicating the gesture history. The most recent gesture is last.\nCalling this method also clears the gesture history.\nMicroPython understands the following gestures: 'up', 'down', 'left', 'right',\n'face up', 'face down', 'freefall', '3g', '6g', '8g' and 'shake'.
microbit.accelerometer.get_values() \nGet the acceleration measurements in all axes at once, as a three-element tuple of integers ordered as X, Y, Z.

Pushbutton 按键

microbit.button_a.is_pressed() \nIf button A is pressed down, is_pressed() is True, else False.
microbit.button_a.was_pressed() \nUse was_pressed() to learn if button A was pressed since the last time\nwas_pressed() was called. Returns True or False.
microbit.button_a.get_presses() \nUse get_presses() to get the running total of button presses, and also\nreset this counter to zero.
microbit.button_b.is_pressed() \nIf button B is pressed down, is_pressed() is True, else False.
microbit.button_b.was_pressed() \nUse was_pressed() to learn if button B was pressed since the last time\nwas_pressed() was called. Returns True or False.
microbit.button_b.get_presses() \nUse get_presses() to get the running total of button presses, and also\nreset this counter to zero.

Compass 3D direction heading 三轴磁场传感器

microbit.compass.is_calibrated() \nIf micro:bit's compass is_calibrated() and adjusted for accuracy, return True.\nIf compass hasn't been adjusted for accuracy, return False.
microbit.compass.calibrate() \nIf micro:bit is confused, calibrate() the compass to adjust the its accuracy.\nWill ask you to rotate the device to draw a circle on the display. Afterwards, micro:bit will know which way is north.
microbit.compass.clear_calibration() \nReset micro:bit's compass using clear_calibration() command.\nRun calibrate() to improve accuracy.
microbit.compass.get_x() \nReturn magnetic field detected along micro:bit's X axis.\nUsually, the compass returns the earth's magnetic field in micro-Tesla units.\nUnless...a strong magnet is nearby!
microbit.compass.get_y() \nReturn magnetic field detected along micro:bit's Y axis.\nUsually, the compass returns the earth's magnetic field in micro-Tesla units.\nUnless...a strong magnet is nearby!
microbit.compass.get_z() \nReturn magnetic field detected along micro:bit's Z axis.\nUsually, the compass returns the earth's magnetic field in micro-Tesla units.\nUnless...a strong magnet is nearby!
microbit.compass.get_field_strength() \nReturn strength of magnetic field around micro:bit.
microbit.compass.heading() \nReturn a number between 0-360 indicating the device's heading. 0 is north.

Display 5x5 LED grid LED点阵

microbit.display.show(x, delay=400, wait=True, loop=False, clear=False) \nUse show(x) to print the string or image 'x' to the display. If 'x' is a list\nof images they will be animated together.\nUse 'delay' to specify the speed of frame changes in milliseconds.\nIf wait is False animation will happen in the background while the program continues.\nIf loop is True the animation will repeat forever.\nIf clear is True the display will clear at the end of the animation.
microbit.display.scroll(string, delay=150, wait=True, loop=False, monospace=False) \nUse scroll(string) to scroll the string across the display.\nUse delay to control how fast the text scrolls.\nIf wait is False the text will scroll in the background while the program continues.\nIf loop is True the text will repeat forever.\nIf monospace is True the characters will always take up 5 pixel-columns.
microbit.display.clear() \nUse clear() to clear micro:bit's display.
microbit.display.get_pixel(x, y) \nUse get_pixel(x, y) to return the display's brightness at LED pixel (x,y).\nBrightness can be from 0 (LED is off) to 9 (maximum LED brightness).
microbit.display.set_pixel(x, y, b) \nUse set_pixel(x, y, b) to set the display at LED pixel (x,y) to brightness 'b'\nwhich can be set between 0 (off) to 9 (full brightness).
microbit.display.on() \nUse on() to turn on the display.
microbit.display.off() \nUse off() to turn off the display.
microbit.display.is_on() \nUse is_on() to query if the micro:bit's display is on (True) or off (False).
microbit.display.read_light_level():获取光照强度,返回值0~255

Pins GPIO功能

microbit.pin0.is_touched() \nIf pin0 is_touched() on micro:bit, return True. If nothing is touching the\npin, return False.
microbit.pin0.read_digital() \nread_digital() value from pin0. The reading will be either 0 (lo) or 1 (hi).
microbit.pin0.write_digital(value) \nSet pin0 to output high if value is 1, or to low, it it is 0.
microbit.pin0.read_analog() \nRead the voltage applied to pin0. Return the reading as a number between\n0 (meaning 0v) and 1023 (meaning 3.3v).
microbit.pin0.write_analog(value) \nSet pin0 to output a value between 0 and 1023.
microbit.pin0.set_analog_period(period) \nSet the period of the PWM signal output to period milliseconds.
microbit.pin0.set_analog_period_microseconds(period) \nSet the period of the PWM signal output to period microseconds.microbit.pin1.is_touched() \nIf pin1 is_touched() on micro:bit, return True. If nothing is touching the\npin, return False.
microbit.pin1.read_digital() \nread_digital() value from pin1. The reading will be either 0 (lo) or 1 (hi).
microbit.pin1.write_digital(value) \nSet pin1 to output high if value is 1, or to low, it it is 0.
microbit.pin1.read_analog() \nRead the voltage applied to pin1. Return the reading as a number between\n0 (meaning 0v) and 1023 (meaning 3.3v).
microbit.pin1.write_analog(value) \nSet pin1 to output a value between 0 and 1023.
microbit.pin1.set_analog_period(period) \nSet the period of the PWM signal output to period milliseconds.
microbit.pin1.set_analog_period_microseconds(period) \nSet the period of the PWM signal output to period microseconds.microbit.pin2.is_touched() \nIf pin2 is_touched() on micro:bit, return True. If nothing is touching the\npin, return False.
microbit.pin2.read_digital() \nread_digital() value from pin2. The reading will be either 0 (lo) or 1 (hi).
microbit.pin2.write_digital(value) \nSet pin2 to output high if value is 1, or to low, it it is 0.
microbit.pin2.read_analog() \nRead the voltage applied to pin2. Return the reading as a number between\n0 (meaning 0v) and 1023 (meaning 3.3v).
microbit.pin2.write_analog(value) \nSet pin2 to output a value between 0 and 1023.
microbit.pin2.set_analog_period(period) \nSet the period of the PWM signal output to period milliseconds.
microbit.pin2.set_analog_period_microseconds(period) \nSet the period of the PWM signal output to period microseconds.microbit.pin3.read_digital() \nread_digital() value from pin3. The reading will be either 0 (lo) or 1 (hi).
microbit.pin2.write_digital(value) \nSet pin3 to output high if value is 1, or to low, it it is 0.
microbit.pin3.read_analog() \nRead the voltage applied to pin3. Return the reading as a number between\n0 (meaning 0v) and 1023 (meaning 3.3v).
microbit.pin3.write_analog(value) \nSet pin3 to output a value between 0 and 1023.
microbit.pin3.set_analog_period(period) \nSet the period of the PWM signal output to period milliseconds.
microbit.pin3.set_analog_period_microseconds(period) \nSet the period of the PWM signal output to period microseconds.microbit.pin4.read_digital() \nread_digital() value from pin4. The reading will be either 0 (lo) or 1 (hi).
microbit.pin4.write_digital(value) \nSet pin4 to output high if value is 1, or to low, it it is 0.
microbit.pin4.read_analog() \nRead the voltage applied to pin4. Return the reading as a number between\n0 (meaning 0v) and 1023 (meaning 3.3v).
microbit.pin4.write_analog(value) \nSet pin4 to output a value between 0 and 1023.
microbit.pin4.set_analog_period(period) \nSet the period of the PWM signal output to period milliseconds.
microbit.pin4.set_analog_period_microseconds(period) \nSet the period of the PWM signal output to period microseconds.microbit.pin5.read_digital() \nread_digital() value from pin5. The reading will be either 0 (lo) or 1 (hi).
microbit.pin5.write_digital(value) \nSet pin5 to output high if value is 1, or to low, it it is 0.microbit.pin6.read_digital() \nread_digital() value from pin6. The reading will be either 0 (lo) or 1 (hi).
microbit.pin6.write_digital(value) \nSet pin6 to output high if value is 1, or to low, it it is 0.microbit.pin7.read_digital() \nread_digital() value from pin7. The reading will be either 0 (lo) or 1 (hi).
microbit.pin7.write_digital(value) \nSet pin7 to output high if value is 1, or to low, it it is 0.microbit.pin8.read_digital() \nread_digital() value from pin8. The reading will be either 0 (lo) or 1 (hi).
microbit.pin8.write_digital(value) \nSet pin8 to output high if value is 1, or to low, it it is 0.microbit.pin9.read_digital() \nread_digital() value from pin9. The reading will be either 0 (lo) or 1 (hi).
microbit.pin9.write_digital(value) \nSet pin9 to output high if value is 1, or to low, it it is 0.microbit.pin10.read_digital() \nread_digital() value from pin10. The reading will be either 0 (lo) or 1 (hi).
microbit.pin10.write_digital(value) \nSet pin10 to output high if value is 1, or to low, it it is 0.
microbit.pin10.read_analog() \nRead the voltage applied to pin10. Return the reading as a number between\n0 (meaning 0v) and 1023 (meaning 3.3v).
microbit.pin10.write_analog(value) \nSet pin10 to output a value between 0 and 1023.
microbit.pin10.set_analog_period(period) \nSet the period of the PWM signal output to period milliseconds.
microbit.pin10.set_analog_period_microseconds(period) \nSet the period of the PWM signal output to period microseconds.microbit.pin11.read_digital() \nread_digital() value from pin11. The reading will be either 0 (lo) or 1 (hi).
microbit.pin11.write_digital(value) \nSet pin11 to output high if value is 1, or to low, it it is 0.microbit.pin12.read_digital() \nread_digital() value from pin12. The reading will be either 0 (lo) or 1 (hi).
microbit.pin12.write_digital(value) \nSet pin12 to output high if value is 1, or to low, it it is 0.microbit.pin13.read_digital() \nread_digital() value from pin13. The reading will be either 0 (lo) or 1 (hi).
microbit.pin13.write_digital(value) \nSet pin13 to output high if value is 1, or to low, it it is 0.microbit.pin14.read_digital() \nread_digital() value from pin14. The reading will be either 0 (lo) or 1 (hi).
microbit.pin14.write_digital(value) \nSet pin14 to output high if value is 1, or to low, it it is 0.microbit.pin15.read_digital() \nread_digital() value from pin15. The reading will be either 0 (lo) or 1 (hi).
microbit.pin15.write_digital(value) \nSet pin15 to output high if value is 1, or to low, it it is 0.microbit.pin16.read_digital() \nread_digital() value from pin16. The reading will be either 0 (lo) or 1 (hi).
microbit.pin16.write_digital(value) \nSet pin16 to output high if value is 1, or to low, it it is 0.microbit.pin19.read_digital() \nread_digital() value from pin19. The reading will be either 0 (lo) or 1 (hi).
microbit.pin19.write_digital(value) \nSet pin19 to output high if value is 1, or to low, it it is 0.microbit.pin20.read_digital() \nread_digital() value from pin20. The reading will be either 0 (lo) or 1 (hi).
microbit.pin20.write_digital(value) \nSet pin20 to output high if value is 1, or to low, it it is 0.

I2C

microbit.i2c.read(address, n, repeat=False) \nUse read(address, n) to read 'n' bytes from the device with the 7-bit address.\nIf repeat is True, no stop bit will be sent.
microbit.i2c.write(adress, buffer, repeat=False) \nUse write(address, buffer) to write to the 'buffer' of the device at the 7-bit 'address'.\nIf repeat is True, no stop bit will be sent.
microbit.i2c.init(frequency, scl, sda) \nUse init(frequency, scl, sda) to set the bus frequency and pins.

Image

microbit.Image(string) \nCreate and use built-in IMAGES to show on the display. Use:\nImage(\n  '09090:'\n  '99999:'\n  '99999:'\n  '09990:'\n  '00900:')\n...to make a new 5x5 heart image. Numbers go from 0 (off) to 9 (brightest). Note\nthe colon ':' to set the end of a row.
microbit.Image.width() \nReturn the width of the image in pixels.
microbit.Image.height() \nReturn the height of the image in pixels.
microbit.Image.get_pixel(x, y) \nUse get_pixel(x, y) to return the image's brightness at LED pixel (x,y).\nBrightness can be from 0 (LED is off) to 9 (maximum LED brightness).
microbit.Image.set_pixel(x, y, b) \nUse set_pixel(x, y, b) to set the LED pixel (x,y) in the image to brightness\n'b' which can be set between 0 (off) to 9 (full brightness).
microbit.Image.shift_left(n) \nUse shift_left(n) to make a copy of the image but moved 'n' pixels to the left.
microbit.Image.shift_right(n) \nUse shift_right(n) to make a copy of the image but moved 'n' pixels to\nthe right.
microbit.Image.shift_up(n) \nUse shift_up(n) to make a copy of the image but moved 'n' pixels up.
microbit.Image.shift_down(n) \nUse shift_down(n) to make a copy of the image but moved 'n' pixels down.
microbit.Image.copy() \nUse copy() to make a new exact copy of the image.
microbit.Image.crop(x1, y1, x2, y2) \nUse crop(x1, y1, x2, y2) to make a cut-out copy of the image where coordinate\n(x1,y1) is the top left corner of the cut-out area and coordinate (x2,y2) is the\nbottom right corner.
microbit.Image.invert() \nUse invert() to make a negative copy of the image. Where a pixel was bright or\non in the original, it is dim or off in the negative copy.
microbit.Image.HEART
microbit.Image.HEART_SMALL
microbit.Image.HAPPY
microbit.Image.SMILE
microbit.Image.SAD
microbit.Image.CONFUSED
microbit.Image.ANGRY
microbit.Image.ASLEEP
microbit.Image.SURPRISED
microbit.Image.SILLY
microbit.Image.FABULOUS
microbit.Image.MEH
microbit.Image.YES
microbit.Image.NO
microbit.Image.CLOCK12
microbit.Image.CLOCK11
microbit.Image.CLOCK10
microbit.Image.CLOCK9
microbit.Image.CLOCK8
microbit.Image.CLOCK7
microbit.Image.CLOCK6
microbit.Image.CLOCK5
microbit.Image.CLOCK4
microbit.Image.CLOCK3
microbit.Image.CLOCK2
microbit.Image.CLOCK1
microbit.Image.ARROW_N
microbit.Image.ARROW_NE
microbit.Image.ARROW_E
microbit.Image.ARROW_SE
microbit.Image.ARROW_S
microbit.Image.ARROW_SW
microbit.Image.ARROW_W
microbit.Image.ARROW_NW
microbit.Image.TRIANGLE
microbit.Image.TRIANGLE_LEFT
microbit.Image.CHESSBOARD
microbit.Image.DIAMOND
microbit.Image.DIAMOND_SMALL
microbit.Image.SQUARE
microbit.Image.SQUARE_SMALL
microbit.Image.RABBIT
microbit.Image.COW
microbit.Image.MUSIC_CROTCHET
microbit.Image.MUSIC_QUAVER
microbit.Image.MUSIC_QUAVERS
microbit.Image.PITCHFORK
microbit.Image.XMAS
microbit.Image.PACMAN
microbit.Image.TARGET
microbit.Image.TSHIRT
microbit.Image.ROLLERSKATE
microbit.Image.DUCK
microbit.Image.HOUSE
microbit.Image.TORTOISE
microbit.Image.BUTTERFLY
microbit.Image.STICKFIGURE
microbit.Image.GHOST
microbit.Image.SWORD
microbit.Image.GIRAFFE
microbit.Image.SKULL
microbit.Image.UMBRELLA
microbit.Image.SNAKE
microbit.Image.ALL_CLOCKS
microbit.Image.ALL_ARROWS

uart 串口通讯

microbit.uart.init(baudrate=9600, bits=8, parity=None, stop=1, tx=None, rx=None) \nUse init() to set up communication using the default values. \nOtherwise override the defaults as named arguments.
microbit.uart.any() \nIf there are incoming characters waiting to be read, any() will return True.\nOtherwise, returns False.
microbit.uart.read(n) \nUse read() to read characters.\nUse read(n) to read, at most, 'n' bytes of data.
microbit.uart.readall() \nUse readall() to read as much data as possible.
microbit.uart.readline() \nUse readline() to read a line that ends with a newline character.
microbit.uart.readinto(buf, n) \nUse readinto(buf) to read bytes into the buffer 'buf'.\nUse readinto(buff, n) to read, at most, 'n' number of bytes into 'buf'.
microbit.uart.write() \nUse write(buf) to write the bytes in buffer 'buf' to the connected device.

SPI

microbit.spi.init(baudrate=1000000, bits=8, mode=0, sclk=pin13, mosi=pin15, miso=pin14) \nSet up communication. Override the defaults for baudrate, mode,\nSCLK, MOSI and MISO. The default connections are pin13 for SCLK, pin15 for\nMOSI and pin14 for MISO.
microbit.spi.write(buf) \nUse write(buf) to write bytes in buffer 'buf' to the connected device.
microbit.spi.read(n) \nUse read(n) to read 'n' bytes of data.
microbit.spi.write_readinto(out, in) \nUse write_readinto(out, in) to write the 'out' buffer to the connected device\nand read any response into the 'in' buffer. The length of the buffers should\nbe the same. The buffers can be the same object.

Music module 音乐

使用前先import music
music.set_tempo(number, bpm) \nMake a beat last a ‘number’ of ticks long and\nplayed at ‘bpm’ beats per minute.
music.pitch(freq, length=-1, pin=microbit.pin0, wait=True) \nMake micro:bit play a note at ‘freq’ frequency for\n’length’ milliseconds. E.g. pitch(440, 1000) will play concert ‘A’ for 1 second.\nIf length is a negative number the pitch is played continuously.\nUse the optional pin argument to override the default output for the speaker.\nIf wait is False the music will play in the background while the program\ncontinues.
music.play(music, pin=microbit.pin0, wait=True, loop=False) \nMake micro:bit play ‘music’ list of notes. Try out the built in music to see\nhow it works. E.g. music.play(music.PUNCHLINE).\nUse the optional pin argument to override the default output for the speaker.\nIf wait is False the music will play in the background while the program\ncontinues.\nIf loop is True, the tune will repeat.
music.get_tempo() \nReturn the number of ticks in a beat and number of beats per minute.
music.stop(pin=microbit.pin0) \nStops all music playback on the given pin. If no pin is given, pin0 is assumed.
music.reset()\nIf things go wrong, reset() the music to its default settings.
music.DADADADUM
music.ENTERTAINER
music.PRELUDE
music.ODE
music.NYAN
music.RINGTONE
music.FUNK
music.BLUES
music.BIRTHDAY
music.WEDDING
music.FUNERAL
music.PUNCHLINE
music.PYTHON
music.BADDY
music.CHASE
music.BA_DING
music.WAWAWAWAA
music.JUMP_UP
music.JUMP_DOWN
music.POWER_UP
music.POWER_DOWN

Antigravity 反重力 彩蛋

使用方法:
import antigravity

This module 彩蛋

this.authors() \nUse authors() to reveal the names of the people who created this software.
使用方法:
import this
this.authors()

Love module 彩蛋

love.badaboom()\nHear my soul speak:\nThe very instant that I saw you, did\nMy heart fly to your service.
使用方法:
import love
love.badaboom()

NeoPixel module

使用时,先import neopixel
neopixel.NeoPixel(pin, n) \nCreate a list representing a strip of ‘n’ neopixels controlled from the\nspecified pin (e.g. microbit.pin0).\nUse the resulting object to change each pixel by position (starting from 0).\nIndividual pixels are given RGB (red, green, blue) values between 0-255 as a\ntupe. For example, (255, 255, 255) is white:\n\nnp = neopixel.NeoPixel(microbit.pin0, 8)\nnp[0] = (255, 0, 128)\nnp.show()
neopixel.NeoPixel.clear() \nClear all the pixels.
neopixel.NeoPixel.show() \nShow the pixels. Must be called for any updates to become visible.

Radio 无线传输

使用前先:import radio
radio.on() \nTurns on the radio. This needs to be called since the radio draws power and\ntakes up memory that you may otherwise need.
radio.off() \nTurns off the radio, thus saving power and memory.
radio.config(length=32, queue=3, channel=7, power=0, address=0x75626974, group=0, data_rate=radio.RATE_1MBIT) \nConfigures the various settings relating to the radio. The specified default\nvalues are sensible.\n’length’ is the maximum length, in bytes, of a message. It can be up to 251\nbytes long.\n’queue’ is the number of messages to store on the message queue.\n’channel’ (0-100) defines the channel to which the radio is tuned.\n’address’ is an arbitrary 32-bit address that’s used to filter packets.\n’group’ is an 8-bit value used with ‘address’ when filtering packets.\n’data_rate’ is the throughput speed. It can be one of: radio.RATE_250KbIT,\nradio.RATE_1MbIT (the default) or radio.2MBIT.
radio.reset() \nReset the settings to their default value.
radio.send_bytes(message) \nSends a message containing bytes.
radio.receive_bytes() \nReceive the next incoming message from the message queue. Returns ‘None’ if\nthere are no pending messages. Messages are returned as bytes.
radio.send(message) \nSend a message string.
radio.receive() \nReceive the next incoming message from the message queue as a string. Returns\n’None’ if there are no pending messages.
radio.RATE_250KBIT
radio.RATE_1MBIT
radio.RATE_2MBIT

Audio 声音

== 使用前先import audio==
audio.play(source, wait=True, pins=(pin0, pin1)) \nPlay the source to completion where ‘source’ is an iterable, each element of\nwhich must be an AudioFrame instance.
audio.AudioFrame()() \nRepresents a list of 32 samples each of which is a signed byte. It takes just\nover 4ms to play a single frame.

Speech 语句发声

== 使用前先import speech==
speech.translate(words) \nReturn a string containing the phonemes for the English words in the string\n’words’.
speech.say(words, pitch=64, speed=72, mouth=128, throat=128) \nSay the English words in the string ‘words’. Override the optional pitch,\nspeed, mouth and throat settings to change the tone of voice.
speech.pronounce(phonemes, pitch=64, speed=72, mouth=128, throat=128) \nPronounce the phonemes in the string ‘phonemes’. Override the optional pitch,\nspeed, mouth and throat settings to change the tone of voice.
speech.sing(song, pitch=64, speed=72, mouth=128, throat=128) \nSing the phonemes in the string ‘song’. Add pitch information to a phoneme\nwith a hash followed by a number between 1-255 like this: ‘#112DOWWWWWWWW’.\nOverride the optional pitch, speed, mouth and throat settings to change the\ntone of voice.

Math functions

使用前先import math
math.sqrt(x) \nReturn the square root of ‘x’.
math.pow(x, y) \nReturn ‘x’ raised to the power ‘y’.
math.exp(x) \nReturn math.e**‘x’.
math.log(x, base=math.e) \nWith one argument, return the natural logarithm of ‘x’ (to base e).\nWith two arguments, return the logarithm of ‘x’ to the given ‘base’.
math.cos(x) \nReturn the cosine of ‘x’ radians.
math.sin(x) \nReturn the sine of ‘x’ radians.
math.tan(x) \nReturn the tangent of ‘x’ radians.
math.acos(x) \nReturn the arc cosine of ‘x’, in radians.
math.asin(x) \nReturn the arc sine of ‘x’, in radians.
math.atan(x) \nReturn the arc tangent of ‘x’, in radians.
math.atan2(x, y) \nReturn atan(y / x), in radians.
math.ceil(x) \nReturn the ceiling of ‘x’, the smallest integer greater than or equal to ‘x’.
math.copysign(x, y) \nReturn a float with the magnitude (absolute value) of ‘x’ but the sign of ‘y’.
math.fabs(x) \nReturn the absolute value of ‘x’.
math.floor(x) \nReturn the floor of ‘x’, the largest integer less than or equal to ‘x’.
math.fmod(x, y) \nReturn ‘x’ modulo ‘y’.
math.frexp(x) \nReturn the mantissa and exponent of ‘x’ as the pair (m, e).
math.ldexp(x, i) \nReturn ‘x’ * (2**‘i’).
math.modf(x) \nReturn the fractional and integer parts of x.\nBoth results carry the sign of x and are floats.
math.isfinite(x) \nReturn True if ‘x’ is neither an infinity nor a NaN, and False otherwise.
math.isinf(x) \nReturn True if ‘x’ is a positive or negative infinity, and False otherwise.
math.isnan(x) \nReturn True if ‘x’ is a NaN (not a number), and False otherwise.
math.trunc(x) \nReturn the Real value ‘x’ truncated to an Integral (usually an integer).
math.radians(x) \nConvert angle ‘x’ from degrees to radians.
math.degrees(x) \nConvert angle ‘x’ from radians to degrees.

【MicroPython】microbit micropython常用函数(API)相关推荐

  1. oracle常用函数api,Oracle-API OracleAPI、oracle10G函数大全(常用函数)、 联合开发网 - pudn.com...

    Oracle-API 所属分类:Oracle数据库 开发工具:SQL 文件大小:13650KB 下载次数:20 上传日期:2013-09-03 13:09:39 上 传 者:蓝 说明:  Oracle ...

  2. pytorch常用函数API简析与汇总——以备查询

    版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明. 本文链接:https://blog.csdn.net/sherpahu/article/det ...

  3. TensorFlow 学习(七) — 常用函数 api、tf.nn、tf.keras

    0. 四则运算 平方:tf.square(),开方:tf.sqrt() tf.add().tf.sub().tf.mul().tf.div().tf.mod().tf.abs().tf.neg() 1 ...

  4. Appium——api常用函数

    appium常用函数介绍: 获取页面信息: 1. def get_current_activity(cls, driver): ''' 获取当前页面的activity :param driver: : ...

  5. VC API常用函数简单例子大全(1-89)

    第一个:FindWindow根据窗口类名或窗口标题名来获得窗口的句柄,该函数返回窗口的句柄 函数的定义:HWND WINAPI FindWindow(LPCSTR lpClassName ,LPCST ...

  6. VC API常用函数简单例子大全

    VC API常用函数简单例子大全 http://hi.baidu.com/tag/vc%20api%E5%87%BD%E6%95%B0/feeds 系统API查询 http://www.vbgood. ...

  7. VC API常用函数

    第一个:FindWindow根据窗口类名或窗口标题名来获得窗口的句柄,该函数返回窗口的句柄, 这个函数的定义是这样的 HWND WINAPI FindWindow(LPCSTR lpClassName ...

  8. appium python api_Appium常用的API函数

    Appium常用的API函数 (1)获取默认系统语言对应的Strings.xml文件内的数据. get_app_string() (2)查找某一个语言环境对应的字符串文件Strings.xml内数据. ...

  9. HTML5 Audio标签方法和函数API介绍

     问说网 > 文章教程 > 网页制作 > HTML5 Audio标签方法和函数API介绍 Audio APIHTML5HTML5 Audio预加载 HTML5 Audio标签方法和函 ...

  10. linux驱动常用函数

    目录 设备树常用 OF 操作函数 查找节点的 OF 函数 1.of_find_node_by_name 2.of_find_node_by_type 3.of_find_compatible_node ...

最新文章

  1. python与excel互通_【好消息】Python和Excel终于可以互通了!!
  2. [Python]小百合十大爬虫
  3. 11行代码AC——比紫书优化,例题2-3 近似计算——解题报告
  4. 学编程一定要掌握的186个关键单词!
  5. java script数据类型_javascript 六种数据类型
  6. JAVA 构造 MAP 并初始化 MAP、定义时就初始化
  7. 【STM32】初识STM32(型号+封装+内核+储存器+时钟、复位和电源管理+工作模式+ADC)
  8. ubuntu下opencv和qt的安装配置
  9. leetcode958. Check Completeness of a Binary Tree
  10. linux 升级内核为4.10,Linux Kernel 4.10.4 发布下载
  11. 如何使用 Keynote 设计有质感的 PPT 封面?
  12. 青鸟影院的最后一部分
  13. Unity3d C#使用Highlighting System 5.0高光插件的详细使用教学和脚本动态操作
  14. 于仕琪libfacedetection WIN10 VS2015
  15. PLsql 永久注册码
  16. 51单片机(一)—— 51单片机简介
  17. 安卓蓝牙BluetoothBLE开发JDY-10M
  18. 测试电池耗电快的软件,笔记本耗电过快?Win10自带电池检测了解下
  19. 陈老师排课12A版的手工调课的方法
  20. 激光切割dxf图案下载

热门文章

  1. Python分词、情感分析工具——SnowNLP
  2. 如何实现浏览器的全屏效果
  3. NYOJ 124 中位数
  4. nexus部署及配置
  5. pow函数python_python pow函数怎么用
  6. Java之stream流浅析
  7. 《当程序员的那些狗日日子》(五十三)破局(上)
  8. 戴森创“新”公开课再度开讲,持续助力打造洁净居家环境 以升级科技守护家庭健康
  9. ACL过滤数据流量案例
  10. Antimalware Service Executable CPU占用高,如何解决?