real use of the display
Some checks failed
Some checks failed
This commit is contained in:
@ -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, ¤t);
|
||||
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, ¤t);
|
||||
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;
|
||||
|
Reference in New Issue
Block a user