Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

16 bit parallel sprites get corrupted/distorted on rp2040. #3293

Open
ripjohnbrown1859 opened this issue Apr 19, 2024 · 0 comments
Open

16 bit parallel sprites get corrupted/distorted on rp2040. #3293

ripjohnbrown1859 opened this issue Apr 19, 2024 · 0 comments

Comments

@ripjohnbrown1859
Copy link

i am trying to use DMA on a 16 bit parallel ili9486 with a Pico. so far I can display text and images directly through tft.draw and tft.print but once i use sprites, or DMA sprites, it gets distorted or corrupted as shown in the picture on the top of the screen in the picture. im using the earle philhower board package and the most recent library tft_espi version available on platform io. here a link to the user setup file im using.
https://github.com/bphermansson/3_5inchOledTest/blob/main/lib/User_Setup
the specific display
https://www.amazon.com/HiLetgo-Display-ILI9481-480X320-Mega2560/dp/B073R7Q8FF/ref=cm_cr_arp_d_product_top?ie=UTF8
picture of the behavior
20240419_172559

the code

#include <SPI.h>
#include <Wire.h>
#include <TFT_eSPI.h>
#include <SoftwareSerial.h>


TFT_eSPI tft = TFT_eSPI();  // Invoke custom library 
TFT_eSprite spr[3] = {TFT_eSprite(&tft), TFT_eSprite(&tft), TFT_eSprite(&tft)};
uint16_t* sprPtr[3];
uint16_t adcBuffer[100];  //adc data
uint8_t EKGbuffer[360];
uint8_t PLETHbuffer[360];
uint8_t cursorX = 0;
uint8_t systolic = 0;
uint8_t diastolic = 0;
uint8_t pulse = 0;
uint8_t MAP = 0;
String latestMessage = "No message";
uint32_t benchmark = 0;
uint8_t sensorValue = 0;
uint8_t spO2sensorValue = 0;
uint8_t lastEKGValue = 0;
uint8_t lastSpo2Reading = 0;
SoftwareSerial SoftSerial(20, 21); // RX, TX
void setup() {
  //SoftSerial.begin(115200);
  tft.init();
  tft.initDMA();
  tft.setRotation(1);
  tft.fillScreen(TFT_BLACK);
  tft.setTextSize(1);
  tft.setTextColor(TFT_WHITE);
  tft.setCursor(380, 0);
  tft.println("Hello World");
  sprPtr[0] = (uint16_t*)spr[0].createSprite(1, 160);
  sprPtr[1] = (uint16_t*)spr[1].createSprite(1, 160);
  sprPtr[2] = (uint16_t*)spr[2].createSprite(120,320);
  spr[2].setTextColor(TFT_WHITE);
  spr[2].setTextFont(1);
  //spr[2].setColorDepth(1);
  //spr[2].setTextDatum(TL_DATUM);
  //spr[2].setViewport(360, 0, 120, 320);
  tft.startWrite();
}
void loop() {
  tft.dmaWait();
  if(cursorX > 360){

    cursorX = 0;
    sensorValue++;
    if(sensorValue > 160){
      sensorValue = 0;
    }
    spO2sensorValue++;
    if(spO2sensorValue > 160){
      spO2sensorValue = 0;
    }
  }
  spr[2].fillSprite(TFT_BLACK);
  spr[0].drawFastVLine(0, 0, 160, TFT_BLACK);
  spr[1].drawFastVLine(0, 0, 160, TFT_BLACK);
    MAP = (systolic + (2*diastolic))/3;
  spr[0].drawLine(-1, lastEKGValue, 0, sensorValue, TFT_GREEN);
  if(lastSpo2Reading > 0){
  spr[1].drawLine(-1, lastSpo2Reading, 0, spO2sensorValue, TFT_BLUE);
  }
  else{
    spr[1].drawPixel(0, spO2sensorValue, TFT_BLUE);
  }
  spr[2].setTextSize(1);
  spr[2].drawNumber(MAP, 0, 150);
  spr[2].drawNumber((millis() - benchmark), 0, 0);
  spr[2].drawString(latestMessage, 20, 0);
  spr[2].drawString("spO2%",0,90);
  spr[2].drawString("NIBP" , 0, 140);
  spr[2].drawString("HR", 0, 40);
  spr[2].setTextSize(4);
  spr[2].drawNumber(systolic, 2, 160);
  spr[2].drawNumber(diastolic, 2, 200);
  spr[2].drawFastVLine(60, 0, 320, TFT_WHITE);
  tft.pushImageDMA(cursorX+120, 160, 1, 160, sprPtr[0]);
  tft.pushImageDMA(cursorX+120, 0, 1, 160, sprPtr[1]);
  tft.pushImage(0, 0, 120, 320, sprPtr[2]);
  cursorX++;
  benchmark = millis();
}```

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant