当前位置: 首页>>代码示例>>Python>>正文


Python micropython.const函数代码示例

本文整理汇总了Python中micropython.const函数的典型用法代码示例。如果您正苦于以下问题:Python const函数的具体用法?Python const怎么用?Python const使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了const函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: const

* Adafruit's Bus Device library: https://github.com/adafruit/Adafruit_CircuitPython_BusDevice
"""
import time

from micropython import const

import adafruit_bus_device.spi_device as spidev


__version__ = "1.2.3"
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_RFM69.git"


# pylint: disable=bad-whitespace
# Internal constants:
_REG_FIFO            = const(0x00)
_REG_OP_MODE         = const(0x01)
_REG_DATA_MOD        = const(0x02)
_REG_BITRATE_MSB     = const(0x03)
_REG_BITRATE_LSB     = const(0x04)
_REG_FDEV_MSB        = const(0x05)
_REG_FDEV_LSB        = const(0x06)
_REG_FRF_MSB         = const(0x07)
_REG_FRF_MID         = const(0x08)
_REG_FRF_LSB         = const(0x09)
_REG_VERSION         = const(0x10)
_REG_PA_LEVEL        = const(0x11)
_REG_RX_BW           = const(0x19)
_REG_AFC_BW          = const(0x1A)
_REG_RSSI_VALUE      = const(0x24)
_REG_DIO_MAPPING1    = const(0x25)
开发者ID:eiselekd,项目名称:hw,代码行数:31,代码来源:adafruit_rfm69.py

示例2: const

* Author(s): Tony DiCola, Michael McWethy
"""

import time

from micropython import const
from adafruit_bus_device import i2c_device, spi_device
import framebuf

__version__ = "2.4.1"
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_SSD1306.git"

#pylint: disable-msg=bad-whitespace
# register definitions
SET_CONTRAST        = const(0x81)
SET_ENTIRE_ON       = const(0xa4)
SET_NORM_INV        = const(0xa6)
SET_DISP            = const(0xae)
SET_MEM_ADDR        = const(0x20)
SET_COL_ADDR        = const(0x21)
SET_PAGE_ADDR       = const(0x22)
SET_DISP_START_LINE = const(0x40)
SET_SEG_REMAP       = const(0xa0)
SET_MUX_RATIO       = const(0xa8)
SET_COM_OUT_DIR     = const(0xc0)
SET_DISP_OFFSET     = const(0xd3)
SET_COM_PIN_CFG     = const(0xda)
SET_DISP_CLK_DIV    = const(0xd5)
SET_PRECHARGE       = const(0xd9)
SET_VCOM_DESEL      = const(0xdb)
开发者ID:eiselekd,项目名称:hw,代码行数:30,代码来源:adafruit_ssd1306.py

示例3: const

  <https://www.adafruit.com/product/935>`_ (Product ID: 935)

**Software and Dependencies:**

* Adafruit CircuitPython firmware for the ESP8622 and M0-based boards:
  https://github.com/adafruit/circuitpython/releases
"""
from micropython import const

__version__ = "1.1.1"
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_MCP4725.git"


# Internal constants:
_MCP4725_DEFAULT_ADDRESS = 0b01100010
_MCP4725_WRITE_FAST_MODE = const(0b00000000)


class MCP4725:
    """
    MCP4725 12-bit digital to analog converter.  This class has a similar
    interface as the CircuitPython AnalogOut class and can be used in place
    of that module.

    :param ~busio.I2C i2c: The I2C bus.
    :param int address: The address of the device if set differently from the default.
    """


    # Global buffer to prevent allocations and heap fragmentation.
    # Note this is not thread-safe or re-entrant by design!
开发者ID:eiselekd,项目名称:hw,代码行数:31,代码来源:adafruit_mcp4725.py

示例4: const

* Author(s): Original Raspberry Pi code by Tony DiCola, CircuitPython by ladyada,
             refactor by Carter Nelson

"""

__version__ = "2.0.1"
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_PN532.git"

import time
import adafruit_bus_device.i2c_device as i2c_device
from digitalio import Direction
from micropython import const
from adafruit_pn532.adafruit_pn532 import PN532, BusyError, _reset

# pylint: disable=bad-whitespace
_I2C_ADDRESS                   = const(0x24)

class PN532_I2C(PN532):
    """Driver for the PN532 connected over I2C."""
    def __init__(self, i2c, *, irq=None, reset=None, req=None, debug=False):
        """Create an instance of the PN532 class using I2C. Note that PN532
        uses clock stretching. Optional IRQ pin (not used),
        reset pin and debugging output.
        """
        self.debug = debug
        self._irq = irq
        self._req = req
        if reset:
            _reset(reset)
        self._i2c = i2c_device.I2CDevice(i2c, _I2C_ADDRESS)
        super().__init__(debug=debug, reset=reset)
开发者ID:eiselekd,项目名称:hw,代码行数:31,代码来源:i2c.py

示例5: Copyright

# Driver for official MicroPython LCD160CR display
# MIT license; Copyright (c) 2017 Damien P. George

from micropython import const
from utime import sleep_ms
from ustruct import calcsize, pack_into
import uerrno, machine

# for set_orient
PORTRAIT = const(0)
LANDSCAPE = const(1)
PORTRAIT_UPSIDEDOWN = const(2)
LANDSCAPE_UPSIDEDOWN = const(3)

# for set_startup_deco; can be or'd
STARTUP_DECO_NONE = const(0)
STARTUP_DECO_MLOGO = const(1)
STARTUP_DECO_INFO = const(2)

_uart_baud_table = {
    2400: 0,
    4800: 1,
    9600: 2,
    19200: 3,
    38400: 4,
    57600: 5,
    115200: 6,
    230400: 7,
    460800: 8,
}
开发者ID:fabaff,项目名称:micropython,代码行数:30,代码来源:lcd160cr.py

示例6: const

    import struct
except ImportError:
    import ustruct as struct

from micropython import const

import adafruit_bus_device.i2c_device as i2c_device


__version__ = "1.2.1"
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_MMA8451.git"


#pylint: disable=bad-whitespace
# Internal constants:
_MMA8451_DEFAULT_ADDRESS   = const(0x1D)
_MMA8451_REG_OUT_X_MSB     = const(0x01)
_MMA8451_REG_SYSMOD        = const(0x0B)
_MMA8451_REG_WHOAMI        = const(0x0D)
_MMA8451_REG_XYZ_DATA_CFG  = const(0x0E)
_MMA8451_REG_PL_STATUS     = const(0x10)
_MMA8451_REG_PL_CFG        = const(0x11)
_MMA8451_REG_CTRL_REG1     = const(0x2A)
_MMA8451_REG_CTRL_REG2     = const(0x2B)
_MMA8451_REG_CTRL_REG4     = const(0x2D)
_MMA8451_REG_CTRL_REG5     = const(0x2E)
_MMA8451_DATARATE_MASK     = const(0b111)
_SENSORS_GRAVITY_EARTH     = 9.80665

# External user-facing constants:
PL_PUF           = 0      # Portrait, up, front
开发者ID:eiselekd,项目名称:hw,代码行数:31,代码来源:adafruit_mma8451.py

示例7: const

This is a CircuitPython driver for the Bosch BNO055 nine degree of freedom
inertial measurement unit module with sensor fusion.

* Author(s): Radomir Dopieralski
"""
import time

from micropython import const
from adafruit_bus_device.i2c_device import I2CDevice
from adafruit_register.i2c_struct import Struct, UnaryStruct

__version__ = "3.0.4"
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_BNO055.git"

_CHIP_ID = const(0xa0)

CONFIG_MODE = const(0x00)
ACCONLY_MODE = const(0x01)
MAGONLY_MODE = const(0x02)
GYRONLY_MODE = const(0x03)
ACCMAG_MODE = const(0x04)
ACCGYRO_MODE = const(0x05)
MAGGYRO_MODE = const(0x06)
AMG_MODE = const(0x07)
IMUPLUS_MODE = const(0x08)
COMPASS_MODE = const(0x09)
M4G_MODE = const(0x0a)
NDOF_FMC_OFF_MODE = const(0x0b)
NDOF_MODE = const(0x0c)
开发者ID:eiselekd,项目名称:hw,代码行数:29,代码来源:adafruit_bno055.py

示例8: const

See:
    STM32Cube_FW_F4_V1.1.0/Drivers/BSP/Components/lis302dl/lis302dl.h
    STM32Cube_FW_F4_V1.1.0/Drivers/BSP/Components/lis302dl/lis302dl.c
    STM32Cube_FW_F4_V1.1.0/Drivers/BSP/STM32F4-Discovery/stm32f4_discovery.c
    STM32Cube_FW_F4_V1.1.0/Drivers/BSP/STM32F4-Discovery/stm32f4_discovery.h
    STM32Cube_FW_F4_V1.1.0/Drivers/BSP/STM32F4-Discovery/stm32f4_discovery_accelerometer.c
    STM32Cube_FW_F4_V1.1.0/Drivers/BSP/STM32F4-Discovery/stm32f4_discovery_accelerometer.h
    STM32Cube_FW_F4_V1.1.0/Projects/STM32F4-Discovery/Demonstrations/Src/main.c
"""

from micropython import const
from pyb import Pin
from pyb import SPI

READWRITE_CMD = const(0x80) 
MULTIPLEBYTE_CMD = const(0x40)
WHO_AM_I_ADDR = const(0x0f)
OUT_X_ADDR = const(0x29)
OUT_Y_ADDR = const(0x2b)
OUT_Z_ADDR = const(0x2d)
OUT_T_ADDR = const(0x0c)

LIS302DL_WHO_AM_I_VAL = const(0x3b)
LIS302DL_CTRL_REG1_ADDR = const(0x20)
# Configuration for 100Hz sampling rate, +-2g range
LIS302DL_CONF = const(0b01000111)

LIS3DSH_WHO_AM_I_VAL = const(0x3f)
LIS3DSH_CTRL_REG4_ADDR = const(0x20)
LIS3DSH_CTRL_REG5_ADDR = const(0x24)
开发者ID:Achimh3011,项目名称:micropython,代码行数:30,代码来源:staccel.py

示例9: const

"""
import time
import digitalio
from adafruit_register.i2c_bits import RWBits
from adafruit_register.i2c_bit import RWBit
from adafruit_bus_device.i2c_device import I2CDevice
from micropython import const


# ADDRESS_DEF = const(0x39)
# INTEGRATION_TIME_DEF = const(0x01)
# GAIN_DEF = const(0x01)

#pylint: disable-msg=bad-whitespace
#APDS9960_RAM        = const(0x00)
APDS9960_ENABLE     = const(0x80)
APDS9960_ATIME      = const(0x81)
#APDS9960_WTIME      = const(0x83)
#APDS9960_AILTIL     = const(0x84)
# APDS9960_AILTH      = const(0x85)
# APDS9960_AIHTL      = const(0x86)
# APDS9960_AIHTH      = const(0x87)
APDS9960_PILT       = const(0x89)
APDS9960_PIHT       = const(0x8B)
APDS9960_PERS       = const(0x8C)
# APDS9960_CONFIG1    = const(0x8D)
# APDS9960_PPULSE     = const(0x8E)
APDS9960_CONTROL    = const(0x8F)
# APDS9960_CONFIG2    = const(0x90)
APDS9960_ID         = const(0x92)
APDS9960_STATUS     = const(0x93)
开发者ID:eiselekd,项目名称:hw,代码行数:31,代码来源:apds9960.py

示例10: const

__version__ = "2.0.1"
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_l3gd20.git"


from micropython import const
from adafruit_register.i2c_struct import Struct
try:
    from struct import unpack
except ImportError:
    from ustruct import unpack

__version__ = "2.0.1"
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_L3GD20.git"

L3DS20_RANGE_250DPS = const(0)
L3DS20_RANGE_500DPS = const(1)
L3DS20_RANGE_2000DPS = const(2)

_L3GD20_REGISTER_CTRL_REG1 = const(0x20)
_L3GD20_REGISTER_CTRL_REG4 = const(0x23)

# _L3GD20_REGISTER_OUT_X_L = const(0x28)
_L3GD20_REGISTER_OUT_X_L_X80 = const(0xA8)
_L3GD20_REGISTER_OUT_X_L_X40 = const(0x68)

_ID_REGISTER = const(0x0F)

_L3GD20_CHIP_ID = const(0xD4)
_L3GD20H_CHIP_ID = const(0xD7)
开发者ID:eiselekd,项目名称:hw,代码行数:29,代码来源:adafruit_l3gd20.py

示例11: const

* Adafruit CircuitPython firmware (2.2.0+) for the ESP8622 and M0-based boards:
  https://github.com/adafruit/circuitpython/releases

* Adafruit's Bus Device library: https://github.com/adafruit/Adafruit_CircuitPython_BusDevice
"""
try:
    import ustruct as struct
except ImportError:
    import struct

import adafruit_bus_device.i2c_device as i2c_dev
from micropython import const

# Register addresses and other constants:
# pylint: disable=bad-whitespace
_FXOS8700_ADDRESS               = const(0x1F)   # 0011111
_FXOS8700_ID                    = const(0xC7)   # 1100 0111
_FXOS8700_REGISTER_STATUS       = const(0x00)
_FXOS8700_REGISTER_OUT_X_MSB    = const(0x01)
_FXOS8700_REGISTER_OUT_X_LSB    = const(0x02)
_FXOS8700_REGISTER_OUT_Y_MSB    = const(0x03)
_FXOS8700_REGISTER_OUT_Y_LSB    = const(0x04)
_FXOS8700_REGISTER_OUT_Z_MSB    = const(0x05)
_FXOS8700_REGISTER_OUT_Z_LSB    = const(0x06)
_FXOS8700_REGISTER_WHO_AM_I     = const(0x0D)   # 11000111   r
_FXOS8700_REGISTER_XYZ_DATA_CFG = const(0x0E)
_FXOS8700_REGISTER_CTRL_REG1    = const(0x2A)   # 00000000   r/w
_FXOS8700_REGISTER_CTRL_REG2    = const(0x2B)   # 00000000   r/w
_FXOS8700_REGISTER_CTRL_REG3    = const(0x2C)   # 00000000   r/w
_FXOS8700_REGISTER_CTRL_REG4    = const(0x2D)   # 00000000   r/w
_FXOS8700_REGISTER_CTRL_REG5    = const(0x2E)   # 00000000   r/w
开发者ID:eiselekd,项目名称:hw,代码行数:31,代码来源:adafruit_fxos8700.py

示例12: const

# check that consts are not replaced in anything except standalone identifiers

from micropython import const

X = const(1)
Y = const(2)
Z = const(3)

# import that uses a constant
import micropython as X
print(globals()['X'])

# function name that matches a constant
def X():
    print('function X', X)
globals()['X']()

# arguments that match a constant
def f(X, *Y, **Z):
    pass
f(1)

# class name that matches a constant
class X:
    def f(self):
        print('class X', X)
globals()['X']().f()

# constant within a class
class A:
    C1 = const(4)
开发者ID:Achimh3011,项目名称:micropython,代码行数:31,代码来源:const2.py

示例13: const

"""
`adafruit_rgb_display.s6d02a1`
====================================================

A simple driver for the S6D02A1-based displays.

* Author(s): Radomir Dopieralski, Michael McWethy
"""

from micropython import const
from adafruit_rgb_display.rgb import DisplaySPI

__version__ = "3.1.1"
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_RGB_Display.git"

_SWRESET = const(0x01)
_DISPON = const(0x29)
_SLEEPOUT = const(0x11)
_CASET = const(0x2a)
_PASET = const(0x2b)
_RAMWR = const(0x2c)
_RAMRD = const(0x2e)
_COLMOD = const(0x3a)
_MADCTL = const(0x36)

class S6D02A1(DisplaySPI):
    """
    A simple driver for the S6D02A1-based displays.

    >>> import busio
    >>> import digitalio
开发者ID:eiselekd,项目名称:hw,代码行数:31,代码来源:s6d02a1.py

示例14: const

**Software and Dependencies:**

* Adafruit CircuitPython firmware for the supported boards:
  https://github.com/adafruit/circuitpython/releases

* Adafruit's Bus Device library: https://github.com/adafruit/Adafruit_CircuitPython_BusDevice
"""

from micropython import const

__version__ = "1.1.0"
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_CAP1188.git"

# pylint: disable=bad-whitespace
_CAP1188_MID                = const(0x5D)
_CAP1188_PID                = const(0x50)
_CAP1188_MAIN_CONTROL       = const(0x00)
_CAP1188_GENERAL_STATUS     = const(0x02)
_CAP1188_INPUT_STATUS       = const(0x03)
_CAP1188_LED_STATUS         = const(0x04)
_CAP1188_NOISE_FLAGS        = const(0x0A)
_CAP1188_DELTA_COUNT        =(const(0x10),
                              const(0x11),
                              const(0x12),
                              const(0x13),
                              const(0x14),
                              const(0x15),
                              const(0x16),
                              const(0x17))
_CAP1188_SENSITIVTY         = const(0x1F)
开发者ID:eiselekd,项目名称:hw,代码行数:30,代码来源:cap1188.py

示例15: const

A simple driver for the ST7735-based displays.

* Author(s): Radomir Dopieralski, Michael McWethy
"""

try:
    import struct
except ImportError:
    import ustruct as struct
from micropython import const
from adafruit_rgb_display.rgb import DisplaySPI

__version__ = "3.1.1"
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_RGB_Display.git"

_NOP = const(0x00)
_SWRESET = const(0x01)
_RDDID = const(0x04)
_RDDST = const(0x09)

_SLPIN = const(0x10)
_SLPOUT = const(0x11)
_PTLON = const(0x12)
_NORON = const(0x13)

_INVOFF = const(0x20)
_INVON = const(0x21)
_DISPOFF = const(0x28)
_DISPON = const(0x29)
_CASET = const(0x2A)
_RASET = const(0x2B)
开发者ID:eiselekd,项目名称:hw,代码行数:31,代码来源:st7735.py


注:本文中的micropython.const函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。