MotorControlModuleSDFM_TMS3.../Projects/EFC_Communication/UMLibrary/driver/IncrementCounter.cpp
2024-06-07 11:12:56 +03:00

36 lines
781 B
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*
* 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;
}