source: rtos_arduino/trunk/examples/MultiTaskText/Exclusion/rca_app.cpp@ 257

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

バグ修正

File size: 1.7 KB
Line 
1#include "rca.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(RCA_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
70void task1_setup() {
71
72}
73
74void task1_loop() {
75 slp_tsk();
76
77// wai_sem(COUNT_SEM);
78 OLEDCount = 0;
79// sig_sem(COUNT_SEM);
80
81 digitalWrite(LED_PIN, HIGH);
82 dly_tsk(2000);
83 digitalWrite(LED_PIN, LOW);
84}
Note: See TracBrowser for help on using the repository browser.