导航

    • 登录
    • 搜索
    • 版块
    • 产品
    • 教程
    • 论坛
    • 淘宝
    1. 主页
    2. gd3p
    3. 楼层
    G
    • 举报资料
    • 资料
    • 关注
    • 粉丝
    • 屏蔽
    • 帖子
    • 楼层
    • 最佳
    • 群组

    gd3p 发布的帖子

    • RE: arduino_spi_slave 从设备通信错误

      @kidswong999 好的 谢谢

      发布在 OpenMV Cam
      G
      gd3p
    • RE: arduino_spi_slave 从设备通信错误

      @kidswong999 0_154676022284UCQ.png

      那是使用arduino软件版本的问题吗?我使用的是arduino1.0.6

      发布在 OpenMV Cam
      G
      gd3p
    • arduino_spi_slave 从设备通信错误

      #include <SPI.h>
      #define SS_PIN 10
      #define BAUD_RATE 19200
      #define CHAR_BUF 128
      void setup() {
      pinMode(SS_PIN, OUTPUT);
      Serial.begin(BAUD_RATE);
      SPI.begin();
      SPI.setBitOrder(MSBFIRST);
      SPI.setClockDivider(SPI_CLOCK_DIV16);
      SPI.setDataMode(SPI_MODE0);
      delay(1000); // Give the OpenMV Cam time to bootup.
      }
      void loop() {
      int32_t temp = 0;
      char buff[CHAR_BUF] = {0};
      digitalWrite(SS_PIN, LOW);
      delay(1); // Give the OpenMV Cam some time to setup to send data.
      if (SPI.transfer(1) == 85) { // saw sync char?
      SPI.transfer(&temp, 4); // get length
      int zero_legnth = 4 + ((temp + 1) % 4);
      if (temp) {
      SPI.transfer(&buff, min(temp, CHAR_BUF));
      temp -= min(temp, CHAR_BUF);
      }
      while (temp--) SPI.transfer(0); // eat any remaining bytes
      while (zero_legnth--) SPI.transfer(0); // eat zeros.
      }
      digitalWrite(SS_PIN, HIGH);
      Serial.print(buff);
      delay(1); // Don't loop to quickly.
      }
      sketch_jan03a.ino: In function 'void loop()':
      sketch_jan03a:23: error: no matching function for call to 'SPIClass::transfer(int32_t*&, int)'
      D:\360Downloads\Arduino\libraries\SPI/SPI.h:55: note: candidates are: static byte SPIClass::transfer(byte)
      sketch_jan03a:24: error: invalid operands of types 'int32_t*' and 'int' to binary 'operator%'
      sketch_jan03a:26: error: ISO C++ forbids comparison between pointer and integer
      sketch_jan03a:26: error: operands to ?: have different types 'int32_t*' and 'int'
      sketch_jan03a:27: error: ISO C++ forbids comparison between pointer and integer
      sketch_jan03a:27: error: operands to ?: have different types 'int32_t*' and 'int'

      arduino UNO的板子应该没错吧 SPI.transfer(&temp, 4); // get length
      transfer第一个参数应该数传输的数组吧 这个程序传输的是数组吗?

      发布在 OpenMV Cam
      G
      gd3p
    • RE: arduino_spi_slave 从设备通信错误

      @kidswong999 arduino UNO的板子应该没错吧 SPI.transfer(&temp, 4); // get length
      transfer第一个参数应该数传输的数组吧 这个程序传输的是数组吗?

      发布在 OpenMV Cam
      G
      gd3p
    • arduino_spi_slave 从设备通信错误

      #include <SPI.h>
      #define SS_PIN 10
      #define BAUD_RATE 19200
      #define CHAR_BUF 128

      void setup() {
      pinMode(SS_PIN, OUTPUT);
      Serial.begin(BAUD_RATE);
      SPI.begin();
      SPI.setBitOrder(MSBFIRST);
      SPI.setClockDivider(SPI_CLOCK_DIV16);
      SPI.setDataMode(SPI_MODE0);
      delay(1000); // Give the OpenMV Cam time to bootup.
      }

      void loop() {
      int32_t temp = 0;
      char buff[CHAR_BUF] = {0};
      digitalWrite(SS_PIN, LOW);
      delay(1); // Give the OpenMV Cam some time to setup to send data.

      if (SPI.transfer(1) == 85) { // saw sync char?
      SPI.transfer(&temp, 4); // get length
      int zero_legnth = 4 + ((temp + 1) % 4);
      if (temp) {
      SPI.transfer(&buff, min(temp, CHAR_BUF));
      temp -= min(temp, CHAR_BUF);
      }
      while (temp--) SPI.transfer(0); // eat any remaining bytes
      while (zero_legnth--) SPI.transfer(0); // eat zeros.
      }

      digitalWrite(SS_PIN, HIGH);
      Serial.print(buff);
      delay(1); // Don't loop to quickly.
      }

      sketch_jan03a.ino: In function 'void loop()':
      sketch_jan03a:23: error: no matching function for call to 'SPIClass::transfer(int32_t*&, int)'
      D:\360Downloads\Arduino\libraries\SPI/SPI.h:55: note: candidates are: static byte SPIClass::transfer(byte)
      sketch_jan03a:24: error: invalid operands of types 'int32_t*' and 'int' to binary 'operator%'
      sketch_jan03a:26: error: ISO C++ forbids comparison between pointer and integer
      sketch_jan03a:26: error: operands to ?: have different types 'int32_t*' and 'int'
      sketch_jan03a:27: error: ISO C++ forbids comparison between pointer and integer
      sketch_jan03a:27: error: operands to ?: have different types 'int32_t*' and 'int'

      发布在 OpenMV Cam
      G
      gd3p
    • WiFi模板与电脑连接时,WiFi受限制怎么办

      WiFi模板与电脑连接时,WiFi受限制怎么办

      发布在 OpenMV Cam
      G
      gd3p
    • RE: AttributeError: 'tuple' object has no attribute 'cx'

      @kidswong999 谢谢

      发布在 OpenMV Cam
      G
      gd3p
    • 模板匹配时要求模板有大小需求吗?有的话,要求多大呢?

      模板匹配时要求模板有大小需求吗?有的话,要求多大呢?

      发布在 OpenMV Cam
      G
      gd3p
    • RE: AttributeError: 'tuple' object has no attribute 'cx'

      @kidswong999 新买的

      发布在 OpenMV Cam
      G
      gd3p
    • AttributeError: 'tuple' object has no attribute 'cx'
      import sensor, image, time
      
      from pid import PID
      from pyb import Servo
      
      pan_servo=Servo(1)
      tilt_servo=Servo(2)
      
      red_threshold  = (13, 49, 18, 61, 6, 47)
      
      pan_pid = PID(p=0.07, i=0, imax=90) #脱机运行或者禁用图像传输,使用这个PID
      tilt_pid = PID(p=0.05, i=0, imax=90) #脱机运行或者禁用图像传输,使用这个PID
      #pan_pid = PID(p=0.1, i=0, imax=90)#在线调试使用这个PID
      #tilt_pid = PID(p=0.1, i=0, imax=90)#在线调试使用这个PID
      
      sensor.reset()
      
      # Sensor settings
      sensor.set_contrast(1)
      sensor.set_gainceiling(16)
      # HQVGA and GRAYSCALE are the best for face tracking.
      sensor.set_framesize(sensor.HQVGA)
      sensor.set_pixformat(sensor.GRAYSCALE)
      clock = time.clock() # Tracks FPS.
      
      face_cascade = image.HaarCascade("frontalface", stages=25)
      print(face_cascade)
      def find_max(blobs):
          max_size=0
          for blob in blobs:
              if blob[2]*blob[3] > max_size:
                  max_blob=blob
                  max_size = blob[2]*blob[3]
          return max_blob
      
      
      while(True):
          clock.tick() # Track elapsed milliseconds between snapshots().
          img = sensor.snapshot() # Take a picture and return the image.
      
          objects = img.find_features(face_cascade, threshold=0.75, scale=1.35)
          if objects:
              max_blob = find_max(objects)
              pan_error = max_blob.cx()-img.width()/2
              tilt_error = max_blob.cy()-img.height()/2
      
              print("pan_error: ", pan_error)
      
              img.draw_rectangle(max_blob.rect()) # rect
             # img.draw_cross(max_blob.cx(), max_blob.cy()) # cx, cy
      
              pan_output=pan_pid.get_pid(pan_error,1)/2
              tilt_output=tilt_pid.get_pid(tilt_error,1)
              print("pan_output",pan_output)
              pan_servo.angle(pan_servo.angle()+pan_output)
              tilt_servo.angle(tilt_servo.angle()-tilt_output)
      
      
      发布在 OpenMV Cam
      G
      gd3p
    • AttributeError: 'tuple' object has no attribute 'cx'

      AttributeError: 'tuple' object has no attribute 'cx'
      请问大佬们 这个错误怎么修改啊?感谢

      发布在 OpenMV Cam
      G
      gd3p