/* * IncrementCounter.cpp * * Created on: 2 мар. 2020 г. * Author: user */ #include "IncrementCounter.hh" driver::IncrementCounter::operator PositionCode() { long temp_position = pos_code.angle_data + counter.getDeltaCounter(); //todo плохо если temp_position < -line_in_turn... if( temp_position < 0 ) { temp_position += line_in_turn; if( pos_code.turn > 0 ) pos_code.turn--; else { pos_code.turn = max_turn_value - 1; } } else if( temp_position >= line_in_turn ) { temp_position -= line_in_turn; if( pos_code.turn < max_turn_value - 1 ) pos_code.turn++; else { pos_code.turn = 0; } } pos_code.angle_data = temp_position; return pos_code; }