12 cpr = _max_raw_count - _min_raw_count;
13 min_raw_count = _min_raw_count;
14 max_raw_count = _max_raw_count;
29 velocity_calc_timestamp =
_micros();
32 full_rotation_offset = 0;
33 raw_count_prev = getRawCount();
40 raw_count = getRawCount();
42 int delta = raw_count - raw_count_prev;
44 if(abs(delta) > (0.8*cpr) ) full_rotation_offset += delta > 0 ? -
_2PI :
_2PI;
46 float angle = full_rotation_offset + ( (float) (raw_count) / (float)cpr) *
_2PI;
50 float Ts = ( now - velocity_calc_timestamp)*1e-6;
52 if(Ts <= 0 || Ts > 0.5) Ts = 1e-3;
53 velocity = (
angle - angle_prev)/Ts;
56 raw_count_prev = raw_count;
58 velocity_calc_timestamp = now;
70 int MagneticSensorAnalog::getRawCount(){