Download this file
#include "current.h"

#define ALPHA 0.996
#define NB_SAMPLES 3000
#define BURDEN 68
#define NB_TURNS 1012
#define CALIBRATION 1.11
#define RATIO (NB_TURNS / BURDEN * 3.3 / 1024)

Current::Current():
  port(SENSORS_PORT) { }

uint16_t Current::get_value() {
  float x=0.0, y=0.0, old_x, old_y, sum=0;
  // First, let the filter stabilize
  for (uint16_t i=0; i