• OpenMV VSCode 扩展发布了,在插件市场直接搜索OpenMV就可以安装
  • 如果有产品硬件故障问题,比如无法开机,论坛很难解决。可以直接找售后维修
  • 发帖子之前,请确认看过所有的视频教程,https://singtown.com/learn/ 和所有的上手教程http://book.openmv.cc/
  • 每一个新的提问,单独发一个新帖子
  • 帖子需要目的,你要做什么?
  • 如果涉及代码,需要报错提示全部代码文本,请注意不要贴代码图片
  • 必看:玩转星瞳论坛了解一下图片上传,代码格式等问题。
  • erron 110错误代码的原因是什么?



    • 0_1568354210942_6424a122-a8bf-4161-a16c-7bdbeaafce06-image.png
      import utime
      import ustruct

      At reset, the device's ports are inputs with a high value resistor pull-ups to VDD

      If relays turning on during power up are a problem. Add a pull down resistor to each

      relay transistor base.

      CmdBys={
      'IN_P0':0x00, #Read Input port0
      'IN_P1':0x01, #Read Input port1
      'OUT_P0':0x02, #Write Output port0
      'OUT_P1':0x03, #Write Output port1
      'INV_P0':0x04, #Input Port Polarity Inversion port0/1 if B11111111 is
      'INV_P1':0x05, #written input polarity is inverted
      'CONFIG_P0':0x06,#Configuration port0/1 configures the direction of the
      'CONFIG_P1':0x07 #I/O pins, 0 is output 1 is input
      }
      class PCA9555:
      #with no jumpers the full address is 1 0 0 1 1 1
      #1 0 0 A2 A1 A0 0x27 is the default address for the DFR0013 board with no jumpers.
      #0x20 is address for the DFR0013 board with all jumpers.
      def init(self, i2c, address=0x20):
      self.i2c = i2c
      self.address = address

      self.reset()

      def _write(self, address, value):    #这里的address为器件内部地址
          self.i2c.writeto_mem(self.address, address, bytearray([value]))
      
      def _read(self, address):
          return self.i2c.readfrom_mem(self.address, address, 1)[0]
      

      def reset(self):

      self._write(0x00, 0x00) # Mode1

      def Output(self, Outvalue=None):    #高八位给端口1,低八位给端口0
          self._write(CmdBys['CONFIG_P0'], 0x00)
          self._write(CmdBys['CONFIG_P1'], 0x00)
          if Outvalue is None:
              self._write(CmdBys['OUT_P0'], 0x00)
              self._write(CmdBys['OUT_P1'], 0x00)
          else:
              value0=Outvalue&0xff
              value1=(Outvalue>>8)&0xff
              self._write(CmdBys['OUT_P0'], value0)
              self._write(CmdBys['OUT_P1'], value1)
      
      
      def Input(self):
          self._write(CmdBys['CONFIG_P0'], 0xff)
          value0=self._read(CmdBys['IN_P0'])
          self._write(CmdBys['CONFIG_P0'], 0xff)
          value1=self._read(CmdBys['IN_P1'])
          Invalue=(value1<<8)|value0
          return Invalue