#include #include "FX3.h" #pragma comment(lib, "SUB2r-lib.lib") int main() { using namespace std; using namespace S2R; cout << "SUB2r-lib sample #1: basic functionality" << endl << endl; I2C dev; const auto numDevs = dev.deviceCount(); cout << "Cypress devices attached to this system: " << static_cast(numDevs) << endl << endl; for(uint8_t i = 0; i < numDevs; ++i){ auto GAIN_R = IImgSensor::Value::gain_r; cout << "Opening device #" << static_cast(i) << "... "; if(dev.open(i)){ wcout << L"success.\nDevice name is: " << dev[FX3::PropWString::friendly_name].c_str() << endl; cout << "Sensor chipset: " << dev->chipsetName() << endl; cout << "FX3 version info: " << string(dev.fx3Version()) << endl; cout << "FPGA version info: " << string(dev.fpgaVersion()) << endl; auto & ov = *dev.sensor(); // make a shortcut to the sensor chip if(dev){ // or dev.isValid() works, too cout << "current red channel gain is: " << dev->val(GAIN_R) << endl; auto gainR = ov[GAIN_R]; gainR = gainR + 1; // increment the red gain by one and update the sensor with the new value cout << "after increasing red channel gain by 1 it is now: " << gainR << endl; ov[GAIN_R] -= 1; cout << "and back to the previous value of: " << gainR << endl; ov[GAIN_R] *= 1.0; } cout << "Closing the device... "; dev.close(); // or the destructor (or even the next call to open()) will take care of that if(dev){ cout << "something has gone terribly wrong - the device was supposed to be closed by now!" << endl; }else{ cout << "the device is now closed and cannot be accessed without re-opening it" << endl; cout << "For example the red channel gain is now: " << ov[GAIN_R] << endl; cout << "But some info is still available, like the sensor chipset: " << dev->chipsetName() << endl; cout << "Or the information about the limit of red channel gain: " << dev->getLimit(GAIN_R) << endl; } }else{ cout << "failed." << endl; if(dev.isValid()){ wcout << L"But the FX3 part is still functional, so we can get info like the device's name: " << dev[FX3::PropWString::friendly_name].c_str() << endl; } } cout << endl; } return 0; }