rpm function added for part 1
This commit is contained in:
+4
-2
@@ -16,8 +16,10 @@ int main() {
|
||||
|
||||
while (true) {
|
||||
_delay_ms(50);
|
||||
Serial.print("Counts per second: ");
|
||||
Serial.println(encoder.count_per_sec());
|
||||
// Serial.print("Counts per second: ");
|
||||
// Serial.println(encoder.count_per_sec());
|
||||
Serial.print("RPM: ");
|
||||
Serial.println(encoder.rpm());
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include <avr/io.h>
|
||||
/* #include <avr/io.h>
|
||||
#include <util/delay.h>
|
||||
#include <Arduino.h>
|
||||
|
||||
@@ -47,4 +47,4 @@ int main() {
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
} */
|
||||
|
||||
+2
-1
@@ -1,4 +1,4 @@
|
||||
#include <avr/io.h>
|
||||
/* #include <avr/io.h>
|
||||
#include <util/delay.h>
|
||||
#include <Arduino.h>
|
||||
|
||||
@@ -63,3 +63,4 @@ int main() {
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
*/
|
||||
+2
-1
@@ -1,4 +1,4 @@
|
||||
#include <avr/io.h>
|
||||
/* #include <avr/io.h>
|
||||
#include <util/delay.h>
|
||||
#include <Arduino.h>
|
||||
|
||||
@@ -66,3 +66,4 @@ int main() {
|
||||
ISR(INT0_vect) {
|
||||
encoder.update();
|
||||
}
|
||||
*/
|
||||
@@ -44,6 +44,10 @@ void RotaryEncoderDriver::update_delta() {
|
||||
|
||||
float RotaryEncoderDriver::count_per_sec() {
|
||||
return delta / (256.0f * 0.0001f);
|
||||
}
|
||||
|
||||
float RotaryEncoderDriver::rpm() {
|
||||
return (count_per_sec() * 60) / 1050.0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
#include "timer_usec.h"
|
||||
|
||||
Timer_usec::Timer_usec() = default;
|
||||
|
||||
void Timer_usec::init(uint16_t period_us) { // for custom duty cycle duration in ms in part 1
|
||||
TCCR1A = 0;
|
||||
TCCR1B = 0;
|
||||
|
||||
Reference in New Issue
Block a user