INF2004-Project v0.1
 
Loading...
Searching...
No Matches
wheel_encoder.h
Go to the documentation of this file.
1
12#ifndef WHEEL_ENCODER_H // Include guard.
13#define WHEEL_ENCODER_H
14#include "pico/stdlib.h"
15
16// Definitions.
17// ----------------------------------------------------------------------------
18//
19
27#define WHEEL_ENC_CYCLE_PULSE 20
29#define WHEEL_ENC_DIST_PER_PULSE (204.203f / 20.0f)
31#define WHEEL_ENC_SEC_TO_MSEC 1000.0f
32 // End of encoder_driver_constants group.
35
36// Type definitions.
37// ----------------------------------------------------------------------------
38//
39
44typedef struct wheel_encoder
45{
46 uint64_t prev_time;
50
51// Function prototypes.
52// ----------------------------------------------------------------------------
53//
54
55float wheel_enc_get_time_diff(uint64_t current_time, uint64_t prev_time);
56float wheel_enc_get_speed(float time_elapsed, bool is_pulse);
57
58#endif // WHEEL_ENCODER_H
59
60// End of file driver/encoder/wheel_encoder.h.
Struct to store global encoder data.
Definition: wheel_encoder.h:45
uint pulse_count
Number of pulses since last reset.
Definition: wheel_encoder.h:47
uint64_t prev_time
Time of previous interrupt.
Definition: wheel_encoder.h:46
float distance_traversed
Distance traversed since last reset.
Definition: wheel_encoder.h:48
float wheel_enc_get_speed(float time_elapsed, bool is_pulse)
Get the speed in either pulses/second or mm/second.
Definition: wheel_encoder.c:40
struct wheel_encoder wheel_encoder_t
Struct to store global encoder data.
float wheel_enc_get_time_diff(uint64_t current_time, uint64_t prev_time)
Get the time difference in ms.
Definition: wheel_encoder.c:23