-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added interpolation of force values into pwm values
- Loading branch information
“Vincent”
committed
Feb 25, 2024
1 parent
60adccc
commit c4d1f0d
Showing
2 changed files
with
186 additions
and
89 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,35 @@ | ||
#include <cstring> // Include for memcpy | ||
#include <fcntl.h> | ||
#include <iostream> | ||
#include <linux/i2c-dev.h> | ||
#include <iostream> | ||
#include <fcntl.h> | ||
#include <sys/ioctl.h> | ||
#include <unistd.h> | ||
#include <vector> | ||
#include <cstring> // Include for memcpy | ||
#include <fstream> | ||
#include <sstream> | ||
#include <map> | ||
#include <cmath> | ||
|
||
|
||
using namespace std; | ||
|
||
std::map<float, float> pwm_table; | ||
std::vector<float> temperature; | ||
std::vector<uint16_t> pwm_values; | ||
|
||
//--------------------------INITIALISATION-------------------------- | ||
void init(int &file); | ||
|
||
//--------------------------SENDING-------------------------- | ||
void send_status(int8_t status, int file); | ||
std::vector<uint8_t> pwm_to_bytes(std::vector<uint16_t> pwm_values); | ||
void send_pwm(std::vector<uint16_t> pwm_values, int file); | ||
void init(int &file); | ||
|
||
//--------------------------RECEIVING-------------------------- | ||
std::vector<float> readFloatsFromI2C(int file); | ||
uint8_t read_hardware_statusFromI2C(int file); | ||
uint8_t read_hardware_statusFromI2C(int file); | ||
|
||
//--------------------------INTERPOLATION-------------------------- | ||
void get_pwm_table(); | ||
uint16_t interpolate(float force); | ||
std::vector<uint16_t> interpolate_all(std::vector<float> &force_values); |