#include "rca.h" //#define USE_INTERRUPT #include #include #include #include #define LED_PIN 4 void setup() { Serial.begin(115200); pinMode(LED_PIN, OUTPUT); } void loop() { digitalWrite(LED_PIN, HIGH); // turn the LED on (HIGH is the voltage level) delay(1000); // wait for a second digitalWrite(LED_PIN, LOW); // turn the LED off by making the voltage LOW delay(1000); // wait for a second } #define TOUCH_PIN 3 int is_update_oled; void task1_setup() { Wire.begin(); TSL2561.init(); SeeedOled.init(); SeeedOled.deactivateScroll(); is_update_oled = 1; } void task1_loop() { int lux; lux = TSL2561.readVisibleLux(); Serial.print("The Light value is: "); Serial.println(lux); if (is_update_oled == 1) { wai_sem(OLED_SEM); SeeedOled.setTextXY(0, 0); SeeedOled.putNumber(lux); SeeedOled.putString(" "); sig_sem(OLED_SEM); } delay(1000); } #ifdef USE_INTERRUPT void onTouch(void) { Serial.print("hoge"); iwup_tsk(RCA_TASK1); } #endif /* USE_INTERRUPT */ void task2_setup() { pinMode(TOUCH_PIN, INPUT_PULLUP); #ifdef USE_INTERRUPT attachInterrupt(TOUCH_PIN, onTouch, CHANGE); #endif /* USE_INTERRUPT */ } void task2_loop() { #ifdef USE_INTERRUPT slp_tsk(); #else /* USE_INTERRUPT */ delay(1); #endif /* USE_INTERRUPT */ int TouchSensorValue = digitalRead(TOUCH_PIN); if(TouchSensorValue==1) { is_update_oled = 0; wai_sem(OLED_SEM); SeeedOled.setInverseDisplay(); sig_sem(OLED_SEM); }else{ is_update_oled = 1; wai_sem(OLED_SEM); SeeedOled.setNormalDisplay(); sig_sem(OLED_SEM); } } #define NUM_LEDS 1 ChainableLED leds(8, 9, NUM_LEDS); void task3_setup() { leds.init(); } float hue = 0.0; boolean up = true; int count = 0; void task3_loop() { for (byte i=0; i=1.0 && up) up = false; else if (hue<=0.0 && !up) up = true; }