Uruchomienie wyświetlacza graficznego

Pytania, kody i porady dotyczące nie tylko Bascom.
Awatar użytkownika
pimowo
Posty: 392
Rejestracja: 28 maja 2016, 10:07

Uruchomienie wyświetlacza graficznego

Post autor: pimowo » 24 kwie 2018, 15:25

Hej,
Potrzebuję pomocy w uruchomieniu wyświetlacza graficznego.
Wyświetlacz nie ma żadnego opisu na PCB co to dokładnie jest (2.4 TFT LCD SHIELD) ale co ustaliłem:
a) nakładka na Arduino UNO
b) 2,4"
c) 240x320 pikseli
d) prawdopodobnie sterownik SPFD5408
e) gniazdo karty SD (dla mnie zbędne)
f) nakładka dotykowa (dla mnie zbędne)

Co chciałbym uzyskać:
a) uruchomienie na ATmega328 (płytka klon Arduino UNO)
b) wyświetlanie tekstu
- wyświetlacz ma być pionowo
- 10 linii tekstu
- kolorowa czcionka może, ale nie musi być

Wymyśliłem sobie, że najlepiej byłoby użyć czcionki 16x32 (z czcionką sobie poradzę dzięki tematowi FontMaker for BASCOM) i będę miał 15 znaków w 10 kolumnach
Gdyby to wszystko się udało to byłoby idealnie :)

Buszuję w Internecie, ale nie mogę nic znaleźć ciekawego, a znów sam nie dam rady bo zbyt cienki jestem w uszach, aby to zrobić.

Z góry dziękuję za pomoc.
Piotrek
Nie masz wymaganych uprawnień, aby zobaczyć pliki załączone do tego posta.
Awatar użytkownika
niveasoft
Posty: 1216
Rejestracja: 17 sie 2015, 12:13
Kontakt:

Re: Uruchomienie wyświetlacza graficznego

Post autor: niveasoft » 24 kwie 2018, 15:55

Wpisałem na MCS w wyszukiwarkę frazę "SPFD5408" i tam są trzy tematy które prowadzą też do innych tematów oraz zdjęcie tego modułu.
Poczytaj a jak już coś więcej ustalisz to daj znać :P
Awatar użytkownika
pimowo
Posty: 392
Rejestracja: 28 maja 2016, 10:07

Re: Uruchomienie wyświetlacza graficznego

Post autor: pimowo » 24 kwie 2018, 17:34

Na forum MCS oczywiście byłem przed napisaniem tematu, ale coś nie bardzo wiem jak to wszystko ugryźć :(
OK, szukam dalej...
Awatar użytkownika
pimowo
Posty: 392
Rejestracja: 28 maja 2016, 10:07

Re: Uruchomienie wyświetlacza graficznego

Post autor: pimowo » 25 kwie 2018, 10:45

Na stronie gotronik.pl wygrzebałem identyczny wyświetlacz jak mój, a tam w opisie jest:
wyświetlacz graficzny LCD TFT
ekran dotykowy rezystancyjny
sterownik: ST7781
przekątna ekranu: 2,4 cala
rozdzielczość: 240x320
poziomy napięć: 3.3V / 5,0V
interfejs równoległy
liczba kolorów: 18 bit (262,000)
przeznaczenie: jako LCD Shield dla Arduino
gniazdo na kartę SD
przycisk RESET
wymiary: 71 x 52 x 7 mm

Czyli sterownik ST7781
Awatar użytkownika
pimowo
Posty: 392
Rejestracja: 28 maja 2016, 10:07

Re: Uruchomienie wyświetlacza graficznego

Post autor: pimowo » 25 kwie 2018, 13:21

Znalazłem kod dla Arduino UNO:
  1. // Simple Test Sketch for Arduino UNO & 2.4" LCD TFT 320x240 Shield from Banggood.com
  2. // SKU156315 Using the ILITEK ILI9341 or Samsung S6D04H0X Driver Chip(Almost identical chips!)
  3. // 240x320 Resolution RGB and 262K Colors.
  4. // Modified Sketch for UNO by KB1UIF(A.Tedds)
  5. // Based on the new v2 simple UNO test sketch from Banggood.com.
  6. // Various errors were in the Banggood release, which I have corrected.
  7. // I have also added more functions and lots of comments.
  8. // Use at your own risk!!
  9.  
  10. // Arduino UNO pin usage:
  11. // LCD Data Bits :   7   6   5   4   3   2   1   0
  12. // Uno dig. pins :   7   6   5   4   3   2   9   8
  13. // Uno port/pins :  PD7 PD6 PD5 PD4 PD3 PD2 PB1 PB0
  14.  
  15. // Color maping HIGH 5Bits 00000 BLUE, middle 5Bits 00000 GREEN, Low 6 Bits 000000 RED.
  16. // 0000 0,00 0 00,00 0000
  17.  
  18. // With MADCTL set to 0x40, Original Value 48, For RGB-BGR Flip D3.
  19. #define WHITE 0x0000
  20. #define RED 0xFFC0
  21. #define GREEN 0xF81F
  22. #define BLUE 0x07FF
  23. #define CYAN 0x003F
  24. #define MAGENTA 0x07C0
  25. #define YELLOW 0xF800
  26. #define BLACK 0xFFFF
  27.  
  28. //Define TFT LCD Size
  29. #define TFTWIDTH   240
  30. #define TFTHEIGHT  320
  31.  
  32. #define LCD_RD   A0 //Define A0 as LCD_RD (Read)
  33. #define LCD_WR   A1 //Define A1 as LCD_WR (Write)    
  34. #define LCD_RS   A2 //Define A2 as LCD_RS (0=Command/1=Data)      
  35. #define LCD_CS   A3 //Define A3 as LCD_CS (Chip Select)    
  36. #define LCD_RST  A4 //Define A4 as LCD_RST (Shield Reset, NOT to the Reset Button)
  37.  
  38. //-------------------------------------------------------------------------------------------
  39. void Lcd_Writ_Bus(unsigned char d)
  40. {
  41.   //Clear port D relevent bits then AND input (d) with Mask (bits 0-1) for port D out (6 data bits 2-7).
  42.   PORTD = (PORTD & B00000011) | ((d) & B11111100);
  43.   //Clear port B relevent bits then AND input (d) with Mask (bits 2-7) for port B out (2 data bits 0-1).
  44.   PORTB = (PORTB & B11111100) | ((d) & B00000011);
  45.   //Now strobe the LCD shield write control line LCD_WR (A1).
  46.   *(portOutputRegister(digitalPinToPort(LCD_WR))) &=  ~digitalPinToBitMask(LCD_WR);//LCD_WR=0
  47.   *(portOutputRegister(digitalPinToPort(LCD_WR))) |=  digitalPinToBitMask(LCD_WR); //LCD_WR=1
  48. }
  49.  
  50. //-------------------------------------------------------------------------------------------
  51. void Lcd_Write_Com(unsigned char VH)
  52. {
  53.   *(portOutputRegister(digitalPinToPort(LCD_RS))) &=  ~digitalPinToBitMask(LCD_RS);//LCD_RS=0 (Set Control line for Command)
  54.   Lcd_Writ_Bus(VH);//Write Hex Value of COM Register passed to Lcd_Write_Com.
  55. }
  56.  
  57. //-------------------------------------------------------------------------------------------
  58. void Lcd_Write_Data(unsigned char VH)
  59. {
  60.   *(portOutputRegister(digitalPinToPort(LCD_RS))) |=  digitalPinToBitMask(LCD_RS); //LCD_RS=1 (Set control line for Data)
  61.   Lcd_Writ_Bus(VH);//Write Hex Value of Data passed to Lcd_Write_Data.
  62. }
  63. //-------------------------------------------------------------------------------------------
  64. void Lcd_Write_Com_Data(unsigned char com, unsigned char dat)
  65. {
  66.   Lcd_Write_Com(com);//Write Hex Value of COM Register passed to Lcd_Write_Com_Data.
  67.   Lcd_Write_Data(dat);//Write Hex Value of Data passed to Lcd_Write_Com_Data.
  68. }
  69. //-------------------------------------------------------------------------------------------
  70. void Address_set(unsigned int x1, unsigned int y1, unsigned int x2, unsigned int y2)
  71. {
  72.   Lcd_Write_Com(0x2a);//REG 2Ah=COLADDRSET Command 4 Values.
  73.   Lcd_Write_Data(x1 >> 8); //Send Value of x1 with right bit shift x8.
  74.   Lcd_Write_Data(x1);//Send Value of x1.
  75.   Lcd_Write_Data(x2 >> 8); //Send Value of x2 with right bit shift x8.
  76.   Lcd_Write_Data(x2);//Send Value of x2.
  77.  
  78.   Lcd_Write_Com(0x2b);//REG 2Bh=PAGEADDRSET Command 4 Values.
  79.   Lcd_Write_Data(y1 >> 8); //Send Value of y1 with right bit shift x8.
  80.   Lcd_Write_Data(y1);//Send Value of y1.
  81.   Lcd_Write_Data(y2 >> 8); //Send Value of y2 with right bit shift x8.
  82.   Lcd_Write_Data(y2);//Send Value of y2.
  83.  
  84.   Lcd_Write_Com(0x2c); // REG 2Ch = Memory Write
  85. }
  86.  
  87. //-------------------------------------------------------------------------------------------
  88. //Init commands for Shield.
  89. void Lcd_Init(void)
  90. {
  91.   digitalWrite(LCD_RST, HIGH); // Take line HIGH.
  92.   delay(5); //delay of 5mS.
  93.   digitalWrite(LCD_RST, LOW); //Take line LOW to Reset Shield, Active LOW.
  94.   delay(15);//delay of 15mS.
  95.   digitalWrite(LCD_RST, HIGH); //Take Line HIGH allow Shield to function.
  96.   delay(15);//delay of 15mS.
  97.  
  98.   digitalWrite(LCD_CS, HIGH); //Take Chip Select HIGH, Disable Shield Chip, Active LOW.
  99.   digitalWrite(LCD_WR, HIGH); //Take Write line HIGH.
  100.   digitalWrite(LCD_CS, LOW); //Take Chip Select LOW, Enable Shield Chip, Active LOW.
  101.  
  102.   Lcd_Write_Com(0xC0);    //Power control 1
  103.   Lcd_Write_Data(0x23);   //VRH[5:0] 0010 0011 4.60 Volts, default is 4.50 Volts.
  104.  
  105.   Lcd_Write_Com(0xC1);    //Power control 2, Sets the factor used in the step-up circuits
  106.   Lcd_Write_Data(0x10);   //BT[2:0] 0001 0000 default is 10
  107.  
  108.   Lcd_Write_Com(0xC5);    //C5h VCOM control 1 (Contrast?)
  109.   Lcd_Write_Data(0x3e);   //VMH 0011 1110 +4.250 Volts
  110.   Lcd_Write_Data(0x28);   //VML 0010 1000 -1.500 Volts
  111.  
  112.   Lcd_Write_Com(0xC7);    //C7h VCOM control2 Set the VCOM offset voltage.
  113.   Lcd_Write_Data(0x86);   //1000 0110 VML=58 VMH=58
  114.  
  115.   Lcd_Write_Com(0x36);    //MADCTL, Memory Access Control.
  116.   Lcd_Write_Data(0x40);   //Original Value 48, For RGB-BGR Flip D3 40h
  117.  
  118.   Lcd_Write_Com(0x3A);    //COLMOD (Interface Pixel Format)
  119.   Lcd_Write_Data(0x55);   //RGB Interface, Color Format 16Bit,Control Interface Color Format 16bit.
  120.  
  121.   Lcd_Write_Com(0xB1);    //B1h, Frame Rate Control.
  122.   Lcd_Write_Data(0x00);   //[1:0] DIVA division ratio 00 = fosc
  123.   Lcd_Write_Data(0x18);   //[4:0] RTNA Frame Rate 18h 0001 1000 = 79Hz
  124.  
  125.   Lcd_Write_Com(0xB6);    //B6h Display Function Control.
  126.   Lcd_Write_Data(0x08);   //08h PTG [3:2] & PT [1:0] 0000 1000
  127.   //PTG [3:2]: Set the scan mode in non-display area.
  128.   //PT [1:0]: Determine source/VCOM output in a non-display area in the partial display mode.
  129.   Lcd_Write_Data(0x82);   //1000 0010 REV[D7] GS[D6] SS[D5] SM[D4] ISC[3:0]=5Frames 85mS.
  130.   Lcd_Write_Data(0x27);   //0010 0111 NL[5:0]
  131.  
  132.   Lcd_Write_Com(0x11);    //Wake, Exit Sleep.
  133.   delay(120);             //120mS Delay to allow shield to settle.
  134.  
  135.   Lcd_Write_Com(0x29);    //Display on.
  136.  
  137.   Lcd_Write_Com(0x2c);    //Memory Write.
  138. }
  139. //-------------------------------------------------------------------------------------------
  140. void invertColor()
  141. {
  142.   Lcd_Write_Com(0x21); //Invert Colors.
  143. }
  144. //-------------------------------------------------------------------------------------------
  145. void normalColor()
  146. {
  147.   Lcd_Write_Com(0x20); //Normal Colors.
  148. }
  149. //-------------------------------------------------------------------------------------------
  150. void blink(int Times, int DL) //invert colors #Times, DL delay between each.
  151. {
  152.   for (int t = 1; t <= Times; ++t)
  153.   {
  154.     Lcd_Write_Com(0x21); //Invert
  155.     delay(DL);           //DL delay between inversion and normal.
  156.     Lcd_Write_Com(0x20); //Normal
  157.     delay(DL);           //DL delay between normal and inversion.
  158.   }
  159. }
  160. //-------------------------------------------------------------------------------------------
  161. void drawCircle(int x, int y, int radius, unsigned color)
  162. {
  163.   int f = 1 - radius;
  164.   int ddF_x = 1;
  165.   int ddF_y = -2 * radius;
  166.   int x1 = 0;
  167.   int y1 = radius;
  168.  
  169.   digitalWrite(LCD_CS, LOW);//Chip Select Active.
  170.   Address_set(x, y + radius, x, y + radius);
  171.   Lcd_Write_Com(0x2C);
  172.   Lcd_Write_Data(color >> 8);
  173.   Lcd_Write_Data(color);
  174.   Address_set(x, y - radius, x, y - radius);
  175.   Lcd_Write_Com(0x2C);
  176.   Lcd_Write_Data(color >> 8);
  177.   Lcd_Write_Data(color);
  178.   Address_set(x + radius, y, x + radius, y);
  179.   Lcd_Write_Com(0x2C);
  180.   Lcd_Write_Data(color >> 8);
  181.   Lcd_Write_Data(color);
  182.   Address_set(x - radius, y, x - radius, y);
  183.   Lcd_Write_Com(0x2C);
  184.   Lcd_Write_Data(color >> 8);
  185.   Lcd_Write_Data(color);
  186.  
  187.   while (x1 < y1)
  188.   {
  189.     if (f >= 0)
  190.     {
  191.       y1--;
  192.       ddF_y += 2;
  193.       f += ddF_y;
  194.     }
  195.     x1++;
  196.     ddF_x += 2;
  197.     f += ddF_x;
  198.     Address_set(x + x1, y + y1, x + x1, y + y1);
  199.     Lcd_Write_Com(0x2C);
  200.     Lcd_Write_Data(color >> 8);
  201.     Lcd_Write_Data(color);
  202.     Address_set(x - x1, y + y1, x - x1, y + y1);
  203.     Lcd_Write_Com(0x2C);
  204.     Lcd_Write_Data(color >> 8);
  205.     Lcd_Write_Data(color);
  206.     Address_set(x + x1, y - y1, x + x1, y - y1);
  207.     Lcd_Write_Com(0x2C);
  208.     Lcd_Write_Data(color >> 8);
  209.     Lcd_Write_Data(color);
  210.     Address_set(x - x1, y - y1, x - x1, y - y1);
  211.     Lcd_Write_Com(0x2C);
  212.     Lcd_Write_Data(color >> 8);
  213.     Lcd_Write_Data(color);
  214.     Address_set(x + y1, y + x1, x + y1, y + x1);
  215.     Lcd_Write_Com(0x2C);
  216.     Lcd_Write_Data(color >> 8);
  217.     Lcd_Write_Data(color);
  218.     Address_set(x - y1, y + x1, x - y1, y + x1);
  219.     Lcd_Write_Com(0x2C);
  220.     Lcd_Write_Data(color >> 8);
  221.     Lcd_Write_Data(color);
  222.     Address_set(x + y1, y - x1, x + y1, y - x1);
  223.     Lcd_Write_Com(0x2C);
  224.     Lcd_Write_Data(color >> 8);
  225.     Lcd_Write_Data(color);
  226.     Address_set(x - y1, y - x1, x - y1, y - x1);
  227.     Lcd_Write_Com(0x2C);
  228.     Lcd_Write_Data(color >> 8);
  229.     Lcd_Write_Data(color);
  230.   }
  231. }
  232. //-------------------------------------------------------------------------------------------
  233. void drawPixel(unsigned int x, unsigned int y, unsigned int color)
  234. {
  235.   //Check for values falling in display area.
  236.   if ((x < 0) || (y < 0) || (x >= TFTWIDTH) || (y >= TFTHEIGHT)) return;
  237.  
  238.   digitalWrite(LCD_CS, LOW);// Chip Select active
  239.   Address_set(x, y, TFTWIDTH - 1, TFTHEIGHT - 1);
  240.   digitalWrite(LCD_CS, LOW);// Chip Select active
  241.   Lcd_Write_Com(0x2C);
  242.   Lcd_Write_Data(color >> 8);
  243.   Lcd_Write_Data(color);
  244. }
  245. //-------------------------------------------------------------------------------------------
  246. void drawLine(unsigned int x1, unsigned int y1, unsigned int x2, unsigned int y2, unsigned int color)
  247. {
  248.   unsigned int  dx = (x2 > x1 ? x2 - x1 : x1 - x2);
  249.   short     xstep =  x2 > x1 ? 1 : -1;
  250.   unsigned int  dy = (y2 > y1 ? y2 - y1 : y1 - y2);
  251.   short     ystep =  y2 > y1 ? 1 : -1;
  252.   int       col = x1, row = y1;
  253.  
  254.   digitalWrite(LCD_CS, LOW);
  255.   if (dx < dy)
  256.   {
  257.     int t = - (dy >> 1);
  258.     while (true)
  259.     {
  260.       Address_set (col, row, col, row);
  261.       Lcd_Write_Com(0x2C);
  262.       Lcd_Write_Data(color >> 8);
  263.       Lcd_Write_Data(color);
  264.       if (row == y2)
  265.         return;
  266.       row += ystep;
  267.       t += dx;
  268.       if (t >= 0)
  269.       {
  270.         col += xstep;
  271.         t   -= dy;
  272.       }
  273.     }
  274.   }
  275.   else
  276.   {
  277.     int t = - (dx >> 1);
  278.     while (true)
  279.     {
  280.       Address_set (col, row, col, row);
  281.       Lcd_Write_Com(0x2C);
  282.       Lcd_Write_Data(color >> 8);
  283.       Lcd_Write_Data(color);
  284.       if (col == x2)
  285.         return;
  286.       col += xstep;
  287.       t += dy;
  288.       if (t >= 0)
  289.       {
  290.         row += ystep;
  291.         t   -= dx;
  292.       }
  293.     }
  294.   }
  295. }
  296. //-------------------------------------------------------------------------------------------
  297. void drawTriangle(unsigned x0, unsigned y0, unsigned x1, unsigned y1, unsigned x2, unsigned y2, uint16_t color)
  298. {
  299.   drawLine(x0, y0, x1, y1, color);
  300.   drawLine(x1, y1, x2, y2, color);
  301.   drawLine(x2, y2, x0, y0, color);
  302. }
  303.  
  304. //-------------------------------------------------------------------------------------------
  305. void H_line(unsigned int x, unsigned int y, unsigned int l, unsigned int c)
  306. {
  307.   unsigned int i, j;
  308.   Lcd_Write_Com(0x02c); //write_memory_start
  309.   digitalWrite(LCD_RS, HIGH);
  310.   digitalWrite(LCD_CS, LOW);
  311.   l = l + x;
  312.   Address_set(x, y, l, y);
  313.   j = l * 2;
  314.   for (i = 1; i <= j; i++)
  315.   {
  316.     Lcd_Write_Data(c);
  317.   }
  318. }
  319. //-------------------------------------------------------------------------------------------
  320. void V_line(unsigned int x, unsigned int y, unsigned int l, unsigned int c)
  321. {
  322.   unsigned int i, j;
  323.   Lcd_Write_Com(0x02c); //write_memory_start
  324.   digitalWrite(LCD_RS, HIGH);
  325.   digitalWrite(LCD_CS, LOW);
  326.   l = l + y;
  327.   Address_set(x, y, x, l);
  328.   j = l * 2;
  329.   for (i = 1; i <= j; i++)
  330.   {
  331.     Lcd_Write_Data(c);
  332.   }
  333. }
  334. //-------------------------------------------------------------------------------------------
  335. //Draw Rectangle.
  336. void Rect(unsigned int x, unsigned int y, unsigned int w, unsigned int h, unsigned int c)
  337. {
  338.   H_line(x  , y  , w, c);
  339.   H_line(x  , y + h, w, c);
  340.   V_line(x  , y  , h, c);
  341.   V_line(x + w, y  , h, c);
  342. }
  343. //-------------------------------------------------------------------------------------------
  344. //Draw Filled Rectangle.
  345. void Rectf(unsigned int x, unsigned int y, unsigned int w, unsigned int h, unsigned int c)
  346. {
  347.   unsigned int i;
  348.   for (i = 0; i < h; i++)
  349.   {
  350.     H_line(x  , y  , w, c);
  351.     H_line(x  , y + i, w, c);
  352.   }
  353. }
  354. //-------------------------------------------------------------------------------------------
  355. int RGB(int r, int g, int b)
  356. {
  357.   return r << 16 | g << 8 | b;
  358. }
  359. //-------------------------------------------------------------------------------------------
  360. //Fill Screen with color j
  361. void LCD_Clear(unsigned int j)
  362. {
  363.   unsigned int i, m;
  364.   Address_set(0, 0, 239, 319);
  365.   digitalWrite(LCD_CS, LOW); //Chip Select Active.
  366.  
  367.   for (i = 0; i < 240; i++)
  368.     for (m = 0; m < 320; m++)
  369.     {
  370.       Lcd_Write_Data(j >> 8);
  371.       Lcd_Write_Data(j);
  372.     }
  373. }
  374. //-------------------------------------------------------------------------------------------
  375. void setup()
  376. {
  377.   for (int p = 2; p < 10; p++)
  378.   {
  379.     pinMode(p, OUTPUT); //Set Pins 2-9 as Output.
  380.   }
  381.   pinMode(A0, OUTPUT); //Set A0 as Output for LCD_RD (Read)
  382.   pinMode(A1, OUTPUT); //Set A1 as Output for LCD_WR (Write)
  383.   pinMode(A2, OUTPUT); //Set A2 as Output for LCD_RS (0=Command/1=Data)
  384.   pinMode(A3, OUTPUT); //Set A3 as Output for LCD_CS (Chip Select, Active LOW)
  385.   pinMode(A4, OUTPUT); //Set A4 as Output for LCD_RST (Soft Reset, Active LOW)
  386.   digitalWrite(A0, HIGH);//Set idle State for LCD_RD.
  387.   digitalWrite(A1, HIGH);//Set Idle State for LCD_WR.
  388.   digitalWrite(A2, HIGH);//Set input as Data for LCD_RS (0=Command/1=Data)
  389.   digitalWrite(A3, HIGH);//Set Idle State for LCD_CS Active LOW.
  390.   digitalWrite(A4, HIGH);//Set Idle State for LCD_RST Soft Reset active LOW.
  391.  
  392.   Lcd_Init();// Run Init LCD Shield Routine.
  393.  
  394.   LCD_Clear(BLACK);//Clear Screen to Black.
  395. }
  396. //-------------------------------------------------------------------------------------------
  397. void loop()
  398. {
  399.   //LCD_Clear(BLACK);
  400.   LCD_Clear(WHITE);//Clear Screen to White
  401.   delay(1000);
  402.   invertColor();
  403.   delay(1000);
  404.   normalColor();
  405.   LCD_Clear(WHITE);//Clear Screen to White
  406.   blink(1, 200); //Blink 1 times with 200mS Delay between.
  407.   LCD_Clear(RED);//Clear Screen to Red
  408.   blink(1, 200);
  409.   LCD_Clear(GREEN);//Clear Screen to Green
  410.   blink(1, 200);
  411.   LCD_Clear(BLUE);//Clear Screen to Blue
  412.   blink(1, 200);
  413.   LCD_Clear(YELLOW);//Clear Screen to Yellow
  414.   blink(1, 200);
  415.   LCD_Clear(MAGENTA);//Clear Screen to Magenta
  416.   blink(1, 200);
  417.   LCD_Clear(CYAN);//Clear Screen to Cyan
  418.   blink(1, 200);
  419.   LCD_Clear(BLACK);//Clear Screen to Black
  420.   blink(1, 200);
  421.   LCD_Clear(BLACK);//Clear Screen to Black
  422.   //Draw 50 random size, random position, random color triangles.
  423.   for (int i = 0; i < 50; i++)
  424.   {
  425.     drawTriangle(random(239), random(319), random(239), random(319), random(239), random(319), random(65535)); //drawTriangle(x0,y0,x1,y1,x2,y2,Color);
  426.   }
  427.   delay(2000);
  428.   blink(3, 500);
  429.   //Draw 200 random size, random position, random color Lines.
  430.   LCD_Clear(BLACK);//Clear Screen to Black
  431.   for (int i = 0; i < 200; i++)
  432.   {
  433.     drawLine(random(240), random(320), random(240), random(320), random(65535)); // Lines at x, y, x1, y1, color.
  434.   }
  435.   delay(2000);//Delay of 2 Sec.
  436.   blink(3, 500); //Blink 5 times with 100mS Delay between.
  437.   LCD_Clear(BLACK);//Clear Screen to Black
  438.   //Draw 10000 random position and random color dots.
  439.   for (int i = 0; i < 10000; i++)
  440.   {
  441.     drawPixel(random(239), random(319), random(65535)); // Pixels at x, y, color.
  442.   }
  443.   delay(2000);//Delay of 2 Sec.
  444.   blink(3, 500); //Blink 5 times with 100mS Delay between.
  445.   LCD_Clear(BLACK);//Clear Screen to Black
  446.   //Draw 100 random size, random position and random color rectangles.
  447.   for (int i = 0; i < 100; i++)
  448.   {
  449.     Rect(random(120), random(160), random(120), random(160), random(65535)); // rectangle at x, y, width, hight, color.
  450.   }
  451.   delay(2000);//Delay of 2 Sec.
  452.   blink(3, 500); //Blink 5 times with 100mS Delay between.
  453.   LCD_Clear(BLACK);//Clear Screen to Black
  454.   //Draw 100 random size, random color circles about the x, y, position, Center of screen in this example.
  455.   for (int i = 0; i < 100; i++)
  456.   {
  457.     drawCircle(120, 160, random(120), random(65535)); // circles at x, y, radius, color.
  458.   }
  459.   delay(2000);//Delay of 2 Sec.
  460.   blink(3, 500); //Blink 5 times with 100mS Delay between.
  461.   LCD_Clear(BLACK);//Clear Screen to Black
  462.   //Draw 30 random size, random position and random color filled rectangles.
  463.   for (int i = 0; i < 30; i++)
  464.   {
  465.     Rectf(random(120), random(160), random(120), random(160), random(65535)); // Filled Rectangle at x, y, width, hight, color.
  466.   }
  467.   delay(2000);//Delay of 2 Sec.
  468.   blink(3, 500); //Blink 5 times with 100mS Delay between.
  469.   LCD_Clear(BLACK);//Clear Screen to Black
  470.   //while(true);//Stop Sketch Here if required.
  471. }
  472. //-------------------------------------------------------------------------------------------
  473. //End of Sketch.
Wyświetlacz ruszył, rysuje kreski, koła etc :D
Wszystko fajnie, ale mnie nie interesuje Arduino, no i te wszystkie ślaczki niewiele mi mówią :(
Awatar użytkownika
niveasoft
Posty: 1216
Rejestracja: 17 sie 2015, 12:13
Kontakt:

Re: Uruchomienie wyświetlacza graficznego

Post autor: niveasoft » 25 kwie 2018, 13:30

No i jak poczytasz to już pisze ILI9341 i to możesz zassać na MCS tylko ustaw 8bit o ile się nie mylę bo jest też 16bit (wtedy potrzebne dwa porty DATA i trzeci na CONTROL).
Awatar użytkownika
pimowo
Posty: 392
Rejestracja: 28 maja 2016, 10:07

Re: Uruchomienie wyświetlacza graficznego

Post autor: pimowo » 25 kwie 2018, 15:22

Coraz bliżej do celu :)

Teraz mam mały problem z podłączeniem LCD do Arduino UNO.
W plikach które zassałem z MCS mam coś takiego:
  1. Config Portc = Output
  2. Data_disp_low Alias Portc                                   'DB0 --> DB7
  3.  
  4.  
  5. Rs_disp Alias Portd.7                                       'Display DC
  6. Cs_disp Alias Portg.1                                       'Display CS
  7. Res_disp Alias Portg.0                                      'Display Reset
  8.  
  9. Wr_disp Alias Portg.2                                       'Display WR
  10. Port_wr Alias Portg                                         'WR Port
  11. Const Wrpin = 2                                             'WR Pin Nr
  12. 'RD Pin pull it high to 3,3V                 RD Pin vom Display fest auf 3,3V legen
  13.  
  14. Config Rs_disp = Output
  15. Config Cs_disp = Output
  16. Config Wr_disp = Output
  17. Config Res_disp = Output
  18.  
  19. Data_disp_low = &HFF
  20. Wr_disp = 1
  21. Cs_disp = 1
i jak to teraz ogarnąć?

U mnie wygląda to tak:
LCD - Arduino
LCD_RST - PC.4
LCD_CS - PC.3
LCD_RS - PC.2
LCD_WR - PC.1
LCD_RD - PC.0
LCD_D0 - PB.0
LCD_D1 - PB.1
LCD_D2 - PD.2
LCD_D3 - PD.3
LCD_D4 - PD.4
LCD_D5 - PD.5
LCD_D6 - PD.6
LCD_D7 - PD.7

Piny SD_x chyba w moim przypadku nie potrzebne jak nie chcę używać kart SD
Nie masz wymaganych uprawnień, aby zobaczyć pliki załączone do tego posta.
Awatar użytkownika
pimowo
Posty: 392
Rejestracja: 28 maja 2016, 10:07

Re: Uruchomienie wyświetlacza graficznego

Post autor: pimowo » 25 kwie 2018, 17:25

OK, podpoiłem LCD na kabelkach i podłączyłem tak:
LCD_RST - PC.3
LCD_CS - PC.2
LCD_RS - PC.1
LCD_WR - PC.0
LCD_RD - 3V3
LCD_D0 - PD.0
LCD_D1 - PD.1
LCD_D2 - PD.2
LCD_D3 - PD.3
LCD_D4 - PD.4
LCD_D5 - PD.5
LCD_D6 - PD.6
LCD_D7 - PD.7
  1. Config Portd = Output
  2. Data_disp_low Alias Portd                                   'DB0 --> DB7
  3.  
  4. Rs_disp Alias Portc.1                                       'Display DC
  5. Cs_disp Alias Portc.2                                       'Display CS
  6. Res_disp Alias Portc.3                                      'Display Reset
  7.  
  8. Wr_disp Alias Portc.0                                       'Display WR
  9. Port_wr Alias Portc                                         'WR Port
  10. Const Wrpin = 0                                             'WR Pin Nr
  11. 'RD Pin pull it high to 3,3V                 RD Pin vom Display fest auf 3,3V legen
  12.  
  13. Config Rs_disp = Output
  14. Config Cs_disp = Output
  15. Config Wr_disp = Output
  16. Config Res_disp = Output
  17.  
  18. Data_disp_low = &HFF
  19. Wr_disp = 1
  20. Cs_disp = 1
i po tym wszystkim otrzymuję:
.
Zrzut ekranu z 2018-04-25 17-23-36.png
Nie masz wymaganych uprawnień, aby zobaczyć pliki załączone do tego posta.
Awatar użytkownika
niveasoft
Posty: 1216
Rejestracja: 17 sie 2015, 12:13
Kontakt:

Re: Uruchomienie wyświetlacza graficznego

Post autor: niveasoft » 25 kwie 2018, 17:29

Może w przykładzie jest dużo obrazków bo ktoś używał czegoś większego niż 32K Flasha :P
Przejrzyj przykład i wywal obrazki typu BGC. Może jakiś ogromny Font?
Niestety. Mały flash to już potem dla obrazków używa się karty.
Awatar użytkownika
pimowo
Posty: 392
Rejestracja: 28 maja 2016, 10:07

Re: Uruchomienie wyświetlacza graficznego

Post autor: pimowo » 25 kwie 2018, 19:08

Oczywiście masz rację, zmyliło mnie to bootloader :D

Wyświetlacz już rysuje figury i takie tam, ale znów mam problem z tekstem, nie mogę nic wyświetlić :(
ODPOWIEDZ