<< return to Pixycam.com

Adding methods to arduino api

Hello,

I am trying to add additional functionality to the Arduino example files. I have looked through the github repo to try to gain an understanding of the sequence of events but have failed to figure out how methods from the arduino api are mapped to the native Pixy methods. So far I have looked at the setBrightness method. I figured out the following:

TPixy.h - 249: setBrightness -> calls send() with identifier 0x00 and 0xff in Pixy.h
Pixy.h - ln 113: int8_t send -> calls flushSend() -> calls getWordHw() -> calls Spi.transfer()

So at this point I figured some identifier has to be passed via SPI to the Pixy. I searched for “0xfe” from the setBrightness method but this wasn’t used anywhere else.

I found some interesting methods below that somehow must be called:

pixy_cam_set_brightness(uint8_t brightness)
int32_t cam_setBrightness(const uint8_t &brightness)

Can someone explain how methods are mapped from the Arduino api to the native pixy methods? I’d like to access all the methods listed on the libpixyusb-0.4 API Reference page.

I’m also happy to add the methods to the github repo for others to use.

Hello Raph,
Sorry for the confusion. There are two API’s for talking to Pixy that are separate. There is the Arduino API in the src/host/arduino directory. It uses one of the serial interfaces (SPI, I2C or UART). And there is the libpixyusb API for controllers with a USB interface (in src/host/libpixyusb) Since you are using Arduino, all of the relevant code is in the Arduino directory. What functionality would you like to add?

Edward

Hi Edward,

I would be very interested to be able to set the gain/brightness of the sensor from an Arduino. Is there any plan in the future to support that?

Thanks,

Scott

Hi Edward,

Thanks for clarifying. In this case is there any way to know that say 0xfe- corresponds to brightness?

Essentially I would like to be able to have access to the following methods (methods that would augment the functionality of PixyMon would be ideal):

pixy_cam_set_auto_white_balance()
pixy_cam_get_auto_white_balance()
pixy_cam_get_brightness()
pixy_cam_set_white_balance_value()
pixy_cam_get_white_balance_value()
pixy_cam_set_exposure_compensation()
pixy_cam_get_exposure_compensation()

It would be nice if there was a setSignature() method as well. I would like to set an area based on somesome values of x1 to x2, and y1 to y2 and set this as a new signature. Similar to how I can select an area using PixyMon and set the signature.

Again if I knew how the API’s were mapped or which register corresponded to what feature I would be glad to add it to the Arduino API.

Scott Mahr wrote:

I would be very interested to be able to set the gain/brightness of the sensor from an Arduino. Is there any plan in the future to support that?

Hi Scott, this is available in both the Arduino (setBrightness) and libpixyusb (pixy_cam_set_brightness) API’s. The setBrigthness function was added to Arduino recently.

Raph K wrote:

Thanks for clarifying. In this case is there any way to know that say 0xfe- corresponds to brightness?

0xfe is part of the identifier for setting the brightness in the Arduino API. But I may not understand your question.

The two API’s are separate. The Arduino API is very simple and easy to implement on smaller processors with limited resources. The libpixyusb API is more feature-rich.

Hope this helps!

Hi Scott,

I’m guessing that this won’t go anywhere but here it goes:

I was hoping for a list like the following

0xfe = brightness

0xef = some functionality like white balance

0xee = some other functionality like auto exposure

While I understand that the Arduino isn’t super powerful I don’t understand why it can’t send some basic information over SPI to the Pixy with different identifiers. What exactly is different performance-wise from setting the exposure vs setting the brightness? Isn’t it just some another bit register?

Hello Raph,
Brightness and exposure are actually the same thing. We chose the word “brightness” because more people are familiar with the term.

The Arduino API can be expanded, but maybe it would be more helpful if you described what you are trying to do. There might be a better solution. :slight_smile:

Edward