80 lines
2 KiB
C
80 lines
2 KiB
C
|
/*
|
||
|
* Copyright (c) 2024 PM
|
||
|
* SPDX-License-Identifier: Apache-2.0
|
||
|
*/
|
||
|
|
||
|
#include <string.h>
|
||
|
|
||
|
#include <app_version.h>
|
||
|
#include <zephyr/kernel.h>
|
||
|
|
||
|
#include <lvgl.h>
|
||
|
#include <lvgl_input_device.h>
|
||
|
|
||
|
#include <zephyr/drivers/display.h>
|
||
|
#include <zephyr/input/input.h>
|
||
|
#include <zephyr/random/random.h>
|
||
|
|
||
|
#include <zephyr/logging/log.h>
|
||
|
|
||
|
LOG_MODULE_REGISTER(main, CONFIG_APP_LOG_LEVEL);
|
||
|
|
||
|
int main(void)
|
||
|
{
|
||
|
int ret;
|
||
|
printk("IRCAM %s\n", APP_VERSION_STRING);
|
||
|
|
||
|
char count_str[11] = {0};
|
||
|
const struct device *display_dev;
|
||
|
|
||
|
display_dev = DEVICE_DT_GET(DT_CHOSEN(zephyr_display));
|
||
|
if (!device_is_ready(display_dev))
|
||
|
{
|
||
|
printf("Device %s not ready\n", display_dev->name);
|
||
|
return 0;
|
||
|
}
|
||
|
|
||
|
if (display_set_pixel_format(display_dev, PIXEL_FORMAT_RGB_888) != 0)
|
||
|
{
|
||
|
printk("display pixel 888 not ok\n");
|
||
|
printf("Failed to set required pixel format");
|
||
|
return 0;
|
||
|
}
|
||
|
|
||
|
printf("Initialized %s\n", display_dev->name);
|
||
|
static lv_color_t cbuf[32 * 24];
|
||
|
|
||
|
lv_obj_t *ir_image = lv_canvas_create(lv_scr_act());
|
||
|
lv_canvas_set_buffer(ir_image, cbuf, 32, 24, LV_IMG_CF_TRUE_COLOR);
|
||
|
|
||
|
lv_canvas_fill_bg(ir_image, lv_color_make(0x40,0x40,0x40), LV_OPA_COVER);
|
||
|
|
||
|
lv_obj_set_size(ir_image, 32, 24);
|
||
|
lv_obj_align(ir_image, LV_ALIGN_TOP_LEFT, 4, 4);
|
||
|
lv_img_set_pivot(ir_image, 0, 0);
|
||
|
lv_img_set_zoom(ir_image, 256 * 8);
|
||
|
lv_img_set_antialias(ir_image, false);
|
||
|
|
||
|
lv_timer_handler();
|
||
|
display_blanking_off(display_dev);
|
||
|
|
||
|
lv_color32_t color;
|
||
|
while (1)
|
||
|
{
|
||
|
for (int y = 0; y < 24; y++)
|
||
|
{
|
||
|
for (int x = 0; x < 32; x++)
|
||
|
{
|
||
|
color.ch.red = (color.ch.red + 11) % 255;
|
||
|
color.ch.green = (color.ch.green + 17) % 255;
|
||
|
color.ch.blue = (color.ch.blue + 13) % 255;
|
||
|
lv_canvas_set_px_color(ir_image, x, y, color);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
int delay = lv_timer_handler_run_in_period(100);
|
||
|
k_msleep(delay);
|
||
|
}
|
||
|
|
||
|
return 0;
|
||
|
}
|