Last change
on this file since 457 was 457, checked in by coas-nagasima, 4 years ago |
ファイルを追加
|
-
Property svn:eol-style
set to
native
-
Property svn:mime-type
set to
text/x-csrc;charset=UTF-8
|
File size:
1006 bytes
|
Line | |
---|
1 | /*
|
---|
2 | * PinKitセンサータスク
|
---|
3 | */
|
---|
4 |
|
---|
5 | #include "pinkit.h"
|
---|
6 | #include <math.h>
|
---|
7 | #include "device.h"
|
---|
8 | #include "syssvc/syslog.h"
|
---|
9 |
|
---|
10 | pinkit_t pinkit;
|
---|
11 | uint16_t led_state = 0;
|
---|
12 |
|
---|
13 | void pinkit_task(intptr_t exinf)
|
---|
14 | {
|
---|
15 | int i2c_error = 0;
|
---|
16 |
|
---|
17 | Accelerometer_Init(100, 1000);
|
---|
18 | Temperature_Init();
|
---|
19 | BoardFullColorLED_Init();
|
---|
20 | LightSensor_Init();
|
---|
21 |
|
---|
22 | for (;;) {
|
---|
23 | if (i2c_error < 3) {
|
---|
24 | if (Accelerometer_TakeMeasurements(&pinkit.accel))
|
---|
25 | i2c_error = 0;
|
---|
26 | else
|
---|
27 | i2c_error++;
|
---|
28 | }
|
---|
29 | else {
|
---|
30 | i2c_error++;
|
---|
31 | if (i2c_error == 4) {
|
---|
32 | syslog(LOG_NOTICE, "Accelerometer error.");
|
---|
33 | }
|
---|
34 | else if (i2c_error >= 10000)
|
---|
35 | i2c_error = 0;
|
---|
36 | }
|
---|
37 |
|
---|
38 | pinkit.temperature = Temperature_TakeMeasurement();
|
---|
39 | pinkit.humidity = LightSensor_TakeMeasurement();
|
---|
40 |
|
---|
41 | BoardFullColorLED_SetRgb(fabs(pinkit.accel.X) > 0.5, fabs(pinkit.accel.Y) > 0.5, fabs(pinkit.accel.Z) > 0.5);
|
---|
42 | if (pinkit.ledOn)
|
---|
43 | led_state |= LED04;
|
---|
44 | else
|
---|
45 | led_state &= ~LED04;
|
---|
46 | led_out(led_state);
|
---|
47 |
|
---|
48 | Temperature_Start();
|
---|
49 | LightSensor_Start();
|
---|
50 |
|
---|
51 | dly_tsk(10);
|
---|
52 | }
|
---|
53 | }
|
---|
54 |
|
---|
Note:
See
TracBrowser
for help on using the repository browser.