<commit_before>#include "StepperControlEncoder.h"

StepperControlEncoder::StepperControlEncoder() {
	//lastCalcLog	= 0;

        pinChannelA     = 0;
        pinChannelB     = 0;

        position        = 0;
	encoderType	= 0; // default type
	scalingFactor	= 100;

}

void StepperControlEncoder::test() {
                Serial.print("R88 ");
                Serial.print("position ");
                Serial.print(position);
                Serial.print(" channel A ");
                Serial.print(prvValChannelA);
                Serial.print(" -> ");
                Serial.print(curValChannelA);
                Serial.print(" channel B ");
                Serial.print(prvValChannelB);
                Serial.print(" -> ");
                Serial.print(curValChannelB);
                Serial.print("\r\n");
}

void StepperControlEncoder::loadPinNumbers(int channelA, int channelB, int channelAQ, int channelBQ) {
	pinChannelA  = channelA;
	pinChannelB  = channelB;
	pinChannelAQ = channelAQ;
	pinChannelBQ = channelBQ;

	readChannels();
	shiftChannels();
}

void StepperControlEncoder::loadSettings(int encType, int scaling) {
	encoderType = encType;
	scalingFactor = scaling;
}

void StepperControlEncoder::setPosition(long newPosition) {
	position = newPosition;
}

long StepperControlEncoder::currentPosition() {
	return position;
}

/* Check the encoder channels for movement accoridng to thisspecification
                    ________            ________
Channel A          /        \          /        \
             _____/          \________/          \________
                         ________            ________
Channel B               /        \          /        \
             __________/          \________/          \____
                                   __
Channel I                         /  \
             ____________________/    \___________________

rotation ----------------------------------------------------->

*/


void StepperControlEncoder::readEncoder() {

	// save the old values, read the new values
	shiftChannels();
	readChannels();

	int delta = 0;

	// and check for a position change<commit_msg>adding encoder scaling<commit_after>#include "StepperControlEncoder.h"

StepperControlEncoder::StepperControlEncoder() {
	//lastCalcLog	= 0;

        pinChannelA     = 0;
        pinChannelB     = 0;

        position        = 0;
	encoderType	= 0; // default type
	scalingFactor	= 100;

}

void StepperControlEncoder::test() {
                Serial.print("R88 ");
                Serial.print("position ");
                Serial.print(position);
                Serial.print(" channel A ");
                Serial.print(prvValChannelA);
                Serial.print(" -> ");
                Serial.print(curValChannelA);
                Serial.print(" channel B ");
                Serial.print(prvValChannelB);
                Serial.print(" -> ");
                Serial.print(curValChannelB);
                Serial.print("\r\n");
}

void StepperControlEncoder::loadPinNumbers(int channelA, int channelB, int channelAQ, int channelBQ) {
	pinChannelA  = channelA;
	pinChannelB  = channelB;
	pinChannelAQ = channelAQ;
	pinChannelBQ = channelBQ;

	readChannels();
	shiftChannels();
}

void StepperControlEncoder::loadSettings(int encType, int scaling) {
	encoderType = encType;
	scalingFactor = scaling;
}

void StepperControlEncoder::setPosition(long newPosition) {
	position = newPosition;
}

long StepperControlEncoder::currentPosition() {
	if (scalingFactor == 100 || scalingFactor == 0) {
		return position;
	} else {
		return position * scalingFactor / 100;
	}
}

/* Check the encoder channels for movement accoridng to thisspecification
                    ________            ________
Channel A          /        \          /        \
             _____/          \________/          \________
                         ________            ________
Channel B               /        \          /        \
             __________/          \________/          \____
                                   __
Channel I                         /  \
             ____________________/    \___________________

rotation ----------------------------------------------------->

*/


void StepperControlEncoder::readEncoder() {

	// save the old values, read the new values
	shiftChannels();
	readChannels();

	int delta = 0;

	// and check for a position change
{'fraction_non_alphanumeric': 0.11610997500568053, 'fraction_numerical': 0.006589411497386958, 'mean_word_length': 1.6534056660638938, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 14, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5691693', 'n_tokens_mistral': 1203, 'n_tokens_neox': 1095, 'n_words': 229}