TFT дисплей 2.4
- Войдите на сайт для отправки комментариев
Втр, 14/11/2017 - 15:28
TFT дисплей 2.4 длелает зеркальне зображение !

#include <Adafruit_GFX.h> // Core graphics library
#include <SWTFT.h> // Hardware-specific library
// LCD_CS A3 // Chip Select goes to Analog 3
// LCD_CD A2 // Command/Data goes to Analog 2
// LCD_WR A1 // LCD Write goes to Analog 1
// LCD_RD A0 // LCD Read goes to Analog 0
// LCD_RESET A4
// D0 connects to digital pin 8
// D1 connects to digital pin 9
// D2 connects to digital pin 2
// D3 connects to digital pin 3
// D4 connects to digital pin 4
// D5 connects to digital pin 5
// D6 connects to digital pin 6
// D7 connects to digital pin 7
#define BLACK 0x0000
#define BLUE 0x001F
#define RED 0xF800
#define GREEN 0x07E0
#define CYAN 0x07FF
#define MAGENTA 0xF81F
#define YELLOW 0xFFE0
#define WHITE 0xFFFF
SWTFT tft;
long interval1 = 1000;
long LastTime1 = 0;
int h;
int m;
int s;
void setup() {
tft.reset();
tft.begin();
tft.fillScreen(BLACK);
tft.setRotation(3);
}
void loop() {
tft.invertDisplay(true);
delay(500);
tft.invertDisplay(false);
delay(500);
testText();
teme();
}
void teme(){
if (millis() - LastTime1 > interval1) {
LastTime1 = millis();
s=s+1;
}
if(s==60){
s=0;
m=m+1;
}
if(m==60)
{
m=0;
h=h+1;
}
if(h==24)
{
h=1;
}
}
void testText() {
tft.setCursor(0, 0);
tft.setTextColor(YELLOW);
tft.setTextSize(2);
tft.println(1234.56);
tft.setTextColor(RED,BLACK);
tft.setTextSize(4);
tft.println(0xDEADBEEF, HEX);
tft.println(String (s)+":"+(m)+":"+(h));
tft.setTextColor(GREEN);
tft.setTextSize(5);
tft.println("Groop");
tft.setTextSize(2);
tft.println("I implore thee,");
tft.setTextSize(1);
tft.println("my foonting turlingdromes.");
tft.println("And hooptiously drangle me");
tft.println("with crinkly bindlewurdles,");
tft.println("Or I will rend thee");
tft.println("in the gobberwarts");
tft.println("with my blurglecruncheon,");
tft.println("see if I don't!");
}
С пытался с помощью оператора в стороке 50-53 tft.invertDisplay(); но некакой реакции. Как можно сделать что бы нормальное отображение??
Крутяк!
Как ты этого добился?
Мне такой дисплей с китая пришел, я вобще ничего не делал!
Мне такой дисплей с китая пришел, я вобще ничего не делал!
Когда-то давно, у меня на телефоне (кнопочном ещё) экран также зеркалил. Что-то со шлейфом было вроде...
Так что может это и не программное, а аппаратный брак
A если так - tft.setRotation( 3);
A если так - tft.setRotation( 3);
у меня так 44 строке и написано
044 tft.setRotation(3);
не имеет значения в каком положении!
Когда зеркало подставляешь то всё нормально, только как это программно сделать, если можно??
Ну так попробуйте tft.setRotation(0); или tft.setRotation(1); или tft.setRotation(2);
Интуитивно, разве нет?
tft.setRotation() вряд ли поможет, нужно в библиотеке вывод пикселей менять наоборот.
библеотека Adafruit_GFX.h
#ifndef _ADAFRUIT_GFX_H #define _ADAFRUIT_GFX_H #if ARDUINO >= 100 #include "Arduino.h" #include "Print.h" #else #include "WProgram.h" #endif #define swap(a, b) { int16_t t = a; a = b; b = t; } class Adafruit_GFX : public Print { public: Adafruit_GFX(int16_t w, int16_t h); // Constructor // This MUST be defined by the subclass: virtual void drawPixel(int16_t x, int16_t y, uint16_t color) = 0; // These MAY be overridden by the subclass to provide device-specific // optimized code. Otherwise 'generic' versions are used. virtual void drawLine(int16_t x0, int16_t y0, int16_t x1, int16_t y1, uint16_t color), drawFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color), drawFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color), drawRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color), fillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color), fillScreen(uint16_t color), invertDisplay(boolean i); // These exist only with Adafruit_GFX (no subclass overrides) void drawCircle(int16_t x0, int16_t y0, int16_t r, uint16_t color), drawCircleHelper(int16_t x0, int16_t y0, int16_t r, uint8_t cornername, uint16_t color), fillCircle(int16_t x0, int16_t y0, int16_t r, uint16_t color), fillCircleHelper(int16_t x0, int16_t y0, int16_t r, uint8_t cornername, int16_t delta, uint16_t color), drawTriangle(int16_t x0, int16_t y0, int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint16_t color), fillTriangle(int16_t x0, int16_t y0, int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint16_t color), drawRoundRect(int16_t x0, int16_t y0, int16_t w, int16_t h, int16_t radius, uint16_t color), fillRoundRect(int16_t x0, int16_t y0, int16_t w, int16_t h, int16_t radius, uint16_t color), drawBitmap(int16_t x, int16_t y, const uint8_t *bitmap, int16_t w, int16_t h, uint16_t color), drawBitmap(int16_t x, int16_t y, const uint8_t *bitmap, int16_t w, int16_t h, uint16_t color, uint16_t bg), drawXBitmap(int16_t x, int16_t y, const uint8_t *bitmap, int16_t w, int16_t h, uint16_t color), drawChar(int16_t x, int16_t y, unsigned char c, uint16_t color, uint16_t bg, uint8_t size), setCursor(int16_t x, int16_t y), setTextColor(uint16_t c), setTextColor(uint16_t c, uint16_t bg), setTextSize(uint8_t s), setTextWrap(boolean w), setRotation(uint8_t r); #if ARDUINO >= 100 virtual size_t write(uint8_t); #else virtual void write(uint8_t); #endif int16_t height(void) const; int16_t width(void) const; uint8_t getRotation(void) const; protected: const int16_t WIDTH, HEIGHT; // This is the 'raw' display w/h - never changes int16_t _width, _height, // Display w/h as modified by current rotation cursor_x, cursor_y; uint16_t textcolor, textbgcolor; uint8_t textsize, rotation; boolean wrap; // If set, 'wrap' text at right edge of display }; #endif // _ADAFRUIT_GFX_Hбиблеотека SWTFT.h
#ifndef _SWTFT_H_ #define _SWTFT_H_ #if ARDUINO >= 100 #include "Arduino.h" #else #include "WProgram.h" #endif #include <Adafruit_GFX.h> class SWTFT : public Adafruit_GFX { public: SWTFT(void); // SWTFT(void); void begin(uint16_t id = 0x9325); void drawPixel(int16_t x, int16_t y, uint16_t color); ///////////////////////////////////////// void writeA16B3(uint16_t address, uint8_t ub, uint8_t mb, uint8_t lb); void drawPixel3(int16_t x, int16_t y, uint8_t r, uint8_t g, uint8_t b); void drawLine3Byte(int16_t x0, int16_t y0, int16_t x1, int16_t y1, uint8_t r, uint8_t g, uint8_t b) ; ////////////////////////////////////////// void drawFastHLine(int16_t x0, int16_t y0, int16_t w, uint16_t color); void drawFastVLine(int16_t x0, int16_t y0, int16_t h, uint16_t color); void fillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t c); void fillScreen(uint16_t color); void reset(void); void setRegisters8(uint8_t *ptr, uint8_t n); void setRegisters16(uint16_t *ptr, uint8_t n); void setRotation(uint8_t x); // These methods are public in order for BMP examples to work: void setAddrWindow(int x1, int y1, int x2, int y2); void pushColors(uint16_t *data, uint8_t len, boolean first); uint16_t color565(uint8_t r, uint8_t g, uint8_t b), readPixel(int16_t x, int16_t y), readID(void); private: void init(), // These items may have previously been defined as macros // If not, function versions are declared: #ifndef write8 write8(uint8_t value), #endif #ifndef setWriteDir setWriteDir(void), #endif #ifndef setReadDir setReadDir(void), #endif #ifndef writeRegister8 writeRegister8(uint8_t a, uint8_t d), #endif #ifndef writeRegister16 writeRegister16(uint16_t a, uint16_t d), #endif #ifndef writeRegisterPair writeRegisterPair(uint8_t aH, uint8_t aL, uint16_t d), #endif setLR(void), flood(uint16_t color, uint32_t len); uint8_t driver; #ifndef read8 uint8_t read8fn(void); #define read8isFunctionalized #endif #ifndef USE_ADAFRUIT_SHIELD_PINOUT #ifdef __AVR__ volatile uint8_t *csPort , *cdPort , *wrPort , *rdPort; uint8_t csPinSet , cdPinSet , wrPinSet , rdPinSet , csPinUnset, cdPinUnset, wrPinUnset, rdPinUnset, _reset; #endif #if defined(__SAM3X8E__) Pio *csPort , *cdPort , *wrPort , *rdPort; uint32_t csPinSet , cdPinSet , wrPinSet , rdPinSet , csPinUnset, cdPinUnset, wrPinUnset, rdPinUnset, _reset; #endif #endif }; // For compatibility with sketches written for older versions of library. // Color function name was changed to 'color565' for parity with 2.2" LCD // library. #define Color565 color565 #endif //_SWTFT_H_так вот библеотеки где тут чото поменять?
библеотека Adafruit_GFX.h
библеотека SWTFT.h
так вот библеотеки где тут чото поменять?
Нужно ковырять файлы *.cpp данных библиотек, скорее всего функцию drawPixel().
Вот SWTFT.cpp
На верно надо в нести изменения 270,271 строку?
Вот SWTFT.cpp
На верно надо в нести изменения 270,271 строку?
Я бы попробовал внести изменения в функцию drawPixel() (строка 445) - она является основной при рисовании графических объектов.
Узнаем контроллер экрана, читаем его мануал, там много тонких настроек в т.ч. и порядка сканирования экрана, повороты - один из них. Вооружившись знаниями лезем в либу смотрим, есть ли работа с требуемыми настройками. Если есть - юзаем, иначе - дописываем. Этот путь сложный, но верный т.к. окромя результата дает вам знания. Пути попроще - купить новый экран, может повезет, перебрать либы их дочертиков, поныть на форуме и т.д. Выбирайте вобщем,
проще экран -> в ведро и пойти пиво пить.
http://arduino.ru/forum/apparatnye-voprosy/arduino-i-displei-ot-sotikov-...