全文搜索结果:
- lsm6dso陀螺仪传感器 @micropython:mpy-lib:sensor
- 0', '', '1000', '', '2000') class LSM6DSO(): def __init__(self, i2c, addr = 0x6B): self.i2... lf.scale_a('2g') self.scale_g('125') def int16(self, d): return d if d < 0x8000 else d - 0x10000 def setreg(self, reg, dat): self.tb[0] = dat ... elf.i2c.writeto_mem(self.addr, reg, self.tb) def getreg(self, reg): self.i2c.readfrom_mem_
- lsm6ds33陀螺仪传感器 @micropython:mpy-lib:sensor
- C i2c = I2C(1, freq=400000) gyr = LSM6DS33(i2c) def GYR_IRQ(t): pyb.LED(1).toggle() print('A:... G = (2, 1, 4, 0, 8, 0, 16) class LSM6DS33(): def __init__(self, i2c, addr = 0x6B): self.i2... self._scale_a = 0 self._scale_g = 0 def int16(self, d): return d if d < 0x8000 else d - 0x10000 def setreg(self, reg, dat): self.tb[0] = dat
- lsm303ah @micropython:mpy-lib:sensor
- C i2c = I2C(1, freq=400000) mag = LSM303AH(i2c) def MAG_IRQ(t): pyb.LED(1).toggle() print('M:... UTZ_L_REG_M = const(0x6C) class LSM303AH(): def __init__(self, i2c): self.i2c = i2c ... LSM303AH_ADDR_M, LSM303AH_CFG_REG_A_M, 0x80) def int16(self, d): return d if d < 0x8000 else d - 0x10000 def setreg(self, addr, reg, dat): self.tb[0]
- lis2dw12 @micropython:mpy-lib:sensor
- ('2g', '4g', '8g', '16g') class LIS2DW12(): def __init__(self, i2c, addr = 0x19): self.i2... le) self.oneshot_mode(False) def int16(self, d): return d if d < 0x8000 else d - 0x10000 def setreg(self, reg, dat): self.tb[0] = dat ... elf.i2c.writeto_mem(self.addr, reg, self.tb) def getreg(self, reg): self.i2c.readfrom_mem_
- ds3231高精度rtc @micropython:mpy-lib:misc
- KDAY = (4) PER_MONTH = (5) class DS3231(): def __init__(self, i2c): self.i2c = i2c self.setReg(DS3231_REG_CTRL, 0x4C) def DecToHex(self, dat): return (dat//10) * 16 + (dat%10) def HexToDec(self, dat): return (dat//16) * 10 + (dat%16) def setReg(self, reg, dat): self.i2c.writeto(
- microbit模拟时钟 @microbit:趣味程序:makecode
- 90) DS1302_REG_RAM = (0xC0) class DS1302: def __init__(self, clk, dio, cs): self.clk = ... self.dio = dio self.cs = cs def DecToHex(self, dat): return (dat//10) * 16 + (dat%10) def HexToDec(self, dat): return (dat//16) * 10 + (dat%16) def write_byte(self, dat): for i in range(8):
- snes_控制器 @microbit:趣味程序:micropython
- NES: # set up which micro:bit pins to use def __init__(self, latch, clock, data): self.... # take a reading and return a 16bit integer def getReading(self): self.latch.write_digita... ctionary of button names and the readings def info(self): reading = self.getReading() ... turn a list of buttons that have been pressed def pressed(self): d = self.info() ou
- lis2mdl @micropython:mpy-lib:sensor
- LIS2MDL i2c = I2C(1) mdl = LIS2MDL.LIS2MDL(i2c) def tim_irq(t): print(mdl.get()) tim = Timer(1, ... DL_OUTZ_L_REG = const(0x6C) class LIS2MDL(): def __init__(self, i2c): self.i2c = i2c ... eshot = False self.irq_v = [0, 0, 0] def int16(self, d): return d if d < 0x8000 else d - 0x10000 def setreg(self, reg, dat): self.tb[0] = dat
- apds9930接近和环境光传感器 @micropython:mpy-lib:sensor
- PDS9930_PGAIN = (1, 2, 4, 8) class APDS9930: def __init__(self, i2c): self.i2c = i2c ... self.ALS_Enable() self.Power() def setReg(self, reg, dat): self.i2c.writeto(... 930_I2C_ADDRESS, bytearray([reg|0xA0, dat])) def getReg(self, reg): self.i2c.writeto(APDS9... elf.i2c.readfrom(APDS9930_I2C_ADDRESS, 1)[0] def get2Reg(self, reg): self.i2c.writeto(APDS
- lps22气压传感器 @micropython:mpy-lib:sensor
- mport Timer i2c = I2C(1) lps = LPS22.LPS22(i2c) def tim_irq(t): print(lps.get_irq()) tim = Timer... 22_PRESS_OUT_L = const(0x29) class LPS22(): def __init__(self, i2c, addr = 0x5D): self.i2... REG1, 0x1A) self.oneshot_mode(False) def oneshot_mode(self, oneshot=None): if ones... self.setreg(LPS22_CTRL_REG1, self.rb[0]) def int16(self, d): return d if d < 0x8000 el
- hts221 @micropython:mpy-lib:sensor
- rom machine import I2C class HTS221(object): def __init__(self, i2c): self.i2c = i2c ... reg(0x20, 0x85) self.oneshot_mode(0) def oneshot_mode(self, oneshot = None): if on... 01 self.setreg(0x20, self.rb[0]) def ONE_SHOT(self, b): if self.oneshot: ... getreg(0x27) & b: return def int16(self, d): return d if d < 0x8000 el
- micropython程序优化实例 @micropython:代码和程序
- ort Pin import time led = Pin('A13') N = 200000 def blink_simple(n): for i in range(n): led.on() led.off() def time_it(f, n): t0 = time.ticks_us() f(n) ... ort Pin import time led = Pin('A13') N = 200000 def blink_simple(n): on = led.on off = led.of... for i in range(n): on() off() def time_it(f, n): t0 = time.ticks_us() f(n)
- pcf8563实时时钟 @micropython:mpy-lib:misc
- 563_REG_YEAR = const(8) class PCF8563(): def __init__(self, i2c): self.i2c = i2c ... y(7) self.DT = [0] * 8 # set reg def setReg(self, reg, dat): self.tb[0] = dat ... 563_I2C_ADDRESS, reg, self.tb) # get reg def getReg(self, reg): self.i2c.readfrom_mem_... ESS, reg, self.rb) return self.rb[0] def DecToHex(self, dat): return (dat//10) * 1
- bme280温湿度气压传感器 @micropython:mpy-lib:sensor
- ME280_I2C_ADDR = const(0x76) class BME280(): def __init__(self, i2c): self.i2c = i2c ... self.H = 0 self.version = '1.0' def short(self, dat): if dat > 32767: ... else: return dat # set reg def setReg(self, reg, dat): buf = bytearray(2... riteto(BME280_I2C_ADDR, buf) # get reg def getReg(self, reg): buf = bytearray(1)
- stts751温度传感器 @micropython:mpy-lib:sensor
- STTS751 i2c = I2C(1) stt = STTS751.STTS751(i2c) def tim_irq(t): print(stt.temperature_irq()) tim... 51_REG_THERMHYS = const(33) class STTS751(): def __init__(self, i2c): self.i2c = i2c ... hot = False self.oneshot_mode(False) def int16(self, d): return d if d < 0x8000 else d - 0x10000 def setreg(self, reg, dat): self.tb[0] = dat