void CSettingsPanel::mVoltagePlusClick(wxCommandEvent& WXUNUSED(event)) { int step = adl->mODParameters.sVddc.iStep; int current = mVoltageSlider->GetValue(); if (current+step <= adl->mODParameters.sVddc.iMax) { CheckVoltage(current+step); } }
EXPORT_C void DSDIOPsu::DoTickService() /** Periodic update called only while PSU is on. This checks whether it is safe to remove power from the card or enter sleep mode. */ { TRACE1(TTraceContext(EBorder), UTraceModuleEPBusSDIO::ESDIODSDIOPsuDoTickService, reinterpret_cast<TUint32>(this)); // @SymTraceDataPublishedTvk DSDIOSocket& theSocket = *static_cast<DSDIOSocket*>(iSocket); if(IsLocked()) { // // If the card is locked, we use the inactivity timeout to determine // whether we can enter sleep mode. // // Note that the power is not turned off, but the clients are notified // to give them an opportunity to de-register themselves or enter a // function-dependant low-power sleep mode). // if(iInactivityTimeout && ++iInactivityCount > iInactivityTimeout) { theSocket.SignalSleepMode(); iInactivityCount = 0; } } else { // // If the card is not locked, then we power down the card after the // specified interval (iNotLockedTimeout). This shall perform an // asynchronous power down and reset of the card before removing power // to ensure that the card is in the lowest possible state of power // consumption should the underlying hardware not support a programmable PSU. // if(iNotLockedTimeout) iNotLockedCount++; if(iInactivityTimeout) iInactivityCount++; if ((iNotLockedTimeout && iNotLockedCount > iNotLockedTimeout) && (iInactivityTimeout && iInactivityCount > iInactivityTimeout)) { theSocket.ResetAndPowerDown(); iInactivityCount = 0; iNotLockedCount = 0; } } CheckVoltage(KPsuChkWhileOn); TRACE1(TTraceContext(EBorder), UTraceModuleEPBusSDIO::ESDIODSDIOPsuDoTickServiceReturning, reinterpret_cast<TUint32>(this)); // @SymTraceDataPublishedTvk }
/*--------------------------------------------------------------------------------------------------*/ int InitEmoro(void){ int ret_value = 0; int ADC_read; long Vin, Vin_decimal; char lcd[20]; unsigned char d[7], chk=0; GLAM_EEPROMReadBytes(121,7, d); /* address 121 -> LCD, 122 -> switches */ /* 123 -> Accelerometer, 124 -> Gyroscope */ /* 125 -> Compas, 126 -> Bluetooth, 127 -> Chk */ for(unsigned char n=0; n<7; n++) /* calculate checksum */ chk^=*(d+n); if(chk^0xAA == 0){ if(d[0] == 0xC8){ /* check LCD */ if(Lcd.init() == 0){ /* initialize lcd */ Lcd.backlightOn(); /* turn on lcd backlight */ ret_value |= (LCD_AVAILABLE); /* set return value -> LCD Available */ initialized_emoro_hw = ret_value; } } if(d[1] == 0xC8){ /* check switches */ InitSwitch(); /* initialize switch (SW1 - SW4) */ ret_value |= (SW_AVAILABLE); /* set return value -> Switch Available */ } if(Acc.testConnection() & d[2] == 0xC8){ /* test Acc and check */ Acc.init(); /* initialize acceleration sensor BMA150 */ ret_value |= (ACC_AVAILABLE); /* set return value -> ACC Available */ } if(Gyr.testConnection() & d[3] == 0xC8){ /* test Gyr and check */ Gyr.initBasic(); /* initialize gyroscope L3GD20 */ ret_value |= (GYR_AVAILABLE); /* set return value -> GYR Available */ } if(Mag.testConnection() & d[4] == 0xC8){ /* test magnetometer and check */ Mag.init(); /* initialize magnetometer */ ret_value |= (MAG_AVAILABLE); /* set return value -> MAG Available */ } if(d[5] == 0xC8){ if(Bluetooth.init() == 0){ /* initialize bluetooth communication */ ret_value |= (BLUETOOTH_AVAILABLE); /* set return value -> Bluetooth Available */ } } ADC_read=CheckVoltage(); /* read input voltage */ Vin=(long)(ADC_read*15/1024); /* calculate voltage; whole number */ Vin_decimal=(long)ADC_read*1500/1024-Vin*100; /* calculate decimal places */ if( Vin >= 5 & (Vin == 6 & Vin_decimal<20) ){ /* if Vin>=5V & Vin < 6.20V batt is */ sprintf(lcd, "Vin=%d.%d", (int)Vin, (int)Vin_decimal); Serial.begin(9600); /* initialize Serial monitor UART 9600 bps */ Serial.println((char*)"Voltage low:"); Serial.println(lcd); if(ret_value & LCD_AVAILABLE){ Lcd.clear(); /* low, for Vin<5V:USB power supply */ Lcd.printString((char*)"Voltage low:"); Lcd.locate(1,0); Lcd.printString(lcd); } for (int rep=0; rep<2; rep++){ tone(BUZ_BUILTIN, NOTE_C6, 50); _delay_ms(100); /* Mores code letter S(...) */ tone(BUZ_BUILTIN, NOTE_C6, 50); _delay_ms(100); tone(BUZ_BUILTIN, NOTE_C6, 50); _delay_ms(200); tone(BUZ_BUILTIN, NOTE_C6, 150); _delay_ms(200);/* Mores code letter O(---) */ tone(BUZ_BUILTIN, NOTE_C6, 150); _delay_ms(200); tone(BUZ_BUILTIN, NOTE_C6, 150); _delay_ms(300); tone(BUZ_BUILTIN, NOTE_C6, 50); _delay_ms(100); /* Mores code letter S(...) */ tone(BUZ_BUILTIN, NOTE_C6, 50); _delay_ms(100); tone(BUZ_BUILTIN, NOTE_C6, 50); _delay_ms(400); } noTone(BUZ_BUILTIN); Lcd.clear(); } } if(ret_value & MAG_AVAILABLE){ if(ReadSwitch(SW_2) == 1){ /* magnetometer calibration request? */ Serial.begin(9600); Serial.println((char*)"Compass"); Serial.println((char*)"Calibration.....\n"); if(ret_value & LCD_AVAILABLE){ Lcd.clear(); Lcd.printString((char*)"Compass "); Lcd.locate(1,0); Lcd.printString((char*)"Calibration....."); } while(ReadSwitch(SW_2)==1); /* wait button release */ _delay_ms(300); /* mag calibration step 1 */ Serial.println((char*)"Lay board flat"); Serial.println((char*)"Press button 1\n"); if(ret_value & LCD_AVAILABLE){ Lcd.clear(); Lcd.printString((char*)"Lay board flat"); Lcd.locate(1,0); Lcd.printString((char*)"Press button 1"); } WaitSwitch(SW_1); Mag.calibrate(1); _delay_ms(500); /* mag calibration step 2 */ Serial.println((char*)"Rotate 180 degre"); Serial.println((char*)"Press button 1\n"); if(ret_value & LCD_AVAILABLE){ Lcd.clear(); Lcd.printString((char*)"Rotate 180 degre"); Lcd.locate(1,0); Lcd.printString((char*)"Press button 1"); } WaitSwitch(SW_1); Mag.calibrate(2); _delay_ms(300); /* mag calibration step 2 */ Serial.println((char*)"Flip board"); Serial.println((char*)"Press button 1\n"); if(ret_value & LCD_AVAILABLE){ Lcd.clear(); Lcd.printString((char*)"Flip board"); Lcd.locate(1,0); Lcd.printString((char*)"Press button 1"); } WaitSwitch(SW_1); Mag.calibrate(3); _delay_ms(300); Serial.println((char*)"Calibration"); Serial.println((char*)"Complete\n"); if(ret_value & LCD_AVAILABLE){ Lcd.clear(); Lcd.printString((char*)"Calibration "); Lcd.locate(1,0); Lcd.printString((char*)"Complete "); } _delay_ms(1500); Serial.println((char*)"Press button 1\n"); if(ret_value & LCD_AVAILABLE){ Lcd.clear(); Lcd.locate(1,0); Lcd.printString((char*)"Press button 1"); } while(ReadSwitch(SW_1)==0){ int dir, inc, str; Mag.read(&dir, &inc, &str); sprintf(lcd, "Direction=%3d", dir); Serial.println(lcd); if(ret_value & LCD_AVAILABLE){ Lcd.locate(0, 0); Lcd.printString(lcd); } } Lcd.clear(); } } initialized_emoro_hw = ret_value; return initialized_emoro_hw; }
void Process() { if (s_unProcessStep == STEP_NONE) { return; } //Test LED control if (s_unProcessStep & STEP_TEST_LED) { if (TestLED_Proc()) { //finished. s_unProcessStep &= ~STEP_TEST_LED; TEST_LED_OFF; } } if (s_unProcessStep & STEP_REF_ON) { CheckVoltage(); s_unProcessStep &= ~STEP_REF_ON; } if (s_unProcessStep & STEP_TEMPERATURE) { if (s_unRetry == 0) { //Timeout to get data, cacel s_unProcessStep &= ~STEP_TEMPERATURE; TestLED_MeasureFailed(); } else { s_unRetry--; if (GetTemperature()) { //next step is getting humidity. StartHumidity(); s_unProcessStep &= ~STEP_TEMPERATURE; s_unProcessStep |= STEP_HUMIDITY; s_unRetry = 10; } } } if (s_unProcessStep & STEP_HUMIDITY) { if (s_unRetry == 0) { //Timeout to get data, cancel s_unProcessStep &= ~STEP_HUMIDITY; TestLED_MeasureFailed(); } else { s_unRetry--; if (GetHumidity()) { //finish SHT11 measure s_unProcessStep &= ~STEP_HUMIDITY; // 进行温度和湿度的换算,计算出正确的问题,以及相对湿度(暂时不在分机转换,因为1122分机是汇编写的,无法进行浮点运输。还是要到Center运输后,再通过串口送到主机) TestLED_MeasureSuccess(); } } } if (s_unProcessStep & STEP_BMP085_TEMPERATURE) { s_unProcessStep &= ~STEP_BMP085_TEMPERATURE; // 读取温度,继续压力测量 if (GetTemperature_BMP085()) { StartPressure_BMP085(); s_unProcessStep |= STEP_BMP085_PRESSURE; } } else if (s_unProcessStep & STEP_BMP085_PRESSURE) { s_unProcessStep &= ~STEP_BMP085_PRESSURE; // 读取压力值,换算温度和压力 if (GetPressure_BMP085()) { CalculateBMP085Data(); } } }
void CSettingsPanel::mVoltageSliderScroll(wxScrollEvent& WXUNUSED(event)) { CheckVoltage(mVoltageSlider->GetValue()); }