MicroPython

micropython: quelques commandes

 

help permet de connaitre le contenu d’un bibliothèque, les class utilisables comme I2C par exemple

 

>>> import machine
>>> help(machine)

object <module 'umachine'> is of type module

  __name__ -- umachine

  mem8 -- <8-bit memory>
  mem16 -- <16-bit memory>
  mem32 -- <32-bit memory>
  freq -- <function>
  reset -- <function>
  reset_cause -- <function>
  unique_id -- <function>
  idle -- <function>
  sleep -- <function>
  deepsleep -- <function>
  disable_irq -- <function>
  enable_irq -- <function>
  time_pulse_us -- <function>
  RTC -- <class 'RTC'>
  Timer -- <class 'Timer'>
  WDT -- <class 'WDT'>
  Pin -- <class 'Pin'>
  Signal -- <class 'Signal'>
  PWM -- <class 'PWM'>
  ADC -- <class 'ADC'>
  UART -- <class 'UART'>
  I2C -- <class 'I2C'>
  SPI -- <class 'HSPI'>
  DEEPSLEEP -- 4
  PWRON_RESET -- 0
  HARD_RESET -- 6
  DEEPSLEEP_RESET -- 5
  WDT_RESET -- 1
  SOFT_RESET -- 4

puis pour la class I2C de la librairie machine:

>>> from machine import I2C

>>> help(I2C)
 object <class 'I2C'> is of type type
 init -- <function>
 scan -- <function>
 start -- <function>
 stop -- <function>
 readinto -- <function>
 write -- <function>
 readfrom -- <function>
 readfrom_into -- <function>
 writeto -- <function>
 readfrom_mem -- <function>
 readfrom_mem_into -- <function>
 writeto_mem -- <function>

 

class Pin, broche de l’Esp8266:

>>> help(Pin)                                                       object <class 'Pin'> is of type type                                   init -- <function>                                                  value -- <function>                                                 off -- <function>                                                   on -- <function>                                                    irq -- <function>                                                   IN -- 0                                                             OUT -- 1                                                            OPEN_DRAIN -- 2                                                     PULL_UP -- 1                                                        IRQ_RISING -- 1                                                     IRQ_FALLING -- 2
écran OLED, address 0x3C
>>> import ssd1306
# 128x 64 à l'addresse 0x3C
>>> oled= ssd1306.SSD1306_I2C(128, 64, i2c, 0x3c)
>>> help(oled)
object <SSD1306_I2C object at 3fff08e0> is of type SSD1306_I2C                  
__qualname__ -- SSD1306_I2C                             write_data -- <function write_data at 0x3fff1d40>       __module__ -- ssd1306                                   write_cmd -- <function write_cmd at 0x3fff1c10>         __init__ -- <closure>