#pragma once


// change mA and mW to A and W

#if (USE_INA260 == 1)

  void measure_ina260(float *v1, float *i1, float *p1)
  {
    #ifdef DEBUG
        long function_start = micros(); 
    #endif // DEBUG
  
    if (!ina260_ok) 
    {
      Serial.printf("[%s]: INA260 NOT WORKING\n",__func__);
      *v1 = 0;
      *i1 = 0;
      *p1 = 0;
    } else 
    {
      // change mV to V
      *v1 = ((float) ina260.readBusVoltage())/1000;
      // change mA to A
      *i1 = ((float)ina260.readCurrent())/1000;
      // change mW to W
      *p1 = ((float)ina260.readPower())/1000;
    }

     #ifdef DEBUG
      Serial.printf("[%s]: v1=%0.3fV, i1=%0.4fA,p1=%0.4fmW \n",__func__,*v1,*i1,*p1);
      Serial.printf("[%s]: took %uus\n",__func__,(micros()-function_start));
    #endif // DEBUG
  }

#endif
