Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionLast revisionBoth sides next revision | ||
code:sub2r-lib [2018/11/06 00:09] – [UFix_8_8] Igor Yefmov | code:sub2r-lib [2022/09/10 20:38] – [Basic "vendor request" call] Igor Yefmov | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== Windows ====== | ====== Windows ====== | ||
- | You can download the library from [[http://download.sub2r.com/ | + | You can download the library from [[http:// |
- A header file '' | - A header file '' | ||
- Both '' | - Both '' | ||
- | - A sample | + | - Sample |
+ | - Sample code that showcases the use of '' | ||
+ | - Sample code for controlling FPS: '' | ||
- | The library is built using MSVC 2017 version '' | + | The library is built using MSVC 2022 version '' |
- | ===== byte_span | + | ===== Basic " |
- | Beginning with version '' | + | |
- | Quite often a need arises to represent | + | SUB2r API calls are implemented as USB "vendor request" |
- | + | ||
- | All the library' | + | |
Sample usage: | Sample usage: | ||
Line 19: | Line 18: | ||
using S2R::FX3; | using S2R::FX3; | ||
FX3 fx3; // by default opens device #0 | FX3 fx3; // by default opens device #0 | ||
- | if(fx3){ | + | if(fx3.isValid()){ |
- | | + | |
const auto rc{m_fx3.vrCmd(Fx3Cmd:: | const auto rc{m_fx3.vrCmd(Fx3Cmd:: | ||
, VrCmdOpType:: | , VrCmdOpType:: | ||
, 0 // " | , 0 // " | ||
, 0 // " | , 0 // " | ||
- | , byte_span(vi))}; // buffer to read into | + | , vi)}; |
return vi; // 32 bits of the " | return vi; // 32 bits of the " | ||
} | } | ||
Line 269: | Line 268: | ||
^ Method ^ Signature ^ Functionality ^ | ^ Method ^ Signature ^ Functionality ^ | ||
| '' | | '' | ||
- | SPIConfigStatus(uint16_t _val = 0) noexcept;</ | + | constexpr |
- | | '' | + | | '' |
- | | '' | + | | '' |
Individual bits are described in the [[code: | Individual bits are described in the [[code: | ||
Line 360: | Line 359: | ||
| <code c++> | | <code c++> | ||
| <code c++> | | <code c++> | ||
- | |||
- | |||
- | ==== UFix_8_8 ==== | ||
- | {{ : | ||
- | |||
- | A helper class for working with a 2-byte floating number format used to specify fractional parameters for the FX3. More details are available in [[code: | ||
- | |||
- | ^ Method ^ Signature ^ Functionality ^ | ||
- | | '' | ||
- | UFix_8_8( | ||
- | uint8_t _i | ||
- | , uint8_t _f = 0 | ||
- | ) noexcept</ | ||
- | | '' | ||
- | UFix_8_8(double _d) | ||
- | noexcept;</ | ||
- | | '' | ||
- | gsl:: | ||
- | ) noexcept;</ | ||
- | | '' | ||
- | operator double() const | ||
- | noexcept;</ | ||
- | | '' | ||
- | operator uint16_t() const | ||
- | noexcept;</ | ||
- | uint8_t valI{1}, valF{128}; | ||
- | auto val{S2R:: | ||
- | S2R::I2C dev; | ||
- | // a port to set the image adjustment auto-func- | ||
- | // tions' update interval | ||
- | constexpr uint8_t port{0xDF}; | ||
- | dev.vrCmd(port, | ||
- | </ | ||
Line 411: | Line 377: | ||
using namespace S2R; | using namespace S2R; | ||
- | cout << " | + | cout << " |
- | | + | const auto numDevs{ImgSensor:: |
- | | + | cout << " |
- | cout << " | + | ImgSensor dev(false); |
- | for(uint8_t i = 0; i < numDevs; ++i){ | + | for(uint8_t i{}; i < numDevs; ++i){ |
- | auto GAIN_R | + | auto GAIN_R{IImgSensorChip:: |
cout << " | cout << " | ||
if(dev.open(i)){ | if(dev.open(i)){ | ||
- | wcout << L" | + | wcout << L" |
- | cout << " | + | cout << " |
- | cout << "FX3 version info: " << string(dev.fx3Version()) << | + | cout << "FX3 version info: " << string(dev.fx3Version()) << |
- | cout << "FPGA version info: " << string(dev.fpgaVersion()) << | + | cout << "FPGA version info: " << string(dev.fpgaVersion()) << |
- | auto & ov = *dev.sensor(); | + | |
- | if(dev){ | + | |
- | cout << " | + | cout << " |
- | auto gainR = ov[GAIN_R]; | + | auto gainR{ov[GAIN_R]}; |
gainR = gainR + 1; // increment the red gain by one and update the sensor with the new value | 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 << | + | cout << "after increasing red channel gain by 1 it is now: " << gainR << |
ov[GAIN_R] -= 1; | ov[GAIN_R] -= 1; | ||
- | cout << "and back to the previous value of: " << gainR << | + | cout << "and back to the previous value of: " << gainR << |
ov[GAIN_R] *= 1.0; | ov[GAIN_R] *= 1.0; | ||
} | } | ||
Line 437: | Line 403: | ||
dev.close(); | dev.close(); | ||
if(dev){ | if(dev){ | ||
- | cout << " | + | cout << " |
}else{ | }else{ | ||
- | cout << "the device is now closed and cannot be accessed without re-opening it" | + | cout << "the device is now closed and cannot be accessed without re-opening it\n"; |
- | cout << "For example the red channel gain is now: " << | + | cout << "For example the red channel gain is now: " << |
- | cout << "But some info is still available, like the sensor chipset: " << dev-> | + | cout << "But some info is still available, like the sensor chipset: " << dev-> |
- | cout << "Or the information about the limit of red channel gain: " << dev-> | + | cout << "Or the information about the limit of red channel gain: " << dev-> |
} | } | ||
}else{ | }else{ | ||
- | cout << " | + | cout << " |
if(dev.isValid()){ | if(dev.isValid()){ | ||
- | wcout << L"But the FX3 part is still functional, so we can get info like the device' | + | wcout << L"But the FX3 part is still functional, so we can get info like the device' |
} | } | ||
} | } | ||
- | cout << | + | cout << |
} | } | ||
return 0; | return 0; | ||
Line 469: | Line 435: | ||
FIXME | FIXME | ||
+ | ====== Previous versions ====== | ||
+ | * [[SUB2r-lib-2020-10-08]] | ||
+ | * [[SUB2r-lib-2019-04-29]] |