TFT 3.5 Inch Display Coding Help!

Hello!

So, I have a boat GPS unit that I made, and right now, it shows the direction im going and the desired direction for the correct course as lines on the display. Im trying to draw a "boat shape" instead of a line, and have it point in the current direction. There's plenty of info on what I made in this post: Arduino Sketch too Big; How to Shorten it? - #126 by kgray9

Is that even possible :thinking:? I think it is :thought_balloon:.

Basically just a generic "boat" outline instead of a line.
Edit: Like this boat outline: Sailing Simulator by NauticEd

Thanks in advance!

You're asking, can I make a drawing from simple geometric shapes? What is the problem exactly?

Ummm, well this draws the current course and correct course lines:

screen.drawLine(
    screen.width() / 2,
    circleCenter,
    screen.width() / 2 + circleRadius * sin(Course * M_PI / 180.),
    circleCenter - circleRadius * cos(Course * M_PI / 180.),
    COLOR_RGB565_GREEN);

  // Draw the courseToHome Course bearing line in RED
  screen.drawLine(
    screen.width() / 2,
    circleCenter,
    screen.width() / 2 + circleRadius * sin(courseToHome * M_PI / 180.),
    circleCenter - circleRadius * cos(courseToHome * M_PI / 180.),
    COLOR_RGB565_RED);

Im wondering how I can make it draw a boat outline instead of a line.

Options include, but are not limited to:

  1. Draw a triangle at one end of a rectangle, using the appropriate graphics function calls.

  2. Sketch an arbitrary "boat shape" on graph paper or a sketch program and read off coordinates of some reasonable number of points. Plot the polygon.

Rotate and scale the figure as required.

Example of the second approach:

1 Like

Hello @jremington

Thanks for the detailed response; I appreciate it :wink:

As seen in my other topic, the display is extremely slow :frowning:. To draw the shape, I would basically draw lines from one point to the next, but it takes forever to draw one line. It would take up to 4 whole seconds to just draw a simple boat outline.

Even then, im not sure how to make it point in the right direction :thinking:.

Sounds like you are doing something very wrong with the display. An Arduino Uno can draw a line in a few milliseconds on typical displays.

Rotating and scaling figures are fundamental to elementary graphics programming. There are countless tutorials on line explaining how to do that. To draw your boat shape, you have no choice but to learn how.

One place to start: https://www.cse.unr.edu/~sushil/class/games/notes/2D-Graphics.pdf

1 Like

Thanks @jremington

What is a bitmap? Is like a way to store a monochrome "drawing" of a boat (outline)?

That is another option. A bitmap is an image that has already been drawn.
Depending on space available, make a boat for each cardinal direction, or however many you want, and call the appropriate image based on the heading.

1 Like

Thanks @cncnotes

Or, I could rotate the bitmap according to the course :wink:.

Lol, and there’s 0 space available. I already had to delete most of my code due to “sketch too big” issues

I just tried a online bmp converter, but the translated file doesn’t make any sense; there is no “0xff” or such, just lots of random symbols.

True, but may be computationally quite expensive :robot:

1 Like

That is the problem with bitmaps. I think drawing the lines, perhaps something really simple like a very elongated triangle may be a good bet

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.