Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 6bde3b0

Browse files
Update examples
1 parent 61e1024 commit 6bde3b0

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

‎content/hardware/10.mega/boards/giga-r1-wifi/tutorials/cheat-sheet/cheat-sheet.md‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -572,14 +572,13 @@ void printWifiStatus()
572572
Serial.println(" dBm");
573573
}
574574
```
575-
576575
### RTC / UDP / NTP Example (Timezone)
577576

578577
This example provides an option to set the timezone. As the received epoch is based on GMT time, you can input e.g. `-1` or `5` which represents the hours. The `timezone` variable is changed at the top of the example.
579578

580579
```arduino
581580
/*
582-
Udp NTP Client
581+
Udp NTP Client with Timezone Adjustment
583582
584583
Get the time from a Network Time Protocol (NTP) time server
585584
Demonstrates use of UDP sendPacket and ReceivePacket
@@ -703,7 +702,7 @@ unsigned long parseNtpPacket() {
703702
constexpr unsigned long seventyYears = 2208988800UL;
704703
const unsigned long epoch = secsSince1900 - seventyYears;
705704
706-
new_epoch = epoch + (3600 * timezone); //multiply the timezone with 3600 (1 hour)
705+
const unsigned long new_epoch = epoch + (3600 * timezone); //multiply the timezone with 3600 (1 hour)
707706
708707
set_time(new_epoch);
709708

‎content/hardware/10.mega/boards/giga-r1-wifi/tutorials/giga-wifi/giga-wifi.md‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ This example provides an option to set the timezone. As the received epoch is ba
352352

353353
```arduino
354354
/*
355-
Udp NTP Client
355+
Udp NTP Client with Timezone Adjustment
356356
357357
Get the time from a Network Time Protocol (NTP) time server
358358
Demonstrates use of UDP sendPacket and ReceivePacket
@@ -365,6 +365,8 @@ This example provides an option to set the timezone. As the received epoch is ba
365365
by Tom Igoe
366366
modified 28 Dec 2022
367367
by Giampaolo Mancini
368+
modified 29 Jan 2024
369+
by Karl Söderby
368370
369371
This code is in the public domain.
370372
*/
@@ -474,7 +476,7 @@ unsigned long parseNtpPacket() {
474476
constexpr unsigned long seventyYears = 2208988800UL;
475477
const unsigned long epoch = secsSince1900 - seventyYears;
476478
477-
new_epoch = epoch + (3600 * timezone); //multiply the timezone with 3600 (1 hour)
479+
const unsigned long new_epoch = epoch + (3600 * timezone); //multiply the timezone with 3600 (1 hour)
478480
479481
set_time(new_epoch);
480482

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /