Advertisement
Forzaferrarileo

Untitled

Feb 25th, 2015
388
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.03 KB | None | 0 0
  1. #include "lepton_i2c.h"
  2.  
  3.  
  4. LEP_CAMERA_PORT_DESC_T port;
  5. LEP_SYS_TELEMETRY_ENABLE_STATE_E state;
  6.  
  7. bool connected;
  8.  
  9. int lepton_connect(){
  10.  
  11.     LEP_RESULT result = LEP_OpenPort(1, LEP_CCI_TWI, 400, &port);
  12.  
  13.     if( result == LEP_OK ){
  14.         connected = true;
  15.         return 0;
  16.     }
  17.     else{
  18.         return -1;
  19.     }  
  20. }
  21.  
  22. int enable_telemetry(int header){
  23.  
  24.     if(!connected){
  25.         lepton_connect();
  26.     }
  27.  
  28.     LEP_RESULT tel_location;
  29.     LEP_RESULT tel_enbl = LEP_SetSysTelemetryEnableState(&port, LEP_TELEMETRY_ENABLED);
  30.  
  31.     if(header == 0){   
  32.         tel_location = LEP_SetSysTelemetryLocation(&port, LEP_TELEMETRY_LOCATION_HEADER);
  33.     }
  34.     else if(header == 1){
  35.         tel_location = LEP_SetSysTelemetryLocation(&port, LEP_TELEMETRY_LOCATION_FOOTER);
  36.     }
  37.  
  38.     if(tel_enbl == LEP_OK && tel_location == LEP_OK){
  39.         return 0;
  40.     }else{
  41.         return -1;
  42.     }
  43.  
  44. }
  45.  
  46. bool telemetry_enabled(){
  47.  
  48.     if(!connected){
  49.         lepton_connect();
  50.     }
  51.  
  52.     LEP_GetSysTelemetryEnableState(&port, &state);
  53.  
  54.     if( state == LEP_TELEMETRY_ENABLED ){
  55.         return true;
  56.     }
  57.     else{  
  58.         return false;
  59.     }
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement