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

drawBmp() displays cropped image #456

Closed
TheRegularDX opened this issue Oct 11, 2023 · 5 comments
Closed

drawBmp() displays cropped image #456

TheRegularDX opened this issue Oct 11, 2023 · 5 comments

Comments

@TheRegularDX
Copy link

TheRegularDX commented Oct 11, 2023

Environment ( 実行環境 )

  • MCU or Board name: ESP32-2432S028
  • Panel Driver IC: ILI9341
  • Bus type: SPI
  • LovyanGFX version: latest
  • FrameWork version: ArduinoESP32 v2.0.3
  • Build Environment: PlatformIO
  • Operating System: macOS

Problem Description ( 問題の内容 )

loading an image from an sd card and displaying it with drawBmp() results in a cropped image being displayed on the lcd, specifically only the bottom portion of the image. ive tried other pictures but got the same result.

Expected Behavior ( 期待される動作 )

a full image gets displayed on the lcd

Actual Behavior ( 実際の動作 )

cropped image gets displayed.

Steps to reproduce ( 再現のための前提条件 )

  1. init display
  2. init sd card
  3. load an image and display it like this:
auto file = SD.open("/1.bmp");	
lcd.drawBmp(&file, 100, 50);

Code to reproduce this issue ( 再現させるためのコード )

// frankenstein code from many examples and tutorials. 
// i am a beginner and this was a bit hard to set up. 
// loyvan if possible please improve the documentation thank you

#include <Arduino.h>
#include <LovyanGFX.hpp>
#include <LGFX_AUTODETECT.hpp>  
#include <SPI.h>
#include <SD.h>
#include <FS.h>

#define LGFX_ESP32_2432S028                // Sunton ESP32 2432S028

#define SD_MOSI 23
#define SD_MISO 19
#define SD_SCK 18
#define SD_CS 5

static LGFX lcd;                 
SPIClass SD_SPI;

int SD_init()
{
  SD_SPI.begin(SD_SCK, SD_MISO, SD_MOSI);
  if (!SD.begin(SD_CS, SD_SPI, 40000000))
  {
    Serial.println("Card Mount Failed");
    return 1;
  }
  uint8_t cardType = SD.cardType();

  if (cardType == CARD_NONE)
  {
    Serial.println("No TF card attached");
    return 1;
  }
  return 0;
}


void setup(void)
{
  Serial.begin(115200);
  lcd.init();
  lcd.setRotation(1);
  lcd.setBrightness(128);

  if (SD_init() == 0)
  {
    Serial.println("TF card initialized successfully");

  } else {
    Serial.println("TF card initialization failed");

  }

}

void loop(void)
{
	auto file = SD.open("/1.bmp");	
	lcd.drawBmp(&file, 100, 50);
}
@TheRegularDX
Copy link
Author

This is the result:

20231011_135347.jpg

Unfortunately i dont have access to 1.bmp right now. Ill upload it when possible

@TheRegularDX
Copy link
Author

Captura de Pantalla 2023-10-02 a la(s) 20 22 24

here is the original image. the 1.bmp is a converted version of this image

@lovyan03
Copy link
Owner

no need SPIClass SD_SPI;
you can use SPI instance

@lovyan03
Copy link
Owner

Do the following

  SPI.begin(SD_SCK, SD_MISO, SD_MOSI);
  if (!SD.begin(SD_CS, SPI, 40000000))

@TheRegularDX
Copy link
Author

thank you! noob mistake. now it works fine

@tobozo tobozo closed this as completed Oct 12, 2023
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

3 participants