rpm function added for part 1
This commit is contained in:
Vendored
+4
-4
@@ -8,8 +8,8 @@
|
||||
{
|
||||
"name": "PlatformIO",
|
||||
"includePath": [
|
||||
"C:/Users/helgi/H26/ESP/Projects/esp_project1_h26/include",
|
||||
"C:/Users/helgi/H26/ESP/Projects/esp_project1_h26/src",
|
||||
"C:/Users/helgi/H26/ESP/Projects/ESP_Project2_H26/include",
|
||||
"C:/Users/helgi/H26/ESP/Projects/ESP_Project2_H26/src",
|
||||
"C:/Users/helgi/.platformio/packages/framework-arduino-avr/cores/arduino",
|
||||
"C:/Users/helgi/.platformio/packages/framework-arduino-avr/variants/eightanaloginputs",
|
||||
"C:/Users/helgi/.platformio/packages/framework-arduino-avr/libraries/EEPROM/src",
|
||||
@@ -22,8 +22,8 @@
|
||||
"browse": {
|
||||
"limitSymbolsToIncludedHeaders": true,
|
||||
"path": [
|
||||
"C:/Users/helgi/H26/ESP/Projects/esp_project1_h26/include",
|
||||
"C:/Users/helgi/H26/ESP/Projects/esp_project1_h26/src",
|
||||
"C:/Users/helgi/H26/ESP/Projects/ESP_Project2_H26/include",
|
||||
"C:/Users/helgi/H26/ESP/Projects/ESP_Project2_H26/src",
|
||||
"C:/Users/helgi/.platformio/packages/framework-arduino-avr/cores/arduino",
|
||||
"C:/Users/helgi/.platformio/packages/framework-arduino-avr/variants/eightanaloginputs",
|
||||
"C:/Users/helgi/.platformio/packages/framework-arduino-avr/libraries/EEPROM/src",
|
||||
|
||||
Vendored
+3
-3
@@ -12,7 +12,7 @@
|
||||
"type": "platformio-debug",
|
||||
"request": "launch",
|
||||
"name": "PIO Debug",
|
||||
"executable": "C:/Users/helgi/H26/ESP/Projects/esp_project1_h26/.pio/build/nanoatmega328new/firmware.elf",
|
||||
"executable": "C:/Users/helgi/H26/ESP/Projects/ESP_Project2_H26/.pio/build/nanoatmega328new/firmware.elf",
|
||||
"projectEnvName": "nanoatmega328new",
|
||||
"toolchainBinDir": "C:/Users/helgi/.platformio/packages/toolchain-atmelavr/bin",
|
||||
"internalConsoleOptions": "openOnSessionStart",
|
||||
@@ -25,7 +25,7 @@
|
||||
"type": "platformio-debug",
|
||||
"request": "launch",
|
||||
"name": "PIO Debug (skip Pre-Debug)",
|
||||
"executable": "C:/Users/helgi/H26/ESP/Projects/esp_project1_h26/.pio/build/nanoatmega328new/firmware.elf",
|
||||
"executable": "C:/Users/helgi/H26/ESP/Projects/ESP_Project2_H26/.pio/build/nanoatmega328new/firmware.elf",
|
||||
"projectEnvName": "nanoatmega328new",
|
||||
"toolchainBinDir": "C:/Users/helgi/.platformio/packages/toolchain-atmelavr/bin",
|
||||
"internalConsoleOptions": "openOnSessionStart"
|
||||
@@ -34,7 +34,7 @@
|
||||
"type": "platformio-debug",
|
||||
"request": "launch",
|
||||
"name": "PIO Debug (without uploading)",
|
||||
"executable": "C:/Users/helgi/H26/ESP/Projects/esp_project1_h26/.pio/build/nanoatmega328new/firmware.elf",
|
||||
"executable": "C:/Users/helgi/H26/ESP/Projects/ESP_Project2_H26/.pio/build/nanoatmega328new/firmware.elf",
|
||||
"projectEnvName": "nanoatmega328new",
|
||||
"toolchainBinDir": "C:/Users/helgi/.platformio/packages/toolchain-atmelavr/bin",
|
||||
"internalConsoleOptions": "openOnSessionStart",
|
||||
|
||||
@@ -26,6 +26,7 @@ public:
|
||||
int position();
|
||||
void update_delta();
|
||||
float count_per_sec();
|
||||
float rpm();
|
||||
|
||||
};
|
||||
#endif
|
||||
|
||||
+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();
|
||||
}
|
||||
*/
|
||||
@@ -46,6 +46,10 @@ float RotaryEncoderDriver::count_per_sec() {
|
||||
return delta / (256.0f * 0.0001f);
|
||||
}
|
||||
|
||||
float RotaryEncoderDriver::rpm() {
|
||||
return (count_per_sec() * 60) / 1050.0;
|
||||
}
|
||||
|
||||
|
||||
ISR(INT0_vect) {
|
||||
driver->update();
|
||||
|
||||
@@ -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