My team recently got our V5, and we switched to PROS. Right now we use pros::lcd commands to display text to the screen, but we want to improve our auton selector GUI as well as be able to display graphs for debugging. All we need is the ability to display shapes, lines, points, and text, and get the x and y coordinates of where you are touching the screen, but I can’t find a way to do this. I tried using the LVGL library, but I couldn’t find a way to make simple shapes, and we don’t need things like fancy sliders and buttons that are included in that library. Thanks for any ideas!
A rectangle can be made with a base object. Here is @jpearman’s post with a simple function for drawing one with LVGL.
Here is the doc for a line object.
From @ theol0403 LVGL is planing on supporting canvas drawing in the next version.
However, I really don’t understand the desire to draw at such a low level for Auton selection and debugging. LVGL has a rich set of feature using tabs, buttons and call backs, gauges and sliders. You can create multiple regions of the screen for data presentation and user input. Here are some of the threads that show how powerful it is.
printf to the screen:
Examples:
extra fonts:
Thanks for your reply. The reason I want to use more basic shapes is to have more freedom to customize the design. I want to try designing elements that aren’t in the LVGL library, like a grapher for testing PID control. It would be convenient to have simple commands like rect(), ellipse(), point(), text(), etc. It seems wasteful to use the more complicated LVGL library and make lengthy custom functions just to draw a simple shape. I did try @jpearman’s rectangle function and it worked, but it can’t make a solid rectangle, and I still can’t draw points.
Actually, LVGL already supports canvas, the only holdup is waiting for PROS to update.
You can look at the source here: https://github.com/littlevgl/lvgl/blob/master/lv_objx/lv_canvas.h
Unfortunately, it only supports shapes such as rect, circle, and line, for text you still have to make a label.
Truth be told, the beta version of PROS 3 had native canvas support much like VCS, called tmei, but they opted for LVGL and at that time the two engines conflicted. I still have that version of PROS in one of my early projects https://github.com/theol0403/theov5-Vision-Tracking/blob/4814fa220ba62df2830f6d77879bc92b999f2a50/include/pros/tmei.hpp
I hope it’s ok I shared that.
I don’t imagine it will ever come to the production pros, but I understand the value of canvas drawing and maybe the pros team might have a way of combining or switching between the two systems. Maybe I can see if I can try to do something about it myself, depends whether the pros source is available from that time.
Edit: Looks like it is available https://github.com/purduesigbots/pros/tree/b36ec35efff1c187c72df49a8ea36331320da59e/src/display
And all it does is call the VexOS api. I think it is definitely possible to add this to production pros.
Alternatively, all these functions can be implemented in a way similar to how jpearman did it, someone will just have to guess the forward declarations. The toughest part of doing this is conflicting with LVGL.
I might do this after worlds, and package it in an install-able pros template for people to use as an alternative to LVGL.
you can probably register another dummy display driver and make that the active display, then handle buffer updates anyway you want.
First here is simple tutorial on how to use LVLG. Also LVGL already has many elements including graphs and lines. You can completely customize the look of everything but it does take a lot of code.
There is however a very simple way to draw directly to the screen…
lv_vdb_t * framebuffer = lv_vdb_get();
while(true)
{
for(int x = 0; x < LV_HOR_RES; x++)
{
for(int y = 0; y < LV_VER_RES; y++)
{
framebuffer->buf[(y * LV_HOR_RES) + x].red = 255;
framebuffer->buf[(y * LV_HOR_RES) + x].green = 255;
framebuffer->buf[(y * LV_HOR_RES) + x].blue = 255;
framebuffer->buf[(y * LV_HOR_RES) + x].alpha = 255;
}
}
lv_vdb_flush();
pros::delay(3); //must be 3 or more
}