mu-opensource / MuVisionSensor3

Open source arduino library for MU Vision Sensor 3
12 stars 4 forks source link

Morpx-bbs Git-rep Git-release

MuVisionSensor

Pic-vision-sensor

The MU Vision Sensor is a sensor module that supports Arduino, Microbit, and other haredware platform that supports UART or I2C communication protocols.

You can use these libraries to read data or set properties of the MU Vision Sensor.

Simple example

How quickly can you get up and running with the library? Here's a simple program:

#include <MuVisionSensor.h>
#include <Wire.h>
#define VISION_TYPE VISION_BALL_DETECT
#define MU_ADDRESS    0x60
MuVisionSensor Mu(MU_ADDRESS);
void setup() { 
  Wire.begin();                                           // I2C or Serial must initialize before MU vision sensor
  Mu.begin(&Wire);                                        // MU begin
  Mu.VisionBegin(VISION_TYPE);                            // vision begin
}
void loop() {
  if (Mu.GetValue(VISION_TYPE, kStatus)) {                // get vision status value
    int x = Mu.GetValue(VISION_TYPE, kXValue);            // get vision X axes value
    int y = Mu.GetValue(VISION_TYPE, kYValue);            // get vision Y axes value
    int width = Mu.GetValue(VISION_TYPE, kWidthValue);    // get vision width value
    int height = Mu.GetValue(VISION_TYPE, kHeightValue);  // get vision height value
    int label = Mu.GetValue(VISION_TYPE, kLabel);         // get vision label value
  }
}

Supported platforms

Right now the library is supported on a variety of arduino compatable platforms. If you want to use the library on other plantforms which supported on C/C++, please follow the steps below:

Uart

1.Edit file mu_uart_interface.h in path MuVisionSensor/src/

2.Modify typedef hw_port_t in line 15 to the UART Class supported by the platform

3.Save and close file mu_uart_interface.h

4.Edit file mu_uart_interface.cpp in path MuVisionSensor/src/

5.Override the functions below:


/**
* @brief  Uart read characters from stream into buffer.
* @param  buf: uart buffer.
* @param  length: the number of characters you want to read.
* @retval returns the number of characters placed in the buffer, terminates if length characters have been read, or timeout.
*/
size_t MuUart::read(uint8_t* buf, uint8_t length);

/**

I2C

1.Edit file mu_vision_sensor_i2c_hw_interface.h in path MuVisionSensor/src/

2.Modify typedef MuVsI2C in line 24 to the I2C Class supported by the platform

3.Save and close file mu_vision_sensor_i2c_hw_interface.h

4.Edit file mu_vision_sensor_i2c_hw_interface.cpp in path MuVisionSensor/src/

5.Override the functions below:


/**
* @brief  I2C read byte.
* @param  reg_address: register address.
* @param  temp: register value.
* @retval 0: read success
*         not 0: error
*/
uint32_t MuVisionSensorI2C::I2CRead(uint8_t reg_address, uint8_t* temp);

/**

What about other library for MuVisionSensor?

For more information

Check out the official site http://www.morpx.com/zn.index.html for links to documentation, issues, and news