User Tools

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revisionBoth sides next revision
code:sub2r-lib [2022/08/30 18:42] – [byte_span] Igor Yefmovcode:sub2r-lib [2022/08/30 18:45] – [Sample code] Igor Yefmov
Line 408: Line 408:
     using namespace S2R;     using namespace S2R;
  
-    cout << "SUB2r-lib sample #1: basic functionality" << endl << endl;+    cout << "SUB2r-lib sample #1: basic functionality\n\n";
  
-    I2C dev; +    const auto numDevs{ImgSensor::deviceCount()}
-    const auto numDevs = dev.deviceCount(); +    cout << "Cypress devices attached to this system: " << static_cast<int>(numDevs) << "\n\n"; 
-    cout << "Cypress devices attached to this system: " << static_cast<int>(numDevs) << endl << endl+    ImgSensor dev(false)
-    for(uint8_t i = 0; i < numDevs; ++i){ +    for(uint8_t i{}; i < numDevs; ++i){ 
-        auto GAIN_R = IImgSensor::Value::gain_r;+        auto GAIN_R{IImgSensorChip::Value::gain_r};
         cout << "Opening device #" << static_cast<int>(i) << "... ";         cout << "Opening device #" << static_cast<int>(i) << "... ";
         if(dev.open(i)){         if(dev.open(i)){
-            wcout << L"success.\nDevice name is: " << dev[FX3::PropWString::friendly_name].c_str() << endl+            wcout << L"success.\nDevice name is: " << dev[FX3::PropWString::friendly_name].c_str() << "\n"
-            cout << "Sensor chipset: " << dev->chipsetName() << endl+            cout << "Sensor chipset: " << dev->chipsetName() << "\n"
-            cout << "FX3 version info: " << string(dev.fx3Version()) << endl+            cout << "FX3 version info: " << string(dev.fx3Version()) << "\n"
-            cout << "FPGA version info: " << string(dev.fpgaVersion()) << endl+            cout << "FPGA version info: " << string(dev.fpgaVersion()) << "\n"
-            auto & ov = *dev.sensor();  // make a shortcut to the sensor chip +            
-            if(dev){    // or dev.isValid() works, too +                auto & ov{dev.sensor()}  // shortcut to the sensor chip 
-                cout << "current red channel gain is: " << dev->val(GAIN_R) << endl+                cout << "current red channel gain is: " << dev->val(GAIN_R) << "\n"
-                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 << endl;+                cout << "after increasing red channel gain by 1 it is now: " << gainR << "\n";
                 ov[GAIN_R] -= 1;                 ov[GAIN_R] -= 1;
-                cout << "and back to the previous value of: " << gainR << endl;+                cout << "and back to the previous value of: " << gainR << "\n";
                 ov[GAIN_R] *= 1.0;                 ov[GAIN_R] *= 1.0;
             }             }
Line 434: Line 434:
             dev.close();    // or the destructor (or even the next call to open()) will take care of that             dev.close();    // or the destructor (or even the next call to open()) will take care of that
             if(dev){             if(dev){
-                cout << "something has gone terribly wrong - the device was supposed to be closed by now!" << endl;+                cout << "something has gone terribly wrong - the device was supposed to be closed by now!\n";
             }else{             }else{
-                cout << "the device is now closed and cannot be accessed without re-opening it" << endl+                cout << "the device is now closed and cannot be accessed without re-opening it\n"; 
-                cout << "For example the red channel gain is now: " << ov[GAIN_R] << endl+                cout << "For example the red channel gain is now: " << dev.sensor()[GAIN_R] << "\n"
-                cout << "But some info is still available, like the sensor chipset: " << dev->chipsetName() << endl+                cout << "But some info is still available, like the sensor chipset: " << dev->chipsetName() << "\n"
-                cout << "Or the information about the limit of red channel gain: " << dev->getLimit(GAIN_R) << endl;+                cout << "Or the information about the limit of red channel gain: " << dev->getLimit(GAIN_R) << "\n";
             }             }
         }else{         }else{
-            cout << "failed." << endl;+            cout << "failed.\n";
             if(dev.isValid()){             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;+                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() << "\n";
             }             }
         }         }
-        cout << endl;+        cout << "\n";
     }     }
     return 0;     return 0;

This website uses cookies. By using the website, you agree with storing cookies on your computer. Also, you acknowledge that you have read and understand our Privacy Policy. If you do not agree, please leave the website.

More information