aetius Posted Sunday at 09:26 AM Share Posted Sunday at 09:26 AM Buna ziua. As dori s-a construiesc swr-metru de aici... https://cloud.mail.ru/public/M1nc/nb9k12etY Dar nu stiu cum s-a procedez ,vad ca sunt biblioteci diferetie ,dar care ar fi bune pentru ILI9341 (am cateva bucati si le-as pune la treaba) ? Nu sunt mare specialist in programare dar pot citi si invata... #include "SPI.h" #include "TFT_22_ILI9225.h" #define TFT_RST 50 //50 вывод Mega2560 на RST ЖКИ #define TFT_RS 49 //49 вывод Mega2560 на RS ЖКИ #define TFT_CS 53 //53 вывод Mega2560 на CS ЖКИ #define TFT_SDI 51 //51 вывод Mega2560 на SDI ЖКИ #define TFT_CLK 52 //52 вывод Mega2560 на CLK ЖКИ #define TFT_LED 45 //45 вывод ШИМ для подсветки #define TFT_BRIGHTNESS 120 //инициализация яркости подсветки ЖКИ TFT_22_ILI9225 tft = TFT_22_ILI9225(TFT_RST, TFT_RS, TFT_CS, TFT_LED, TFT_BRIGHTNESS); //инициализация аппаратного SPI int a_old, b_old; void setup() { //***************************** Заставка ****************************** tft.setBacklight(0); //отключаем подсветку экрана tft.begin(); tft.clear(); //инициализация дисплея, очистка экрана, задержка 1000мс tft.setOrientation(1); //альбомная ориентация экрана } void loop() { int a=analogRead(A0)/25; //расчет переменной a int ReadR=analogRead(A0); int ReadG=analogRead(A0); int ReadB=analogRead(A0); int R,G,B; if (ReadB<=255) {ReadB=255; B=ReadB;} if (ReadB>512) {ReadB=0; B=ReadB;} if ((ReadB>255)&&(ReadB<=512)){B=map(ReadB,512,256,0,255);} if (ReadG<=255){G=map(ReadG,0,255,0,255);} if ((ReadG>255)&&(ReadG<=768)){ReadG=255; G=ReadG;} if (ReadG>768){G=map(ReadG,769,1023,255,0);} if (ReadR<512){ReadR=0; R=ReadR;} if ((ReadR>=512)&&(ReadR<=768)){R=map(ReadR,512,768,0,255);} if (ReadR>769){ReadR=255; R=ReadR;} if (a > a_old) { //если новое значение больше старого(движение градусника вправо) for(int i=a_old; i<a; i++){ //включаем цикл tft.fillRectangle(10+i*5,60,12+i*5,75,tft.setColor(R,G,B));} //рисуем градусник a_old=a;} //выравниваем старое и новое значение else { //иначе tft.fillRectangle(10+a*5,60,12+a_old*5,75,COLOR_BLACK); //стираем градусник при движении влево a_old=a;} //выравниваем старое и новое значение } Cred ca de aici s-ar incepe dar nu stiu ce s-a modific ? Multumesc de citire. Quote Link to comment Share on other sites More sharing options...
nico_2010 Posted Sunday at 05:54 PM Share Posted Sunday at 05:54 PM Incepe cu Adafruit library pentru ILI9341. Quote Link to comment Share on other sites More sharing options...
aetius Posted Sunday at 08:22 PM Author Share Posted Sunday at 08:22 PM (edited) Multumesc de raspuns.am modificat ce am stiut ... #include "Adafruit_GFX.h" #include "Adafruit_ILI9341.h" #include "SPI.h" #define TFT_CS 8 #define TFT_RST 9 #define TFT_DC 10 Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_RST); int a_old, b_old; void setup() { tft.begin(); tft.setRotation(3); // Depending on your display orientation, you might need to adjust this value. // Fill the screen with a background color tft.fillScreen(ILI9341_BLACK); } void loop() { int a=analogRead(A0)/25; int ReadR=analogRead(A0); int ReadG=analogRead(A0); int ReadB=analogRead(A0); int R,G,B; if (ReadB<=255) {ReadB=255; B=ReadB;} if (ReadB>512) {ReadB=0; B=ReadB;} if ((ReadB>255)&&(ReadB<=512)){B=map(ReadB,512,256,0,255);} if (ReadG<=255){G=map(ReadG,0,255,0,255);} if ((ReadG>255)&&(ReadG<=768)){ReadG=255; G=ReadG;} if (ReadG>768){G=map(ReadG,769,1023,255,0);} if (ReadR<512){ReadR=0; R=ReadR;} if ((ReadR>=512)&&(ReadR<=768)){R=map(ReadR,512,768,0,255);} if (ReadR>769){ReadR=255; R=ReadR;} if (a > a_old) { for(int i=a_old; i<a; i++){ tft.fillRect(10+i*5,60,12+i*5,75,ILI9341_RED);} //AM PUS CULOARE ROSIE ,NU AM STIUT CUM ALTFEL a_old=a;} else { tft.fillRect(10+a*5,60,12+a_old*5,75,ILI9341_BLACK); a_old=a;} } Nu am erori ,dar NU am obtinut ce este in poza...(Vreo 2 exemple cat am incercat de la adafruit merg pe ili9341) Am obtinut ce este mai jos in imagine... Edited Sunday at 08:23 PM by aetius Quote Link to comment Share on other sites More sharing options...
nico_2010 Posted Monday at 06:14 AM Share Posted Monday at 06:14 AM Foloseste urmatoarele: #include "Adafruit_SPITFT.h" Si in loc de: //Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_RST); // in loc de ce este scris folosesti asta: Adafruit_SPITFT tft = Adafruit_SPITFT(30, 240, TFT_CS, TFT_DC, TFT_MOSI, TFT_SCLK, TFT_RST); tft.fillRect(10+i*5,60,12+i*5,75,ILI9341_RED);} //AM PUS CULOARE ROSIE ,NU AM STIUT CUM ALTFEL a_old=a;} scrie : tft.fillRect(10+i*5,60,12+i*5,75,tft.color565);} a_old=a;} TFT_MOSI si TFT_SCLK trebuie sa le definesti tu, conform conexiunilor cu placa Arduino. Quote Link to comment Share on other sites More sharing options...
aetius Posted Monday at 07:18 AM Author Share Posted Monday at 07:18 AM Am eroarea asta la final (lista este mai lunga). Compilation error: invalid cast to abstract class type 'Adafruit_SPITFT' Quote Link to comment Share on other sites More sharing options...
nico_2010 Posted Monday at 08:38 AM Share Posted Monday at 08:38 AM #include <Adafruit_GFX.h> #include <Adafruit_SPITFT.h> #include <Adafruit_SPITFT_Macros.h> #include <gfxfont.h> #include <Adafruit_ILI9341.h> #define TFT_CS 8 #define TFT_RST 9 #define TFT_DC 10 Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_RST); //Adafruit_SPITFT tft = Adafruit_SPITFT(30, 240, TFT_CS, TFT_DC, TFT_MOSI, TFT_SCLK, TFT_RST); int a_old, b_old; void setup() { tft.begin(); tft.setRotation(3); // Depending on your display orientation, you might need to adjust this value. // Fill the screen with a background color tft.fillScreen(ILI9341_BLACK); } void loop() { int a = analogRead(A0) / 25; int ReadR = analogRead(A0); int ReadG = analogRead(A0); int ReadB = analogRead(A0); int R, G, B; if (ReadB <= 255) { ReadB = 255; B = ReadB; } if (ReadB > 512) { ReadB = 0; B = ReadB; } if ((ReadB > 255) && (ReadB <= 512)) { B = map(ReadB, 512, 256, 0, 255); } if (ReadG <= 255) { G = map(ReadG, 0, 255, 0, 255); } if ((ReadG > 255) && (ReadG <= 768)) { ReadG = 255; G = ReadG; } if (ReadG > 768) { G = map(ReadG, 769, 1023, 255, 0); } if (ReadR < 512) { ReadR = 0; R = ReadR; } if ((ReadR >= 512) && (ReadR <= 768)) { R = map(ReadR, 512, 768, 0, 255); } if (ReadR > 769) { ReadR = 255; R = ReadR; } if (a > a_old) { for (int i = a_old; i < a; i++) { tft.fillRect(10 + i * 5, 60, 12 + i * 5, 75, tft.color565(R, G, B)); } a_old = a; } else { tft.fillRect(10 + a * 5, 60, 12 + a_old * 5, 75, tft.color565(R, G, B)); } a_old = a; } Quote Link to comment Share on other sites More sharing options...
aetius Posted Monday at 09:42 AM Author Share Posted Monday at 09:42 AM Quote Link to comment Share on other sites More sharing options...
aetius Posted Tuesday at 06:03 AM Author Share Posted Tuesday at 06:03 AM Am mai incercat diferite variante si nu am reusit sa-l fac s-a arate ca in poza ,ca in prima poza, cred ca o s-a comand din China un tft ILI9225... Multumesc. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.