36 lines
768 B
C++
36 lines
768 B
C++
/*
|
|
* 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;
|
|
|
|
}
|