add pressure sensor. Only reading once though
Some checks failed
Some checks failed
This commit is contained in:
@ -81,7 +81,7 @@ int main(void)
|
||||
|
||||
cfb_set_kerning(dev, 3);
|
||||
|
||||
const struct device *ina;
|
||||
const struct device *ina, *bmp;
|
||||
|
||||
ina = DEVICE_DT_GET(DT_NODELABEL(ina231));
|
||||
if (!device_is_ready(dev))
|
||||
@ -90,11 +90,20 @@ int main(void)
|
||||
return 0;
|
||||
}
|
||||
|
||||
bmp = DEVICE_DT_GET(DT_NODELABEL(bmp388));
|
||||
if (!device_is_ready(dev))
|
||||
{
|
||||
printf("Device %s not ready\n", bmp->name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
while (1)
|
||||
{
|
||||
int ret;
|
||||
struct sensor_value voltage, current, pressure;
|
||||
char str_v[15] = {0};
|
||||
char str_i[15] = {0};
|
||||
char str_p[15] = {0};
|
||||
|
||||
ret = sensor_sample_fetch(ina);
|
||||
if (ret < 0)
|
||||
@ -103,7 +112,6 @@ int main(void)
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct sensor_value voltage, current;
|
||||
ret = sensor_channel_get(ina, SENSOR_CHAN_VOLTAGE, &voltage);
|
||||
if (ret < 0)
|
||||
{
|
||||
@ -117,10 +125,18 @@ int main(void)
|
||||
return 0;
|
||||
}
|
||||
|
||||
sprintf(str_v, "V:%d.%06d", voltage.val1, voltage.val2);
|
||||
sprintf(str_i, "I:%d.%06d", current.val1, current.val2);
|
||||
ret = sensor_sample_fetch(bmp);
|
||||
if (ret < 0)
|
||||
{
|
||||
LOG_ERR("Could not fetch sample (%d)", ret);
|
||||
return 0;
|
||||
}
|
||||
|
||||
printf("%s\t%s\n", str_v, str_i);
|
||||
sprintf(str_v, "V:%01d.%06d", voltage.val1, voltage.val2);
|
||||
sprintf(str_i, "I:%01d.%06d", current.val1, current.val2);
|
||||
sprintf(str_p, "P:%05d.%02d", pressure.val1, pressure.val2 / 10000);
|
||||
|
||||
printf("%s\t%s\t%s\n", str_v, str_i, str_p);
|
||||
|
||||
cfb_framebuffer_clear(dev, false);
|
||||
if (cfb_print(dev, str_v, 0, 0))
|
||||
@ -133,6 +149,11 @@ int main(void)
|
||||
printf("Failed to print a string\n");
|
||||
continue;
|
||||
}
|
||||
if (cfb_print(dev, str_p, 0, 32))
|
||||
{
|
||||
printf("Failed to print a string\n");
|
||||
continue;
|
||||
}
|
||||
|
||||
cfb_framebuffer_finalize(dev);
|
||||
#if defined(CONFIG_ARCH_POSIX)
|
||||
|
@ -95,12 +95,6 @@
|
||||
label = "Interrupt 5 from BMX055 9-DOF";
|
||||
zephyr,code = <INPUT_KEY_0>;
|
||||
};
|
||||
|
||||
int_baro: int_baro {
|
||||
gpios = <&gpio0 27 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>;
|
||||
label = "Interrupt from BMP388 barometer";
|
||||
zephyr,code = <INPUT_KEY_0>;
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
@ -161,6 +155,14 @@
|
||||
rshunt-micro-ohms = <50000>;
|
||||
adc-mode = "Bus and shunt voltage continuous";
|
||||
};
|
||||
|
||||
bmp388: bmp388@76 {
|
||||
compatible = "bosch,bmp388";
|
||||
reg = <0x76>;
|
||||
int-gpios = <&gpio0 27 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>;
|
||||
odr = "1.563";
|
||||
osr-press = <1>;
|
||||
};
|
||||
};
|
||||
|
||||
&spi1 {
|
||||
|
Reference in New Issue
Block a user