add second accelerometer for comparison
Some checks failed
Build / build (macos-12) (push) Waiting to run
Build / build (macos-14) (push) Waiting to run
Build / build (windows-2022) (push) Waiting to run
Build / build (ubuntu-22.04) (push) Failing after 15s
Documentation / build (push) Successful in 3s

This commit is contained in:
2024-04-28 00:35:57 -06:00
parent da8f165451
commit 7fddc21eee
3 changed files with 40 additions and 11 deletions

View File

@ -84,7 +84,7 @@ int main(void)
cfb_set_kerning(dev, 3);
const struct device *ina, *bmp, *bmx, *hdc;
const struct device *ina, *bmp, *bmx, *lis, *hdc;
ina = DEVICE_DT_GET(DT_NODELABEL(ina231));
if (!device_is_ready(ina))
@ -108,6 +108,14 @@ int main(void)
}
LOG_INF("Initialized %s\n", bmx->name);
lis = DEVICE_DT_GET(DT_NODELABEL(lis2dh));
if (!device_is_ready(lis))
{
LOG_ERR("Device %s not ready\n", lis->name);
return 0;
}
LOG_INF("Initialized %s\n", lis->name);
// hdc = DEVICE_DT_GET(DT_NODELABEL(hdc1080));
// if (!device_is_ready(dev))
// {
@ -118,12 +126,13 @@ int main(void)
while (1)
{
int ret;
struct sensor_value voltage, current, pressure, temperature, accel_x, humidity;
struct sensor_value voltage, current, pressure, temperature, accel_z, accel_z_ref, humidity;
char str_v[15] = {0};
char str_i[15] = {0};
char str_p[16] = {0};
char str_t[16] = {0};
char str_ax[16] = {0};
char str_az[16] = {0};
char str_az_ref[16] = {0};
char str_h[16] = {0};
ret = sensor_sample_fetch(ina);
@ -176,7 +185,20 @@ int main(void)
LOG_ERR("Could not get temperature (%d)", ret);
return 0;
}
ret = sensor_channel_get(bmx, SENSOR_CHAN_ACCEL_X, &accel_x);
ret = sensor_channel_get(bmx, SENSOR_CHAN_ACCEL_Z, &accel_z);
if (ret < 0)
{
LOG_ERR("Could not get acceleration (%d)", ret);
return 0;
}
ret = sensor_sample_fetch(lis);
if (ret < 0)
{
LOG_ERR("Could not fetch sample (%d)", ret);
return 0;
}
ret = sensor_channel_get(lis, SENSOR_CHAN_ACCEL_Z, &accel_z_ref);
if (ret < 0)
{
LOG_ERR("Could not get acceleration (%d)", ret);
@ -200,7 +222,8 @@ int main(void)
sprintf(str_i, "I:%01d.%06d", current.val1, current.val2);
sprintf(str_p, "P:%03d.%04d", pressure.val1, pressure.val2 / 100);
sprintf(str_t, "T:%03d.%04d", temperature.val1, temperature.val2 / 100);
sprintf(str_ax, "X:%03d.%04d", accel_x.val1, accel_x.val2 / 100);
sprintf(str_az, "Z:%03d.%04d", accel_z.val1, accel_z.val2 / 100);
sprintf(str_az_ref, "Z:%03d.%04d", accel_z_ref.val1, accel_z_ref.val2 / 100);
sprintf(str_h, "H:%05d.%06d", humidity.val1, humidity.val2);
// printf("%s\t%s\t%s\t%s\n", str_v, str_i, str_p, str_t);
@ -216,12 +239,12 @@ int main(void)
printf("Failed to print a string\n");
continue;
}
if (cfb_print(dev, str_ax, 0, 16 * 2))
if (cfb_print(dev, str_az, 0, 16 * 2))
{
printf("Failed to print a string\n");
continue;
}
if (cfb_print(dev, str_t, 0, 16 * 3))
if (cfb_print(dev, str_az_ref, 0, 16 * 3))
{
printf("Failed to print a string\n");
continue;