Micro Radar Flight Tracker with CYD

 

For this project I have updated and modified the code by Anthony Sturdy for ESP32 based flight tracker. Thanks to Anthony Sturdy for this open-source project. His github repository here.

I've modified the source code to directly upload to the  ESP32 CYD module and also you don't need any soldering for this project.

Core Hardware Specs of the module:

      ·         Microcontroller: ESP32-WROOM-32 (Dual-core 240 MHz, 520 KB SRAM, 4 MB Flash).
·         Connectivity: Built-in Wi-Fi and Bluetooth.
·         Display: 2.8-inch resistive touchscreen with 320 × 240 px resolution (ILI9341 display       driver, XPT2046 touch controller).
·         Expansion: MicroSD card slot for external storage, plus a few breakout headers for sensors   (e.g., DHT11) and extra GPIO pins.
·         Power: 5V operating voltage via micro-USB or type-C



Note: There are many clones of this board, you may buy the same model "ESP32-2432S028R" as I've used here to avoid setup error.

Source file:

Checkout my drive link here
Note: Two files are given, one with plane icon another with triangle icon.

Setup guideline:

I have made a pdf guideline step by step so you do not have to go through troubles.
Checkout the guideline pdf drive link here

Troubleshooting: Screen orientation fix for some CYD boards

If your screen appears flipped or mirrored, open include/LGFX.h and find these three lines in the panel config block

Change their value to :

cfg.panel_width = 320;
cfg.panel_height = 240;
cfg.offset_rotation  = 7;
And reupload .

If you face any other error please feel free to send email with a subject "Micro Radar CYD" to abid.business01@gmail.com

Visit my YouTube channel 
Facebook page 

Comments

  1. Is that code correct as such...graphics look corrupted on 320x240 resolution?

    ReplyDelete
    Replies
    1. Code is correct, many of the viewers have made it work.

      Delete
    2. Ok, I see that the LGFX.h has correct width, height...I can see on Amazon that the board that I bought is said to have; Touch screen: ESP32-2432S028R and Driver Chip: ILI9341 . So these should work....but it justdoes not seem to get correct way on screen???

      Delete
    3. ok, managed to get it...but what ever reason, this seemed to work
      - swapping widt/height
      - rotation = 5
      - not sure if offset_x / y has any meaning

      LGFX.h
      ...
      cfg.panel_width = 320;
      cfg.panel_height = 240;
      cfg.offset_x = 0;
      cfg.offset_y = 0;
      cfg.offset_rotation = 5;
      ...

      I also comment out "tft.setRotation" on main.cpp, is that actually needed if the value is already set on LGFX.h ?

      Delete
    4. This comment has been removed by the author.

      Delete
    5. I can see small difference on your board pictures, one of them seems to have perhaps micro-usb power, and that usb is slightly side, but some are with usb-c and more middle...on my board is usb-c and usb is quite on middle also.

      Delete
    6. Thanks MarkoK, this fixed it for me as well, although it leaves the usb-c power at the top. I tried use rotation=7 to get the usb-c on the bottom but that messes up the graphics for whatever reason.

      Delete
    7. Yes, I have tried many combinations, but have not been able to find one that would flip the display 180 degrees, so that USB port would be down without messing the screen completely...

      Delete
  2. I'm having these two error come up when running the program: ** [.pio/build/esp32dev/libfd3/LovyanGFX/lgfx/utility/._lgfx_miniz.c.o] Error 1
    *** [.pio/build/esp32dev/libfd3/LovyanGFX/lgfx/Fonts/efont/._lgfx_efont_cn.c.o] Error 1

    ReplyDelete
    Replies
    1. Are you using Mac? Gemini was quessing following reason.

      "If you are working on a Mac (or using a project folder that was zipped/copied on a Mac), macOS automatically creates hidden metadata files called AppleDouble files that start with ._. PlatformIO sees these ghost files, thinks they are actual C source files, and tries to compile them. Because they just contain file metadata and not actual C code, the compiler panics and crashes."

      Delete
  3. Yes I was. I will switch to windows and run from that and see if it works. Thanks

    ReplyDelete
    Replies
    1. Got it! Works perfectly now. Thanks I did not know that about mac's making those ghost files.

      Delete
    2. You can use Mac also

      Step 1: Clean out the Mac ghost files
      ​You need to purge those hidden ._ files from your project directory.
      ​Open your terminal.
      ​Navigate (cd) into your project folder.
      ​ find and destroy all ._ files in your project directory

      Step 2: Nuke the build cache
      ​PlatformIO has already cached the bad build files, so you need to force it to start fresh.
      ​In VS Code: Click the PlatformIO icon (the alien head) on the left sidebar, expand your project env, and click Clean.
      ​Alternatively: Just manually delete the entire hidden .pio folder inside your project directory.

      Delete
  4. To change the units from meters to feet and meters/second to knots, you need to modify the DrawAircraftInfo function within the AircraftManager.cpp
    The current code displays the values directly from the OpenSky data, which is provided in meters and m/s. You just need to apply the math conversions and update the label strings.
    The Code Change

    Locate the DrawAircraftInfo function at the bottom of your file and replace it with this version:

    void AircraftManager::DrawAircraftInfo(LGFX_Sprite& backbuffer, int x, int y, const TrackedAircraft& tracked) const
    {
    const int lineHeight = tft.fontHeight() + 1;

    // Convert values
    // velocity is in m/s, convert to knots by multiplying by 1.94384
    float speedKnots = tracked.state.velocity * 1.94384f;

    // baroAltitude is in meters, convert to feet by multiplying by 3.28084
    float altitudeFt = tracked.state.baroAltitude * 3.28084f;

    backbuffer.setTextSize(1);
    backbuffer.setTextColor(lgfx::color888(0, 128, 0));

    backbuffer.drawString(tracked.state.callsign, x + 5, y + 5);

    // Display Speed in Knots
    backbuffer.drawString(String(speedKnots, 0) + "kts", x + 5, y + 5 + lineHeight);

    // Display Altitude in Feet
    backbuffer.drawString(String(altitudeFt, 0) + "ft", x + 5, y + 5 + lineHeight * 2);
    }

    ReplyDelete
    Replies
    1. Thank you so much for contributing this code. I'm not a coder but was able to do a copy and paste and recompile and it worked! My only problem now is that even after making the changes to the display specifications referenced up above my display is 180 degrees with the USB port on top and not the bottom. If you have any recomendations I sure would appreciate it.

      Delete
    2. This seems to be an issue, perhaps not all boards, but surprisingly many. I tried many combinations, but have not managed to flip screen 180 degrees.
      To my understanding that offset_rotation=7 should work...but some reason it doesn't...

      Delete
  5. I did some calculations to change the knots to mph but for whatever reason I dont think the aircraft listed on the radar is actually correct in mph. I show a Boeing flying at 450 kots and yet the radar is showing 267 MPH.. calculation is multipling by 1.151

    ReplyDelete
  6. Here is some direct replacement code for DrawAircraftIcon which will rotate the plane icon to the proper heading as opposed to the 4 cardinal directions. (if I knew how to use github I'd put in some sort of request there, but I don't so I didn't, but someone else feel free to).


    void AircraftManager::DrawAircraftIcon(LGFX_Sprite& backbuffer, int x, int y, const TrackedAircraft& tracked) const
    {
    // normalise heading into [0, 360)
    float heading = fmodf(tracked.state.trueTrack, 360.0f);
    if (heading < 0) heading += 360.0f;

    // Create a temporary sprite for the rotated image
    LGFX_Sprite rotated;
    rotated.setColorDepth(16);
    rotated.createSprite(PLANE_ICON_SIZE, PLANE_ICON_SIZE);

    // Set swap bytes on the temporary sprite before pushing the image
    rotated.setSwapBytes(true);
    rotated.pushImage(0, 0, PLANE_ICON_SIZE, PLANE_ICON_SIZE, planeUp, PLANE_ICON_TRANSPARENT);
    rotated.setSwapBytes(false);

    // Push the rotated sprite to the backbuffer
    rotated.pushRotateZoom(&backbuffer, x, y, heading, 1.0, 1.0);

    rotated.deleteSprite();
    }

    ReplyDelete
    Replies
    1. Thank you so much for contributing this code. I'm 78 and not a coder but was able to successfully copy and paste and recompile the code and it works great. Your code really adds to the look of the display!

      Delete
    2. Is it possible to use a larger display (4” or larger) and does the code need to be changed?

      Delete
    3. I cannot test, but on easiest just modifying display width/height values might be enough... assuming any calculations is based on those.

      Delete
    4. Hi all.The bigger screens use different interface chips, so it would not be an easy task.. Did anyone try?? thanks..

      Delete
    5. Probably not, with code that can't even be configured to successfully do a 180° orientation switch I can't imagine getting it to work on a larger display without a complete rewrite.

      Delete
  7. Brilliant Work!
    I have got it working.
    I altered the orientation - Thank You MarkoK
    I altered the speed and Altitude to Knots and Feet - Thank You Xraydelta101
    I altered the Aircraft Logo to face the direction of travel - Thank You Tom
    My only issue is that my display has the USB C Port at the top instead of the bottom, but I haven't settled on a case yet....

    ReplyDelete

Post a Comment