start of velocity code

This commit is contained in:
ReFil 2021-01-08 20:21:45 +00:00
parent ad5d53d4bf
commit 293e1a60b7
2 changed files with 4 additions and 2 deletions

View file

@ -103,8 +103,8 @@ static int ma730_sample_fetch(const struct device *dev, enum sensor_channel chan
if (ma730_spi_read_data(dev, &val)) {
return -EIO
}
data->oldangle = data->angle;
data->angle = val;
}
static int ma730_channel_get(const struct device *dev, enum sensor_channel chan,
@ -115,7 +115,8 @@ static int ma730_channel_get(const struct device *dev, enum sensor_channel chan,
return -ENOTSUP;
}
else if (chan == SENSOR_CHAN_ROTATION) {
val->val1 = int(data->angle / (65536*resolution));
float absang = data->angle / (65536*(cfg->resolution)/2.5)
val->val1 = int(absang);
}
else {
//velocity code

View file

@ -90,6 +90,7 @@ struct ma730_data {
const struct device *bus;
struct spi_cs_control cs_ctrl;
uint16_t oldangle;
uint16_t angle;
int8_t velocity;
bool direction;