real use of the display
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 4s

This commit is contained in:
2024-04-23 23:38:12 -06:00
parent e1772508fe
commit 6d42a445de

View File

@ -70,6 +70,7 @@ int main(void)
printf("font width %d, font height %d\n",
font_width, font_height);
}
cfb_framebuffer_set_font(dev, 0);
printf("x_res %d, y_res %d, ppt %d, rows %d, cols %d\n",
x_res,
@ -91,47 +92,52 @@ int main(void)
while (1)
{
for (int i = 0; i < MIN(x_res, y_res); i++)
int ret;
char str_v[15] = {0};
char str_i[15] = {0};
ret = sensor_sample_fetch(ina);
if (ret < 0)
{
int ret;
ret = sensor_sample_fetch(ina);
if (ret < 0)
{
LOG_ERR("Could not fetch sample (%d)", ret);
return 0;
}
struct sensor_value voltage, current;
ret = sensor_channel_get(ina, SENSOR_CHAN_VOLTAGE, &voltage);
if (ret < 0)
{
LOG_ERR("Could not get sample (%d)", ret);
return 0;
}
ret = sensor_channel_get(ina, SENSOR_CHAN_CURRENT, &current);
if (ret < 0)
{
LOG_ERR("Could not get sample (%d)", ret);
return 0;
}
printf("voltage: %d.%06d\tcurrent: %d.%06d\n", voltage.val1, voltage.val2, current.val1, current.val2);
cfb_framebuffer_clear(dev, false);
if (cfb_print(dev,
"0123456789mMgj!\"§$%&/()=",
i, i))
{
printf("Failed to print a string\n");
continue;
}
cfb_framebuffer_finalize(dev);
#if defined(CONFIG_ARCH_POSIX)
k_sleep(K_MSEC(20));
#endif
LOG_ERR("Could not fetch sample (%d)", ret);
return 0;
}
struct sensor_value voltage, current;
ret = sensor_channel_get(ina, SENSOR_CHAN_VOLTAGE, &voltage);
if (ret < 0)
{
LOG_ERR("Could not get sample (%d)", ret);
return 0;
}
ret = sensor_channel_get(ina, SENSOR_CHAN_CURRENT, &current);
if (ret < 0)
{
LOG_ERR("Could not get sample (%d)", ret);
return 0;
}
sprintf(str_v, "V:%d.%06d", voltage.val1, voltage.val2);
sprintf(str_i, "I:%d.%06d", current.val1, current.val2);
printf("%s\t%s\n", str_v, str_i);
cfb_framebuffer_clear(dev, false);
if (cfb_print(dev, str_v, 0, 0))
{
printf("Failed to print a string\n");
continue;
}
if (cfb_print(dev, str_i, 0, 16))
{
printf("Failed to print a string\n");
continue;
}
cfb_framebuffer_finalize(dev);
#if defined(CONFIG_ARCH_POSIX)
k_sleep(K_MSEC(20));
#endif
}
int ret;