void OpenOBC::hardwareTest() { debug->detach(this, &OpenOBC::uartHandler); Input* ccmData = new Input(CCM_DATA_PORT, CCM_DATA_PIN); IO* ccmClock = new IO(CCM_CLOCK_PORT, CCM_CLOCK_PIN); IO* ccmLatch = new IO(CCM_LATCH_PORT, CCM_LATCH_PIN); Input* speedInput = new Input(SPEED_PORT, SPEED_PIN); Input* fuelLevelInput = new Input(FUEL_LEVEL_PORT, FUEL_LEVEL_PIN); Input* fuelConsInput = new Input(FUEL_CONS_PORT, FUEL_CONS_PIN); printf("hardware test...\r\n"); lcd->printf("hardware test..."); delay(200); while(debug->readable() && debug->get() == ' ') { wdt.feed(); while(debug->readable() && debug->get() == ' '); delay(200); } printf("K and L bus echo test...\r\n"); zke->query(); printf("button test...\r\n"); lcd->printf("button test..."); while(1) { if(debug->readable() && debug->get() == ' ') break; wdt.feed(); lcd->printf("button mask: 0x%05x", keypad->getKeys()); printf("button mask: 0x%05x (press space to continue)\r\n", keypad->getKeys()); delay(50); printf("\033[A"); } printf("\r\n"); printf("output test... (press space to continue)\r\n"); lcd->printf("output test..."); io0->setOutput(); io1->setOutput(); while(1) { if(debug->readable() && debug->get() == ' ') break; wdt.feed(); //all on lcdLight->on(); clockLight->on(); auxLight->on(); keypadLight->on(); timerLed->on(); limitLed->on(); codeLed->on(); out0->on(); out1->on(); out2->on(); out3->on(); io0->on(); io1->on(); chime0->on(); chime1->on(); ventilation->on(); antitheftHorn->on(); ews->on(); ccmLight->on(); ccmClock->on(); ccmLatch->on(); delay(500); //all off lcdLight->off(); clockLight->off(); auxLight->off(); keypadLight->off(); timerLed->off(); limitLed->off(); codeLed->off(); out0->off(); out1->off(); out2->off(); out3->off(); io0->off(); io1->off(); chime0->off(); chime1->off(); ventilation->off(); antitheftHorn->off(); ews->off(); ccmLight->off(); ccmClock->off(); ccmLatch->off(); delay(500); } io0->setInput(); io1->setInput(); lcdLight->on(); clockLight->on(); keypadLight->on(); printf("input test...\r\n"); lcd->printf("input test..."); while(1) { if(debug->readable() && debug->get() == ' ') break; wdt.feed(); printf("x% 2.2f y% 2.2f z% 2.2f\r\n", accel->getX(), accel->getY(), accel->getZ()); printf("stalkButton: %i sdcardDetect: %i io0: %i io1: %i ccmData: %i speed: %i\r\n", *stalkButton ? 1 : 0, *sdcardDetect ? 1 : 0, *io0 ? 1 : 0, *io1 ? 1 : 0, *ccmData ? 1 : 0, *speedInput ? 1 : 0); printf("illumination: %i ambientLight: %i brakeSwitch: %i brakeCheck: %i\r\n", *illumination ? 1 : 0, *ambientLight ? 1 : 0, *brakeSwitch ? 1 : 0, *brakeCheck ? 1 : 0); printf("batteryVoltage: % 2.2f temperature: % 2.2f vstart: % 2.2f analogIn1: % 2.2f analogIn2: % 2.2f\r\n", batteryVoltage->read(), temperature->read(), vstart->read(), analogIn1->read(), analogIn2->read()); printf("fuelLevel: %i fuelCons: %i\r\n", *fuelLevelInput ? 1 : 0, *fuelConsInput ? 1 : 0); printf("(press space to continue)\r\n"); fflush(stdout); delay(50); printf("\033[6A"); } printf("\r\n\r\n\r\n\r\n\r\n\r\n"); printf("test complete\r\n"); lcd->printf("test complete"); debug->attach(this, &OpenOBC::uartHandler); }