Fórum témák

» Több friss téma
Fórum » Arduino
A klónok CH340 Soros-USB illesztőjének drivere (Letöltés)
Lapozás: OK   674 / 838
(#) mnyugger válasza Poli hozzászólására (») Jan 21, 2021 /
 
Köszönöm a válaszokat.
A probléma megoldódott.
Nem az FTDI volt rossz, hanem az Arduino Pro Mini.
Más módszerrel ( Unóval párhuzamosan) sem volt feltölthető és egy másik Pro-ra mindkét módszerrel igen. XP alól.
Még hátra van egy ellenpróba Windows 10 alól. Lehet, hogy ezt kihagyom. Van egy XP-s notebookom. Erre pont jó lesz.
A hozzászólás módosítva: Jan 21, 2021
(#) mnyugger válasza Poli hozzászólására (») Jan 21, 2021 /
 
De! jól volt kötve. ezeregyszer leelenőriztem.
(#) Kovidivi válasza mnyugger hozzászólására (») Jan 21, 2021 /
 
A reset jel sem mindig az igazi, soros kondival van megoldva, ha egyáltalán meg van, vagy elég a kondi kapacitása, vagy nem... Ez is gondot okozhat.
(#) tbarath válasza sargarigo hozzászólására (») Jan 22, 2021 / 1
 
Illetve még egy érdekességet találtam a Pi Pico-n: "Supported input power 1.8–5.5V DC"
Mert van ams1117, vagy valami hasonló feszstab van rajta, hanem egy boost-buck converter. Szóval 2 ceruzaelemről vagy egy Li-ion celláról is simán elmegy, nem kell mellé külön áramkör.
(#) sargarigo válasza tbarath hozzászólására (») Jan 22, 2021 / 1
 
Addig addig beszélünk róla, hogy csak veszek egyet!
(#) moltam válasza tbarath hozzászólására (») Jan 23, 2021 /
 
A külön assemblyvel programozható PIO periféria nagyon ötletes, tetszik.
(#) kiborg hozzászólása Jan 24, 2021 /
 
Sziasztok!
Hol találok arra valami leírást, hogy az Arduino melyik Timereket használja egy STM32103-ban? Másrészt meg keresek infót arról, hogy hogyan lehet megoldani a nem használt Timerek használatát Arduino alól ? Persze mindez STM32F103-on.
Van valakinek erről infója?
(#) lobo67 válasza kiborg hozzászólására (») Jan 25, 2021 /
 
Fejből nem tudom, stm-en tiszta arduinot nem használok (meg mással sem nagyon), de a forrásokból biztosan ki lehet deríteni.
(#) Kovács Tibor hozzászólása Jan 25, 2021 /
 
Kedves Fórumtársak!
Kettős számláló építését szeretném de nem találtam rá kész programot.
16*2 LCD-vel szeretném építeni, UNO-val, két külön reed relés bemenettel .
Tudtok segíteni hogy van-e használható ami készen van vagy legalább kiindulásnak jó?
2db Vízóra állását szeretném távleolvasással figyelni elsőre csak napi leolvasással.
Itt még jó lenne ha a tényleges óraállás beírható lenne a számláló indulásaként. ezred köbmétereket tehát litert mérne, de a kijelző köbmétert jelezne ki.
Később naplózni szeretném hogy grafikon is legyen belőle.
tehát vannak tervek, segítsetek lsz. elindulni!
Olyan számlálóm már működik ami egy órát figyel, de tovább kéne lépni.
A
(#) pipi válasza Kovács Tibor hozzászólására (») Jan 25, 2021 /
 
Hali!
Ha már van egyórás, akkor csak a megfelelő programrészeket kell megduplázni a másik input pin-nel, és változókkal...
(#) Bakman válasza Kovács Tibor hozzászólására (») Jan 25, 2021 /
 
Milyen órát figyel az, ami már működik? A vízórát hogyan tervezed figyelni? Van valamilyen elektronikus kimenete?
(#) Kovács Tibor válasza pipi hozzászólására (») Jan 25, 2021 /
 
Hali!
Ez ennyire egyszerű lenne? Van benne egy ciklus, azt hogy fűzzem egymásba? Vagy csak tegyem egymás mellé ?
(#) mnyugger válasza Kovács Tibor hozzászólására (») Jan 25, 2021 /
 
Megszakítással kezeld le az óráktól érkező impulzusokat.
(#) sargarigo válasza Kovács Tibor hozzászólására (») Jan 25, 2021 /
 
Mivel senki sem orákulum, nem tudjuk megmondani mit változtass a kódodon! Mellékeld hogy lássuk miről van szó!
(#) Kovács Tibor válasza Bakman hozzászólására (») Jan 25, 2021 /
 
Hali!

Ez egy mellék vízmérő. Van egy mágnes az óra mutatóján, azt figyeli a reed relé.
(#) Kovács Tibor válasza sargarigo hozzászólására (») Jan 25, 2021 /
 
Sziasztok!
Bocsánat, gondolhattam volna, küldöm..
(#) mnyugger válasza Kovács Tibor hozzászólására (») Jan 25, 2021 /
 
Ez a program kb. semmi!
(#) sargarigo válasza Kovács Tibor hozzászólására (») Jan 25, 2021 /
 
Igen, az a lényeg hogy tedd egymás mellé! HA ez a kód már működik egy órára, akkor a benne lévő részeket meg kell duplázni ahogy kolléga is mondta.
Ami most benne van az egyik órára, azt átmásolod mögé (természetesen értelemszerűen), és nem a régi óra bemeneteket használod, hanem az újakat. Kb ennyi.
Viszont a kódod küllemére érdemes kicsit többet szánni, mert amíg ilyen saláta, nagyon nehéz elemezni. Neked is jót tesz majd, amikor megpróbálod bővíteni.
A rendszerleírást pedig az indító kérdésbe ajánlott beleírni, hogy ne nekünk kelljen utólag kifaggatni a részletekről.

Próbáld meg, aztán majd segítünk!
A hozzászólás módosítva: Jan 25, 2021
(#) pipi válasza Kovács Tibor hozzászólására (») Jan 25, 2021 /
 
Ezt biza jobban át kell írni, nem egyszerű duplázás, mert ciklusban várja hogy a reed mozduljon... vagyis ez alatt a másik reedet nem venné észre.
Mint javasolta Mnyugger át kéne írni megszakításosra, vagy változóban tárolni mindkét reed állapotát, és ha valamelyiken változás van azt számolni
(#) szikorapéter hozzászólása Jan 25, 2021 /
 
Sziasztok. Van egy programom, enkóderre alapul, de jelenleg az nem elérhető csak nyomógomb.
Milyen formában változtassak hogy a sima nyomógombokkal is használható legyen a program?

  1. #include <Wire.h>                                       // I2C library
  2. #include <LiquidCrystal_I2C.h>                          // I2C LCD library
  3. LiquidCrystal_I2C lcd(0x27,20,4);                       // set the LCD address to 0x27 for a 20 chars and 4 line display
  4.  
  5. //--Define constants
  6. #define encoder0PinA  2                        // Setup the encoder pins
  7. #define encoder0PinB  4                        // Setup the encoder pins
  8. #define encoderbtn 6                           // encoder pushbutton
  9. #define DDS_CLOCK 180000000                    // 30MHz x 6 (onboard rock)
  10.  
  11.  
  12. //---define variables
  13. volatile long encoder0Pos = 10000000;          // setup a value to count with
  14. volatile long oldencoder0Pos = encoder0Pos ;   // used to compare
  15. int varVal;                                    // variable for reading the pin status
  16. int varHz = 1;                                 // 1=Hz, 2=KHz, 3=10KHz, 4=100KHz, 5=MHz tuning step mode
  17. int long varMult = 1;                          // used to plug in as the multiplier
  18. char varBuf1[8];                               // used to convert an int to a string array for the freq display
  19. char varBuf2[10];                              // used to format the freq display with commas      
  20. unsigned long varCurrentMillis;                // current time via the Millis function
  21. long varPreviousMillis = 0;                    // used as a timer to avoid bounce
  22. long varInterval = 500;                        // interval used with a timer (milliseconds)
  23. byte ddsLOAD = 8;                              // AD9851 LOAD   Arduino D8
  24. byte ddsCLOCK = 9;                             // AD9851 CLOCK  Arduino D9
  25. byte ddsDATA = 10;                             // AD9851 FQ_UD  Ardunio D10
  26. long varTuning_word;                           // Used to hold the word for the DDS
  27.  
  28.  
  29.  
  30. void setup() {
  31. //---Setup encoder  
  32.   pinMode(encoderbtn, INPUT);
  33.   pinMode(encoder0PinA, INPUT);
  34.   digitalWrite(encoder0PinA, HIGH);       // turn on pullup resistor
  35.   pinMode(encoder0PinB, INPUT);
  36.   digitalWrite(encoder0PinB, HIGH);       // turn on pullup resistor
  37.   attachInterrupt(0, doEncoder, CHANGE);  // encoder pin on interrupt 0 - pin 2
  38. //---Initial screen setup  
  39.   lcd.init();                             // initialize the lcd
  40.   lcd.backlight();                        // turn on the lcd backlight
  41.   lcd.clear();                            // good practice to make sure that display is clear
  42.   lcd.setCursor(0,2);                     // column,row
  43.   lcd.print("Zikha DDS Generator");
  44.   lcd.setCursor(4,3);                     // column,row
  45.   lcd.print("AM modulation");
  46.   lcd.setCursor(0,0);                     // column,row
  47.   lcd.print("Freq: ");
  48.   sprintf(varBuf1,"%8lu", encoder0Pos);   // convert initial freq for display
  49.   sprintf(varBuf2,"%1c%1c,%1c%1c%1c,%1c%1c%1c", varBuf1[0], varBuf1[1], varBuf1[2], varBuf1[3], varBuf1[4], varBuf1[5], varBuf1[6], varBuf1[7], varBuf1[8]);
  50.   lcd.print(varBuf2);
  51.   lcd.setCursor(0,1);                    // column,row
  52.   lcd.print("Hertz 1");                        // prints out step; should variablize
  53. //---setup pins for AD9851
  54.   pinMode (ddsDATA, OUTPUT);              // sets pin 10 as OUPUT
  55.   pinMode (ddsCLOCK, OUTPUT);             // sets pin 9 as OUTPUT
  56.   pinMode (ddsLOAD, OUTPUT);              // sets pin 8 as OUTPUT
  57.   sendFrequency(encoder0Pos);             // send the initial freq to the DDS
  58. }
  59.  
  60.  
  61.  
  62. void loop(){
  63.   encoderStatus();                        // check for encoder button press
  64.   lcdStatus();                            // function for lcd updates
  65.   if (encoder0Pos != oldencoder0Pos)      // only update the DDS if the freq has changed
  66.     sendFrequency(encoder0Pos);           // function to update the DDS
  67. }
  68.  
  69.  
  70.  
  71. void sendFrequency(long encoder0Pos){                        // function to update the DDS
  72.   varTuning_word = (encoder0Pos * pow(2, 32)) / DDS_CLOCK;   // set value for the DDS
  73.   digitalWrite (ddsLOAD, LOW);                               // take load pin low
  74.   //--start loop--
  75.   for(int i = 0; i < 32; i++)                                // loop through the bits
  76.   {
  77.     if ((varTuning_word & 1) == 1)                           // test for binary 1
  78.       outOne();                                              // function to send 1 serial
  79.     else
  80.       outZero();                                             // function to send 0 serial
  81.     varTuning_word = varTuning_word >> 1;                    
  82.   }
  83.   //--end loop--
  84.   byte_out(0x09);                                            // send the end command
  85.   digitalWrite (ddsLOAD, HIGH);                              // take the load pin high
  86. }
  87.  
  88.  
  89.  
  90.  
  91. void byte_out(unsigned char byte)         // spin through a byte (8 bits)
  92. {                                         // send it a bit a time
  93.   int i;
  94.  
  95.   for (i = 0; i < 8; i++)
  96.   {
  97.     if ((byte & 1) == 1)
  98.       outOne();
  99.     else
  100.       outZero();
  101.     byte = byte >> 1;
  102.   }
  103. }
  104.  
  105.  
  106.  
  107.  
  108. void outOne(){                            // send 1 to the DDS        
  109.   digitalWrite(ddsCLOCK, LOW);            // set the ddsCLOCK pin low
  110.   digitalWrite(ddsDATA, HIGH);            // set the ddsDATA pin high
  111.   digitalWrite(ddsCLOCK, HIGH);           // set the ddsCLOCK pin HIGH
  112.   digitalWrite(ddsDATA, LOW);             // set the ddsDATA ping low
  113. }
  114.  
  115.  
  116.  
  117. void outZero(){                           // send 0 to the DDS
  118.   digitalWrite(ddsCLOCK, LOW);            // set the ddsCLOCK pin low
  119.   digitalWrite(ddsDATA, LOW);             // set the ddsDATA pin low
  120.   digitalWrite(ddsCLOCK, HIGH);           // set the ddsCLOCK pin high
  121. }
  122.  
  123.  
  124.  
  125. void encoderStatus (){                    // this is checking for the button press and setting the MHZ, KHz, Hz cursor
  126.   varCurrentMillis = millis();            // set variable = time
  127.   if(varCurrentMillis - varPreviousMillis > varInterval) {
  128.      varPreviousMillis = varCurrentMillis;  
  129.      varVal = digitalRead(encoderbtn);    // read input value and store it in val
  130.      if (varVal == LOW) {                 // check if the button is pressed
  131.         if (varHz == 6) {                 // 1 Hz, 2 100Hz, 3 KHz, 4 10KHz, 5 100KHz, 6 MHz
  132.         varHz = 0;                        // reset from MHz to Hz  
  133.         }    
  134.       varHz = varHz + 1;                  // move one position
  135.      }
  136.   }
  137. }
  138.  
  139.  
  140.  
  141.  
  142.  
  143. void lcdStatus (){
  144.     sprintf(varBuf1,"%8lu", encoder0Pos);        
  145.     sprintf(varBuf2,"%1c%1c,%1c%1c%1c,%1c%1c%1c", varBuf1[0], varBuf1[1], varBuf1[2], varBuf1[3], varBuf1[4], varBuf1[5], varBuf1[6], varBuf1[7], varBuf1[8]);
  146.     if (encoder0Pos != oldencoder0Pos){
  147.       lcd.setCursor(6,0);                   // column,row
  148.       lcd.print(varBuf2);                   // prints out the freq
  149.     }
  150.  
  151.    switch (varHz) {
  152.     case 1:             // if 1 move the cursor to Hz
  153.       lcd.setCursor(0,1);                  // column,row
  154.       lcd.print("Hertz 1         ");                      // prints out step
  155.       varMult = 1;        
  156.       break;
  157.     case 2:                                 // if 2 move the cursor to 100 Hz
  158.       lcd.setCursor(0,1);                  // column,row
  159.       lcd.print("Hertz 100      ");                      // prints out step
  160.       //varMult = 1000/2;                   // original encoder with detents
  161.       varMult = 100;                        // AA0ZZ encoder, no detents
  162.       break;
  163.     case 3:                                 // if 2 move the cursor to KHz
  164.       lcd.setCursor(0,1);                  // column,row
  165.       lcd.print("Kilohertz 1     ");                      // prints out step
  166.       //varMult = 1000/2;                   // original encoder with detents
  167.       varMult = 1000;                       // AA0ZZ encoder, no detents
  168.       break;
  169.      case 4:                                // if 3 move the cursor to 10KHz
  170.       lcd.setCursor(0,1);                  // column,row
  171.       lcd.print("Kilohertz 10    ");                      // prints out step
  172.       //varMult = 10000/2;                  // original encoder with detents
  173.       varMult = 10000;                      // AA0ZZ encoder, no detents
  174.       break;  
  175.     case 5:                                 // if 4 move the cursor to 100KHz
  176.       lcd.setCursor(0,1);                  // column,row
  177.       lcd.print("Kilohertz 100    ");                      // prints out step
  178.       //varMult = 100000/2;                 // original encoder with detents
  179.       varMult = 100000;                     // AA0ZZ encoder, no detents
  180.       break;  
  181.     case 6:                                 // if 5 move the cursor to MHz
  182.       lcd.setCursor(0,1);                  // column,row
  183.       lcd.print("Megahertz 1    ");                      // prints out step
  184.       //varMult = 500000;                   // original encoder with detents
  185.       varMult = 1000000;                    // AA0ZZ encoder, no detents
  186.       break;
  187.     }
  188.     if (encoder0Pos <= 00000001) {            // lower bounds limit
  189.         encoder0Pos  = 00000001;
  190.     }
  191.     if (encoder0Pos >= 30000000) {           // upper bounds limit
  192.         encoder0Pos  = 30000000;
  193.     }
  194. }
  195.  
  196.  
  197.  
  198.  
  199.  
  200. void doEncoder(){
  201.  oldencoder0Pos = encoder0Pos;                // reset the variables so that we can compare them next time
  202.   if (digitalRead(encoder0PinA) == HIGH) {    // found a low-to-high on channel A
  203.     if (digitalRead(encoder0PinB) == LOW) {   // check channel B to see which way
  204.                                               // encoder is turning
  205.       encoder0Pos = encoder0Pos - varMult;    // CCW
  206.     }
  207.     else {
  208.       encoder0Pos = encoder0Pos + varMult;    // CW
  209.     }
  210.   }
  211.   else                                        // found a high-to-low on channel A
  212.   {
  213.     if (digitalRead(encoder0PinB) == LOW) {   // check channel B to see which way
  214.                                               // encoder is turning  
  215.       encoder0Pos = encoder0Pos + varMult;    // CW
  216.     }
  217.     else {
  218.       encoder0Pos = encoder0Pos - varMult;    // CCW
  219.     }
  220.   }
  221.  }
  222.  
  223. /*  to read the other two transitions - just use another attachInterrupt()
  224. in the setup and duplicate the doEncoder function into say,
  225. doEncoderA and doEncoderB.
  226. You also need to move the other encoder wire over to pin 3 (interrupt 1).
  227. */
(#) pipi válasza szikorapéter hozzászólására (») Jan 25, 2021 /
 
Szerintem jobban jársz enkóderrel, a sarki közértben is kapható
https://www.hestore.hu/search.php?q=enk%C3%B3der
(#) saviola88 hozzászólása Jan 26, 2021 /
 
Sziasztok!
Van egy kínai lézergravírozóm kínai arduino nano-val és GRBL 1.1 firmware-el.
Előfordult már, hogy lefagyott a program és ilyenkor egyhelyben áll a lézer és égeti a fát.
Létezik programfagyás ellen valami megoldás? Pl.: valamelyik kimetére egy jel hogyha fagyás van és egy relével bontani a tápját? Vagy, hogy önmagát kapcsolja le ha ilyet észlel?
Bármilyen megoldás érdekel, feltéve ha rá megoldás.
Előre is köszi!
(#) vargham válasza saviola88 hozzászólására (») Jan 26, 2021 /
 
Watchdog. Nézd meg az adatlapot, és a példákat, hogyan kell használni.
A hozzászólás módosítva: Jan 26, 2021
(#) pipi válasza saviola88 hozzászólására (») Jan 26, 2021 /
 
Barkácsolnék az x és y tengelyhez egy-egy újraindulós monoflop-ot, amely bemenete a STEP-re van kötve. Ha nincs léptetés, monoflop lejár, lézert letiltja.
Szoftverbe utólag macerás betenni, meg kell keresni, ellenőrizni minden hosszabb ciklust...
(#) vargham válasza pipi hozzászólására (») Jan 26, 2021 /
 
Nem kell ellenőrizni. A WDT reseteli az MCU-t ha elszáll a szoftver.
(#) moltam válasza vargham hozzászólására (») Jan 26, 2021 /
 
Ha viszont olyan ciklusba lép a kontroller amiben túlcsordulhat a wdt counter és nincs kiadva benne az időszakos wdt reset, akkor resetelni fog kéretlenül is, nem fog működni a kód.
(#) pipi válasza vargham hozzászólására (») Jan 26, 2021 /
 
A watchdog számlálót törölni kell rendszeresen, ha jól fut a program vagy a fő ciklusban, illetve olyan hosszabb hurkokban, amely ideje meghaladja wdt számláló max értékének megfelelő időt.
Ha elszáll a program a számláló törlése nem valósul meg, a watcdog megszólal.
Szóval át kell nézni a szoftvert, nem elég csak a fő ciklusba betenni. Egy ilyen bonyolult programot átnézni, minden "szükséges" helyre betenni a törlést, igencsak macerás, és ha mégis valahonnan kimaradt, akkor majd lehet 1 hét málva derül ki, mikor lesz egy nem kivánt reset
(#) saviola88 hozzászólása Jan 26, 2021 /
 
Köszönöm a segítséget mindenkinek!
A monoflop-os dolgot fogom megvalósítani. Köszönöm az ötletet!
(#) hajoskapitany hozzászólása Feb 4, 2021 /
 
Sziasztok!
Minap vettem egy kijelzőt az aliexpressről. Ki akartam próbálni a TFT_eSPI valamint az Arduino_GFX könyvtárral de nem sikerült. Végül a buydisplay honlapján megtaláltam ezt a kijelzőt és az ottani példakódot próbálva működött, de furcsán viselkedik:
Képernyőfrissítéskor elhalványul, a színek nem jelenek meg rendesen, kivéve ha a fillScreen parancsot használom. Nem tudok rájönni mi lehet a gondja. Ha esetleg a használhatóvá tételében tudnátok segíteni, azt megköszönném. A könnyebb megértés véget mellékelek egy videót a működéséről.

Ebből a nyák nélüli változatot vettem meg: Aliexpress

És innen származik a grafikus teszt: Buydisplay

A képernyőről készült videó: Link

A próbát egy megával végeztem szoftveres SPI-vel és a kijelzőhöz csak a háttérvilágítást korlátozó ledet tettem pluszba, mást nem. Még annyi, hogy a kijelző meghajtó egy GC9A01-es IC.

A kód mellett még pár .h és .cpp fájl is van a példakódhoz, ha kell, bemásolom azokat is.
  1. /***************************************************
  2. EastRising Technology Co.,LTD
  3. Examples for ER-TFTM1.28-1 graphics test
  4. Display is Hardward or Software SPI SPI 4-Wire SPI Interface  3.3V Power Supply
  5. NOTE: testOK: DUE    If you use MEGA and UNO board, you need to add level conversion.
  6. ****************************************************/
  7. /*
  8.   ==TFT Hardware SPI connection ==
  9.     OLED   =>    Arduino
  10.   *1. GND    ->    GND
  11.   *2. VCC    ->    3.3
  12.   *3. SCL    ->    SCK
  13.   *4. SDA    ->    MOSI
  14.   *5. RES    ->    8
  15.   *6. DC     ->    9
  16.   *7. CS     ->    10
  17.   *8. BLK     ->    NC  
  18. */
  19.  
  20. /*
  21.   ==TFT Software SPI connection ==
  22.     OLED   =>    Arduino
  23.   *1. GND    ->    GND
  24.   *2. VCC    ->    3.3
  25.   *3. SCL    ->    13
  26.   *4. SDA    ->    11
  27.   *5. RES    ->    8
  28.   *6. DC     ->    9
  29.   *7. CS     ->    10
  30.   *8. BLK     ->    NC  
  31. */
  32.  
  33.  
  34. #include "SPI.h"
  35. #include "ERGFX.h"
  36. #include "TFTM1.28-1.h"
  37.  
  38. #define TFT_RST 8
  39. #define TFT_DC 9
  40. #define TFT_CS 10
  41. // If using the Hardware SPI
  42. //GC9A01 tft = GC9A01(TFT_CS, TFT_DC,TFT_RST);
  43.  
  44. // If using the Software SPI
  45.  
  46. #define TFT_CLK  13
  47. #define TFT_MOSI 11  
  48. GC9A01 tft = GC9A01(TFT_CS, TFT_DC, TFT_MOSI, TFT_CLK, TFT_RST);
  49.  
  50. void setup() {
  51.   Serial.begin(9600);
  52.   Serial.println("GC9A01 Test!");
  53.  
  54.   tft.begin();
  55. }
  56.  
  57.  
  58. void loop(void) {
  59.   Serial.print(F("Screen fill              "));
  60.   Serial.println(testFillScreen());
  61.   delay(1000);
  62.  
  63.   Serial.print(F("Text                     "));
  64.   Serial.println(testText());
  65.   delay(3000);
  66.  
  67.  
  68.   Serial.print(F("Horiz/Vert Lines         "));
  69.   Serial.println(testFastLines(GC9A01_RED, GC9A01_BLUE));
  70.   delay(1000);
  71.  
  72.   Serial.print(F("Rectangles (outline)     "));
  73.   Serial.println(testRects(GC9A01_GREEN));
  74.   delay(1000);
  75.  
  76.   Serial.print(F("Rectangles (filled)      "));
  77.   Serial.println(testFilledRects(GC9A01_YELLOW, GC9A01_MAGENTA));
  78.   delay(1000);
  79.  
  80.   Serial.print(F("Circles (filled)         "));
  81.   Serial.println(testFilledCircles(10, GC9A01_MAGENTA));
  82.  
  83.   Serial.print(F("Circles (outline)        "));
  84.   Serial.println(testCircles(10, GC9A01_WHITE));
  85.   delay(1000);
  86.  
  87.   Serial.print(F("Triangles (outline)      "));
  88.   Serial.println(testTriangles());
  89.   delay(1000);
  90.  
  91.   Serial.print(F("Triangles (filled)       "));
  92.   Serial.println(testFilledTriangles());
  93.   delay(1000);
  94.  
  95.   Serial.print(F("Rounded rects (outline)  "));
  96.   Serial.println(testRoundRects());
  97.   delay(1000);
  98.  
  99.   Serial.print(F("Rounded rects (filled)   "));
  100.   Serial.println(testFilledRoundRects());
  101.   delay(1000);
  102.   Serial.println(F("Done!"));
  103. }
  104.  
  105. unsigned long testFillScreen() {
  106.   unsigned long start = micros();
  107.   tft.fillScreen(GC9A01_WHITE);
  108.   return micros() - start;
  109. }
  110.  
  111. unsigned long testText() {
  112.   tft.fillScreen(GC9A01_BLACK);
  113.   unsigned long start = micros();
  114.   tft.setCursor(100, 10);
  115.   tft.setTextColor(GC9A01_MAGENTA);  tft.setTextSize(2);
  116.   tft.println("Hellow!");
  117.   delay(2000);
  118.     tft.setCursor(50, 30);
  119.   tft.setTextColor(GC9A01_YELLOW); tft.setTextSize(2);
  120.   tft.println(123456.78);
  121.   delay(2000);
  122.       tft.setCursor(50, 50);
  123.   tft.setTextColor(GC9A01_RED);    tft.setTextSize(3);
  124.   tft.println(0xDEADBEEF, HEX);
  125.   delay(2000);
  126.        tft.setCursor(10, 80);
  127.    tft.setTextColor(GC9A01_GREEN); tft.setTextSize(2);
  128.   tft.println("www.buydisplay.com");
  129.   delay(2000);
  130.    tft.setTextColor(GC9A01_CYAN); tft.setTextSize(4);
  131.   tft.println("EastRising");
  132.   delay(2000);
  133.       tft.setCursor(35,160);
  134.     tft.setTextColor(GC9A01_BLUE); tft.setTextSize(5);
  135.   tft.println("Groop");
  136.   delay(2000);
  137.   return micros() - start;
  138. }
  139.  
  140. unsigned long testLines(uint16_t color) {
  141.   unsigned long start, t;
  142.   int           x1, y1, x2, y2,
  143.                 w = tft.width(),
  144.                 h = tft.height();
  145.  
  146.   tft.fillScreen(GC9A01_BLACK);
  147.  
  148.   x1 = y1 = 0;
  149.   y2    = h - 1;
  150.   start = micros();
  151.   for(x2=0; x2<w; x2+=6) tft.drawLine(x1, y1, x2, y2, color);
  152.   x2    = w - 1;
  153.   for(y2=0; y2<h; y2+=6) tft.drawLine(x1, y1, x2, y2, color);
  154.   t     = micros() - start; // fillScreen doesn't count against timing
  155.  
  156.   tft.fillScreen(GC9A01_BLACK);
  157.  
  158.   x1    = w - 1;
  159.   y1    = 0;
  160.   y2    = h - 1;
  161.   start = micros();
  162.   for(x2=0; x2<w; x2+=6) tft.drawLine(x1, y1, x2, y2, color);
  163.   x2    = 0;
  164.   for(y2=0; y2<h; y2+=6) tft.drawLine(x1, y1, x2, y2, color);
  165.   t    += micros() - start;
  166.  
  167.   tft.fillScreen(GC9A01_BLACK);
  168.  
  169.   x1    = 0;
  170.   y1    = h - 1;
  171.   y2    = 0;
  172.   start = micros();
  173.   for(x2=0; x2<w; x2+=6) tft.drawLine(x1, y1, x2, y2, color);
  174.   x2    = w - 1;
  175.   for(y2=0; y2<h; y2+=6) tft.drawLine(x1, y1, x2, y2, color);
  176.   t    += micros() - start;
  177.  
  178.   tft.fillScreen(GC9A01_BLACK);
  179.  
  180.   x1    = w - 1;
  181.   y1    = h - 1;
  182.   y2    = 0;
  183.   start = micros();
  184.   for(x2=0; x2<w; x2+=6) tft.drawLine(x1, y1, x2, y2, color);
  185.   x2    = 0;
  186.   for(y2=0; y2<h; y2+=6) tft.drawLine(x1, y1, x2, y2, color);
  187.  
  188.   return micros() - start;
  189. }
  190.  
  191. unsigned long testFastLines(uint16_t color1, uint16_t color2) {
  192.   unsigned long start;
  193.   int           x, y, w = tft.width(), h = tft.height();
  194.  
  195.   tft.fillScreen(GC9A01_BLACK);
  196.   start = micros();
  197.   for(y=0; y<h; y+=5) tft.drawFastHLine(0, y, w, color1);
  198.   for(x=0; x<w; x+=5) tft.drawFastVLine(x, 0, h, color2);
  199.  
  200.   return micros() - start;
  201. }
  202.  
  203. unsigned long testRects(uint16_t color) {
  204.   unsigned long start;
  205.   int           n, i, i2,
  206.                 cx = tft.width()  / 2,
  207.                 cy = tft.height() / 2;
  208.  
  209.   tft.fillScreen(GC9A01_BLACK);
  210.   n     = min(tft.width(), tft.height());
  211.   start = micros();
  212.   for(i=2; i<n; i+=6) {
  213.     i2 = i / 2;
  214.     tft.drawRect(cx-i2, cy-i2, i, i, color);
  215.   }
  216.  
  217.   return micros() - start;
  218. }
  219.  
  220. unsigned long testFilledRects(uint16_t color1, uint16_t color2) {
  221.   unsigned long start, t = 0;
  222.   int           n, i, i2,
  223.                 cx = tft.width()  / 2 - 1,
  224.                 cy = tft.height() / 2 - 1;
  225.  
  226.   tft.fillScreen(GC9A01_BLACK);
  227.   n = min(tft.width(), tft.height());
  228.   for(i=n; i>0; i-=6) {
  229.     i2    = i / 2;
  230.     start = micros();
  231.     tft.fillRect(cx-i2, cy-i2, i, i, color1);
  232.     t    += micros() - start;
  233.     // Outlines are not included in timing results
  234.     tft.drawRect(cx-i2, cy-i2, i, i, color2);
  235.   }
  236.  
  237.   return t;
  238. }
  239.  
  240. unsigned long testFilledCircles(uint8_t radius, uint16_t color) {
  241.   unsigned long start;
  242.   int x, y, w = tft.width(), h = tft.height(), r2 = radius * 2;
  243.  
  244.   tft.fillScreen(GC9A01_BLACK);
  245.   start = micros();
  246.   for(x=radius; x<w; x+=r2) {
  247.     for(y=radius; y<h; y+=r2) {
  248.       tft.fillCircle(x, y, radius, color);
  249.     }
  250.   }
  251.  
  252.   return micros() - start;
  253. }
  254.  
  255. unsigned long testCircles(uint8_t radius, uint16_t color) {
  256.   unsigned long start;
  257.   int           x, y, r2 = radius * 2,
  258.                 w = tft.width()  + radius,
  259.                 h = tft.height() + radius;
  260.  
  261.   // Screen is not cleared for this one -- this is
  262.   // intentional and does not affect the reported time.
  263.   start = micros();
  264.   for(x=0; x<w; x+=r2) {
  265.     for(y=0; y<h; y+=r2) {
  266.       tft.drawCircle(x, y, radius, color);
  267.     }
  268.   }
  269.  
  270.   return micros() - start;
  271. }
  272.  
  273. unsigned long testTriangles() {
  274.   unsigned long start;
  275.   int           n, i, cx = tft.width()  / 2 - 1,
  276.                       cy = tft.height() / 2 - 1;
  277.  
  278.   tft.fillScreen(GC9A01_BLACK);
  279.   n     = min(cx, cy);
  280.   start = micros();
  281.   for(i=0; i<n; i+=5) {
  282.     tft.drawTriangle(
  283.       cx    , cy - i, // peak
  284.       cx - i, cy + i, // bottom left
  285.       cx + i, cy + i, // bottom right
  286.       tft.color565(0, 0, i));
  287.   }
  288.  
  289.   return micros() - start;
  290. }
  291.  
  292. unsigned long testFilledTriangles() {
  293.   unsigned long start, t = 0;
  294.   int           i, cx = tft.width()  / 2 - 1,
  295.                    cy = tft.height() / 2 - 1;
  296.  
  297.   tft.fillScreen(GC9A01_BLACK);
  298.   start = micros();
  299.   for(i=min(cx,cy); i>10; i-=5) {
  300.     start = micros();
  301.     tft.fillTriangle(cx, cy - i, cx - i, cy + i, cx + i, cy + i,
  302.       tft.color565(0, i, i));
  303.     t += micros() - start;
  304.     tft.drawTriangle(cx, cy - i, cx - i, cy + i, cx + i, cy + i,
  305.       tft.color565(i, i, 0));
  306.   }
  307.  
  308.   return t;
  309. }
  310.  
  311. unsigned long testRoundRects() {
  312.   unsigned long start;
  313.   int           w, i, i2,
  314.                 cx = tft.width()  / 2 - 1,
  315.                 cy = tft.height() / 2 - 1;
  316.  
  317.   tft.fillScreen(GC9A01_BLACK);
  318.   w     = min(tft.width(), tft.height());
  319.   start = micros();
  320.   for(i=0; i<w; i+=6) {
  321.     i2 = i / 2;
  322.     tft.drawRoundRect(cx-i2, cy-i2, i, i, i/8, tft.color565(i, 0, 0));
  323.   }
  324.  
  325.   return micros() - start;
  326. }
  327.  
  328. unsigned long testFilledRoundRects() {
  329.   unsigned long start;
  330.   int           i, i2,
  331.                 cx = tft.width()  / 2 - 1,
  332.                 cy = tft.height() / 2 - 1;
  333.  
  334.   tft.fillScreen(GC9A01_BLACK);
  335.   start = micros();
  336.   for(i=min(tft.width(), tft.height()); i>20; i-=6) {
  337.     i2 = i / 2;
  338.     tft.fillRoundRect(cx-i2, cy-i2, i, i, i/8, tft.color565(0, i, 0));
  339.   }
  340.  
  341.   return micros() - start;
  342. }

Előre is köszönöm szépen!
(#) papus51 hozzászólása Feb 4, 2021 /
 
Sziasztok.
Építettem egy műszert, ami NEO7M GPS modulból kap frekvenciát. Szükségem lenne kijelezni egy LED bekapcsolásával amikor valós GPS kapcsolat van. Praktikusan a $GPGGA sorból a hatodik (FIX) adat amikor nagyobb mint nulla, akkor kellene a LED-et bekapcsolni.
Mivel a programozás nem erősségem, ARDUINO UNO-m viszont van kéznél, kérdezem, hogy tudna-e valaki segíteni egy ilyen feladatra készült programmal?
Hát, előre is köszönöm, ha akad valakinek.
Következő: »»   674 / 838
Bejelentkezés

Belépés

Hirdetés
Lapoda.hu     XDT.hu     HEStore.hu
Az oldalon sütiket használunk a helyes működéshez. Bővebb információt az adatvédelmi szabályzatban olvashatsz. Megértettem