| 9 | |
| 10 | == Geeek Pi2040 の動作ログ |
| 11 | |
| 12 | |
| 13 | {{{ |
| 14 | >>> import sys |
| 15 | >>> sys.implementation |
| 16 | (name='micropython', version=(1, 19, 1), _machine='Raspberry Pi Pico with RP2040', _mpy=4102) |
| 17 | >>> |
| 18 | >>> help() |
| 19 | Welcome to MicroPython! |
| 20 | |
| 21 | For online help please visit https://micropython.org/help/. |
| 22 | |
| 23 | For access to the hardware use the 'machine' module. RP2 specific commands |
| 24 | are in the 'rp2' module. |
| 25 | |
| 26 | Quick overview of some objects: |
| 27 | machine.Pin(pin) -- get a pin, eg machine.Pin(0) |
| 28 | machine.Pin(pin, m, [p]) -- get a pin and configure it for IO mode m, pull mode p |
| 29 | methods: init(..), value([v]), high(), low(), irq(handler) |
| 30 | machine.ADC(pin) -- make an analog object from a pin |
| 31 | methods: read_u16() |
| 32 | machine.PWM(pin) -- make a PWM object from a pin |
| 33 | methods: deinit(), freq([f]), duty_u16([d]), duty_ns([d]) |
| 34 | machine.I2C(id) -- create an I2C object (id=0,1) |
| 35 | methods: readfrom(addr, buf, stop=True), writeto(addr, buf, stop=True) |
| 36 | readfrom_mem(addr, memaddr, arg), writeto_mem(addr, memaddr, arg) |
| 37 | machine.SPI(id, baudrate=1000000) -- create an SPI object (id=0,1) |
| 38 | methods: read(nbytes, write=0x00), write(buf), write_readinto(wr_buf, rd_buf) |
| 39 | machine.Timer(freq, callback) -- create a software timer object |
| 40 | eg: machine.Timer(freq=1, callback=lambda t:print(t)) |
| 41 | |
| 42 | Pins are numbered 0-29, and 26-29 have ADC capabilities |
| 43 | Pin IO modes are: Pin.IN, Pin.OUT, Pin.ALT |
| 44 | Pin pull modes are: Pin.PULL_UP, Pin.PULL_DOWN |
| 45 | |
| 46 | Useful control commands: |
| 47 | CTRL-C -- interrupt a running program |
| 48 | CTRL-D -- on a blank line, do a soft reset of the board |
| 49 | CTRL-E -- on a blank line, enter paste mode |
| 50 | |
| 51 | For further help on a specific object, type help(obj) |
| 52 | For a list of available modules, type help('modules') |
| 53 | >>> |
| 54 | >>> help(machine.Pin) |
| 55 | object <class 'Pin'> is of type type |
| 56 | init -- <function> |
| 57 | value -- <function> |
| 58 | low -- <function> |
| 59 | high -- <function> |
| 60 | off -- <function> |
| 61 | on -- <function> |
| 62 | toggle -- <function> |
| 63 | irq -- <function> |
| 64 | IN -- 0 |
| 65 | OUT -- 1 |
| 66 | OPEN_DRAIN -- 2 |
| 67 | ALT -- 3 |
| 68 | PULL_UP -- 1 |
| 69 | PULL_DOWN -- 2 |
| 70 | IRQ_RISING -- 8 |
| 71 | IRQ_FALLING -- 4 |
| 72 | >>> |
| 73 | >>> help('modules') |
| 74 | __main__ framebuf uasyncio/funcs ujson |
| 75 | _boot gc uasyncio/lock umachine |
| 76 | _boot_fat math uasyncio/stream uos |
| 77 | _onewire micropython ubinascii urandom |
| 78 | _rp2 neopixel ucollections ure |
| 79 | _thread onewire ucryptolib uselect |
| 80 | _uasyncio rp2 uctypes ustruct |
| 81 | builtins uarray uerrno usys |
| 82 | cmath uasyncio/__init__ uhashlib utime |
| 83 | dht uasyncio/core uheapq uzlib |
| 84 | ds18x20 uasyncio/event uio |
| 85 | Plus any modules on the filesystem |
| 86 | >>> |
| 87 | >>> help('rp2') |
| 88 | object rp2 is of type str |
| 89 | encode -- <function> |
| 90 | find -- <function> |
| 91 | rfind -- <function> |
| 92 | index -- <function> |
| 93 | rindex -- <function> |
| 94 | join -- <function> |
| 95 | split -- <function> |
| 96 | splitlines -- <function> |
| 97 | rsplit -- <function> |
| 98 | startswith -- <function> |
| 99 | endswith -- <function> |
| 100 | strip -- <function> |
| 101 | lstrip -- <function> |
| 102 | rstrip -- <function> |
| 103 | format -- <function> |
| 104 | replace -- <function> |
| 105 | count -- <function> |
| 106 | partition -- <function> |
| 107 | rpartition -- <function> |
| 108 | center -- <function> |
| 109 | lower -- <function> |
| 110 | upper -- <function> |
| 111 | isspace -- <function> |
| 112 | isalpha -- <function> |
| 113 | isdigit -- <function> |
| 114 | isupper -- <function> |
| 115 | islower -- <function> |
| 116 | >>> |
| 117 | }}} |
| 118 | |
| 119 | [KhoPyboard PyBoard一覧に戻る] |