#define LIGHTSENS SENSOR_3 /* per l'utilizzo dell'emulatore */ #ifdef EMULEGOS # include "emuLegOs.h" #else # include # include # include # include # include #endif #ifdef EMULEGOS # define RCXMAIN rcx_main #else # define RCXMAIN main #endif wakeup_t sensor_press_wakeup(wakeup_t data); wakeup_t sensor_release_wakeup(wakeup_t data); int RCXMAIN(int argc, char **argv) { int FINE, L; ds_active(&LIGHTSENS); FINE = 0; cputs("hello"); sleep(1); cls(); while(!FINE){ wait_event(&sensor_press_wakeup,0); if(SENSOR_1<0xf000) // keep in mind. FINE = 1; else L = LIGHT_3; lcd_int(L); wait_event(&sensor_release_wakeup,0); cls(); } cputs("end"); sleep(1); cls(); ds_passive(&LIGHTSENS); return 0; } wakeup_t sensor_press_wakeup(wakeup_t data) { lcd_refresh(); return SENSOR_1<0xf000 || SENSOR_2<0xf000; } wakeup_t sensor_release_wakeup(wakeup_t data) { lcd_refresh(); return SENSOR_1>0xf000 && SENSOR_2>0xf000; }