changed function signiture to return uint8 type instead of uint16.

This commit is contained in:
jakeg00dwin 2025-02-14 14:02:13 -08:00
parent 724237147f
commit 71ff471fde
2 changed files with 4 additions and 3 deletions

View File

@ -106,7 +106,7 @@ uint16_t ReadFader(void);
/** /**
* @brief Reads the ADC value from the Speed pot. * @brief Reads the ADC value from the Speed pot.
*/ */
uint16_t ReadSpeed(void); uint8_t ReadSpeed(void);
/** /**

View File

@ -83,7 +83,7 @@ void InitProg(void) {
InitTimer0(); InitTimer0();
} }
uint16_t ReadSpeed(void) { uint8_t ReadSpeed(void) {
// Initialize ADC // Initialize ADC
ADMUX = (0 << MUX1) | (1 << MUX0); // Select ADC1 (PB2) ADMUX = (0 << MUX1) | (1 << MUX0); // Select ADC1 (PB2)
ADCSRA = (1 << ADEN) | (1 << ADPS1) | (1 << ADPS0); // Enable ADC, prescaler 8 ADCSRA = (1 << ADEN) | (1 << ADPS1) | (1 << ADPS0); // Enable ADC, prescaler 8
@ -91,7 +91,7 @@ uint16_t ReadSpeed(void) {
ADCSRA |= (1 << ADSC); // Start conversion ADCSRA |= (1 << ADSC); // Start conversion
while (ADCSRA & (1 << ADSC)) { while (ADCSRA & (1 << ADSC)) {
} // Wait for conversion to finish } // Wait for conversion to finish
return ADC; return (uint8_t)(ADC >> 2);
} }
@ -132,6 +132,7 @@ uint8_t MotorGetSavedPos(void) {
void MotorMoveTo(uint8_t target) { void MotorMoveTo(uint8_t target) {
double speed_delay = ReadFader();
uint8_t pos = (uint8_t)(ReadFader() >> 2); uint8_t pos = (uint8_t)(ReadFader() >> 2);
while (diff(target, pos) > 8) { while (diff(target, pos) > 8) {