2121#endif
2222
2323// ---------- CHANGE HERE -------------
24- int timeZone = 2 ; // Adjust your timezone (e.g., 2 means UTC+2)
24+ // Adjust your timezone (e.g., 2 means UTC+2)
25+ int timeZone = 2 ;
2526
26- // WiFi credentials
27- char ssid[] = " Soldered-testingPurposes" ;
28- char pass[] = " Testing443" ;
29- char api_key_news[] = " 10fb57f24c784ee7be7a9cc419b775cc" ;
27+ // WiFi credentials (replace with your WiFi network details)
28+ char ssid[] = " YourWiFiSSID" ; // Replace with your WiFi SSID
29+ char pass[] = " YourWiFiPassword" ; // Replace with your WiFi password
3030
31+ // News API key (get one from https://newsapi.org/)
32+ char api_key_news[] = " YourNewsAPIKey" ; // Replace with your News API key
3133// ------------------------------------
3234
3335// Include necessary libraries
@@ -56,27 +58,36 @@ void setup()
5658{
5759 // Initialize serial communication for debugging
5860 Serial.begin (115200 );
61+ Serial.println (F (" Starting Inkplate10_News example..." ));
5962
6063 // Initialize the display
6164 inkplate.begin ();
6265 inkplate.setTextWrap (false );
66+ Serial.println (F (" Display initialized." ));
6367
6468 // Connect to WiFi
69+ Serial.println (F (" Setting WiFi credentials..." ));
6570 network.setCredentials (ssid, pass, api_key_news);
6671 network.setTimeZone (timeZone);
72+ Serial.println (F (" Connecting to WiFi..." ));
6773 network.begin ();
6874
6975 // Set the current time
76+ Serial.println (F (" Setting time..." ));
7077 setTime ();
7178
7279 // Fetch news data and display it
80+ Serial.println (F (" Fetching news data..." ));
7381 struct news *entities = network.getData (inkplate);
7482 if (entities != nullptr )
7583 {
84+ Serial.println (F (" News data fetched successfully. Drawing news..." ));
7685 drawNews (entities);
7786 }
7887 else
7988 {
89+ Serial.println (F (" Failed to fetch news data." ));
90+ // Display an error message if fetching news fails
8091 inkplate.clearDisplay ();
8192 inkplate.setCursor (50 , 230 );
8293 inkplate.setTextSize (2 );
@@ -85,9 +96,11 @@ void setup()
8596 }
8697
8798 // Update the display
99+ Serial.println (F (" Updating display..." ));
88100 inkplate.display ();
89101
90102 // Enter deep sleep until the next update
103+ Serial.println (F (" Entering deep sleep..." ));
91104 esp_sleep_enable_timer_wakeup (1000 * DELAY_MS);
92105 esp_deep_sleep_start ();
93106}
@@ -170,11 +183,12 @@ void drawNews(struct news *entities)
170183
171184 for (int i = 0 ; i < maxBoxes && entities[i].title [0 ] != ' \0 ' && entities[i].description [0 ] != ' \0 ' ; i++)
172185 {
186+ Serial.printf (" Drawing news item %d...\n " , i + 1 );
173187 int y0 = startY + i * (boxHeight + boxSpacing);
174188 int y1 = y0 + boxHeight;
175189
176190 // Draw the title
177- inkplate.drawTextBox (leftMargin, y0+ 5 , inkplate.width () - rightMargin, y0 + 80 , entities[i].title , 1 , >_Pressura16pt7b, 30 , false , 18 );
191+ inkplate.drawTextBox (leftMargin, y0 + 5 , inkplate.width () - rightMargin, y0 + 80 , entities[i].title , 1 , >_Pressura16pt7b, 30 , false , 18 );
178192
179193 // Draw the description
180194 inkplate.drawTextBox (leftMargin, y0 + 80 , inkplate.width () - rightMargin, y1 + 20 , entities[i].description , 1 , &Inter12pt7b, 30 , false , 16 );
0 commit comments