Skip to content

Commit 6887371

Browse files
committed
Update for deprecation of non-Chrono timing APIs
1 parent a7ca7a1 commit 6887371

File tree

64 files changed

+280
-157
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+280
-157
lines changed

APIs_Drivers/AnalogIn_ex_2/main.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55

66
#include "mbed.h"
77

8+
using namespace std::chrono_literals;
9+
810
AnalogIn input(A0);
911

1012
#define NUM_SAMPLES 1024
@@ -15,7 +17,7 @@ int main()
1517

1618
for (int i = 0; i < NUM_SAMPLES; i++) {
1719
samples[i] = input.read_u16();
18-
ThisThread::sleep_for(1);
20+
ThisThread::sleep_for(1ms);
1921
}
2022

2123
printf("Results:\n");

APIs_Drivers/AnalogIn_ex_3/main.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55

66
#include "mbed.h"
77

8+
using namespace std::chrono_literals;
9+
810
// Initialize a pins to perform analog input and digital output functions
911
AnalogIn ain(A0);
1012
DigitalOut dout(LED1);
@@ -24,6 +26,6 @@ int main(void)
2426
// print the percentage and 16 bit normalized values
2527
printf("percentage: %3.3f%%\n", ain.read() * 100.0f);
2628
printf("normalized: 0x%04X \n", ain.read_u16());
27-
ThisThread::sleep_for(200);
29+
ThisThread::sleep_for(200ms);
2830
}
2931
}

APIs_Drivers/AnalogOut_ex_2/main.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55

66
#include "mbed.h"
77

8+
using namespace std::chrono_literals;
9+
810
// Initialize a pins to perform analog and digital output functions
911
// Adjust analog output pin name to your board spec.
1012
AnalogOut aout(A5);
@@ -20,7 +22,7 @@ int main(void)
2022
printf("aout = %1.2f volts\n", aout.read() * 3.3f);
2123
// turn on the led if the voltage is greater than 0.5f * VCC
2224
dout = (aout > 0.5f) ? 1 : 0;
23-
ThisThread::sleep_for(1000);
25+
ThisThread::sleep_for(1s);
2426
}
2527
}
26-
}
28+
}

APIs_Drivers/BusInOut_ex_1/main.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,17 @@
55

66
#include "mbed.h"
77

8+
using namespace std::chrono_literals;
9+
810
BusInOut pins(D0, D1, D2); // Change these pins to buttons on your board.
911

1012
int main() {
1113
while(1) {
1214
pins.output();
1315
pins = 0x3;
14-
ThisThread::sleep_for(1000);
16+
ThisThread::sleep_for(1s);
1517
pins.input();
16-
ThisThread::sleep_for(1000);
18+
ThisThread::sleep_for(1s);
1719
if(pins == 0x6) {
1820
printf("Hello!\n");
1921
}

APIs_Drivers/BusIn_ex_1/main.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55

66
#include "mbed.h"
77

8+
using namespace std::chrono_literals;
9+
810
BusIn nibble(D0, D1, D2, D3); // Change these pins to buttons on your board.
911

1012
int main()
@@ -48,6 +50,6 @@ int main()
4850
printf("0b1111, D3,D2,D1,D0 are high \n\r");
4951
break;
5052
}
51-
ThisThread::sleep_for(1000);
53+
ThisThread::sleep_for(1s);
5254
}
5355
}

APIs_Drivers/BusOut_ex_1/main.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,16 @@
55

66
#include "mbed.h"
77

8+
using namespace std::chrono_literals;
9+
810
BusOut myleds(LED1, LED2, LED3, LED4);
911

1012
int main()
1113
{
1214
while (1) {
1315
for (int i = 0; i < 16; i++) {
1416
myleds = i;
15-
ThisThread::sleep_for(250);
17+
ThisThread::sleep_for(250ms);
1618
}
1719
}
1820
}

APIs_Drivers/CAN_ex_1/main.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
#include "mbed.h"
1212

13+
using namespace std::chrono_literals;
1314

1415
Ticker ticker;
1516
DigitalOut led1(LED1);
@@ -43,7 +44,7 @@ int main()
4344
printf("Message received: %d\n", msg.data[0]);
4445
led2 = !led2;
4546
}
46-
ThisThread::sleep_for(200);
47+
ThisThread::sleep_for(200ms);
4748
}
4849
}
4950

APIs_Drivers/DigitalInOut_ex_1/main.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55

66
#include "mbed.h"
77

8+
using namespace std::chrono_literals;
9+
810
DigitalInOut mypin(LED1);
911

1012
int main()
@@ -21,11 +23,11 @@ int main()
2123
// write to pin as output
2224
mypin.output();
2325
mypin = !mypin; // toggle output
24-
ThisThread::sleep_for(500);
26+
ThisThread::sleep_for(500ms);
2527

2628
// read from pin as input
2729
mypin.input();
2830
printf("mypin.read() = %d \n\r", mypin.read());
29-
ThisThread::sleep_for(500);
31+
ThisThread::sleep_for(500ms);
3032
}
3133
}

APIs_Drivers/DigitalIn_ex_1/main.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55

66
#include "mbed.h"
77

8+
using namespace std::chrono_literals;
9+
810
DigitalIn mypin(SW2); // change this to the button on your board
911
DigitalOut myled(LED1);
1012

@@ -22,6 +24,6 @@ int main()
2224
while (1) {
2325
printf("mypin has value : %d \n\r", mypin.read());
2426
myled = mypin; // toggle led based on value of button
25-
ThisThread::sleep_for(250);
27+
ThisThread::sleep_for(250ms);
2628
}
2729
}

APIs_Drivers/DigitalOut_ex_1/main.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55

66
#include "mbed.h"
77

8+
using namespace std::chrono_literals;
9+
810
DigitalOut myled(LED1);
911

1012
int main()
@@ -18,10 +20,10 @@ int main()
1820
while (1) {
1921
myled = 1; // set LED1 pin to high
2022
printf("myled = %d \n\r", (uint8_t)myled);
21-
ThisThread::sleep_for(500);
23+
ThisThread::sleep_for(500ms);
2224

2325
myled.write(0); // set LED1 pin to low
2426
printf("myled = %d \n\r", myled.read());
25-
ThisThread::sleep_for(500);
27+
ThisThread::sleep_for(500ms);
2628
}
2729
}

0 commit comments

Comments
 (0)