int main() { int l = 1; uint8_t c[2]; X.output(); Y.output(); Z.output(); E.output(); setleds(l); if (1) { UART * s = new UART(0, 9600); s->send((uint8_t *) "Start\n", 6); for(;;) { for (int i = 0 ; ((i & (1 << 22)) == 0) && !g_LoopDummy ; i++) { } c[0] = '0' + (l & 7); c[1] = '\n'; //s->send(c, 2); setleds(l++); } } }
v8::Handle<v8::Value> GPIO::SetMode(const v8::Arguments& args) { v8::HandleScope scope; GPIO* obj = ObjectWrap::Unwrap<GPIO>(args.This()); if (!obj->opened) { std::string err_msg = "GPIO " + obj->pin_num + " is not opened."; v8::ThrowException(v8::Exception::Error(v8::String::New(err_msg.c_str()))); return scope.Close(v8::Undefined()); } if (args.Length() < 1) { v8::ThrowException(v8::Exception::TypeError(v8::String::New("Wrong number of arguments"))); return scope.Close(v8::Undefined()); } if (!args[0]->IsString()) { v8::ThrowException(v8::Exception::TypeError(v8::String::New("Wrong arguments"))); return scope.Close(v8::Undefined()); } std::string mode(*v8::String::Utf8Value(args[0])); int res = obj->setMode(mode); if (res < 0) { std::string err_msg = "OPERATION FAILED: Unable to change GPIO " + obj->pin_num + " mode."; v8::ThrowException(v8::Exception::Error(v8::String::New(err_msg.c_str()))); return scope.Close(v8::Undefined()); } obj->log("GPIO " + obj->pin_num + " mode changed to " + mode + "."); return scope.Close(v8::Integer::New(res)); }
void ADXL345::calibrate(GPIO light) { zeroX = 0; zeroY = 0; zeroZ = 0; vector v; for (int i = 0; i < 1000; i++) { if (i % 15 == 0) light.toggle(); read(v); zeroX += v.x; zeroY += v.y; zeroZ += (1-v.z); delayMillis(5); } light.low(); zeroX /= 1000; zeroY /= 1000; zeroZ /= 1000; calibrated = 1; }
// This thread function is a friend function of the class void* threadedPoll(void *value) { GPIO *gpio = static_cast<GPIO*>(value); while(gpio->threadRunning) { gpio->callbackFunction(gpio->waitForEdge()); usleep(gpio->debounceTime * 1000); } return 0; }
bool run(void *p) { if (xSemaphoreTake(sem, 9999)) { //p2_wire0.toggle(); p2_wire0.setHigh(); vTaskDelay(500); p2_wire0.setLow(); } return true; }
v8::Handle<v8::Value> GPIO::Toggle(const v8::Arguments& args) { v8::HandleScope scope; GPIO* obj = ObjectWrap::Unwrap<GPIO>(args.This()); std::string path = "/sys/class/gpio/gpio" + obj->pin_num + "/value"; int value = obj->ReadValue(path); std::ostringstream ss; ss << !value; obj->WriteValue(path, ss.str()); return scope.Close(v8::Integer::New(0)); }
v8::Handle<v8::Value> GPIO::Close(const v8::Arguments& args) { v8::HandleScope scope; GPIO* obj = ObjectWrap::Unwrap<GPIO>(args.This()); int res = obj->close(); if (res < 0) { std::string err_msg = "OPERATION FAILED: Unable to close GPIO " + obj->pin_num + "."; v8::ThrowException(v8::Exception::Error(v8::String::New(err_msg.c_str()))); return scope.Close(v8::Undefined()); } obj->log("GPIO " + obj->pin_num + " closed."); return scope.Close(v8::Integer::New(res)); }
// This thread function is a friend function of the class void* threadedToggle(void *value) { GPIO *gpio = static_cast<GPIO*>(value); bool isHigh = (bool) gpio->getValue(); //find current value while(gpio->threadRunning) { if (isHigh) gpio->setValue(GPIO::HIGH); else gpio->setValue(GPIO::LOW); usleep(gpio->togglePeriod * 500); isHigh=!isHigh; if(gpio->toggleNumber>0) gpio->toggleNumber--; if(gpio->toggleNumber==0) gpio->threadRunning=false; } return 0; }
void ledTaskCallback (OS::Task &task) { UNUSED(task); while(1){ led1.on(); led2.off(); OS::sleep(500); led1.off(); led2.on(); OS::sleep(500); } }
bool init(void) { p2_wire0.setAsInput(); SW.init(); LE.init(); return true; }
UltrasonicSensor(LPC1758_GPIO_Type Power_Pin, bool filterOpt = false, int filterSize = 0): GpioPower(Power_Pin), avg_filter(filterSize), isFilterUsed(filterOpt) { /* Configuring the GpioPower pin as Output */ GpioPower.setAsOutput(); }
bool init(void) { p2_wire0.setAsOutput(); const uint8_t port2_1 = 1; eint3_enable_port2(port2_1, eint_rising_edge, switch_edge); LE.init(); vSemaphoreCreateBinary(sem); return true; }
void setup(){ gpio26 = new GPIO("26"); gpio19 = new GPIO("19"); gpio13 = new GPIO("13"); gpio6 = new GPIO("6"); gpio21 = new GPIO("21"); gpio26->export_gpio(); gpio19->export_gpio(); gpio13->export_gpio(); gpio6->export_gpio(); gpio21->export_gpio(); gpio26->setdir_gpio("out"); gpio19->setdir_gpio("out"); gpio13->setdir_gpio("out"); gpio6->setdir_gpio("out"); gpio21->setdir_gpio("in"); }
int main() { u8 State=REMOTECONTROL_LOCK; u8 OldState=REMOTECONTROL_LOCK; double Receive_data=0; //接收数据 10ms double RcUpdata=0; //遥控器状态更新时间 20ms ledBlueGPIO.SetLevel(0); while(1) { if(tskmgr.TimeSlice(Receive_data,0.01) ) //0.01 { Hi.DataListening_SendPC();//监听飞机发送来的数据转发给PC Hi.DataListening_SendCopter();//监听PC发送来的数据转发给飞机 } if(tskmgr.TimeSlice(RcUpdata,0.08) ) { State=RC.Updata(80,2000); Hi.SendData2Copter(RC.GetYawVal(),RC.GetThrottleVal(),RC.GetRollVal(),RC.GetPitchVal(),false); if(State == REMOTECONTROL_LOCK && OldState ==REMOTECONTROL_UNLOCK ) { OldState = REMOTECONTROL_LOCK; Hi.SendOrder(0XA0); ledBlueGPIO.SetLevel(1);//上锁状态为亮 } else if(State ==REMOTECONTROL_UNLOCK && OldState ==REMOTECONTROL_LOCK)//解锁 { Hi.SendOrder(0XA1); OldState = REMOTECONTROL_UNLOCK; ledBlueGPIO.SetLevel(0);//解锁状态为灭 //tskmgr.DelayS(1); } if(State == REMOTECONTROL_UNLOCK) //如果解锁了才向上位机发送 Hi.SendData2Copter(RC.GetYawVal(),RC.GetThrottleVal(),RC.GetRollVal(),RC.GetPitchVal(),true); } } }
void mainTaskCallback (OS::Task &task) { UNUSED(task); OS::sleep(100); en2v8.on(); OS::sleep(100); OS::sleep(100); bluetoothShutdown.off(); OS::sleep(100); Bluetooth::instance().init("MobilECG"); //Turn on ECG clock TIM_HandleTypeDef tim; tim.Instance = TIM1; HAL_TIM_PWM_Start(&tim, TIM_CHANNEL_3); if (!ADS1298::instance().start()) Logger::panic("Failed to initialize ADS1298."); while(1){ if (!Bluetooth::instance().isConnected()){ ADS1298::instance().clear(); OS::sleep(10); continue; } if (ADS1298::instance().getAvailableData()<512){ OS::sleep(10); continue; } ecgSender.send(); } }
void ApplicationEntryPoint() { BOOL result; //RAM RamTest ( (UINT32*)RAMTestBase, (UINT32)RAMTestSize, (ENDIAN_TYPE)ENDIANESS, BUS_WIDTH ); TimedEvents eventsTest; //UART usartTest ( COMTestPort, 9600, USART_PARITY_NONE, 8, USART_STOP_BITS_ONE, USART_FLOW_NONE ); GPIO gpioTest ( GPIOTestPin ); //SPI spiTest ( SPIChipSelect, SPIModule, g_EEPROM_STM95x ); Timers timersTest ( DisplayInterval, TimerDuration ); do { //result = RamTest.Execute ( STREAM__OUT ); result = eventsTest.Execute( STREAM__OUT ); //result = usartTest.Execute ( STREAM__OUT ); result = gpioTest.Execute ( STREAM__OUT ); //result = spiTest.Execute ( STREAM__OUT ); result = timersTest.Execute( STREAM__OUT ); } while(FALSE); // run only once! while(TRUE); }
bool run(void *p) { if (p2_wire0.read()) { // Turn on LED1 LE.on(1); } else { // Turn off LED2 LE.off(1); } return true; }
static Matrix *shared_matrix() { static Matrix *matrix = NULL; if (!matrix) { PanelConfiguration panelConfig; if (gOptions.panel_configuration_file.length()) { panelConfig.readConfigurationFile(gOptions.panel_configuration_file); } #ifdef USE_VIRTUAL_CANVAS matrix = new VirtualCanvas(panelConfig.rows, panelConfig.chainedDisplays, panelConfig.parallelDisplays); #else GPIO *io = new GPIO(); if (!io->Init()) { cerr << "Unable to initialize GPIO. Permissions?" << endl; return nullptr; } matrix = new RGBMatrix(io, panelConfig.rows, panelConfig.chainedDisplays, panelConfig.parallelDisplays); #endif } return matrix; }
int main(int argc, char *argv[]) { GPIO gpio; gpio.Init(); RGBMatrix matrix(&gpio); Visualizer *visualizer = new Visualizer(&matrix); int command[]={2,0,0,0,0,0,0}; //Array with length 7 to get Information from the Webfile socketConnection(); socketfunction(command); //Wait for the first command while(true) { Visualizer *visualizer = new Visualizer(&matrix); visualizer->setCommand(command); visualizer->Start(); // Start doing things. socketfunction(command); //change animation as needed visualizer->Stop(); } getchar(); close(sockfd); delete visualizer; }
v8::Handle<v8::Value> GPIO::Read(const v8::Arguments& args) { v8::HandleScope scope; GPIO* obj = ObjectWrap::Unwrap<GPIO>(args.This()); if (!obj->opened) { std::string err_msg = "GPIO " + obj->pin_num + " is not opened."; v8::ThrowException(v8::Exception::Error(v8::String::New(err_msg.c_str()))); return scope.Close(v8::Undefined()); } if (obj->mode == GPIO::OUT) { std::string err_msg = "GPIO " + obj->pin_num + " is not in the right mode"; v8::ThrowException(v8::Exception::Error(v8::String::New(err_msg.c_str()))); return scope.Close(v8::Undefined()); } int res = obj->read(); std::ostringstream ss; ss << res; if (res < 0) { std::string err_msg = "OPERATION FAILED: Unable to change GPIO " + obj->pin_num + " value."; v8::ThrowException(v8::Exception::Error(v8::String::New(err_msg.c_str()))); return scope.Close(v8::Undefined()); } obj->log("GPIO " + obj->pin_num + " value changed to " + ss.str() + "."); return scope.Close(v8::Integer::New(res)); }
v8::Handle<v8::Value> GPIO::Write(const v8::Arguments& args) { v8::HandleScope scope; GPIO* obj = ObjectWrap::Unwrap<GPIO>(args.This()); if (args.Length() < 1) { v8::ThrowException(v8::Exception::TypeError(v8::String::New("Wrong number of arguments"))); return scope.Close(v8::Undefined()); } if (!args[0]->IsNumber()) { v8::ThrowException(v8::Exception::TypeError(v8::String::New("Wrong arguments"))); return scope.Close(v8::Undefined()); } v8::Local<v8::Integer> param1 = args[0]->ToInteger(); int value = param1->IntegerValue(); int res = obj->write(value); if (res < 0) { std::string err_msg = "OPERATION FAILED: Unable to change GPIO " + obj->pin_num + " value."; v8::ThrowException(v8::Exception::Error(v8::String::New(err_msg.c_str()))); return scope.Close(v8::Undefined()); } std::ostringstream ss; ss << value; obj->log("GPIO " + obj->pin_num + " value changed to " + ss.str() + "."); return scope.Close(v8::Integer::New(res)); }
void DialogRecepti::beep() {//функция за звук при натискане на бутон QTime tme; GPIO *buzzer; buzzer = new GPIO(PIN31); buzzer->openPin(); buzzer->setDirection(GPIO::Out); tme.restart(); buzzer->setState(true); while(tme.elapsed()<25){qApp->processEvents();} buzzer->setState(false); buzzer->closePin(); delete buzzer; }
void DialogMenu::beep() { // qApp->beep(); QTime tme; GPIO *buzzer; buzzer = new GPIO(PIN31); buzzer->openPin(); buzzer->setDirection(GPIO::Out); tme.restart(); buzzer->setState(true); while(tme.elapsed()<25){qApp->processEvents();} buzzer->setState(false); buzzer->closePin(); delete buzzer; }
int main() { double record_UI_Updata=0; //UI更新时间片 double record_UI_power=0;//电量更新 double record_UI_time_hight=0;//时间更新 double record_UI_YRPT_CLOCK=0;//时间更新 double record_JoystickUpdata=0; double test=0; ledRedGPIO.SetLevel(1); ledGREGPIO.SetLevel(1); while(1) { Rc2Copter.DataListening(); if(tskmgr.TimeSlice(record_UI_Updata,0.1)) //0.1秒更新一次UI { //MessageShow.setTextBox("t21",num); if(tskmgr.TimeSlice(record_UI_power,5))//每5秒更新一次电量值 { MessageShow.setTextBox(UI_RcPower,pressure.Voltage_I(1,1,2,4.2),1); MessageShow.setTextBox(UI_CopterPower,Rc2Copter.RcvPower,1); } if(tskmgr.TimeSlice(record_UI_time_hight,1))//每秒更新一次高度和时间 { MessageShow.setTextBox(UI_Hight,Rc2Copter.RcvHight,0); MessageShow.setTextBox(UI_AliveTime,Rc2Copter.RcvTime,0); } if(tskmgr.TimeSlice(record_UI_YRPT_CLOCK,0.5)) //没0.5秒更新一次显示 { MessageShow.setTextBox(UI_YAW,Rc2Copter.RcvYaw,0); MessageShow.setTextBox(UI_ROOL,Rc2Copter.RcvRoll,0); MessageShow.setTextBox(UI_PITCH,Rc2Copter.RcvPitch,0); MessageShow.setTextBox(UI_THR,Rc2Copter.RcvThr,0); if(Rc2Copter.ClockState == 1) MessageShow.vis(UI_FlyClock,1);//显示 为橙色 else MessageShow.vis(UI_FlyClock,0);//隐藏 为蓝色 } //更新摇杆状态显示 MessageShow.outputDirection(UI_DirectionL,RC.getLeftState()); MessageShow.outputDirection(UI_DirectionR,RC.getNightState()); } if(tskmgr.TimeSlice(record_JoystickUpdata,0.1)) //0.1秒更新一次摇杆状态 { if(RC.Updata()) { //遥控器状态判断 外八解锁,内八上锁 if(RC.getLeftState() == 7 && RC.getNightState() == 9) //解 { Rc2Copter.FlightLockControl(false); } else if(RC.getLeftState() == 9 && RC.getNightState() == 7) { Rc2Copter.FlightLockControl(true); } else if(RC.getLeftState() == 1 && RC.getNightState() == 3 && Rc2Copter.ClockState == 1) //外八且上锁 { } else//如果处于解锁状态则发送数据 { if(Rc2Copter.ClockState == 0) { //发送数据 Rc2Copter.SendData2Copter(1000,1000,1000,1000); } } } } if(tskmgr.TimeSlice(test,0.1)) com1<<pressure[5]<<"\t"<<pressure[6]<<"\t"<<pressure[8]<<"\t"<<pressure[9]<<"\n"; } }
int main(int argc, char *argv[]) { global_terminate = false; enabled = false; bool correct_luminance = true, screensaver = false, do_fork = false; int rows_on_display = 32, chained_displays = 1, pwm_bits = 0, brightness_in = 50, fps = 50; int listen_port = 3333; screensaver_t ss = SS_CLOCK; // FIXME commandline selectable std::string default_font = DEFAULT_FONT_FILE; int c = -1; while((c = getopt(argc, argv, "p:r:c:t:lsP:b:f:dF:h")) != -1) { switch(c) { case 'p': pwm_bits = atoi(optarg); break; case 'r': rows_on_display = atoi(optarg); break; case 'c': chained_displays = atoi(optarg); break; case 't': pwm_bits = atoi(optarg); break; case 'l': correct_luminance = !correct_luminance; break; case 's': screensaver = true; break; case 'P': listen_port = atoi(optarg); break; case 'b': brightness_in = atoi(optarg); break; case 'f': fps = atoi(optarg); break; case 'd': do_fork = true; break; case 'F': default_font = optarg; break; case 'h': help(); return 0; default: help(); error_exit(false, "option %c is not understood", c); } } signal(SIGINT, sigh); signal(SIGTERM, sigh); signal(SIGUSR1, toggle); srand(time(NULL)); font::init_fonts(); GPIO io; if (!io.Init()) error_exit(false, "Failed to initialized GPIO sub system"); srand(time(NULL)); RGBMatrix m(&io, rows_on_display, chained_displays, 1); if (pwm_bits > 0 && !m.SetPWMBits(pwm_bits)) error_exit(false, "Invalid range of pwm-bits"); if (correct_luminance) m.set_luminance_correct(true); std::atomic_int brightness(brightness_in); double_buffer_t db; db.w = m.width(); // change for different panel layout db.h = m.height(); int pixel_bytes = db.w * db.h * 3; db.data = new uint8_t[pixel_bytes]; db.brightness = &brightness; db.flag = db.need_update = false; db.screensaver = screensaver; db.font_name = default_font; pthread_rwlock_t clients_lock; pthread_rwlock_init(&clients_lock, NULL); std::map<std::string, disp_element_t *> clients; ThreadedCanvasManipulator *image_gen = new UpdateMatrix(&m, &db, &clients_lock, &clients, fps, ss); image_gen->Start(); if (do_fork && daemon(0, 0) == -1) error_exit(true, "Failed to daemon()"); printf("Go!\n"); main_loop(&db, &clients_lock, &clients, &brightness, &db.need_update, listen_port); terminate_threads(&clients_lock, &clients); global_terminate = true; image_gen->Stop(); // Stopping threads and wait for them to join. delete image_gen; font::uninit_fonts(); printf("END\n"); return 0; }
int main(){ u8 order=0; double record_updataSensor=0; double record_alive=0; double record_getwifi=0; bool network=false ; //网络连接标识位 char *ip = (char*)calloc(15, sizeof(char*) ); char *WifiName = (char*)calloc(20, sizeof(char*) ); char *WifiPassword = (char*)calloc(20, sizeof(char*) ); /*开机WIFI模式选择*****************************************************************/ if(wifimemory.getWifiSum()!=0)//判断表中是否已经保存wifi信息 { while( wifimemory.Load(WifiName,WifiPassword) ) { if(wifi.ConnectNetwork_client(WifiName,WifiPassword,SERVER_IP,1111)) //每次连接历时20秒 {network=true; break;} } if(network ==false) { wifi.ConnectNetwork_server(MODULE_COM,0); WIFI.ClearReceiveBuffer(); } } else { wifi.ConnectNetwork_server(MODULE_COM,0); WIFI.ClearReceiveBuffer(); } Led.SetLevel(1);//将指示灯熄灭(模式切换结束) /*END*********************************************************************************/ while(1) { order=CMCT_Tool.GetStateOrder(WIFI); switch(order) { case DELAY:{}break; /*启动********************************************************************************************/ case START:{//启动 while(1){ if(tskmgr.ClockTool(record_updataSensor,3)) //每三秒执行一次更新 { co2.Updata(); if(network) wifi.Send(20,CMCT_Tool.ToServerPack(CO2Number,co2.DATA_H,co2.DATA_L,0)); else wifi.Send(0,20,CMCT_Tool.ToClientPack(CO2Number,co2.DATA_H,co2.DATA_L,0)); } if(CMCT_Tool.GetStateOrder(WIFI)==DELAY) break; } }break; /*END********************************************************************************************/ /*复位******************************************************************************************/ case RESET:{//复位 wifimemory.ClearAllData(); //清空所有保存信息 *((u32 *)0xE000ED0C) = 0x05fa0004; }break; /*END******************************************************************************************/ /*获取WIFI信息*********************************************************************************/ case GETWIFI:{//得到wifi账号密码 record_getwifi=tskmgr.Time(); while(1) { if(CMCT_Tool.GetWifiNameAndPassword(WifiName,WifiPassword,WIFI) ) { //保存WIFI账号密码 com<<WifiName<<"\t"<<WifiPassword<<"\n"; break; } if(tskmgr.ClockTool(record_getwifi,30)) //超时10秒退出 break; } }break; /*END******************************************************************************************/ /*模式切换*************************************************************************************/ case MODEL:{//模式切换 wifi.ConnectNetwork_server(MODULE_COM,0); WIFI.ClearReceiveBuffer(); network=false; }break; /*END******************************************************************************************/ /*存活确认*************************************************************************************/ case ALIVE:{//存活确认 if(network) CMCT_Tool.SendAlive(wifi,CO2Number,1); //存活确认,数据位全为0xff else CMCT_Tool.SendAlive(wifi,CO2Number,0); }break; /*END******************************************************************************************/ /*常态******************************************************************************************/ default: { if(tskmgr.ClockTool(record_updataSensor,3)) //每三秒执行一次更新 co2.Updata();//当没有命令时更新传感器 if(tskmgr.ClockTool(record_alive,60)) //每60秒发送一次存活确认 { if(network) CMCT_Tool.SendAlive(wifi,CO2Number,1); else CMCT_Tool.SendAlive(wifi,CO2Number,0); } } } } }
int main(){ bluetoothShutdown.on(); en2v8.off(); OS::run(); }
void update(){ usleep(100); gpio21->getval_gpio(state_button); if(state_button == "1"){ usleep(5000); gpio26->setval_gpio("1"); gpio19->setval_gpio("0"); gpio13->setval_gpio("0"); gpio6->setval_gpio("1"); usleep(5000); gpio26->setval_gpio("1"); gpio19->setval_gpio("0"); gpio13->setval_gpio("1"); gpio6->setval_gpio("0"); usleep(5000); gpio26->setval_gpio("0"); gpio19->setval_gpio("1"); gpio13->setval_gpio("1"); gpio6->setval_gpio("0"); usleep(5000); gpio26->setval_gpio("0"); gpio19->setval_gpio("1"); gpio13->setval_gpio("0"); gpio6->setval_gpio("1"); } }
int main(int argc, char * argv[]) { // Parse cmd line args if (argc < 2) { printf("Usage: %s <gpio-pin>\n", argv[0]); return 1; } uint8_t gpioPin = atoi(argv[1]); // Setup TUI if (!Screen::Instance()->init()) return 1; int32_t width, height; Screen::Instance()->size(width, height); // Initialize gpio GPIO* gpio = NULL; #ifdef BEAGLEBONEBLACK gpio = new BBBGPIO(gpioPin); #endif if (gpio == NULL) { fprintf(stderr, "Error: No target device was specified when compiling this test\n"); Screen::Instance()->destroy(); return 1; } if (!gpio->init()) { fprintf(stderr, "Error: Initializing GPIO\n"); Screen::Instance()->destroy(); return 1; } gpio->setMode(GPIO::OUTPUT); // Line content definitions typedef enum LINE_CONTENT_ENUM { BORDER_TOP_LINE = 0, TITLE_LINE, TITLE_SEP_LINE, CONTROLS_LINE, BORDER_BOT_LINE } LINE_CONTENT; // Print border Screen::Instance()->printRectangle(0, BORDER_TOP_LINE, width - 1, BORDER_BOT_LINE); // Print static text to screen #ifdef BEAGLEBONEBLACK Screen::Instance()->printTextCenter(0, width - 1, TITLE_LINE, "embed-lib: BeagleBone Black GPIO Write Test"); #endif Screen::Instance()->printHLine (0, width - 1, TITLE_SEP_LINE); Screen::Instance()->printText(1, CONTROLS_LINE, " s - Set r - Reset q - Quit"); // Main loop char c; while ((c = (Screen::Instance()->getCh())) != 'q') { switch (c) { case 's' : gpio->digitalWrite(1); break; case 'r' : gpio->digitalWrite(0); default: break; } } gpio->destroy(); delete gpio; Screen::Instance()->destroy(); }
int ccdbgDevice_initialize(void) { return (!resetPin.isActive() || !dcPin.isActive() || !ddPin.isActive()) ? -1 : 0; }