Skip to content

Commit 6fc8231

Browse files
[Thread Tutorial] Update sensor app checkpoints.
1 parent f37de86 commit 6fc8231

File tree

5 files changed

+28
-53
lines changed

5 files changed

+28
-53
lines changed

examples/tutorials/thread_network/01_sensor_final/main.c

Lines changed: 0 additions & 51 deletions
This file was deleted.
File renamed without changes.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#include <stdio.h>
2+
3+
#include <libtock-sync/sensors/temperature.h>
4+
#include <libtock-sync/services/alarm.h>
5+
#include <libtock/kernel/ipc.h>
6+
#include <libtock/tock.h>
7+
8+
static int current_temperature = 0;
9+
10+
int main(void) {
11+
// Measure temperature -- returned in the form 2200 => 22C
12+
libtocksync_temperature_read(&current_temperature);
13+
14+
// Convert temperature
15+
int whole_degree = current_temperature / 100;
16+
int decimal_degree = current_temperature % 100;
17+
18+
printf("Hello World, the temperature is: %i.%i\r\n", whole_degree, decimal_degree);
19+
20+
return 0;
21+
}
File renamed without changes.

examples/tutorials/thread_network/01_sensor_final/01_sensor_ipc/main.c renamed to examples/tutorials/thread_network/02_sensor_final/main.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,14 @@ int main(void) {
1212
// We measure the temperature in the main loop and
1313
//print this value to the console.
1414
while (1) {
15-
// Measure temperature.
15+
// Measure temperature -- returned in the form 2200 => 22C
1616
libtocksync_temperature_read(&current_temperature);
17-
printf("Current temperature: %d\r\n", current_temperature);
17+
18+
// Convert temperature
19+
int whole_degree = current_temperature / 100;
20+
int decimal_degree = current_temperature % 100;
21+
22+
printf("Current temperature: %i.%i\r\n", whole_degree, decimal_degree);
1823

1924
// Delay 1000 ms (1 second).
2025
libtocksync_alarm_delay_ms(1000);

0 commit comments

Comments
 (0)