BRT Community

Please login or register.

Login with username, password and session length
Advanced search  

News:

Welcome to the Bridgetek Community!

Please read our Welcome Note

Technical Support enquires
please contact the team
@ Bridgetek Support

Please refer to our website for detailed information on all our products - Bridgetek - Bridging Technology

Author Topic: Drawing arcs and circles  (Read 9137 times)

raffaeler

  • Newbie
  • *
  • Posts: 13
    • View Profile
Drawing arcs and circles
« on: March 01, 2023, 08:22:06 AM »

Hello, I am on the BT815.
I can currrently draw concave polygons filled with a gradient, but not convex and I gave up on this.

I am currently looking for drawing arcs and unfilled/transparent circles. I found the Ft_Esd_ArcLine.c and Ft_Esd_CircleLine.c but the code has some obscure dependency.
Questions:
1. Is it possible to use the ESD widget outside the ESD environment? (i.e. loading in memory in some way and calling their code?)
2. Is there any other better way to draw arcs and circles?

Thank you
Logged
Electronic Engineer, Senior Software Architect, Speaker, Trainer

TFTLCDCyg

  • Newbie
  • *
  • Posts: 19
    • View Profile
Re: Drawing arcs and circles
« Reply #1 on: March 10, 2023, 11:16:08 PM »

I've been modifying the library for gameduino 2 for some time with the permission of the good James Bowman, to be able to adapt it to STM32 or teensy 4/4.1 boards; with the idea of ​​being able to apply the full potential of the library with faster MCUs than AVRs. The project is called GDSTx, the repository is on Github.

In a chat with chatGPT, with the idea of ​​fine-tuning some parts of the project I'm working on, I asked him to indicate what the code would be like to draw an arc of variable length, using GDSTx, after an exchange of corrections, this was the result:

Code: [Select]
#include <GDSTx.h>

long previousMillis = 0;
long intervalo = 250;
int valor=0;

void setup()
{
  GD.begin();
}
void loop()
{
  GD.ClearColorRGB(0x100020);
  GD.Clear();

  GD.SaveContext(); //Guardamos los parámetros de color y transparencia
  GD.Begin(LINE_STRIP);
  GD.ColorRGB(0xFFFFFF); //Color del arco
  int x, y;
  unsigned long currentMillis = millis();       
  if(currentMillis - previousMillis > intervalo)
  {
   previousMillis = currentMillis;         
   valor=GD.random(0,359);
  }
   
  for (int i = 0; i <= valor; i++) {
    x = 400 + 100 * cos(i * PI/180 );
    y = 240 + 100 * sin(i * PI/180 );
    GD.Vertex2f(16*x, 16*y); //Se ajustan las dimensiones en pantalla
  }
  GD.RestoreContext(); //Restauramos los parámetros de color y transparencia

  GD.SaveContext(); //Guardamos los parámetros de color y transparencia
  GD.ColorRGB(0xFFFFFF); //Color del texto
  GD.cmd_text(0, 455, 26, 0, "Coded by chatGPT/FT81xmania"); //Texto del título
  GD.RestoreContext(); //Restauramos los parámetros de color y transparencia

  GD.swap();
}

Logged

raffaeler

  • Newbie
  • *
  • Posts: 13
    • View Profile
Re: Drawing arcs and circles
« Reply #2 on: March 17, 2023, 05:07:48 PM »

Great work!
Initially I tried to use the Gameduino library because it looked a very neat and good way to work.
But moving it to a plain ESP32 looked like a lot of work, but I may have missed something.
There are ports on Github but they are quite old and not sure about their validity.
How difficult was your port?
Thank you
Logged
Electronic Engineer, Senior Software Architect, Speaker, Trainer

Rudolph

  • Sr. Member
  • ****
  • Posts: 389
    • View Profile
Re: Drawing arcs and circles
« Reply #3 on: March 20, 2023, 12:06:40 PM »

I just checked the code and while it works this is probably the worst solution to solve the problem.

  GD.Begin(LINE_STRIP);
  GD.ColorRGB(0xFFFFFF);
  int x, y;

  for (int i = 0; i <= valor; i++) {
    x = 400 + 100 * cos(i * PI/180 );
    y = 240 + 100 * sin(i * PI/180 );
    GD.Vertex2f(16*x, 16*y);
  }
  GD.RestoreContext();

So the segment of the circle is actually composed of a LINE_STRIP for which the coordinates are calculated.
Not only does this take rather long to calculate, one full circle would take 18% of the display list.

Not that I have a simple and elegant solution for the issue, for circles I am using two DOTs and making it to an arc might involve SCISSORS.
Or two DOTs and a RECTANGLE could be used.
A different solution would be to render the arc in a bitmap and display it.

An arc command would be as nice, yes, but this is something we do not currently have.
Logged

BRT Community

  • Administrator
  • Hero Member
  • *****
  • Posts: 733
    • View Profile
Re: Drawing arcs and circles
« Reply #4 on: March 20, 2023, 01:13:07 PM »

Hi,

As you said Rudolph, two dots is a good way to make an un-filled circle.

Blending/stencilling can be used to create an arc by drawing an edge strip to overlap the active or non-active area of the circle if you want to have a certain quadrant shown and then only displaying the part of the circle which is within this arc. This is similar to the technique we often use to draw an arc gauge. We can create and post a small example here once it is ready.

Best Regards, BRT Community

 
Logged

TFTLCDCyg

  • Newbie
  • *
  • Posts: 19
    • View Profile
Re: Drawing arcs and circles
« Reply #5 on: March 21, 2023, 02:36:51 AM »

That example was only an approximation with simple mathematics, the editor can only handle basic things, more advanced examples can be achieved with relatively few instructions, but with slightly more complex mathematics that must consider that the TFT has the Y axis reference frame on the contrary, we must not forget that the EVEx graphics chip does all the drawing work, leaving the MCU only the calculation part.

MCU: teensy 3.6
TFT: NHD 5" FT813
Library: GDSTx (2023)
https://www.youtube.com/watch?v=LmyN9tgATtc

MCU: Nucleo STM32F767ZI
TFT: Riverdi FT813 5"
https://www.youtube.com/watch?v=Yb60PmJu5S0

MCU: Arduino Due
TFT: 4DSystem FT843 4.3" (FT800)
Library: gameduino 2
https://www.youtube.com/watch?v=FOhaWL84bKU
Logged

raffaeler

  • Newbie
  • *
  • Posts: 13
    • View Profile
Re: Drawing arcs and circles
« Reply #6 on: March 23, 2023, 10:31:10 AM »

Gentleman, thank you all for your answers.
I looked into the FTDI code to create arcs and, while it is certainly more efficient, it has a lot of dependencies and it's hard to pull off from the Screen Designer.
I played a bit with filling convex and concave polylines with weird results. Unfortunately there are not examples explaining well how to use them.

I will try using the scissors but it's a painful process. This is going to be a far too expensive development for this project.
Logged
Electronic Engineer, Senior Software Architect, Speaker, Trainer

BRT Community

  • Administrator
  • Hero Member
  • *****
  • Posts: 733
    • View Profile
Re: Drawing arcs and circles
« Reply #7 on: March 23, 2023, 01:02:52 PM »

Hi,

Do you have SIN and COS functions in your MCU code framework?
It can be done using just the EVE commands (we can send an example) but ideally it works best if you have these trig functions available (either full or via lookup table).

Best Regards,
BRT Community
Logged

raffaeler

  • Newbie
  • *
  • Posts: 13
    • View Profile
Re: Drawing arcs and circles
« Reply #8 on: March 23, 2023, 03:11:18 PM »

Yes, ESP32 does support the trig functions, thanks

Another (slightly unrelated) question. Do you have an example to fill polygons (with a mix of convex/concave points)?
I found posts in this forum using the stencils, but when there is an irregular shape, the filling process fails somewhere as this snippet shows:

Code: [Select]
CLEAR(1, 1, 1)
SAVE_CONTEXT()
LINE_WIDTH(32)
COLOR_RGB(255, 255, 0)
STENCIL_OP(INCR, INCR)
COLOR_MASK(0,0,0,0)
BEGIN(EDGE_STRIP_L)
VERTEX2F(7232, 2848)
VERTEX2F(5984, 5344)
VERTEX2F(8272, 4144)
VERTEX2F(10496, 4944)
VERTEX2F(9760, 1504)
VERTEX2F(5920, 1504)
VERTEX2F(7232, 2848)
END()

STENCIL_OP(KEEP, KEEP)
COLOR_MASK(1,1,1,1)
STENCIL_FUNC(EQUAL, 1, 255)
CMD_GRADIENT(655, 38, 0x0000FF, 348, 416, 0xFF0000)

Logged
Electronic Engineer, Senior Software Architect, Speaker, Trainer

Rudolph

  • Sr. Member
  • ****
  • Posts: 389
    • View Profile
Re: Drawing arcs and circles
« Reply #9 on: March 24, 2023, 07:51:16 AM »

That example was only an approximation with simple mathematics, the editor can only handle basic things, more advanced examples can be achieved with relatively few instructions, but with slightly more complex mathematics that must consider that the TFT has the Y axis reference frame on the contrary, we must not forget that the EVEx graphics chip does all the drawing work, leaving the MCU only the calculation part.

MCU: teensy 3.6
TFT: NHD 5" FT813
Library: GDSTx (2023)
https://www.youtube.com/watch?v=LmyN9tgATtc

MCU: Nucleo STM32F767ZI
TFT: Riverdi FT813 5"
https://www.youtube.com/watch?v=Yb60PmJu5S0

MCU: Arduino Due
TFT: 4DSystem FT843 4.3" (FT800)
Library: gameduino 2
https://www.youtube.com/watch?v=FOhaWL84bKU

Well, I did not write that the code is not working, I wrote that the code presented is the worst solution for the issue, it still is a solution.
The examples look fancy but there is no source-code for the first and the third.
And while there is an archive with code for the second, I can not get GD3_Gauge_NG_3.rar to compile in the Arduino IDE 1.x and it is not even using the original GD2 library - whatever it is that it actually uses.
So there is no way to tell how long this takes to execute, how full the display list is and what the framerate is.

And speaking of GD2 library, I analyzed the datastream for a 7" GD3X display for the following code using Gameduino2-v1.3.4.zip and a FTDI NerO:

Code: [Select]
#include <EEPROM.h>
#include <SPI.h>
#include <GD2.h>

void setup()
{
  GD.begin(0);
  GD.ClearColorRGB(0x103000);
  GD.Clear();
  GD.cmd_text(GD.w / 2, GD.h / 2, 31, OPT_CENTER, "Hello world");
  GD.swap(); 
}

void loop()
{
}

So I modified the basic hello-world example to only run once.

And not going into details, I wonder why there even is the "Hello world" displayed on the screen at the end.
My impression is that GD2 library is more working by chance than by design - and I really did not expect that.
Apart from the 320ms delay a good portion of the >400ms from start to finish is spent on waiting for the command co-processor to time out on the supplied commands.

I put a EVE_GD3X config in my library and modified my Arduino code to this:
Code: [Select]
void setup()
{
    pinMode(EVE_CS, OUTPUT);
    digitalWrite(EVE_CS, HIGH);
    pinMode(EVE_PDN, OUTPUT);
    digitalWrite(EVE_PDN, LOW);

    SPI.begin(); /* sets up the SPI to run in Mode 0 and 1 MHz */
    SPI.beginTransaction(SPISettings(8000000, MSBFIRST, SPI_MODE0));

    TFT_init();
    TFT_display();
}

void TFT_init(void)
{
    if(E_OK == EVE_init())
    {
        tft_active = 1;

        EVE_memWrite8(REG_PWM_DUTY, 0x40);  /* setup backlight, range is from 0 = off to 0x80 = max */

        EVE_memWrite32(REG_TOUCH_TRANSFORM_A, 0x0000D09D);
        EVE_memWrite32(REG_TOUCH_TRANSFORM_B, 0xFFFFFE27);
        EVE_memWrite32(REG_TOUCH_TRANSFORM_C, 0xFFF0838A);
        EVE_memWrite32(REG_TOUCH_TRANSFORM_D, 0xFFFFFF72);
        EVE_memWrite32(REG_TOUCH_TRANSFORM_E, 0xFFFF7D2B);
        EVE_memWrite32(REG_TOUCH_TRANSFORM_F, 0x01F3096A);
    }
}

void TFT_display(void)
{
    if(tft_active != 0)
    {
        EVE_start_cmd_burst(); /* start writing to the cmd-fifo as one stream of bytes, only sending the address once */

        EVE_cmd_dl(CMD_DLSTART); /* start the display list */
        EVE_cmd_dl(DL_CLEAR_COLOR_RGB | BLACK); /* set the default clear color to black */
        EVE_cmd_dl(DL_CLEAR | CLR_COL | CLR_STN | CLR_TAG); /* clear the screen - this and the previous prevent artifacts between lists, Attributes are the color, stencil and tag buffers */

        EVE_cmd_text(EVE_HSIZE / 2, EVE_VSIZE / 2, 31, EVE_OPT_CENTER, "Hello World");

        EVE_cmd_dl(DL_DISPLAY); /* instruct the co-processor to show the list */
        EVE_cmd_dl(CMD_SWAP); /* make this list active */

        EVE_end_cmd_burst(); /* stop writing to the cmd-fifo, the cmd-FIFO will be executed automatically after this or when DMA is done */
    }
}

So almost the same display.
I did not use the external flash, did not flip the view upside down and have the BT816 running at 72MHz instead of 60MHz.
This needs 120ms from start to finish with a fraction of the SPI traffic.

The logfiles are attached, these are from the Salaea Logic 2 software.

« Last Edit: March 25, 2023, 02:16:35 PM by Rudolph »
Logged

TFTLCDCyg

  • Newbie
  • *
  • Posts: 19
    • View Profile
Re: Drawing arcs and circles
« Reply #10 on: March 28, 2023, 05:08:00 PM »

Thanks for taking some time.

The library for gameduino 23x has the file wiring.h as its axis of operation, within that file the starting of the EVEx chips occurs.

This is the library I've been testing with: GDSTx. You just have to place it in the libraries folder of the arduino IDE.

I uploaded the video examples, as evidence that it is possible to draw arc segments, not to test them; As I said, I have spent several years trying to understand the library and adapt it to be able to use it with teensy 4.1 and especially with its SDIO reader. Over time there have been several versions of the library, which is why I decided to upload the changes to Github to always have a backup. Unfortunately several examples were lost, when the hard drive I was working on failed a couple of years ago; only youtube videos remained.

I apologize for not being able to share the complete examples or the libraries, as I no longer have them.

I share the example for drawing arc segments, which resulted from all those experiments.

Logged

BRT Community

  • Administrator
  • Hero Member
  • *****
  • Posts: 733
    • View Profile
Re: Drawing arcs and circles
« Reply #11 on: March 29, 2023, 05:25:31 PM »

Hi,

Here is a small example of one way to use edge strips to draw an arc.

We can post an explanation too of how it works when ready. The only dependency is that you need cos and sin functions.
When drawing an arc using stencilling, the edge strips provide a good way to shade in an angle. However, each one (top, bottom, left, right) generally only work well for associated 90 degree areas and so we need to use more than one to make this arc.

This is just a basic one but we have used this technique for various arc gauge styles. You can add a point to make the leading and training edges rounded etc or a large point on the leading edge depending on the style which you want. You can also add more error checking etc. to handle out of range values.

It takes in various parameters including the max angle, min angle and the active value which defines how much of the arc is filled in.

p.s. one way to see what is happening is to comment out the line which turns off the color updates EVE_COLOR_MASK(0, 0, 0, 0);   and set a COLOR_RGB for each section.
Here is a small illustration attached showing how the centre circles, the wedge at the bottom and the four quadrant edge strips form a stencil which can then be colored in to make the active part of the arc.

Hope it helps,
BRT Community


Code: [Select]
void Custom_Widget_Arc_Gauge(uint16_t arc_centerx, uint16_t arc_centery, uint16_t arc_radius, uint16_t arc_thickness, uint32_t Arc_Active_Color, uint32_t Arc_Inactive_Color, uint16_t arc_min_limit, uint16_t arc_max_limit, uint16_t arc_value)
{
double arc_value_rad = 0;
uint16_t arc_activex = 0;
uint16_t arc_activey = 0;

double arc_min_limit_rad = 0;
uint16_t arc_start_x = 0;
uint16_t arc_start_y = 0;

double arc_max_limit_rad = 0;
uint16_t arc_end_x = 0;
uint16_t arc_end_y = 0;

//--------------------------------------------------------------------------------------------------------
// Process the angle data which will be used to make a uniform motion of the arc
//--------------------------------------------------------------------------------------------------------

// Ensure the value is within limits
if(arc_value > arc_max_limit)
arc_value = arc_max_limit;
if(arc_value < arc_min_limit)
arc_value = arc_min_limit;

//---------------------------------------------------------

// Calculate the angle in Radians for the Cos and Sin functions
// radians = ((degrees*pi)/180)

// For the arc which we will fill (the actual value of the arc gauge)
// Note: 0 degress is at the very bottom of the circle
if(arc_value > 180)
arc_value_rad = ((arc_value-180) * 3.14)/180;
else
arc_value_rad = (arc_value * 3.14)/180;

// For the min limit which can be for example at 20 degrees from the bottom
if(arc_min_limit > 180)
arc_min_limit_rad = ((arc_min_limit-180) * 3.14)/180;
else
arc_min_limit_rad = (arc_min_limit * 3.14)/180;

// For the max limit which can be for example at 340 degrees from the bottom
if(arc_max_limit > 180)
arc_max_limit_rad = ((arc_max_limit-180) * 3.14)/180;
else
arc_max_limit_rad = (arc_max_limit * 3.14)/180;

//---------------------------------------------------------

// Calculate the coordinates of the starting point, the gauge arc and the point at the tip of the arc

// for the arc gauge itself
arc_activex = (sin(arc_value_rad) * arc_radius);
arc_activey = (cos(arc_value_rad) * arc_radius);

// for the starting angle (the minimum value of the arc as it is normally not desired to be a full 360 deg circle)
arc_start_x = (sin(arc_min_limit_rad) * arc_radius);  
arc_start_y = (cos(arc_min_limit_rad) * arc_radius);         

// for the finishing angle (the maximum value of the arc as it is normally not desired to be a full 360 deg circle)
arc_end_x = (sin(arc_max_limit_rad) * arc_radius);     
arc_end_y = (cos(arc_max_limit_rad) * arc_radius);         

//--------------------------------------------------------------------------------------------------------
// Write to the stencil buffer and disable writing to the screen to make an invisible arc
//--------------------------------------------------------------------------------------------------------

// Set the stencil to increment and diasble writes to the screen
EVE_STENCIL_OP(EVE_STENCIL_INCR, EVE_STENCIL_INCR);
EVE_COLOR_MASK(0, 0, 0, 0);

// Draw concentric circles to form the stencil so that the arc has a unique stencil value and we can shade it later
EVE_BEGIN(EVE_BEGIN_POINTS);

// Outer circle makes the outer edge of the arc
EVE_POINT_SIZE(arc_radius*16);
EVE_VERTEX2F(((arc_centerx)*16), (arc_centery)*16);
EVE_VERTEX2F(((arc_centerx)*16), (arc_centery)*16);

// Inner circle makes the inner edge of the arc
EVE_POINT_SIZE((arc_radius - arc_thickness)*16);
EVE_VERTEX2F(((arc_centerx)*16), (arc_centery)*16);
EVE_VERTEX2F(((arc_centerx)*16), (arc_centery)*16);
EVE_END();

//--------------------------------------------------------------------------------------------------------
// Draw the edge strips which will fill in the arc
//--------------------------------------------------------------------------------------------------------

// These are drawn per quadrant as each edge strip will only work well on an angle up to 90 deg

// 0 - 89 Deg
if((arc_value > 0) && (arc_value < 90))
{
// Edge strip to draw the arc
EVE_BEGIN(EVE_BEGIN_EDGE_STRIP_B);
EVE_VERTEX2F(((arc_centerx - arc_start_x)*16), (arc_centery+arc_start_y)*16);
EVE_VERTEX2F(((arc_centerx)*16), (arc_centery)*16);
EVE_VERTEX2F(((arc_centerx - arc_activex)*16), (arc_centery + arc_activey)*16);
}
else
{
// Edge strip to draw the arc
EVE_BEGIN(EVE_BEGIN_EDGE_STRIP_B);
EVE_VERTEX2F(((arc_centerx - arc_start_x)*16), (arc_centery+arc_start_y)*16);
EVE_VERTEX2F(((arc_centerx)*16), (arc_centery)*16);
EVE_VERTEX2F(((arc_centerx - arc_radius)*16), (arc_centery)*16);
}

// 90 - 179 deg
if((arc_value >= 90)&& (arc_value < 180))
{
// Edge strip to draw the arc
EVE_BEGIN(EVE_BEGIN_EDGE_STRIP_L);
EVE_VERTEX2F(((arc_centerx)*16), (arc_centery)*16);
EVE_VERTEX2F(((arc_centerx - arc_activex)*16), (arc_centery - arc_activey)*16);
}
else if (arc_value > 90)
{
// Edge strip to draw the arc
EVE_BEGIN(EVE_BEGIN_EDGE_STRIP_L);
EVE_VERTEX2F(((arc_centerx)*16), (arc_centery)*16);
EVE_VERTEX2F(((arc_centerx)*16), (arc_centery - arc_radius)*16);
}

// 180 - 269 deg
if((arc_value >= 180)&& (arc_value < 270))
{
// Edge strip to draw the arc
EVE_BEGIN(EVE_BEGIN_EDGE_STRIP_A);
EVE_VERTEX2F(((arc_centerx-1)*16), (arc_centery)*16);
EVE_VERTEX2F(((arc_centerx + arc_activex)*16), (arc_centery - arc_activey)*16);
}
else if (arc_value > 180)
{
// Edge strip to draw the arc
EVE_BEGIN(EVE_BEGIN_EDGE_STRIP_A);
EVE_VERTEX2F(((arc_centerx-1)*16), (arc_centery)*16);
EVE_VERTEX2F(((arc_centerx + arc_radius )*16), (arc_centery)*16);
}

// 270 - 359 deg
if((arc_value > 270)&& (arc_value < 360))
{
// Edge strip to draw the arc
EVE_BEGIN(EVE_BEGIN_EDGE_STRIP_R);
EVE_VERTEX2F(((arc_centerx)*16), (arc_centery)*16);
EVE_VERTEX2F(((arc_centerx + arc_activex)*16), (arc_centery + arc_activey)*16);
}
else if (arc_value > 270)
{
// Edge strip to draw the arc
EVE_BEGIN(EVE_BEGIN_EDGE_STRIP_R);
EVE_VERTEX2F(((arc_centerx)*16), (arc_centery)*16);
EVE_VERTEX2F(((arc_centerx)*16), (arc_centery + arc_radius)*16);
}

// and finally draw a wedge shape at the bottom to ensure the inactive part of the arc is not coloured in

EVE_BEGIN(EVE_BEGIN_EDGE_STRIP_B);
EVE_VERTEX2F(((arc_centerx - arc_start_x)*16), (arc_centery + arc_start_y)*16);
EVE_VERTEX2F(((arc_centerx)*16), (arc_centery)*16);
EVE_VERTEX2F(((arc_centerx + arc_end_x)*16), (arc_centery + arc_end_y)*16);
EVE_VERTEX2F(((arc_centerx)*16), (arc_centery)*16);

EVE_END();

//--------------------------------------------------------------------------------------------------------
// Draw a circle which will fill the arc
//--------------------------------------------------------------------------------------------------------

// Stop incrementing the stencil
EVE_STENCIL_OP(EVE_STENCIL_KEEP, EVE_STENCIL_KEEP);
// re-enable writes to the screen
EVE_COLOR_MASK(1, 1, 1, 1);

// For the Active arc area, only draw in areas with stencil == 3
EVE_STENCIL_FUNC(EVE_TEST_EQUAL, 3, 255);
EVE_BEGIN(EVE_BEGIN_POINTS);
EVE_COLOR_RGB( ((uint8_t)(Arc_Active_Color>>16)), ((uint8_t)(Arc_Active_Color>>8)),  ((uint8_t)(Arc_Active_Color)));
EVE_POINT_SIZE(arc_radius*16);
EVE_VERTEX2F(((arc_centerx)*16), (arc_centery)*16);
////////EVE_END();

// For the Inactive area of the arc, only draw in areas with stencil == 2
EVE_STENCIL_FUNC(EVE_TEST_EQUAL, 2, 255);
EVE_BEGIN(EVE_BEGIN_POINTS);
EVE_COLOR_RGB( ((uint8_t)(Arc_Inactive_Color>>16)), ((uint8_t)(Arc_Inactive_Color>>8)),  ((uint8_t)(Arc_Inactive_Color)));
EVE_POINT_SIZE(arc_radius*16);
EVE_VERTEX2F(((arc_centerx)*16), (arc_centery)*16);
////////EVE_END();

EVE_END();

//--------------------------------------------------------------------------------------------------------
// Clean up to avoid affecting other items later in the display list
//--------------------------------------------------------------------------------------------------------

EVE_STENCIL_FUNC(EVE_TEST_ALWAYS, 1, 255); // Revert to always drawing for the subsequent items

EVE_CLEAR(0,1,0); // Clear the stencil buffer to ensure it does not affect other items on the screen
}

//###############################################################################################################################################################
//###############################################################################################################################################################

void eve_display(void)
{

uint16_t arc_value = 40; // actual value
uint8_t direction = 0; // 0 means count up

while(1)
{
EVE_LIB_BeginCoProList();                                               // Begin new screen
EVE_CMD_DLSTART();                                                      // Tell co-processor to create new Display List

EVE_CLEAR_COLOR_RGB(0x00, 0x55, 0xFF);                                  // Specify color to clear screen to
EVE_CLEAR(1,1,1);                                                       // Clear color, stencil, and tag buffer

EVE_COLOR_RGB(255, 255, 255);
EVE_CMD_NUMBER(200, 200, 30, EVE_OPT_CENTERX, arc_value); // Print numerical arc value

EVE_COLOR_RGB(255, 255, 255);

//                      position Diam  Arc    Arc color  Arc color ----values------
//                                            active      backgnd   limit    arc
//                       X    Y  Size width    RRGGBB      RRGGBB  min max  value
Custom_Widget_Arc_Gauge(200, 200, 180, 30,   0xFF6000,  0x800080, 40, 320, arc_value);

EVE_DISPLAY();                                                          // Tell EVE that this is end of list
EVE_CMD_SWAP();                                                         // Swap buffers in EVE to make this list active

EVE_LIB_EndCoProList();                                                 // Finish the co-processor list burst write
EVE_LIB_AwaitCoProEmpty();                                              // Wait until co-processor has consumed all commands

if(direction == 0)
{
arc_value ++;
if(arc_value == 320)
direction = 1; // count down next time
}
else
{
arc_value --;
if(arc_value == 40)
direction = 0; // count up next time
}
}
}
« Last Edit: March 30, 2023, 10:01:07 AM by BRT Community »
Logged

Rudolph

  • Sr. Member
  • ****
  • Posts: 389
    • View Profile
Re: Drawing arcs and circles
« Reply #12 on: March 29, 2023, 06:07:08 PM »

First of I feel like I need to apologize, I am certain that a live conversation would come across friendlier. :-)
Sorry.

Thanks for taking some time.

This is a mere coincidence, I only analyzed the SPI traffic from GD2 library to be able to add
support for the GD3X to my library.
I do not know why, but there is close to no documentation for the GD3X.
Anyway, I got all the data I was looking for and some I was not looking for.

Quote
The library for gameduino 23x has the file wiring.h as its axis of operation, within that file the starting of the EVEx chips occurs.

This is the library I've been testing with: GDSTx. You just have to place it in the libraries folder of the arduino IDE.

I already saw that it differs from GD2 library but did not have a chance so far to actually run it and look at the trace.
I opened an issue on Github to ask about the target support.
Looks like of the boards I have "only" the Teensy 4.1 is supported and I did not get around connecting a display, yet.

Quote
I uploaded the video examples, as evidence that it is possible to draw arc segments, not to test them; As I said, I have spent several years trying to understand the library and adapt it to be able to use it with teensy 4.1 and especially with its SDIO reader. Over time there have been several versions of the library, which is why I decided to upload the changes to Github to always have a backup. Unfortunately several examples were lost, when the hard drive I was working on failed a couple of years ago; only youtube videos remained.

I apologize for not being able to share the complete examples or the libraries, as I no longer have them.

I share the example for drawing arc segments, which resulted from all those experiments.

Absolutely no need for you to apologize.
I liked the examples and also the last image looks very nice.
Only my perspective is a bit different, my view is from the bottom and not from the top.
I spent quite a number of years now writing my own library.

And while I still apreciate your examples, my view from the bottom tells me that GD2 library and also GDSTx library
has a number of issues at the very core, starting with that the initialization bears close to no resemblence with the description in the programming guide.
Yes, this is way off topic now and again coincidence that I even saw this.

Have a look at my library: https://github.com/RudolphRiedel/FT800-FT813/
Not to switch over, but to take whatever you might need.
My library does for example use DMA for the display-update SPI transfers on the Teensy 4 boards.
Logged