This page is read only. You can view the source, but not change it. Ask your administrator if you think this is wrong. ====== avr_libc standard könyvtár ====== Az avr_libc egy, az Arduino telepítésével együtt installált könyvtár, ami egy egyszerű lib felhívással (#include<stdlib.h>) elérhető. A legtöbb funkciója az Arduino standard hívásokon keresztül is elérhető, de van néhány hasznos, ott meg nem található funkciója is. Leírása itt található: http://www.nongnu.org/avr-libc/user-manual/group__avr__stdlib.html#g6c140bdd3b9bd740a1490137317caa44 ===== dtostrf() ===== {{anchor:dtostrf}} [[hu:arduino:variables#float|float]] / [[hu:arduino:variables#double|double]] konvertálása [[hu:arduino:variables#char_array|karakter-lánc]]cá, normál formátumban: **"[-]d.ddd"**. === Szintaktika === <color green>dtostrf (//value//, //width//, //prec//, //out//)</color> \\ <color green>//value//</color> (float, double): bemeneti érték \\ <color green>//width//</color> (signed char): egész helyiérték pozíciók száma \\ <color green>//prec//</color> (unsigned char): törtrész pozíciók száma\\ <color green>//out//</color> (char*): kimenet\\ - A törtrészt, ha annak a megjelenítési helye kisebb, mint a számé, kerekíti. \\ - Az egészrész kezdeti üres pozícióit szóközzel tölti fel. \\ - Negatív //with// érték az eredményt balra igazítja, egyébként az igazítás jobbra történik \\ === Példa === <code> #include<stdlib.h> float i = 12345.6789; char buff1[10]; char buff2[10]; char buff3[10]; char buff4[4]; void setup() { Serial.begin(9600); } void loop() { // dtostrf(FLOAT,WIDTH,PRECSISION,BUFFER); dtostrf(i,5,2,buff1); Serial.print("buff1: "); Serial.println(buff1); dtostrf(i,4,0,buff2); Serial.print("buff2: "); Serial.println(buff2); dtostrf(i,2,4,buff3); Serial.print("buff3: "); Serial.println(buff3); dtostrf(i,6,2,buff4); Serial.print("buff4: "); Serial.println(buff4); delay(100000); } </code> A monitor tartalma: <code> buff1: 12345.68 buff2: 12346 buff3: 12345.6790 buff4: 12345.68 </code> ===== dtostre() ===== {{anchor:dtostre}} [[hu:arduino:variables#float|float]] / [[hu:arduino:variables#double|double]] konvertálása [[hu:arduino:variables#char_array|karakter-lánc]]cá, kitevős formátumban: **"[-]d.ddde±dd"**. === Szintaktika === <color green>dtostre (//value//, //out//, //prec//, //flag//)</color> \\ <color green>//value//</color> (float, double): bemeneti érték \\ <color green>//out//</color> (char*): kimenet\\ <color green>//prec//</color> (unsigned char): törtrész pozíciók száma\\ <color green>//flag//</color> (unsigned char): egész helyiérték pozíciók száma \\ Ez a funkció nekem nem működött. ===== atoi() ===== {{anchor:atoi}} [[hu:arduino:variables#char_array|Karakter-lánc]] konvertálása [[hu:arduino:variables#int|int]]-té. === Szintaktika === (int) = <color green>atoi (//char*//)</color> \\ <color green>//char*//</color>: bemeneti karakterlánc \\ A funkció visszatérési típusa: int. - A karakterlánc egész-részét konvertálja (a tizedespont előtt) - Nem ügyel a túlcsordulásra === Példa === <code> #include<stdlib.h> char buff1[]="12345.67"; int i; void setup() { Serial.begin(9600); } void loop() { i = atoi(buff1); Serial.print(" :"); Serial.println(i); delay(100000); } </code> A monitor tartalma: <code> :12345 </code> ===== itoa() ===== {{anchor:itoa}} [[hu:arduino:variables#int|int]] konvertálása [[hu:arduino:variables#char_array|Karakter-lánc]]-cá. === Szintaktika === <color green>itoa(//val//, //char*//, //radix//)</color> \\ <color green>//val//</color> (int/long): bemeneti int / long \\ <color green>//char*//</color>: kimeneti karakterlánc \\ <color green>//radix//</color>: szükséges buffer mérete, 2..36\\ ===== atof() ===== {{anchor:atof}} [[hu:arduino:variables#char_array|Karakter-lánc]] konvertálása [[hu:arduino:variables#float|float]]-tá. === Szintaktika === (float) = <color green>atof (//char*//)</color> \\ <color green>//char*//</color>: bemeneti karakterlánc \\ A funkció visszatérési típusa: float - A karakterlánc tartalmát konvertálja (a tizedesértékekkel együtt) - Nem ügyel a túlcsordulásra Példaként lásd: [[:#atoi|atoi]] ===== atol() ===== {{anchor:atol}} [[hu:arduino:variables#char_array|Karakter-lánc]] konvertálása [[hu:arduino:variables#long|long]]-gá. === Szintaktika === (long) = <color green>atol (//char*//)</color> \\ <color green>//char*//</color>: bemeneti karakterlánc \\ A funkció visszatérési típusa: long - Nem ügyel a túlcsordulásra Példaként lásd: [[:#atoi|atoi]] hu/arduino/lib_avr_libc.txt 2022/04/21 15:02()