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 revision
Previous revision
code:sub2r-lib [2022/08/30 18:45] – [Sample code] Igor Yefmovcode:sub2r-lib [2022/09/10 20:39] (current) – [Basic "vendor request" call] Igor Yefmov
Line 11: Line 11:
  
 ===== Basic "vendor request" call ===== ===== Basic "vendor request" call =====
 +
 +SUB2r API calls are implemented as USB "vendor request" commands, where ''USB_SETUP_PACKET::bmRequest::Type'' is set to ''2'', following the USB specification.
  
 Sample usage: Sample usage:
Line 19: Line 21:
     array<std::byte, 4> vi{};     array<std::byte, 4> vi{};
     const auto rc{m_fx3.vrCmd(Fx3Cmd::fx3_version // vendor request command     const auto rc{m_fx3.vrCmd(Fx3Cmd::fx3_version // vendor request command
-                              , VrCmdOpType::read // read from device +                            , VrCmdOpType::read   // read from device 
-                              , 0                 // "value" +                            , 0                   // "value" 
-                              , 0                 // "index" +                            , 0                   // "index" 
-                              , vi)};             // buffer to read into+                            , vi)};               // buffer to read into
     return vi;                                    // 32 bits of the "version info" (4 bytes)     return vi;                                    // 32 bits of the "version info" (4 bytes)
 } }
Line 357: Line 359:
 | <code c++>m_rollingbar</code> | enable/disable a rolling bar, only valid when ''m_mode == color_bar'' | | <code c++>m_rollingbar</code> | enable/disable a rolling bar, only valid when ''m_mode == color_bar'' |
 | <code c++>m_enabled</code> | enable/disable the test pattern mode | | <code c++>m_enabled</code> | enable/disable the test pattern mode |
- 
- 
-==== UFix_8_8 ==== 
-{{ :code:class-ufix_8_8.png?nolink|Class diagram - 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:numberformats#ufix_88|UFIX 8.8 documentation]]. 
- 
-^ Method ^ Signature ^ Functionality ^ 
-| ''constructor'' | <code c++>constexpr 
-  UFix_8_8( 
-      uint8_t _i 
-    , uint8_t _f = 0 
-    ) noexcept</code> | construct a number from provided integer (''_i'') and fractional (''_f'') parts, for example: <code c++>auto uf88{1, 128}; // uf88 is now 1.5</code>No validation is performed to make sure the ''_f'' is in range [''0''..''255''] | 
-| ''constructor'' | <code c++>constexpr 
-  UFix_8_8(double _d) 
-    noexcept;</code> | construct from a floating-point number, i.e.: <code c++>auto uf88{1.2};</code> | 
-| ''constructor'' | <code c++>UFix_8_8( 
-    gsl::span<const std::byte> _buf 
-    ) noexcept;</code> | use this constructor when you read a 2-byte ''UFix_8_8'' value from FX3 | 
-| ''operator double'' | <code c++>constexpr 
-  operator double() const 
-    noexcept;</code> | a type conversion into a floating-point number | 
-| ''operator uint16_t'' | <code c++>constexpr 
-  operator uint16_t() const 
-    noexcept;</code> | make 2 bytes that are ready to be written to FX3, for example:<code c++>// omitting all the error checks!!! 
-uint8_t valI{1}, valF{128}; 
-auto val{S2R::UFix_8_8(valI, valF)}; 
-S2R::I2C dev; 
-// a port to set the image adjustment auto- 
-// functions' update interval 
-constexpr uint8_t port{0xDF}; 
-dev.vrCmd(port, S2R::FX3::write, val, 0); 
-</code> | 
  
  

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