Announcement

Collapse
No announcement yet.

Example for graph plot

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Example for graph plot

    Is there any example for how to make a graph plot on 4Duino? For example, I have a (x,y) point and I would like to plot that pixel on the screen.

    Thanks,
    Raj

  • #2
    Hi Rajbex,

    We don't have any example for that.

    However, you can easily implement this by using:

    Code:
    Display.gfx_PutPixel("x", "y", "colr");            // set point at x y
    You simply need to calculate the X and Y coordinates.

    If you want something like the scope in ViSi and ViSi Genie environments, all you have to do is to have a buffer with size equal to the width of your X-axis to contain the Y values.

    Then move these values accordingly.

    Perform this by deleting the old graph (using Display.gfx_PutPixel with color same to the background) then writing the new graph (using Display.gfx_PutPixel with the color of your graph).

    For convenience, let's assume you have a small graph area of 10x10 pixels.

    You have a width of 10 so you need to have:

    Code:
    int y_val[10];
    Since you have 10 pixels for the Y-axis, the values of y_val shouldn't exceed 10 pixels counting from the X-axis. Otherwise, the pixel will be outside the graph area.

    Let's say y_val contains:
    Code:
    {1, 5, 6, 7, 2, 3, 5, 2, 4, 8}
    And new data NEW_DATA is ready. You need to delete the old graph by changing the color back to the background color then move the data to be like this:
    Code:
    {5, 6, 7, 2, 3, 5, 2, 4, 8, NEW_DATA}
    And display the graph again. Since you are plotting several points at once, it is a good idea to use a for loop with Display.gfx_PutPixel.

    Just keep in mind the origin of your graph area since you would need to compute for the actual X and Y coordinates of the display.

    I hope this helped. If you need more assistance, don't hesitate to ask.

    Best Regards,
    Juniel Cruz

    Comment


    • kk13krishna
      kk13krishna commented
      Editing a comment
      sir, please send me a demo code of arduino to plot any graph on 4d system lcd
Working...
X