Projek zegara z pasków LED i pierścienia NeoPixel - Problem z kompilacją programu - Wersja do druku +- Arduino Polska Forum (https://forum.arduinopolska.pl) +-- Dział: Inne (https://forum.arduinopolska.pl/dzial-inne) +--- Dział: Poradniki (https://forum.arduinopolska.pl/dzial-poradniki) +--- Wątek: Projek zegara z pasków LED i pierścienia NeoPixel - Problem z kompilacją programu (/watek-projek-zegara-z-pask%C3%B3w-led-i-pier%C5%9Bcienia-neopixel-problem-z-kompilacj%C4%85-programu) |
Projek zegara z pasków LED i pierścienia NeoPixel - Problem z kompilacją programu - pawel4350 - 06-01-2024 Cześć. Potrzebuję pomocy bo na prawdę czarno już to widzę a na prawdę szkoda by było żeby te części elektroniczne tylko tak leżakowały do swego czasu kiedy już przyjdzie pora wykorzystać je kiedyś do czego innego a tym bardziej, że bardzo mi zależy na tym projekcie. Od razu uprzedzam, że jestem kompletnie początkujący także bardzo proszę o wyrozumiałość. Chcę zbudować bardzo fajny zegar oparty o 2 płytki arduino pro mini, taśmę adresowalną LED i ring też adresowalny. Projekt pochodzi ze strony https://www.forgani.com/electronics-projects/strip-neopixel-ring-clock/ Mam problem z zaprogramowaniem tych płytek choćby tej pierwszej (z drugą już nie próbowałem bo nie ma sensu skoro będzie ta sama sytuacja). Do programowania używam środowiska Arduino IDE w systemie operacyjnym Windows 10. Środowisko jest oczywiście w najnowszej werssji. Mam do dyspozycji konwerter CP2102. Wyczytałem też, że można użyć Arduino UNO jako programatora do Arduino pro mini więc ewentualnie mam też Arduino UNO. Niby wszystko przygotowałem tak jak trzeba aby już tylko załadować program, sterowniki też są poinstalowane i najnowsze ale niestety pojawia mi się komunikat: "Compilation error: exit status 1" i przez to nie chce mi załadować szkicu na płytkę. Kombinowałem najpierw z tym konwerterem CP2102 z wciskaniem resetu w odpowiednim momencie i nic. Spróbowałem z Arduino UNO i też nic nie pomaga nawet po zainstalowaniu wszystkich niezbędnych do tego projektu bibliotek i też w najnowszych wersjach. Nie widzę już nic więcej co mogło by mi tu pomóc aby wreszcie można było załadować szkic bez żadnego problemu i przez to stoję z całym projektem w miejscu już bezradny. W załączniku wrzucał cały kod projektu może tam gdzieś jest jakiś błąd a jeśli tak to gdzie i co tu należy zrobić. Cały kod tego projektu jest podzielony na 2 części (po jednej dla każdej z płytek). Załączam też poniżej komunikaty z konsoli jakie się generują podczas kompilacji: Część 1 C:\Users\pawel\OneDrive\Dokumenty\Arduino\libraries\DCF77\DCF77.cpp: In static member function 'static void DCF77::finalizeBuffer()': C:\Users\pawel\OneDrive\Dokumenty\Arduino\libraries\DCF77\DCF77.cpp:160:21: error: 'now' was not declared in this scope filledTimestamp = now(); ^~~ C:\Users\pawel\OneDrive\Dokumenty\Arduino\libraries\DCF77\DCF77.cpp:160:21: note: suggested alternative: 'pow' filledTimestamp = now(); ^~~ pow C:\Users\pawel\OneDrive\Dokumenty\Arduino\libraries\DCF77\DCF77.cpp: In static member function 'static bool DCF77::receivedTimeUpdate()': C:\Users\pawel\OneDrive\Dokumenty\Arduino\libraries\DCF77\DCF77.cpp:189:46: error: 'now' was not declared in this scope time_t processedTime = latestupdatedTime + (now() - processingTimestamp); ^~~ C:\Users\pawel\OneDrive\Dokumenty\Arduino\libraries\DCF77\DCF77.cpp:189:46: note: suggested alternative: 'pow' time_t processedTime = latestupdatedTime + (now() - processingTimestamp); ^~~ pow C:\Users\pawel\OneDrive\Dokumenty\Arduino\libraries\DCF77\DCF77.cpp:197:20: error: 'SECS_PER_MIN' was not declared in this scope if(difference < 2*SECS_PER_MIN) { ^~~~~~~~~~~~ C:\Users\pawel\OneDrive\Dokumenty\Arduino\libraries\DCF77\DCF77.cpp:197:20: note: suggested alternative: 'WCHAR_MIN' if(difference < 2*SECS_PER_MIN) { ^~~~~~~~~~~~ WCHAR_MIN C:\Users\pawel\OneDrive\Dokumenty\Arduino\libraries\DCF77\DCF77.cpp:209:25: error: 'SECS_PER_MIN' was not declared in this scope if(shiftDifference < 2*SECS_PER_MIN) { ^~~~~~~~~~~~ C:\Users\pawel\OneDrive\Dokumenty\Arduino\libraries\DCF77\DCF77.cpp:209:25: note: suggested alternative: 'WCHAR_MIN' if(shiftDifference < 2*SECS_PER_MIN) { ^~~~~~~~~~~~ WCHAR_MIN C:\Users\pawel\OneDrive\Dokumenty\Arduino\libraries\DCF77\DCF77.cpp: In static member function 'static bool DCF77::processBuffer()': C:\Users\pawel\OneDrive\Dokumenty\Arduino\libraries\DCF77\DCF77.cpp:271:2: error: 'tmElements_t' was not declared in this scope tmElements_t time; ^~~~~~~~~~~~ C:\Users\pawel\OneDrive\Dokumenty\Arduino\libraries\DCF77\DCF77.cpp:284:12: error: request for member 'Second' in 'time', which is of non-class type 'time_t(time_t*) {aka long unsigned int(long unsigned int*)}' time.Second = 0; ^~~~~~ C:\Users\pawel\OneDrive\Dokumenty\Arduino\libraries\DCF77\DCF77.cpp:285:9: error: request for member 'Minute' in 'time', which is of non-class type 'time_t(time_t*) {aka long unsigned int(long unsigned int*)}' time.Minute = rx_buffer->Min-((rx_buffer->Min/16)*6); ^~~~~~ C:\Users\pawel\OneDrive\Dokumenty\Arduino\libraries\DCF77\DCF77.cpp:286:12: error: request for member 'Hour' in 'time', which is of non-class type 'time_t(time_t*) {aka long unsigned int(long unsigned int*)}' time.Hour = rx_buffer->Hour-((rx_buffer->Hour/16)*6); ^~~~ C:\Users\pawel\OneDrive\Dokumenty\Arduino\libraries\DCF77\DCF77.cpp:287:12: error: request for member 'Day' in 'time', which is of non-class type 'time_t(time_t*) {aka long unsigned int(long unsigned int*)}' time.Day = rx_buffer->Day-((rx_buffer->Day/16)*6); ^~~ C:\Users\pawel\OneDrive\Dokumenty\Arduino\libraries\DCF77\DCF77.cpp:288:12: error: request for member 'Month' in 'time', which is of non-class type 'time_t(time_t*) {aka long unsigned int(long unsigned int*)}' time.Month = rx_buffer->Month-((rx_buffer->Month/16)*6); ^~~~~ C:\Users\pawel\OneDrive\Dokumenty\Arduino\libraries\DCF77\DCF77.cpp:289:12: error: request for member 'Year' in 'time', which is of non-class type 'time_t(time_t*) {aka long unsigned int(long unsigned int*)}' time.Year = 2000 + rx_buffer->Year-((rx_buffer->Year/16)*6) -1970; ^~~~ C:\Users\pawel\OneDrive\Dokumenty\Arduino\libraries\DCF77\DCF77.cpp:290:24: error: 'makeTime' was not declared in this scope latestupdatedTime = makeTime(time); ^~~~~~~~ C:\Users\pawel\OneDrive\Dokumenty\Arduino\libraries\DCF77\DCF77.cpp:290:24: note: suggested alternative: 'mktime' latestupdatedTime = makeTime(time); ^~~~~~~~ mktime C:\Users\pawel\OneDrive\Dokumenty\Arduino\libraries\DCF77\DCF77.cpp: In static member function 'static time_t DCF77::getTime()': C:\Users\pawel\OneDrive\Dokumenty\Arduino\libraries\DCF77\DCF77.cpp:310:44: error: 'now' was not declared in this scope time_t currentTime =latestupdatedTime + (now() - processingTimestamp); ^~~ C:\Users\pawel\OneDrive\Dokumenty\Arduino\libraries\DCF77\DCF77.cpp:310:44: note: suggested alternative: 'pow' time_t currentTime =latestupdatedTime + (now() - processingTimestamp); ^~~ pow C:\Users\pawel\OneDrive\Dokumenty\Arduino\libraries\DCF77\DCF77.cpp: In static member function 'static time_t DCF77::getUTCTime()': C:\Users\pawel\OneDrive\Dokumenty\Arduino\libraries\DCF77\DCF77.cpp:325:42: error: 'SECS_PER_HOUR' was not declared in this scope int UTCTimeDifference = (CEST ? 2 : 1)*SECS_PER_HOUR; ^~~~~~~~~~~~~ C:\Users\pawel\OneDrive\Dokumenty\Arduino\libraries\DCF77\DCF77.cpp:326:64: error: 'now' was not declared in this scope time_t currentTime =latestupdatedTime - UTCTimeDifference + (now() - processingTimestamp); ^~~ C:\Users\pawel\OneDrive\Dokumenty\Arduino\libraries\DCF77\DCF77.cpp:326:64: note: suggested alternative: 'pow' time_t currentTime =latestupdatedTime - UTCTimeDifference + (now() - processingTimestamp); ^~~ pow exit status 1 Compilation error: exit status 1 A tutaj komunikat z konsoli przy drugiej części kodu (dla drugiej płytki arduino pro mini, która jest wykorzystana w projekcie): C:\Users\pawel\OneDrive\Dokumenty\Arduino\libraries\DCF77\DCF77.cpp: In static member function 'static void DCF77::finalizeBuffer()': C:\Users\pawel\OneDrive\Dokumenty\Arduino\libraries\DCF77\DCF77.cpp:160:21: error: 'now' was not declared in this scope filledTimestamp = now(); ^~~ C:\Users\pawel\OneDrive\Dokumenty\Arduino\libraries\DCF77\DCF77.cpp:160:21: note: suggested alternative: 'pow' filledTimestamp = now(); ^~~ pow C:\Users\pawel\OneDrive\Dokumenty\Arduino\libraries\DCF77\DCF77.cpp: In static member function 'static bool DCF77::receivedTimeUpdate()': C:\Users\pawel\OneDrive\Dokumenty\Arduino\libraries\DCF77\DCF77.cpp:189:46: error: 'now' was not declared in this scope time_t processedTime = latestupdatedTime + (now() - processingTimestamp); ^~~ C:\Users\pawel\OneDrive\Dokumenty\Arduino\libraries\DCF77\DCF77.cpp:189:46: note: suggested alternative: 'pow' time_t processedTime = latestupdatedTime + (now() - processingTimestamp); ^~~ pow C:\Users\pawel\OneDrive\Dokumenty\Arduino\libraries\DCF77\DCF77.cpp:197:20: error: 'SECS_PER_MIN' was not declared in this scope if(difference < 2*SECS_PER_MIN) { ^~~~~~~~~~~~ C:\Users\pawel\OneDrive\Dokumenty\Arduino\libraries\DCF77\DCF77.cpp:197:20: note: suggested alternative: 'WCHAR_MIN' if(difference < 2*SECS_PER_MIN) { ^~~~~~~~~~~~ WCHAR_MIN C:\Users\pawel\OneDrive\Dokumenty\Arduino\libraries\DCF77\DCF77.cpp:209:25: error: 'SECS_PER_MIN' was not declared in this scope if(shiftDifference < 2*SECS_PER_MIN) { ^~~~~~~~~~~~ C:\Users\pawel\OneDrive\Dokumenty\Arduino\libraries\DCF77\DCF77.cpp:209:25: note: suggested alternative: 'WCHAR_MIN' if(shiftDifference < 2*SECS_PER_MIN) { ^~~~~~~~~~~~ WCHAR_MIN C:\Users\pawel\OneDrive\Dokumenty\Arduino\libraries\DCF77\DCF77.cpp: In static member function 'static bool DCF77::processBuffer()': C:\Users\pawel\OneDrive\Dokumenty\Arduino\libraries\DCF77\DCF77.cpp:271:2: error: 'tmElements_t' was not declared in this scope tmElements_t time; ^~~~~~~~~~~~ C:\Users\pawel\OneDrive\Dokumenty\Arduino\libraries\DCF77\DCF77.cpp:284:12: error: request for member 'Second' in 'time', which is of non-class type 'time_t(time_t*) {aka long unsigned int(long unsigned int*)}' time.Second = 0; ^~~~~~ C:\Users\pawel\OneDrive\Dokumenty\Arduino\libraries\DCF77\DCF77.cpp:285:9: error: request for member 'Minute' in 'time', which is of non-class type 'time_t(time_t*) {aka long unsigned int(long unsigned int*)}' time.Minute = rx_buffer->Min-((rx_buffer->Min/16)*6); ^~~~~~ C:\Users\pawel\OneDrive\Dokumenty\Arduino\libraries\DCF77\DCF77.cpp:286:12: error: request for member 'Hour' in 'time', which is of non-class type 'time_t(time_t*) {aka long unsigned int(long unsigned int*)}' time.Hour = rx_buffer->Hour-((rx_buffer->Hour/16)*6); ^~~~ C:\Users\pawel\OneDrive\Dokumenty\Arduino\libraries\DCF77\DCF77.cpp:287:12: error: request for member 'Day' in 'time', which is of non-class type 'time_t(time_t*) {aka long unsigned int(long unsigned int*)}' time.Day = rx_buffer->Day-((rx_buffer->Day/16)*6); ^~~ C:\Users\pawel\OneDrive\Dokumenty\Arduino\libraries\DCF77\DCF77.cpp:288:12: error: request for member 'Month' in 'time', which is of non-class type 'time_t(time_t*) {aka long unsigned int(long unsigned int*)}' time.Month = rx_buffer->Month-((rx_buffer->Month/16)*6); ^~~~~ C:\Users\pawel\OneDrive\Dokumenty\Arduino\libraries\DCF77\DCF77.cpp:289:12: error: request for member 'Year' in 'time', which is of non-class type 'time_t(time_t*) {aka long unsigned int(long unsigned int*)}' time.Year = 2000 + rx_buffer->Year-((rx_buffer->Year/16)*6) -1970; ^~~~ C:\Users\pawel\OneDrive\Dokumenty\Arduino\libraries\DCF77\DCF77.cpp:290:24: error: 'makeTime' was not declared in this scope latestupdatedTime = makeTime(time); ^~~~~~~~ C:\Users\pawel\OneDrive\Dokumenty\Arduino\libraries\DCF77\DCF77.cpp:290:24: note: suggested alternative: 'mktime' latestupdatedTime = makeTime(time); ^~~~~~~~ mktime C:\Users\pawel\OneDrive\Dokumenty\Arduino\libraries\DCF77\DCF77.cpp: In static member function 'static time_t DCF77::getTime()': C:\Users\pawel\OneDrive\Dokumenty\Arduino\libraries\DCF77\DCF77.cpp:310:44: error: 'now' was not declared in this scope time_t currentTime =latestupdatedTime + (now() - processingTimestamp); ^~~ C:\Users\pawel\OneDrive\Dokumenty\Arduino\libraries\DCF77\DCF77.cpp:310:44: note: suggested alternative: 'pow' time_t currentTime =latestupdatedTime + (now() - processingTimestamp); ^~~ pow C:\Users\pawel\OneDrive\Dokumenty\Arduino\libraries\DCF77\DCF77.cpp: In static member function 'static time_t DCF77::getUTCTime()': C:\Users\pawel\OneDrive\Dokumenty\Arduino\libraries\DCF77\DCF77.cpp:325:42: error: 'SECS_PER_HOUR' was not declared in this scope int UTCTimeDifference = (CEST ? 2 : 1)*SECS_PER_HOUR; ^~~~~~~~~~~~~ C:\Users\pawel\OneDrive\Dokumenty\Arduino\libraries\DCF77\DCF77.cpp:326:64: error: 'now' was not declared in this scope time_t currentTime =latestupdatedTime - UTCTimeDifference + (now() - processingTimestamp); ^~~ C:\Users\pawel\OneDrive\Dokumenty\Arduino\libraries\DCF77\DCF77.cpp:326:64: note: suggested alternative: 'pow' time_t currentTime =latestupdatedTime - UTCTimeDifference + (now() - processingTimestamp); ^~~ pow exit status 1 Compilation error: exit status 1 A tutaj załączam linki do filmików, które pokazują jak ten zegar ma działać https://www.youtube.com/watch?v=ZoRDr95QzdQ&t=16s drugi filmik https://www.youtube.com/watch?v=4fzjkswrgDs Nawet ChatGPT dotąd nie dał rady aby rozwiązać wreszcie problem. Także bardzo proszę o pomoc RE: Projek zegara z pasków LED i pierścienia NeoPixel - Problem z kompilacją programu - pawel4350 - 06-01-2024 Tutaj załączam kod źródłowy bo post będzie zbyt długi /* * Arduino Clock with Ring, Strip, LCD 128X64, dfPlayer, IR Remote, Temperature, DCF77, * (PART 1/2) * The device will be powered by a 5 volt battery. * http://www.forgani.com/electronics-projects/ */ #include <RTClib.h> #include <TimeLib.h> RTC_DS1307 RTC; // establish clock object uint8_t mins, secs, hrs; const char* dayName[7] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}; const char* monName[12] = {"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}; #include "Wire.h" #include <OneWire.h> #include <DallasTemperature.h> OneWire oneWire(4); // ONE_WIRE_BUS - DS18B20_PIN 4 DallasTemperature sensors(&oneWire); float angle = 0; #include <U8glib.h> U8GLIB_ST7920_128X64_1X u8g(10); // CS_PIN 10 #include <DCF77.h> #include <Time.h> DCF77 DCF=DCF77(2,0); // DCF_PIN,DCF_INTERRUPT - DCF77PIN 2 unsigned long lastDCF=0; time_t DCFtime; void setup() { //Serial.begin(9600); DCF.Start(); Wire.begin(); if (!RTC.begin()) { //Serial.println("Couldn't find RTC"); while(1); } pinMode(6, OUTPUT); // DCFBlinkPin digitalWrite(6,1); delay(1000); digitalWrite(6,0); sensors.begin(); // DS18B20 starten delay(10); } byte X2 = 0; byte Y2 = 0; byte X3 = 0; byte Y3 = 0; byte ScreenWith = 128; byte ScreenWithC = 102; byte ScreenHeight = 64; byte ScreenHeightC = 37; /* Main program */ void loop() { if (now()-lastDCF > 3600 || lastDCF==0) setDateDs1307(); uint8_t DCFSignalState=digitalRead(2) ^ 1; digitalWrite(6, DCFSignalState); // DCFBlinkPin DateTime now = RTC.now(); sensors.requestTemperatures(); secs = now.second(); mins = now.minute(); hrs = now.hour(); /* Serial.print(hrs); Serial.print(":"); Serial.print(mins); Serial.print(":"); Serial.println(secs); Serial.print("Temperatur: "); Serial.print(now.dayOfTheWeek()); Serial.print(" "); Serial.println("C"); */ u8g.firstPage(); do { u8g.setColorIndex(1); u8g.setFont(u8g_font_6x13); u8g.setPrintPos(2, 36); u8g.print(dayName[now.dayOfTheWeek()]); u8g.setFont(u8g_font_5x7); u8g.setPrintPos(2, 45); u8g.print(now.day()); u8g.setPrintPos(15, 45); u8g.print(monName[(now.month() - 1)]); u8g.setPrintPos(53, 45); u8g.print(now.year()); //show time u8g.setFont(u8g_font_fub17); u8g.drawLine(2, 22, 60, 22); u8g.drawLine(2, 23, 60, 23); byte horPos = 0; if (hrs < 10) { u8g.drawStr(1, 20, "0"); horPos = 15; } else horPos = 1; u8g.setPrintPos(horPos, 20); u8g.print(hrs); u8g.drawStr(27, 17, ":"); byte minPos = 0; if (mins < 10) { u8g.drawStr(35, 20, "0"); minPos = 48; // 51 } else minPos = 35; u8g.setPrintPos(minPos, 20); u8g.print(mins); u8g.setFont(u8g_font_9x15B); u8g.drawStr(63, 13, ":"); byte secPos = 0; if (secs < 10) { u8g.drawStr(72, 15, "0"); secPos = 82; } else secPos = 72; u8g.setPrintPos(secPos, 15); u8g.print(secs); u8g.setFont(u8g_font_9x15B); u8g.setPrintPos(2, 60); u8g.print(sensors.getTempCByIndex(0), 1); u8g.drawCircle(43, 52, 2); u8g.drawStr(48, 60, "C"); u8g.drawDisc(ScreenWithC, ScreenHeightC, 23); u8g.setColorIndex(0); u8g.drawDisc(ScreenWithC, ScreenHeightC, 1.5); u8g.setFont(u8g_font_5x7); u8g.setFontPosTop(); u8g.drawStr(ScreenWithC - 1, ScreenHeightC - 23 - 3, "."); //12 u8g.drawStr(ScreenWithC + 23 - 4, ScreenHeightC - 6, "."); //3 u8g.drawStr(ScreenWithC - 1, ScreenHeightC + 23 - 8, "."); //6 u8g.drawStr(ScreenWithC - 23 + 1, ScreenHeightC - 6, "."); //9 u8g.drawCircle(ScreenWithC, ScreenHeightC, 22); u8g.drawStr(ScreenWithC - 12, ScreenHeightC + 15 - 9, "4gani"); draw_pointer(hrs - 1, 12, 11); draw_pointer(mins - 5, 60, 15); draw_pointer(secs - 5, 60, 18); } while (u8g.nextPage()); delay(600); } void draw_pointer(uint8_t valor, uint8_t rotation, uint8_t radius) { angle = valor * 2.0 * 3.1415 / rotation - 1, 5707; X2 = ScreenWithC + radius * cos(angle); Y2 = ScreenHeightC + radius * sin(angle); u8g.drawLine(ScreenWithC, ScreenHeightC, X2, Y2); } void setDateDs1307(){ DCFtime=DCF.getTime(); //Serial.print("Check if new DCF77 time is available"); if (DCFtime!=0) { //Serial.print("set DCF77 time!!"); setTime(DCFtime); lastDCF=now(); Wire.beginTransmission(0x68); // DS1307_ADDRESS 0x68 Wire.write(0x00); //stop Wire.write(decToBcd(second(DCFtime))); Wire.write(decToBcd(minute(DCFtime))); Wire.write(decToBcd(hour(DCFtime))); Wire.write(decToBcd(weekday(DCFtime))); // SUN=7,MON=1... Wire.write(decToBcd(day(DCFtime))); Wire.write(decToBcd(month(DCFtime))); Wire.write(decToBcd(year(DCFtime))); Wire.endTransmission(); } } byte decToBcd(byte val){ return ( (val/10*16)+(val%10) ); } byte bcdToDec(byte val){ return ( (val/16*10)+(val%16) ); } RE: Projek zegara z pasków LED i pierścienia NeoPixel - Problem z kompilacją programu - pawel4350 - 06-01-2024 Część 2 kodu źródłowego - fragment - (dla drugiej płytki arduimo ProMini) Przepraszam od razu, że w ten sposób ale muszę podzielić to wszystko na fragmenty bo nie mam możliwości inaczej tego wszystkiego tu wstawić /* * Arduino Clock with Ring, Strip, LCD 128X64, dfPlayer, IR Remote, Temperature, DCF77 * (PART 1/2) * The device will be powered by a 5 volt battery. * http://www.forgani.com/electronics-projects/ */ #include <IRremote.h> IRrecv irrecv(7); //RECV_PIN decode_results ir_value; #include <DCF77.h> #include <TimeLib.h> // Library mit Zeit-Funktionen einbinden #define DCF77PIN 2 DCF77 DCF=DCF77(DCF77PIN, 0); // DCF_PIN,DCF_INTERRUPT unsigned long lastDCF=0; time_t DCFtime; byte zero=0x00; #include <Adafruit_NeoPixel.h> #define NUM_LEDS 60 Adafruit_NeoPixel ring=Adafruit_NeoPixel(NUM_LEDS, 3, NEO_GRB+NEO_KHZ800); uint8_t process=0; uint8_t brightness=64; #include <RTClib.h> #include "Wire.h" #define DS1307_ADDRESS 0x68 RTC_DS1307 RTC; // establish clock object int mins, secs, hrs, hoursValue; uint8_t monthValue; uint16_t yearValue; uint8_t weekDay, dayValue; bool tftrefresh=0; uint8_t prev_s; uint8_t prev_m; #include "SoftwareSerial.h" #include "DFRobotDFPlayerMini.h" SoftwareSerial mySoftwareSerial(10, 11); // RX, TX DFRobotDFPlayerMini myDFPlayer; bool secsAudio=0; bool minsAudio=1; bool timeAudio=0; #define DCFBlinkPin 4 #define ledAudioPin 5 #define buttonPin 6 int lastButtonState=0; // previous state of the button int ledAudioState=1; // remember current led state void setup() { Serial.begin(9600); DCF.Start(); Wire.begin(); if (!RTC.begin()) { Serial.println("Couldn't find RTC"); while (1); } if (!RTC.isrunning()) { Serial.println("RTC is NOT running!"); RTC.adjust(DateTime(F(__DATE__), F(__TIME__))); //RTC.adjust(DateTime(2018, 4, 5, 23, 14, 10)); // year, month, day, hour, min, } pinMode(DCFBlinkPin, OUTPUT); pinMode(ledAudioPin, OUTPUT); digitalWrite(DCFBlinkPin, 1); digitalWrite(ledAudioPin, 1); delay(1000); digitalWrite(DCFBlinkPin, 0); digitalWrite(ledAudioPin, 0); pinMode(buttonPin, INPUT); irrecv.enableIRIn(); // Start the receiver ring.begin(); ring.show(); ring.setBrightness(brightness); // 0 255 mySoftwareSerial.begin(9600); if (!myDFPlayer.begin(mySoftwareSerial)) { //Use softwareSerial to communicate with mp3. Serial.println(F("Please insert the SD card!")); while (1); } myDFPlayer.outputDevice(DFPLAYER_DEVICE_SD); myDFPlayer.volume(20); //Set volume value. From 0 to 30 speakPhrase(1113, 2500); // ready; } void loop() { if (now()-lastDCF > 3600 || lastDCF==0) setDateDs1307(); int DCFSignalState=digitalRead(DCF77PIN); digitalWrite(DCFBlinkPin, DCFSignalState); DateTime now=RTC.now(); secs=now.second(); mins=now.minute(); hrs=now.hour(); hoursValue=now.hour(); hrs %= 12; hrs *= 5; hrs += (mins/12); yearValue=now.year(); monthValue=now.month(); dayValue=now.day(); weekDay=now.dayOfTheWeek(); Serial.print(yearValue); Serial.print("-"); Serial.print(monthValue); Serial.print("-"); Serial.print(dayValue); Serial.print(" "); Serial.print(hoursValue); Serial.print(":"); Serial.print(mins); Serial.print(":"); Serial.println(secs); /* int buttonState=digitalRead(buttonPin); if (buttonState != lastButtonState) { if (buttonState==1) { if (ledAudioState==1) ledAudioState=0; else ledAudioState=1; } lastButtonState=buttonState; } */ //ring.setBrightness(brightness); // 0 255 digitalWrite(ledAudioPin, (ledAudioState && minsAudio)); if (ledAudioState) { speakTime(); //speakDate(); } if (irrecv.decode(&ir_value)) { Serial.println(ir_value.value, HEX); translateIR(); irrecv.resume(); // receive the next value } doRing(); } /* int prev; void setDateDs1307(){ //if((millis()-prev) > 3600) { // Delay mit Millis damit der µC nach andere Dinge paralell abarbeiten kann time_t DCFtime=DCF.getTime(); // Zeit holen if (DCFtime!=0) { // Prüfen ob neue Zeit vorhanden ist (Wenn Return 0 dann wurde noch keine neue Zeit empfangen) prev=millis(); // Aktuelle millis Zeit in "prev_update" speichern RTC.stopClock(); RTC.second=(second(DCFtime)); // DON'T USE '00' IF YOU MEAN '0' SECONDS!!! RTC.minute=(minute(DCFtime)); RTC.hour=(hour(DCFtime)); RTC.dow=(weekday(DCFtime)); // SUN=7,MON=1... RTC.day=(day(DCFtime)); RTC.month=(month(DCFtime)); RTC.year=(year(DCFtime)); RTC.setTime(); RTC.startClock(); } //} } */ void setDateDs1307(){ DCFtime=DCF.getTime(); // //Serial.print("Check if new DCF77 time is available"); if (DCFtime!=0) { Serial.print("set DCF77 time!!"); setTime(DCFtime); lastDCF=now(); Wire.beginTransmission(DS1307_ADDRESS); Wire.write(zero); //stop Wire.write(decToBcd(second(DCFtime))); Wire.write(decToBcd(minute(DCFtime))); Wire.write(decToBcd(hour(DCFtime))); Wire.write(decToBcd(weekday(DCFtime))); // SUN=7,MON=1... Wire.write(decToBcd(day(DCFtime))); Wire.write(decToBcd(month(DCFtime))); Wire.write(decToBcd(year(DCFtime))); Wire.endTransmission(); } } byte decToBcd(byte val){ return ( (val/10*16)+(val%10) ); } byte bcdToDec(byte val){ return ( (val/16*10)+(val%16) ); } void irLoop() { // IR Serial.println("IR"); if (irrecv.decode(&ir_value)) { Serial.println(ir_value.value, HEX); translateIR(); irrecv.resume(); // receive the next value } } void ringLoop() { // ring Serial.println("RING"); doRing(); } int oldProcess; int hoursNum=0; int tickRandom; void speakTime() { if (minsAudio) { if (hoursValue > 12) hoursNum=hoursValue-12; else hoursNum=hoursValue; if (mins<1 && secs<10) { // each hours speakPhrase(random(1, 11)+1800, 13000); speakPhrase(1008, 1000); // it's speakPhrase(hoursNum, 1000); speakPhrase(1086, 3000); // oclock } else if (mins==30 && secs<2) { // every 30 minuts speakPhrase(random(1, 9)+1700, 3000); } } if (secsAudio) { // every secounds if (oldProcess != process) { tickRandom=random(1, 8); oldProcess=process; } speakPhrase(tickRandom+2000, 1900); } if (timeAudio) { speakPhrase(1095, 1300); // the time is speakPhrase(hoursValue, 1000); speakPhrase(1084, 1100); // hoursAnd speakPhrase(mins, 1000); speakPhrase(1093, 1000); // minutes /* if (hoursNum > 0) speakPhrase(1096, 800); // AM else speakPhrase(1097, 800); // PM */ speakDate(); } // end speak time } void speakDate() { speakPhrase(1202, 1000); // today is speakPhrase(weekDay+1000, 1000); speakPhrase(1114, 700); // the if (dayValue < 21) speakPhrase(dayValue+1060, 1000); else { speakPhrase(1080, 1000); speakPhrase(dayValue-20, 1000); } speakPhrase(monthValue+1020, 1300); speakPhrase(1218, 4300); // the two thousand eighteen timeAudio=0; } RE: Projek zegara z pasków LED i pierścienia NeoPixel - Problem z kompilacją programu - pawel4350 - 06-01-2024 Ostatni fragment części 2 kodu void speakPhrase(int phrase, int wait) { Serial.println(phrase); myDFPlayer.playMp3Folder(phrase); delay(wait); } void translateIR() {// takes action based on IR code received switch (ir_value.value) { /* case 0x202A25D: //Pause case 0x202C837: //red case 0x202D827: //green case 0x20228D7: //yellow case 0x202827D: //exit case 0x202A857: //radio case 0x20238C7: //serach case 0x2026897: //fav 0x20202FD menu case 0x202E817: //sat case 0x20218E7: //pn case 0x2029867: //tv case 0x202E21D: //f1 case 0x202C23D: //f2 case 0x202629D: //help */ /* case 0xFF48B7: case 0x202B04F: Serial.println("ok"); break; case 0xFFA857: case 0x202F807: Serial.println("FORWARD"); break; // + case 0xFFE21D: case 0x2027887: Serial.println("BACKWARD"); break; // +CH case 0xFFC23D: case 0x20228D7: Serial.println("Play"); break; case 0xFFE01F: case 0x202807: Serial.println("STOP"); break; // - */ case 0xFFA25D: case 0x20250AF: Serial.println("0ff"); break; // -CH case 0xFF20DF: case 0x20230CF: Serial.println("mute"); break; // 0x202F00F case 0xFFB04F: case 0x202A857: myDFPlayer.volumeUp(); Serial.println("v+"); break; // +200 case 0xFF906F: case 0x20238C7: myDFPlayer.volumeDown(); Serial.println("v-"); break; //EQ case 0xFF08F7: case 0x20208F7: process--; Serial.println("LEFT"); break; case 0xFFC837: case 0x2028877: process++; Serial.println("RIGHT"); break; case 0xFFEA15: case 0x202D02F: brightness += 10; Serial.println("TOP"); break; case 0xFFC03F: case 0x202708F: brightness -= 10; Serial.println("DOWN"); break; case 0xFF02FD: case 0x20242BD: process++; Serial.println("CH+"); break; // next case 0xFF22DD: case 0x20258A7: process--; Serial.println("CH-"); break; //Prev case 0xFF30CF: case 0x202807F: process=1; Serial.println("1"); break; //202807F,9716BE3F case 0xFF18E7: case 0x20240BF: process=2; Serial.println("2"); break; //20240BF,3D9AE3F7 case 0xFF7A85: case 0x202C03F: process=3; Serial.println("3"); break; //A480D5C7 case 0xFF10EF: case 0x20220DF: process=4; Serial.println("4"); break; case 0xFF38C7: case 0x202A05F: process=5; Serial.println("5"); break; case 0xFF5AA5: case 0x202609F: process=6; Serial.println("6"); break; case 0xFF42BD: case 0x202E01F: process=7; Serial.println("7"); break; //19272021 case 0xFF4AB5: case 0x20210EF: secsAudio=!secsAudio; Serial.println("8"); break; //4D0C93E7 case 0xFF52AD: case 0x202906F: minsAudio=!minsAudio; Serial.println("9"); break; //D334F085 case 0xFF6897: case 0x20200FF: timeAudio=!timeAudio; Serial.println("0"); break; //B5D13D9D default : 'unknown'; } } //END translateIR void doRing() { Serial.println("Ring"); if (prev_s != secs) { prev_s=secs; tftrefresh=!tftrefresh; } if (prev_m != mins) { //if current seconds diff. from previous seconds prev_m=mins; process++; } if (process > 7) process=1; if (tftrefresh==1) { if (process==1) { anyNr1(0, 0, 127); tftrefresh=0; } if (process==2) { anyNr7(0, 0, 127); tftrefresh=0; } if (process==3) anyNr3(0, 0, 127); if (process==4) { anyNr4(0, 0, 127); tftrefresh=0; } if (process==5) { anyNr5(0, 0, 127); tftrefresh=0; } if (process==6) { anyNr6(0, 0, 127); tftrefresh=0; } if (process==7) { anyNr7(0, 0, 127); tftrefresh=0; } } } // fill -----> . void anyNr1(byte red, byte green, byte blue) { for (int l=NUM_LEDS+1; l > secs; l--) { LToRight(l, red/10, green/10, blue/10, 15); // dealy for (int n=0; n < NUM_LEDS; n++) { if (n <= secs) { if (n != mins && n != hrs) ring.setPixelColor(n, 0x000055); } else { if (n != mins && n != hrs) ring.setPixelColor(n, 0x000000); } } } } // remove -- - void anyNr2(byte red, byte green, byte blue) { int l; for (int i=0; i <= NUM_LEDS; i++) { RToLeft(i-4, 0, 0, 0, 10); for (byte n=secs+1; n < NUM_LEDS; n++) { ring.setPixelColor(n, 0x000055); } } } // Pendle --...-- void anyNr3(byte red, byte green, byte blue) { RToLeftSec(secs-5, 0, 0, 127, 40); for (int p=-3; p < 1; p++) { RToLeft((NUM_LEDS/2)+p, 55, 55, 55, 80); } for (int p=1; p > -5; p--) { LToRight((NUM_LEDS/2)+p, 55, 55, 55, 80); } for (byte n=0; n < NUM_LEDS; n++) { if (n==secs && n==mins && n==hrs) continue; ring.setPixelColor(n, 0x000000); } } // ring dot ---> ---> void anyNr4(byte red, byte green, byte blue) { for (uint8_t i=0; i <= (NUM_LEDS/2); i++) { RToLeft(i-4, 70, 70, 70, 10); RToLeft((NUM_LEDS/2)+i, 70, 70, 70, 10); for (byte n=0; n < NUM_LEDS; n++) { if (n==secs && n==mins && n==hrs) continue; ring.setPixelColor(n, 0x000000); } } } // ring back dot <--- <---- void anyNr5(byte red, byte green, byte blue) { for (uint8_t i=0; i <= (NUM_LEDS/2); i++) { LToRight((NUM_LEDS/2)-i, 70, 70, 70, 10); LToRight(NUM_LEDS-i, 70, 70, 70, 10); for (byte n=0; n < NUM_LEDS; n++) { if (n==secs && n==mins && n==hrs) continue; ring.setPixelColor(n, 0x000000); } } } // toCenter dot ----> <---- void anyNr6(byte red, byte green, byte blue) { for (uint8_t i=0; i <= (NUM_LEDS/2); i++) { RToLeft(i-4, 70, 70, 70, 10); LToRight(NUM_LEDS-i, 70, 70, 70, 10); for (uint8_t n=0; n < NUM_LEDS; n++) { if (n==secs && n==mins && n==hrs) continue; ring.setPixelColor(n, 0x000000); } } } // ring dot <---- ----> void anyNr7(byte red, byte green, byte blue) { for (uint8_t i=0; i <= (NUM_LEDS/2); i++) { RToLeft((NUM_LEDS/2)+i-4, 70, 70, 70, 10); LToRight((NUM_LEDS/2)-i, 70, 70, 70, 10); for (uint8_t n=0; n < NUM_LEDS; n++) { if (n==secs && n==mins && n==hrs) continue; ring.setPixelColor(n, 0x000000); } } } void LToRight(uint8_t i, byte red, byte green, byte blue, byte wait) { if (i != secs && i != mins && i != hrs) setPixel(i, red, green, blue); if (i+1 != secs && i+1 != mins && i+1 != hrs) setPixel(i+1, red/10, green/10, blue/10); if (i+2 != secs && i+2 != mins && i+2 != hrs) setPixel(i+2, red/30, green/30, blue/30); if (i+3 != secs && i+3 != mins && i+3 != hrs) setPixel(i+3, red/50, green/50, blue/50); if (i+4 != secs && i+4 != mins && i+4 != hrs) setPixel(i+4, red/70, green/70, blue/70); ring.setPixelColor(secs, 0x000055); ring.setPixelColor(mins, 0x550000); ring.setPixelColor(hrs, 0x005500); ring.show(); delay(wait); } void RToLeft(uint8_t i, byte red, byte green, byte blue, byte wait) { if (i != secs && i != mins && i != hrs) setPixel(i, red/70, green/70, blue/70); if (i+1 != secs && i+1 != mins && i+1 != hrs) setPixel(i+1, red/50, green/50, blue/50); if (i+2 != secs && i+2 != mins && i+2 != hrs) setPixel(i+2, red/30, green/30, blue/30); if (i+3 != secs && i+3 != mins && i+3 != hrs) setPixel(i+3, red/10, green/10, blue/10); if (i+4 != secs && i+4 != mins && i+4 != hrs) setPixel(i+4, red, green, blue); ring.setPixelColor(secs, 0x000055); ring.setPixelColor(mins, 0x550000); ring.setPixelColor(hrs, 0x005500); ring.show(); delay(wait); } void RToLeftSec(uint8_t i, byte red, byte green, byte blue, byte wait) { if (i != mins && i != hrs) setPixel(i, red/70, green/70, blue/70); if (i+1 != mins && i+1 != hrs) setPixel(i+1, red/50, green/50, blue/50); if (i+2 != mins && i+2 != hrs) setPixel(i+2, red/30, green/30, blue/30); if (i+3 != mins && i+3 != hrs) setPixel(i+3, red/10, green/10, blue/10); if (i+4 != mins && i+4 != hrs) setPixel(i+4, red, green, blue); ring.setPixelColor(secs, 0x000055); ring.setPixelColor(mins, 0x550000); ring.setPixelColor(hrs, 0x005500); ring.show(); delay(wait); } void setPixel(uint8_t Pixel, byte red, byte green, byte blue) { ring.setPixelColor(Pixel, ring.Color(red, green, blue)); } RE: Projek zegara z pasków LED i pierścienia NeoPixel - Problem z kompilacją programu - Irvin - 06-01-2024 Kompilacja nie ma nic wspólnego z konwerterem USB-UART, nie musisz mieć podłączonej płytki Arduino, możesz jej nie mieć w tym pokoju co komputer, czy nawet może jeszcze leżeć w paczkomacie. Jak masz bardzo rozbudowany projekt to musisz się dowiedzieć na jakiej wersji Arduino powstał, jakie dokładnie były użyte biblioteki i w jakiej wersji. Bibliotek w jednym temacie do Arduino możesz znaleźć dziesiątki, ale wewnątrz się będą nieco różnić i wywalać tak jak tutaj multum błędów. A nie powinny, skoro to jest projekt, który ktoś już wgrał i przetestował. Samo wgrywanie potrenuj wgrywając do PRO MINI Blinka z przykładów, trzeba wcisnąć RST w odpowiednim momencie, ale już PO POPRAWNEJ kompilacji. Jak będziesz robił zakupy to kup sobie konwerter FTDI, taki czerwony, on ma dodatkowy pin wyprowadzony i zrobi autoreset dokładnie w chwili gdy jest to wymagane: https://www.b4x.com/android/forum/attachments/conexao-ftdi-arduino-pro-mini-jpg.53557/ RE: Projek zegara z pasków LED i pierścienia NeoPixel - Problem z kompilacją programu - pawel4350 - 06-01-2024 (06-01-2024, 19:54)Irvin napisał(a): Kompilacja nie ma nic wspólnego z konwerterem USB-UART, nie musisz mieć podłączonej płytki Arduino, możesz jej nie mieć w tym pokoju co komputer, czy nawet może jeszcze leżeć w paczkomacie. RE: Projek zegara z pasków LED i pierścienia NeoPixel - Problem z kompilacją programu - pawel4350 - 06-01-2024 (06-01-2024, 19:54)Irvin napisał(a): Kompilacja nie ma nic wspólnego z konwerterem USB-UART, nie musisz mieć podłączonej płytki Arduino, możesz jej nie mieć w tym pokoju co komputer, czy nawet może jeszcze leżeć w paczkomacie.To oznacza, że będę musiał się zwrócić z tym bezpośrednio do Autora tego projektu a nie wiem czy się w ogóle doczekam odpowiedzi i kiedy ją otrzymam jeśli ją w ogóle otrzymam bo to różnie jest. Ewentualnie trzeba będzie wymyślić jakiś alternatywny projekt, który by zastąpił ten oryginalny... Chyba, że jeszcze tu na forum znajdzie się ktoś, kto będzie w stanie pomóc mi rozwiązać problem dzięki czemu będę mógł dokończyć ten zegar bo bez tego to na prawdę ani rusz dalej bo co z tego jak dokończę samą budowę skoro bez kodu nawet się nie uruchomi RE: Projek zegara z pasków LED i pierścienia NeoPixel - Problem z kompilacją programu - Irvin - 07-01-2024 Masz datę publikacji video, to już jest jakaś informacja, że biblioteki utworzone po tej dacie na pewno można odrzucić, wersje archiwalne Arduino też są bez problemu do ściągnięcia, była sporo zmiana w okolicach wersji 1.5 ze stałymi zapisanymi do flash, ale tu nie widzę takich błędów, głównie bruździ biblioteka DCF. Jak wejdziesz w biblioteki i znajdziesz swoją zainstalowaną, to też masz opcję wybrać jaką wersję tej biblioteki chcesz, sprawdź czy w starszych jest coś takiego: C:\Users\pawel\OneDrive\Dokumenty\Arduino\libraries\DCF77\DCF77.cpp:290:24: error: 'makeTime' was not declared in this scope latestupdatedTime = makeTime(time); Wiać, że w programie masz "makeTime(time); a kompilator nie wie co to jest, musisz mieć taką bibliotekę, w której jest taka metoda. Niestety by było ciekawiej w opisie biblioteki DCF77 w Arduino IDE jest zapis, że ona pracuje na bazie bibliotek Time i TimeZone, więc musisz je mieć w tej konfiguracji co autor projektu w 2018. Akurat ta biblioteka DCF77 jest w jednej wersji, ale nie ma żadnego problemu, by autor użył jakiejś spoza spoza tych zasobów, a wtedy szukaj wiatru w polu. Tu jednak chodzi o tą zmianę w okolicach Arduino 1.5.x, ściągnij sobie ostatnią wersję, która nie wymagała const przy zmiennych przechowywanych w flash, https://www.arduino.cc/en/software/OldSoftwareReleases , starą wersję time https://playground.arduino.cc/Code/Time/ https://playground.arduino.cc/uploads/Code/Time/index.zip, jest tu informacja, że nie chodzi od wersji 1.6.1 gdzie trzeba dopisać const. Zacznij od wersji 1.5.8 i ewentualnie cofaj się w tył. U mnie udało mi się to skompilować w Arduino 1.5.8, trzeba je jednak wrzucić na komputer wirtualny bo nawet zip dorzucony do WIN burzy się o pliki projektów z nowszych wersji, a korzysta z katalogu i bibliotek Arduino, niestety wielkość wynikowa pliku jest powyżej 32kB i nie mieści się do flash UNO. Ale wypatrzyłem, że kluczem jest bilbioteka TIME w wersji 1.5, gdzie był plik time.h i timlib.h, wcześniej był tylko pierwszy, a w nowszej wersji już tylko drugi, autor skorzystał z obu. Więc obniżyłem tylko wersję tylko tej biblioteki TIME w Arduino 1.8.19 i już ma 30kb, OK dla UNO, nowsza wersja jest lepiej zoptymalizowana. name=Time version=1.5 author=Michael Margolis Sketch uses 30218 bytes (93%) of program storage space. Maximum is 32256 bytes. Global variables use 798 bytes (38%) of dynamic memory, leaving 1250 bytes for local variables. Maximum is 2048 bytes. Wrzucę Ci tu hexa, możesz przetestować. |