File tree Expand file tree Collapse file tree 3 files changed +43
-0
lines changed
examples/tests/temperature Expand file tree Collapse file tree 3 files changed +43
-0
lines changed Original file line number Diff line number Diff line change
1
+ # Makefile for user application
2
+
3
+ # Specify this directory relative to the current application.
4
+ TOCK_USERLAND_BASE_DIR = ../../..
5
+
6
+ # Which files to compile.
7
+ C_SRCS := $(wildcard * .c)
8
+
9
+ # Include userland master makefile. Contains rules and flags for actually
10
+ # building the application.
11
+ include $(TOCK_USERLAND_BASE_DIR ) /AppMakefile.mk
Original file line number Diff line number Diff line change
1
+ Simple Temperature Test
2
+ =======================
3
+
4
+ Uses libtock-sync to read the temperature sensor.
Original file line number Diff line number Diff line change
1
+ #include <stdio.h>
2
+ #include <stdlib.h>
3
+ #include <string.h>
4
+
5
+ #include <libtock-sync/sensors/temperature.h>
6
+
7
+ int main (void ) {
8
+ returncode_t ret ;
9
+
10
+ if (!libtock_temperature_exists ()) {
11
+ printf ("[Temperature] No temperature sensor found.\n" );
12
+ exit (-1 );
13
+ }
14
+
15
+ int temp ;
16
+ ret = libtocksync_temperature_read (& temp );
17
+ if (ret != RETURNCODE_SUCCESS ) {
18
+ printf ("[Temperature] Error reading temperature sensor.\n" );
19
+ printf ("[Temperature] %s\n" , tock_strrcode (ret ));
20
+ exit (-2 );
21
+ }
22
+
23
+ int temp_ones = temp / 100 ;
24
+ int temp_hundredths = temp - (temp_ones * 100 );
25
+ printf ("[Temperature] %d.%d deg C\n" , temp_ones , temp_hundredths );
26
+
27
+ return 0 ;
28
+ }
You can’t perform that action at this time.
0 commit comments