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   237 / 841
(#) Balázs válasza Kera_Will hozzászólására (») Jún 6, 2016 /
 
Az a CS inkább Chip Select lesz szerintem. És ez nem karakteres, hanem grafikus. Bővebben: ILI9163 adatlap
(#) vargaf válasza Kera_Will hozzászólására (») Jún 6, 2016 /
 
Idézet:
„van DB0-DB7 ig az adat bemenetek (jobb esetben csak 4 bites vezérlést írnak hozzájuk így csak az első 4 bit kell DB0-DB3)”

annyi különbséggel, hogy 4 bites vezérlésnél a DB4-DB7 vonalakon kapja az adatot.
A hozzászólás módosítva: Jún 6, 2016
(#) morzsa15 válasza Balázs hozzászólására (») Jún 6, 2016 /
 
Esetleg tud valaki küldeni valami móricka rajzot hogyan is kössem be? Talán egy minta programot is?
(#) Balázs válasza morzsa15 hozzászólására (») Jún 6, 2016 /
 
Ennek a vezérlőnek SPI interfésze is van, az Arduinóhoz készült kijelzők általában ezt használják. Ehhez egy rakat példát találsz, amiből kiindulhatsz. Ha ehhez a párhuzamos interfészhez nem találsz libraryt, akkor neked kell lekódolnod, de nem egy nagy ördöngősség. Raspberry Pi-hoz készült Python kódot is találsz itt.
(#) morzsa15 válasza Balázs hozzászólására (») Jún 6, 2016 /
 
Igen, ezzel még bajom nincs is. Csak azzal hogy nem tudom hogyan kössem be azt nem tudom, abban kellene nekem segítség.
(#) vargaf válasza morzsa15 hozzászólására (») Jún 6, 2016 /
 
Balázs által linkelt oldalakra ránéztél?
Például:
ILI9163c
Ott megvan a bekötés , a driverek.
(#) morzsa15 válasza vargaf hozzászólására (») Jún 6, 2016 /
 
Estére kipróbálom. Majd jelentkezem!
(#) kapu48 válasza vargaf hozzászólására (») Jún 6, 2016 /
 
Mondhatnám, jók vagytok így együtt!

A kérdező linkel 8 adat bites TFT-t!

Erre az első hozzászóló összekeveri a 4 adat bites karakteres LCD vezérléssel!
Ami grafikus LCD-nél már nem is létezik!

A másik pedig meg ad egy SPI vezérlő mintát!
(#) Kera_Will válasza kapu48 hozzászólására (») Jún 6, 2016 /
 
1 bolond 100at csinál
(#) ha1drp válasza morzsa15 hozzászólására (») Jún 6, 2016 /
 
Az általad használt ili9163 TFT vezérlő ic-nek semmi köze a többiek által hasonlított karakteres, avagy egyszínű grafikus kijelzőhöz. Nemhogy 4 bites busza nincs, hanem 16 bites adatokkal programozható. Semmilyen karakter ROM-mal nem rendelkezik. Ráadásul max. 3.3v-os logikával dolgozik! Egyedi inicializáló rutinja van, minden paraméter (fényerő , gamma stb) szoftveresen állítható. Ha nem ismert az inicializálás menete kicsi az esély a felélesztéséhez. Úgy tűnik az SPI kommunikáció sem választható opció, mert hardveresen a 8 bites busz van csak engedélyezve.
(#) vargaf válasza kapu48 hozzászólására (») Jún 6, 2016 /
 
Az első hozzászólásomnál csak a DB0-DB3 helyett a DB4-DB7 használatára hívtam fel a figyelmet! Egy szóval sem említettem, hogy ez a kijelző ilyen vezérlésű. A másodiknál pedig linkeltem egy megoldást!
(#) dannu hozzászólása Jún 6, 2016 /
 
Üdv olyan problémám lenne hogy ez a kód fordításkor hibával le áll.

Ctags minta hiányzik
Error Compling XY <- Minden verzión végig ment elméletbe mega hoz van a kód .
Valaki tud esetleg segíteni ?


  1. #include <EtherCard.h>
  2. #include <TinyXML.h>
  3. #include <Adafruit_GFX.h>
  4. #include <Adafruit_ST7735.h>1
  5. #include <SPI.h>
  6.  
  7. #include <petit_fatfs.h>
  8. #include <MemoryFree.h>
  9.  
  10. #include <stdlib.h>
  11. #include <string.h>
  12. #include <avr/pgmspace.h>
  13. #include <avr/wdt.h>
  14.  
  15. #define TFT_RST  -1
  16. #define TFT_RS   5
  17. #define TFT_LED  6
  18. #define TFT_CS   7
  19. #define SD_CS    8
  20. #define ETHER_CS 10
  21.  
  22. byte Ethernet::buffer[567];  // 567 is minimum buffer size to avoid losing data
  23. uint32_t last_fetch, bright_on;
  24.  
  25. char website[] PROGMEM = "weather.yahooapis.com";
  26.  
  27. Adafruit_ST7735 tft(TFT_CS, TFT_RS, TFT_RST);
  28.  
  29. //#define DEBUG
  30. #ifdef DEBUG
  31. Print &out = Serial;
  32. #else
  33. Print &out = tft;
  34. #endif
  35.  
  36. #define IN_LOCATION 1
  37. #define IN_UNITS 2
  38. #define IN_ATMOS 4
  39. #define IN_FORECAST 8
  40. #define IN_WIND 16
  41. #define IN_CONDITION 32
  42. #define DISPLAY_UPDATE 64
  43. #define READING_RESPONSE 128
  44. byte status;
  45.  
  46. char temp_unit, pres_unit[3], speed_unit[5], condition_code[3], condition_text[32], city[16];
  47. byte wind_speed, atmos_humidity;
  48. int8_t atmos_rising, condition_temp, wind_chill;
  49. uint16_t wind_direction, atmos_pressure;
  50.  
  51. #define FORECASTS 5
  52. struct forecast {
  53.   int8_t low, high;
  54.   char code[3], day[4], text[24], date[7];
  55. } forecasts[FORECASTS];
  56. byte fcast;
  57.  
  58. byte xmlbuf[90];
  59. TinyXML xml;
  60.  
  61. static int centre_text(const char *s, int x, int size)
  62. {
  63.   return x - (strlen(s)*size*6) / 2;
  64. }
  65.  
  66. static int right(int n, int x, int size)
  67. {
  68.   return x - n*size*6;
  69. }
  70.  
  71. static int val_len(int b)
  72. {
  73.   if (b >= 1000) return 4;
  74.   if (b >= 100) return 3;
  75.   if (b >= 10) return 2;
  76.   if (b >= 0) return 1;
  77.   if (b > -10) return 2;
  78.   return 3;
  79. }
  80.  
  81. // from Adafruit's spitftbitmap ST7735 example
  82. int bmp_draw(byte *buf, int bufsiz, char *filename, uint8_t x, uint8_t y) {
  83.   int      bmpWidth, bmpHeight;   // W+H in pixels
  84.   uint8_t  bmpDepth;              // Bit depth (currently must be 24)
  85.   uint32_t bmpImageoffset;        // Start of image data in file
  86.   uint32_t rowSize;               // Not always = bmpWidth; may have padding
  87.   uint8_t  buffidx = bufsiz;      // Current position in buffer
  88.   boolean  flip    = true;        // BMP is stored bottom-to-top
  89.   int      w, h, row, col;
  90.   uint8_t  r, g, b;
  91.   uint32_t pos = 0;
  92.  
  93.   if((x >= tft.width()) || (y >= tft.height())) return -1;
  94.  
  95. #ifdef DEBUG
  96.   uint32_t startTime = millis();
  97. #endif
  98.  
  99.   int res = PFFS.open_file(filename);
  100.   if (res != FR_OK) {
  101.     out.print(F("file.open!"));
  102.     out.print(' ');
  103.     out.print(filename);
  104.     out.print(' ');
  105.     out.println(res);
  106.     return res;
  107.   }
  108.  
  109.   // Parse BMP header
  110.   uint32_t currPos = 0;
  111.   if (read16(currPos) != 0x4D42) {
  112.     out.println(F("Unknown BMP signature"));
  113.     return -1;
  114.   }
  115. #ifdef DEBUG  
  116.   out.print(F("File size: "));
  117.   out.println(read32(currPos));
  118. #else
  119.   (void)read32(currPos);
  120. #endif  
  121.   (void)read32(currPos); // Read & ignore creator bytes
  122.   bmpImageoffset = read32(currPos); // Start of image data
  123. #ifdef DEBUG
  124.   out.print(F("Image Offset: "));
  125.   out.println(bmpImageoffset, DEC);
  126. #endif
  127.   // Read DIB header
  128. #ifdef DEBUG
  129.   uint32_t header_size = read32(currPos);
  130.   out.print(F("Header size: "));
  131.   out.println(header_size);
  132. #else
  133.   (void)read32(currPos);
  134. #endif
  135.   bmpWidth  = read32(currPos);
  136.   bmpHeight = read32(currPos);
  137.   if (read16(currPos) != 1) {
  138.     out.println(F("# planes -- must be '1'"));
  139.     return -1;
  140.   }
  141.   bmpDepth = read16(currPos); // bits per pixel
  142. #ifdef DEBUG
  143.   out.print(F("Bit Depth: "));
  144.   out.println(bmpDepth);
  145. #endif
  146.   if((bmpDepth != 24) || (read32(currPos) != 0)) {
  147.     // 0 = uncompressed
  148.     out.println(F("BMP format not recognized."));
  149.     return -1;
  150.   }
  151.  
  152. #ifdef DEBUG
  153.   out.print(F("Image size: "));
  154.   out.print(bmpWidth);
  155.   out.print('x');
  156.   out.println(bmpHeight);
  157. #endif
  158.  
  159.   // BMP rows are padded (if needed) to 4-byte boundary
  160.   rowSize = (bmpWidth * 3 + 3) & ~3;
  161.  
  162.   // If bmpHeight is negative, image is in top-down order.
  163.   // This is not canon but has been observed in the wild.
  164.   if (bmpHeight < 0) {
  165.     bmpHeight = -bmpHeight;
  166.     flip      = false;
  167.   }
  168.  
  169.   // Crop area to be loaded
  170.   w = bmpWidth;
  171.   h = bmpHeight;
  172.   if ((x+w-1) >= tft.width())  w = tft.width()  - x;
  173.   if ((y+h-1) >= tft.height()) h = tft.height() - y;
  174.  
  175.   // Set TFT address window to clipped image bounds
  176.   tft.setAddrWindow(x, y, x+w-1, y+h-1);
  177.  
  178.   for (row=0; row<h; row++) { // For each scanline...
  179.  
  180.     // Seek to start of scan line.  It might seem labor-
  181.     // intensive to be doing this on every line, but this
  182.     // method covers a lot of gritty details like cropping
  183.     // and scanline padding.  Also, the seek only takes
  184.     // place if the file position actually needs to change
  185.     // (avoids a lot of cluster math in SD library).
  186.     if (flip) // Bitmap is stored bottom-to-top order (normal BMP)
  187.       pos = bmpImageoffset + (bmpHeight - 1 - row) * rowSize;
  188.     else     // Bitmap is stored top-to-bottom
  189.       pos = bmpImageoffset + row * rowSize;
  190.      
  191.     if (currPos != pos) { // Need seek?
  192.       PFFS.lseek_file(pos);
  193.       currPos = pos;
  194.       buffidx = bufsiz; // Force buffer reload
  195.     }
  196.  
  197.     for (col=0; col<w; col++) { // For each pixel...
  198.       // Time to read more pixel data?
  199.       if (buffidx >= bufsiz) { // Indeed
  200.         int nread;
  201.         PFFS.read_file((char *)buf, bufsiz, &nread);
  202.         currPos += nread;
  203.         buffidx = 0; // Set index to beginning
  204.       }
  205.  
  206.       // Convert pixel from BMP to TFT format, push to display
  207.       b = buf[buffidx++];
  208.       g = buf[buffidx++];
  209.       r = buf[buffidx++];
  210.       tft.pushColor(tft.Color565(r,g,b));
  211.     } // end pixel
  212.   }
  213. #ifdef DEBUG
  214.   out.print(F("Loaded in "));
  215.   out.print(millis() - startTime);
  216.   out.println(F(" ms"));
  217. #endif
  218.   return FR_OK;
  219. }
  220.  
  221. // These read 16- and 32-bit types from the SD card file.
  222. // BMP data is stored little-endian, Arduino is little-endian too.
  223. // May need to reverse subscript order if porting elsewhere.
  224. static uint16_t read16(uint32_t &p) {
  225.   uint16_t result;
  226.   int n;
  227.   PFFS.read_file((char *)&result, sizeof(result), &n);
  228.   p += n;
  229.   return result;
  230. }
  231.  
  232. static uint32_t read32(uint32_t &p) {
  233.   uint32_t result;
  234.   int n;
  235.   PFFS.read_file((char *)&result, sizeof(result), &n);
  236.   p += n;
  237.   return result;
  238. }
  239.  
  240. static const __FlashStringHelper *cardinal_direction(short deg)
  241. {
  242.   if (deg < 12 || deg >= 349)
  243.     return F("N");
  244.   if (deg >= 12 && deg < 34)
  245.     return F("NNE");
  246.   if (deg >= 34 && deg < 57)
  247.     return F("NE");
  248.   if (deg >= 57 && deg < 79)
  249.     return F("ENE");
  250.   if (deg >= 79 && deg < 102)
  251.     return F("E");
  252.   if (deg >= 102 && deg < 124)
  253.     return F("ESE");
  254.   if (deg >= 124 && deg < 147)
  255.     return F("SE");
  256.   if (deg >= 147 && deg < 169)
  257.     return F("SSE");
  258.   if (deg >= 169 && deg < 192)
  259.     return F("S");
  260.   if (deg >= 192 && deg < 214)
  261.     return F("SSW");
  262.   if (deg >= 214 && deg < 237)
  263.     return F("SW");
  264.   if (deg >= 237 && deg < 259)
  265.     return F("WSW");
  266.   if (deg >= 259 && deg < 282)
  267.     return F("W");
  268.   if (deg >= 282 && deg < 304)
  269.     return F("WNW");
  270.   if (deg >= 304 && deg < 327)
  271.     return F("NW");
  272. //  if (deg >= 327 && deg < 349)
  273.   return F("NNW");
  274. }
  275.  
  276. static void display_unit(const char *unit) {
  277.   tft.setTextSize(1);
  278.   tft.print(unit);  
  279. }
  280.  
  281. static void display_unit(char unit) {
  282.   tft.setTextSize(1);
  283.   tft.print(unit);  
  284. }
  285.  
  286. static void display_current() {
  287.   tft.fillScreen(ST7735_WHITE);
  288.   tft.setTextColor(ST7735_BLACK);
  289.  
  290.   tft.setTextSize(2);
  291.   tft.setCursor(1, 1);
  292.   tft.print(wind_speed);
  293.   display_unit(speed_unit);  
  294.   tft.setCursor(1, 17);
  295.   tft.print(cardinal_direction(wind_direction));
  296.  
  297.   tft.setTextSize(2);
  298.   tft.setCursor(1, tft.height()-16);
  299.   tft.print(condition_temp);
  300.   display_unit(temp_unit);
  301.   if (condition_temp != wind_chill) {
  302.     tft.setCursor(1, tft.height()-24);
  303.     tft.print(wind_chill);
  304.   }
  305.  
  306.   tft.setTextSize(2);
  307.   tft.setCursor(right(val_len(atmos_humidity), tft.width(), 2)-6, tft.height()-16);
  308.   tft.print(atmos_humidity);
  309.   tft.setCursor(tft.width()-6, tft.height()-16);  // ???
  310.   display_unit('%');
  311.  
  312.   tft.setTextSize(2);
  313.   tft.setCursor(right(val_len(atmos_pressure), tft.width(), 2)-6*strlen(pres_unit), 1);
  314.   tft.print(atmos_pressure);
  315.   display_unit(pres_unit);
  316.   if (atmos_rising == 1) {
  317.     tft.setCursor(right(6, tft.width(), 1), 17);
  318.     tft.print(F("rising"));
  319.   } else if (atmos_rising == -1) {
  320.     tft.setCursor(right(7, tft.width(), 1), 17);
  321.     tft.print(F("falling"));
  322.   }
  323.  
  324.   tft.setCursor(centre_text(city, 80, 1), 30);
  325.   tft.println(city);
  326.   bmp_draw(xmlbuf, sizeof(xmlbuf), condition_code, 54, 38);
  327.   tft.setCursor(centre_text(condition_text, 80, 1), 90);
  328.   tft.print(condition_text);
  329.  
  330.   int rad = 60, cx = 80, cy = 64;
  331.   const float a = 0.999847695, b = 0.017452406;
  332.   // wind dir is azimuthal angle with N at 0
  333.   float s = 1.0, c = 0.0;
  334.   for (uint16_t i = 0; i < wind_direction; i++) {
  335.     const float ns = a*s + b*c;
  336.     const float nc = a*c - b*s;
  337.     c = nc;
  338.     s = ns;
  339.   }
  340.   // wind dir rotates clockwise so compensate
  341.   int ex = cx-rad*c, ey = cy-rad*s;
  342.   tft.fillCircle(ex, ey, 3, ST7735_BLACK);
  343.   tft.drawLine(ex, ey, ex + wind_speed*(cx - ex)/50, ey+wind_speed*(cy-ey)/50, ST7735_BLACK);
  344. }
  345.  
  346. static void display_forecast(struct forecast *f)
  347. {
  348.   tft.fillScreen(ST7735_WHITE);
  349.  
  350.   tft.setTextSize(2);
  351.   tft.setCursor(1, tft.height()-16);
  352.   tft.print(f->low);
  353.   tft.setTextSize(1);
  354.   tft.print(temp_unit);
  355.   tft.setCursor(1, tft.height()-24);
  356.   tft.print(F("low"));
  357.  
  358.   tft.setTextSize(2);
  359.   tft.setCursor(right(val_len(f->high), tft.width(), 2)-6, tft.height()-16);
  360.   tft.print(f->high);
  361.   tft.setTextSize(1);
  362.   tft.setCursor(tft.width()-6, tft.height()-16);  // ???
  363.   tft.print(temp_unit);
  364.   tft.setCursor(right(4, tft.width(), 1), tft.height()-24);
  365.   tft.print(F("high"));
  366.  
  367.   tft.setTextSize(2);
  368.   tft.setCursor(centre_text(f->day, 80, 2), 14);
  369.   tft.print(f->day);
  370.   tft.setTextSize(1);
  371.   tft.setCursor(centre_text(f->date, 80, 1), 30);
  372.   tft.println(f->date);
  373.   bmp_draw(xmlbuf, sizeof(xmlbuf), f->code, 54, 38);  
  374.   tft.setCursor(centre_text(f->text, 80, 1), 90);
  375.   tft.print(f->text);  
  376. }
  377.  
  378. static void set_status(int bit, boolean cond)
  379. {
  380.   if (cond)
  381.     status |= bit;
  382.   else
  383.     status &= ~bit;
  384. }
  385.  
  386. static void read_str(const char *from, uint16_t fromlen, char *to, uint16_t tolen, bool update = true)
  387. {
  388.   uint16_t len = tolen < fromlen? tolen: fromlen;
  389.   if (strncmp(to, from, len) != 0) {
  390.     strncpy(to, from, len);
  391.     if (len == tolen)
  392.       to[len-1] = '\0';
  393.     else
  394.       to[len] = '\0';
  395.     if (update)
  396.       set_status(DISPLAY_UPDATE, true);
  397.   }    
  398. }
  399.  
  400. static int read_int(const char *from, int curr, bool update = true)
  401. {
  402.   int val = atoi(from);
  403.   int n = val_len(val);
  404.   // bodge for round-up (saves atof)
  405.   if (from[n] == '.') {
  406.     int r = from[n+1] - '0';
  407.     if (r > 4) {
  408.       if (val >= 0)
  409.         val++;
  410.       else
  411.         val--;
  412.     }
  413.   }
  414.   if (val != curr && update)
  415.     set_status(DISPLAY_UPDATE, true);
  416.   return val;
  417. }
  418.  
  419. static boolean strequals(const char *first, PGM_P second)
  420. {
  421.   return strcmp_P(first, second) == 0;
  422. }
  423.  
  424. static boolean strcontains(const char *first, PGM_P second)
  425. {
  426.     return strstr_P(first, second) != 0;
  427. }
  428.  
  429. void xml_callback(uint8_t statusflags, char *tagName, uint16_t tagNameLen, char *data, uint16_t dlen) {
  430.   if (statusflags & STATUS_START_TAG) {
  431.     if (tagNameLen) {
  432.       set_status(IN_LOCATION, strcontains(tagName, PSTR(":location")));
  433.       set_status(IN_UNITS, strcontains(tagName, PSTR(":units")));
  434.       set_status(IN_ATMOS, strcontains(tagName, PSTR(":atmos")));
  435.       set_status(IN_WIND, strcontains(tagName, PSTR(":wind")));
  436.       set_status(IN_CONDITION, strcontains(tagName, PSTR(":condition")));
  437.       set_status(IN_FORECAST, strcontains(tagName, PSTR(":forecast")));
  438.     }
  439.   } else if (statusflags & STATUS_END_TAG) {
  440.     if (strequals(tagName, PSTR("/rss")))
  441.       fcast = 0;
  442.     else if (status & IN_FORECAST) {
  443.       fcast++;
  444.       if (fcast == FORECASTS)
  445.         fcast = 0;
  446.     }
  447.   } else if (statusflags & STATUS_ATTR_TEXT) {
  448.     if (status & IN_LOCATION) {
  449.       if (strequals(tagName, PSTR("city")))
  450.         read_str(data, dlen, city, sizeof(city));    
  451.     } else if (status & IN_UNITS) {
  452.       if (strequals(tagName, PSTR("temperature")))
  453.         temp_unit = *data;
  454.       else if (strequals(tagName, PSTR("pressure")))
  455.         read_str(data, dlen, pres_unit, sizeof(pres_unit));
  456.       else if (strequals(tagName, PSTR("speed")))
  457.         read_str(data, dlen, speed_unit, sizeof(speed_unit));
  458.     } else if (status & IN_WIND) {
  459.       if (strequals(tagName, PSTR("chill")))
  460.         wind_chill = read_int(data, wind_chill);
  461.       else if (strequals(tagName, PSTR("direction")))
  462.         wind_direction = read_int(data, wind_direction);
  463.       else if (strequals(tagName, PSTR("speed")))
  464.         wind_speed = read_int(data, wind_speed);
  465.     } else if (status & IN_ATMOS) {
  466.       if (strequals(tagName, PSTR("humidity")))
  467.         atmos_humidity = read_int(data, atmos_humidity);
  468.       else if (strequals(tagName, PSTR("pressure")))
  469.         atmos_pressure = read_int(data, atmos_pressure);
  470.       else if (strequals(tagName, PSTR("rising")))
  471.         atmos_rising = read_int(data, atmos_rising);
  472.     } else if (status & IN_CONDITION) {
  473.       if (strequals(tagName, PSTR("code")))
  474.         read_str(data, dlen, condition_code, sizeof(condition_code));
  475.       if (strequals(tagName, PSTR("text")))
  476.         read_str(data, dlen, condition_text, sizeof(condition_text));
  477.       else if (strequals(tagName, PSTR("temp")))
  478.         condition_temp = read_int(data, condition_temp);
  479.     } else if (status & IN_FORECAST) {
  480.       if (strequals(tagName, PSTR("day")))
  481.         read_str(data, dlen, forecasts[fcast].day, sizeof(forecasts[fcast].day), false);
  482.       else if (strequals(tagName, PSTR("low")))
  483.         forecasts[fcast].low = read_int(data, forecasts[fcast].low, false);
  484.       else if (strequals(tagName, PSTR("high")))
  485.         forecasts[fcast].high = read_int(data, forecasts[fcast].high, false);
  486.       else if (strequals(tagName, PSTR("code")))
  487.         read_str(data, dlen, forecasts[fcast].code, sizeof(forecasts[fcast].code), false);
  488.       else if (strequals(tagName, PSTR("text")))
  489.         read_str(data, dlen, forecasts[fcast].text, sizeof(forecasts[fcast].text), false);
  490.       else if (strequals(tagName, PSTR("date")))
  491.         read_str(data, dlen, forecasts[fcast].date, sizeof(forecasts[fcast].date), false);
  492.     }
  493.   } else if (statusflags & STATUS_ERROR) {
  494. #ifdef DEBUG
  495.     out.print(F("\nTAG:"));
  496.     out.print(tagName);
  497.     out.print(F(" :"));
  498.     out.println(data);
  499. #endif
  500.     bool rsp = (status & READING_RESPONSE);
  501.     status = 0;
  502.     set_status(DISPLAY_UPDATE, true);
  503.     set_status(READING_RESPONSE, rsp);
  504.   }
  505. }
  506.  
  507. static byte rx()
  508. {
  509.   SPDR = 0xFF;
  510.   loop_until_bit_is_set(SPSR, SPIF);
  511.   return SPDR;
  512. }
  513.  
  514. static void tx(byte d)
  515. {
  516.   SPDR = d;
  517.   loop_until_bit_is_set(SPSR, SPIF);
  518. }
  519.  
  520. uint16_t update_interval = 20*60;
  521. char city_code[7];
  522. char units[2];
  523. byte bright, dim, fade;
  524.  
  525. static void halt() {
  526.   out.println(F("halt"));
  527.   for (;;);
  528. }
  529.  
  530. void setup () {
  531. #ifdef DEBUG
  532.   Serial.begin(57600);
  533. #endif
  534.  
  535.   tft.initR(INITR_REDTAB);
  536.   tft.setRotation(1);
  537.   tft.fillScreen(ST7735_BLACK);
  538.   tft.setTextColor(ST7735_WHITE);
  539.   tft.setCursor(0,0);
  540.   analogWrite(TFT_LED, 0);
  541.  
  542.   out.println(F("Weather Guy (c)2013 Steve"));
  543.   out.println(freeMemory());
  544.  
  545.   // initialise the SD card and read the config file
  546.   out.print(F("PFFS"));
  547.   int res = PFFS.begin(SD_CS, rx, tx);
  548.   if (res != FR_OK) {
  549.     out.print('!');
  550.     out.println(res);
  551.     halt();
  552.   }
  553.   out.println();
  554.   out.print(F("Config"));
  555.   strcpy_P((char *)xmlbuf, PSTR("config"));
  556.   res = PFFS.open_file((char *)xmlbuf);
  557.   if (res != FR_OK) {
  558.     out.print('!');
  559.     out.println(res);
  560.     halt();
  561.   }
  562.   out.println();
  563.   int nread;
  564.   res = PFFS.read_file((char *)xmlbuf, sizeof(xmlbuf), &nread);
  565.   if (res != FR_OK) {
  566.     out.print(F("read!"));
  567.     out.println(res);
  568.     halt();
  569.   }
  570.   const char *delim = " \n";
  571.   char *p = strtok((char *)xmlbuf, delim);
  572.   update_interval = atoi(p);
  573.   p = strtok(0, delim);
  574.   bright = atoi(p);
  575.   p = strtok(0, delim);
  576.   dim = atoi(p);  
  577.   p = strtok(0, delim);
  578.   strcpy(city_code, p);
  579.   p = strtok(0, delim);
  580.   strcpy(units, p);
  581.  
  582.   // ethernet interface mac address, must be unique on the LAN
  583.   out.print(F("Ethernet"));
  584.   byte mac[] = { 0x74, 0x69, 0x69, 0x2d, 0x30, 0x31 };
  585.   if (ether.begin(sizeof Ethernet::buffer, mac, ETHER_CS) == 0) {
  586.     out.println('!');
  587.     halt();
  588.   }
  589.   out.println();
  590.   out.print(F("DHCP"));
  591.   if (!ether.dhcpSetup()) {
  592.     out.println('!');
  593.     halt();
  594.   }
  595.   out.println();
  596.   out.print(F("DNS"));
  597.   if (!ether.dnsLookup(website)) {
  598.     out.println('!');
  599.     halt();
  600.   }
  601.   ether.persistTcpConnection(true);
  602.  
  603.   xml.init(xmlbuf, sizeof(xmlbuf), xml_callback);
  604.  
  605.   analogWrite(TFT_LED, dim);
  606.   fade = dim;
  607.  
  608.   // force first update
  609.   last_fetch = -update_interval;
  610.   wdt_enable(WDTO_8S);
  611. }
  612.  
  613. static void net_callback(byte status, word off, word len) {
  614. #ifdef DEBUG
  615.   out.println(off);
  616.   out.println(len);
  617. #endif
  618.   if (status == 1) {
  619.     set_status(READING_RESPONSE, len == 512);
  620.     char *rs = (char *)Ethernet::buffer+off;  
  621.     while (len-- > 0) {
  622. #ifdef DEBUG
  623.       out.print(*rs);
  624. #endif
  625.       xml.processChar(*rs++);
  626.     }
  627.   }
  628. }
  629.  
  630. void loop() {
  631.  
  632.   uint32_t now = millis();
  633.   ether.packetLoop(ether.packetReceive());
  634.  
  635.   if (fade == dim) {
  636.     if (analogRead(A5) == 1023) {
  637.       bright_on = now;
  638.       fade = bright;
  639.       analogWrite(TFT_LED, fade);
  640.     }
  641.   } else if (now - bright_on > FORECASTS*10000L) {
  642.     analogWrite(TFT_LED, fade++);
  643.     if (fade == dim)
  644.       set_status(DISPLAY_UPDATE, true);
  645.     else
  646.       delay(25);
  647.   }
  648.  
  649.   if (now - last_fetch > update_interval*1000L) {
  650.     last_fetch = now;
  651.     strcpy_P((char *)xmlbuf, PSTR("?w="));
  652.     strcat((char *)xmlbuf, city_code);
  653.     strcat_P((char *)xmlbuf, PSTR("&u="));
  654.     strcat((char *)xmlbuf, units);
  655.     ether.browseUrl(PSTR("/forecastrss"), (char *)xmlbuf, website, PSTR("Accept: text/xml\r\n"), net_callback);
  656.     set_status(READING_RESPONSE, true);
  657.   } else if (!(status & READING_RESPONSE)) {
  658.     wdt_reset();
  659.     if (status & DISPLAY_UPDATE) {  
  660.       display_current();
  661.       set_status(DISPLAY_UPDATE, false);
  662.     } else if (fade != dim && ((now - bright_on) % 10000) == 0) {
  663.       uint32_t t = ((now - bright_on) / 10000) % FORECASTS;
  664.       display_forecast(forecasts+t);
  665.     }
  666.   }
  667. }
A hozzászólás módosítva: Jún 6, 2016
(#) kapu48 válasza dannu hozzászólására (») Jún 6, 2016 /
 
Az újabb IDEk már háklisak rá!
Ezért legyen a 25. sorban 'const':
  1. const char website[] PROGMEM = "weather.yahooapis.com";
(#) dannu válasza kapu48 hozzászólására (») Jún 6, 2016 /
 
Igen próbáltam így is , minden fajta utat be jártam már de nem jött össze . Azért bátorkodtam írni .
(#) Kovidivi válasza dannu hozzászólására (») Jún 6, 2016 /
 
A 4. sor végén az egyes karakter is vicces.
(#) kapu48 válasza dannu hozzászólására (») Jún 6, 2016 /
 
Ha láthatnánk a hiba üzenetett?! Talán!
(#) dannu hozzászólása Jún 7, 2016 /
 
Tessék itt egy kép .

fdfdfdfd.png
    
(#) brumbrus hozzászólása Jún 7, 2016 /
 
Üdv!
Nem tudok kommunikálni az ESP8266 01-gyel! Mikor bedugom az arduinot világít a piros led és egy pillanatra felvillan a kék.
Mivel megám van csináltam egy feszültségosztót (V(in)=5V; R(1)=5.1kohm; R(2)=10kohm; V(out)=3.311V). Ezzel lehet a baj, mert 3.3V-nek kell lennie és nekem 3.311 körül van egy kalkulátor szerint? Vagy mivel? (usb-soros átalakítóm nincs)
A program a következő:
  1. /*  
  2.  Név:        TransparentSerial
  3.  Leírás:     Transzparens USB-soros-SWsoros átjáró ESP-8266 WiFi modulhoz
  4.  Link:       http://www.tavir.hu/iot-0
  5.  Fordító:    Arduino-1.6.5.
  6.  Lapka/chip: Arduino Diecimila/UNO
  7.  Szerző:     superp (nick@ forum.tavir.hu)
  8.  Módosítás:  Cseh Róbert / avr(kukac)tavir(pont)hu
  9.  Licensz:    Public Domain
  10.  
  11. */
  12.  
  13. #include <SoftwareSerial.h>
  14.  
  15. SoftwareSerial ESPSerial(0,1); // RX, TX
  16.  
  17. void setup()
  18. {
  19. Serial.begin(115200); // A belső port megnyitása azonos sebességű legyen az ESPSeriel-al
  20. //Serial.begin(9600); // A belső port megnyitása azonos sebességű legyen az ESPSeriel-al
  21. delay(1000);
  22. //ESPSerial.begin(115200); // ESP8266 port 115200 kapcsolati sebesség
  23. ESPSerial.begin(9600); // ESP8266 port 9600 kapcsolati sebesség
  24. delay(1000);
  25. Serial.println("ESP8266 WIFI PORT START");
  26. Serial.println("AT parancsok:");
  27. }
  28.  
  29. void loop()
  30. {
  31.   // Amennyiben van adat az ESP8266 felől, azt kiírjuk a terminal ablakba
  32.   if (ESPSerial.available()) {
  33.     Serial.write(ESPSerial.read());
  34.   }
  35.  
  36.   // Amit beírunk a terminál ablak parancssorába, azt küldi el az ESP-nek
  37.   if (Serial.available()) {
  38.     ESPSerial.write(Serial.read());
  39.   }
  40. }
(#) brumbrus válasza brumbrus hozzászólására (») Jún 7, 2016 /
 
A kapcsolás:
3.3V-------------------------------------------------------VCC, CH_PD,RESET

GND---------------------GND

Arduino TX1--------Esp RX
Arduino RX0--------Esp TX(feszosztóval)
(#) kapu48 válasza dannu hozzászólására (») Jún 8, 2016 /
 
Ezt nem így gondoltam!

Ott a gomb -> Hibaüzenet Másolása!!!
Aztán PasteBin!!!
(#) csavarkulcs hozzászólása Jún 8, 2016 /
 
Sziasztok!
Ezt megérné megvennem?
kissebb áramkörök építéséhez használnám.
Bővebben: Link

Köszi.
(#) kameleon2 válasza csavarkulcs hozzászólására (») Jún 8, 2016 /
 
Szerintem drága. Vehetsz olcsóbban is: Például a vaterán. - Ha már itthon keresgélsz. Ebay-en filléres tétel és ugyanúgy működik. Nekem is van 1500Ft-os változat és semmi gondom vele.
(#) csavarkulcs válasza kameleon2 hozzászólására (») Jún 8, 2016 /
 
ok. megfontolom, köszi.
(#) dokidoki válasza kapu48 hozzászólására (») Jún 9, 2016 /
 
Legszebb az egészben, hogy mellékvágányon sem karcolja az arduino témakört. Pedig ezért járok ebbe a topikba, hogy erről olvassak, de 'majd mindég lukra futok.
(#) dannu válasza brumbrus hozzászólására (») Jún 9, 2016 /
 
Feszültségre és az amperra figyelj ha nincs meg nem is működik csak villog !
(#) FDAssasin hozzászólása Jún 12, 2016 /
 
Sziasztok!
Az lenne a kérdésem, hogy Arduino UNO esetén át kell írni az Arduino as ISP példát az IDE-ben? Valamelyik modellnél nem ugyanúgy van a reset pin, mint ahogy a példában le van írva, de már nem találom azt az oldalt ahol ezt leírták. Ha számít, Sainsmart UNO R3 klón lapról van szó és USBasp FW-t akarok vele frissíteni
(#) vyky hozzászólása Jún 13, 2016 /
 
Sziasztok. egy kis segítséget kérnék ismét. Adott ez a kód amit már én írtam át.
  1. #include <LiquidCrystal_SR.h>
  2. int encoderPin1 = 2;
  3. int encoderPin2 = 3;
  4.  
  5. volatile int lastEncoded = 0;
  6. volatile long encoderValue = 0;
  7. long meter = 6.594;
  8.  
  9.  
  10. long lastencoderValue = 0;
  11.  
  12. int lastMSB = 0;
  13. int lastLSB = 0;
  14.  
  15. LiquidCrystal_SR lcd(8,7,TWO_WIRE);
  16. //                   | |
  17. //                   | \-- Clock Pin
  18. //                   \---- Data/Enable Pin
  19.  
  20. void setup(){
  21. lcd.begin(16,1);               // initialize the lcd
  22.                    // go home
  23.  
  24.  
  25.   pinMode(encoderPin1, INPUT);
  26.   pinMode(encoderPin2, INPUT);
  27.  
  28.   digitalWrite(encoderPin1, HIGH); //turn pullup resistor on
  29.   digitalWrite(encoderPin2, HIGH); //turn pullup resistor on
  30.  
  31.   //call updateEncoder() when any high/low changed seen
  32.   //on interrupt 0 (pin 2), or interrupt 1 (pin 3)
  33.   attachInterrupt(0, updateEncoder, CHANGE);
  34.   attachInterrupt(1, updateEncoder, CHANGE);
  35. }
  36. void loop(){
  37.  
  38. lcd.setCursor (0,0);
  39. lcd.print(encoderValue*meter);
  40.  
  41.   delay(1000);
  42. }

A problémám az,hogy nem hajlandó csak egész számokat kiírni,ha meg átírom a long-ot float-ra akkor meg nem fogadja el a program.
Előre is köszönöm.
(#) GPeti1977 válasza vyky hozzászólására (») Jún 13, 2016 /
 
A long meter =6.594; mivel long nem lehet csak egész szám.
Vagy long meter = 6594;
és a végeredményt osztod 1000 rel.
A hozzászólás módosítva: Jún 13, 2016
(#) vyky válasza GPeti1977 hozzászólására (») Jún 13, 2016 /
 
De ha átírom float-ra akkor hibával kiáll az IDE.
(#) Balázs válasza vyky hozzászólására (») Jún 13, 2016 /
 
Mert a LiquidCrystal osztály print() metódusának nincs olyan példánya, ami float paraméterrel rendelkezik, így nem tud mit meghívni a fordító. Viszont olyan példány van, aminek a paramétere string, úgyhogy az egy megoldás lehet, hogy átkonvertálod a számodat karakterlánccá. Vagy amit GPeti mondott: alapvetően egész számokkal dolgozol, és a kiíratásnál ügyeskedsz, hogy hova tegyél vesszőt.
Következő: »»   237 / 841
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