Rev | Line | |
---|
[242] | 1 | #include "rca.h"
|
---|
| 2 |
|
---|
| 3 | //#define USE_INTERRUPT
|
---|
| 4 |
|
---|
| 5 | #include <Wire.h>
|
---|
| 6 | #include <Digital_Light_TSL2561.h>
|
---|
| 7 | #include <SeeedOLED.h>
|
---|
| 8 |
|
---|
| 9 | #define TOUCH_PIN 3
|
---|
| 10 |
|
---|
| 11 | int is_update_oled;
|
---|
| 12 |
|
---|
| 13 | void setup()
|
---|
| 14 | {
|
---|
| 15 | Serial.begin(115200);
|
---|
| 16 | Wire.begin();
|
---|
| 17 | TSL2561.init();
|
---|
| 18 |
|
---|
| 19 | SeeedOled.init();
|
---|
| 20 | SeeedOled.deactivateScroll();
|
---|
| 21 |
|
---|
| 22 | is_update_oled = 1;
|
---|
| 23 | }
|
---|
| 24 |
|
---|
| 25 | void loop()
|
---|
| 26 | {
|
---|
| 27 | Serial.print("The Light value is: ");
|
---|
| 28 | Serial.println(TSL2561.readVisibleLux());
|
---|
| 29 |
|
---|
| 30 | if (is_update_oled == 1) {
|
---|
| 31 | wai_sem(OLED_SEM);
|
---|
| 32 | SeeedOled.clearDisplay();
|
---|
| 33 | SeeedOled.putNumber(TSL2561.readVisibleLux());
|
---|
| 34 | sig_sem(OLED_SEM);
|
---|
| 35 | }
|
---|
| 36 |
|
---|
| 37 | delay(1000);
|
---|
| 38 | }
|
---|
| 39 |
|
---|
| 40 | #ifdef USE_INTERRUPT
|
---|
| 41 | void onTouch(void) {
|
---|
| 42 | Serial.print("hoge");
|
---|
| 43 | iwup_tsk(RCA_TASK1);
|
---|
| 44 | }
|
---|
| 45 | #endif /* USE_INTERRUPT */
|
---|
| 46 |
|
---|
| 47 | void task1_setup()
|
---|
| 48 | {
|
---|
| 49 | pinMode(TOUCH_PIN, INPUT_PULLUP);
|
---|
| 50 | #ifdef USE_INTERRUPT
|
---|
| 51 | attachInterrupt(TOUCH_PIN, onTouch, CHANGE);
|
---|
| 52 | #endif /* USE_INTERRUPT */
|
---|
| 53 | }
|
---|
| 54 |
|
---|
| 55 | void task1_loop()
|
---|
| 56 | {
|
---|
| 57 | #ifdef USE_INTERRUPT
|
---|
| 58 | slp_tsk();
|
---|
| 59 | #else /* USE_INTERRUPT */
|
---|
| 60 | delay(1);
|
---|
| 61 | #endif /* USE_INTERRUPT */
|
---|
| 62 |
|
---|
| 63 | int TouchSensorValue = digitalRead(TOUCH_PIN);
|
---|
| 64 |
|
---|
| 65 | if(TouchSensorValue==1) {
|
---|
| 66 | is_update_oled = 0;
|
---|
| 67 | wai_sem(OLED_SEM);
|
---|
| 68 | SeeedOled.setInverseDisplay();
|
---|
| 69 | sig_sem(OLED_SEM);
|
---|
| 70 | }else{
|
---|
| 71 | is_update_oled = 1;
|
---|
| 72 | wai_sem(OLED_SEM);
|
---|
| 73 | SeeedOled.setNormalDisplay();
|
---|
| 74 | sig_sem(OLED_SEM);
|
---|
| 75 | }
|
---|
| 76 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.