source: rtos_arduino/trunk/examples/MultiTaskText/Exclusion/r2ca_app.cpp@ 260

Last change on this file since 260 was 260, checked in by ertl-honda, 8 years ago

マクロ名を更新.
実行モデルを変更.

File size: 1.6 KB
Line 
1#include "r2ca.h"
2
3#include <Wire.h>
4#include <Digital_Light_TSL2561.h>
5#include <SeeedOLED.h>
6
7#define TOUCH_PIN 3
8#define LED_PIN 4
9
10int PreTouchValue = 0;
11int TouchState = 0;
12int LEDState = 0;
13
14extern void CheckTouch(void);
15
16void setup() {
17 Wire.begin();
18 TSL2561.init();
19 SeeedOled.init();
20 SeeedOled.deactivateScroll();
21 SeeedOled.setNormalDisplay();
22 SeeedOled.clearDisplay();
23
24 pinMode(TOUCH_PIN, INPUT_PULLUP);
25 pinMode(LED_PIN, OUTPUT);
26 digitalWrite(LED_PIN, LOW);
27 attachInterrupt(TOUCH_PIN, CheckTouch, CHANGE);
28}
29
30int OLEDCount = 0;
31
32void CheckTouch(){
33 int TouchValue = digitalRead(TOUCH_PIN);
34
35 if ((PreTouchValue == 0) && (TouchValue == 1) && (TouchState == 0)) {
36 TouchState = 1;
37 }
38
39 if ((PreTouchValue == 1) && (TouchValue == 0) && (TouchState == 1)) {
40 TouchState = 0;
41 iwup_tsk(R2CA_TASK1);
42 }
43 PreTouchValue = TouchValue;
44}
45
46void loop() {
47 int lux;
48 int lcount;
49
50// wai_sem(COUNT_SEM);
51 lcount = OLEDCount;
52 lux = TSL2561.readVisibleLux();
53
54 SeeedOled.setTextXY(0, 0);
55 SeeedOled.putString("Digital Light");
56 SeeedOled.setTextXY(1, 0);
57 SeeedOled.putString("Sensor Value is");
58 SeeedOled.setTextXY(2, 0);
59 SeeedOled.putNumber(lux);
60 SeeedOled.putString(" lux ");
61 SeeedOled.setTextXY(4, 0);
62 SeeedOled.putString("Count is");
63 SeeedOled.setTextXY(5, 0);
64 SeeedOled.putNumber(lcount++);
65 SeeedOled.putString(" ");
66 OLEDCount = lcount;
67// sig_sem(COUNT_SEM);
68}
69
70
71void loop1() {
72 slp_tsk();
73
74// wai_sem(COUNT_SEM);
75 OLEDCount = 0;
76// sig_sem(COUNT_SEM);
77
78 digitalWrite(LED_PIN, HIGH);
79 dly_tsk(2000);
80 digitalWrite(LED_PIN, LOW);
81}
Note: See TracBrowser for help on using the repository browser.