BOOL CMsgBoxDlg::OnInitDialog() { CStringLoaderDlg<CBCGPDialog>::OnInitDialog(); GetDlgItem(IDC_STATIC_INFO)->SetWindowText(m_strText); if(m_nType == (MB_OK|MB_ICONQUESTION|MB_SYSTEMMODAL)) { SetWindowPos(&CWnd::wndTopMost,0,0,0,0,SWP_NOMOVE);//保持窗口在最前 } InitWindow(); InitIcon(); InitButton(); CenterWindow(); if (m_bAutoClose) { SetTimer(10, 1000,NULL); } return FALSE; // return TRUE unless you set the focus to a control // 异常: OCX 属性页应返回 FALSE }
Relax::Relax(Playmanagement &playmanager) { Playmanager = &playmanager; std::string Key1 = "."; std::string Key2 = "-"; Button1.Keycode = VkKeyScanEx(Key1.at(0), GetKeyboardLayout(0)) & 0xFF; Button2.Keycode = VkKeyScanEx(Key2.at(0), GetKeyboardLayout(0)) & 0xFF; InitButton(Button1.PressButton, Button1.Keycode, true); //Initiate buttons InitButton(Button1.ReleaseButton, Button1.Keycode, false); InitButton(Button2.PressButton, Button2.Keycode, true); InitButton(Button2.ReleaseButton, Button2.Keycode, false); Klicked = true; //Load first hit }
OP_STATUS GenericThumbnail::OnContentChanged() { RETURN_IF_ERROR(m_title_button->SetText(m_content->GetTitle())); m_busy_spinner->SetVisibility(m_content->IsBusy()); GenericThumbnailContent::ButtonInfo close_button_info; RETURN_IF_ERROR(m_content->GetCloseButtonInfo(close_button_info)); RETURN_IF_ERROR(InitButton(m_close_button, close_button_info)); GenericThumbnailContent::ButtonInfo button_info; RETURN_IF_ERROR(m_content->GetButtonInfo(button_info)); RETURN_IF_ERROR(InitButton(m_content->GetButton(), button_info)); // Watir requirement: SetName(button_info.m_name); return OpStatus::OK; }
int main(void) { /* Reset of all peripherals, Initializes the Flash interface and the Systick. */ HAL_Init(); /* Configure the system clock */ SystemClock_Config(); InitLed(); InitButton(); //Initialization done separately //TODO: Add Clock and GPIO_Init to structure definitions Pinx Out_Pin_1 = SetPinx(GPIOD, GPIO_PIN_11); Pinx Out_Pin_2 = SetPinx(GPIOD, GPIO_PIN_13); Pinx In_Pin_1 = SetPinx(GPIOC, GPIO_PIN_1); Pinx In_Pin_2 = SetPinx(GPIOC, GPIO_PIN_3); Paddle paddle_1 = SetPaddle(In_Pin_1, Out_Pin_1, false); Paddle paddle_2 = SetPaddle(In_Pin_2, Out_Pin_2, false); //Keep in mind, Inverse Logic WritePinx(paddle_1.out,true); WritePinx(paddle_2.out,true); while (1) { if ((DebounceRead(paddle_1.in,DEBOUNCE_SAMPLING_N,DEBOUNCE_THRESHOLD) == GPIO_PIN_SET) && (paddle_1.state == false)) { //int xyz = DebounceRead(paddle_1.in,DEBOUNCE_SAMPLING_N,DEBOUNCE_THRESHOLD); WritePinx(paddle_1.out,false); paddle_1.state = true; HAL_Delay(SHIFT_TIME_MS); WritePinx(paddle_1.out,true); } else if (DebounceRead(paddle_1.in,DEBOUNCE_SAMPLING_N,DEBOUNCE_THRESHOLD) == GPIO_PIN_RESET) { paddle_1.state = false; } if ((DebounceRead(paddle_2.in,DEBOUNCE_SAMPLING_N,DEBOUNCE_THRESHOLD) == GPIO_PIN_SET) && (paddle_2.state == false)) { WritePinx(paddle_2.out,false); paddle_2.state = true; HAL_Delay(SHIFT_TIME_MS); WritePinx(paddle_2.out,true); } else if (DebounceRead(paddle_2.in,DEBOUNCE_SAMPLING_N,DEBOUNCE_THRESHOLD) == GPIO_PIN_RESET) { paddle_2.state = false; } } }
BOOL CBackstagePageInfo::OnInitDialog() { CXTPRibbonBackstagePage::OnInitDialog(); ModifyStyleEx(0, WS_EX_CONTROLPARENT); m_lblInformation.SetFont(&m_fntTitle); m_lblInformation.SetTextColor(RGB(59, 59, 59)); m_lblPermissions.SetFont(&m_fntCaption); m_lblPermissions.SetTextColor(RGB(94, 94, 94)); m_lblPrepareForSharing.SetFont(&m_fntCaption); m_lblPrepareForSharing.SetTextColor(RGB(94, 94, 94)); m_lblVersions.SetFont(&m_fntCaption); m_lblVersions.SetTextColor(RGB(94, 94, 94)); m_lblSeparator4.SetVerticalStyle(TRUE); InitButton(IDC_BUTTON_PROTECTDOCUMENT, TRUE); InitButton(IDC_BUTTON_CHECKFORISSUE, TRUE); InitButton(IDC_BUTTON_MANAGEVERSIONS, FALSE); SetResize(IDC_SEPARATOR_1, XTP_ANCHOR_TOPLEFT, XTP_ANCHOR_TOPRIGHT); SetResize(IDC_SEPARATOR_2, XTP_ANCHOR_TOPLEFT, XTP_ANCHOR_TOPRIGHT); SetResize(IDC_SEPARATOR_3, XTP_ANCHOR_TOPLEFT, XTP_ANCHOR_TOPRIGHT); SetResize(IDC_SEPARATOR_4, XTP_ANCHOR_TOPRIGHT, XTP_ANCHOR_BOTTOMRIGHT); SetResize(IDC_STATIC_PREVIEW, XTP_ANCHOR_TOPRIGHT, XTP_ANCHOR_TOPRIGHT); SetResize(IDC_TEXT1, XTP_ANCHOR_TOPLEFT, XTP_ANCHOR_TOPRIGHT); SetResize(IDC_TEXT2, XTP_ANCHOR_TOPLEFT, XTP_ANCHOR_TOPRIGHT); SetResize(IDC_TEXT3, XTP_ANCHOR_TOPLEFT, XTP_ANCHOR_TOPRIGHT); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE }
void setup(void) { // save_configs(); Serial.begin(115200); read_configs(); InitButton(); LCD.InitLCD(); pinMode(LCD_LIGHT, OUTPUT); digitalWrite(LCD_LIGHT, LOW); pinMode(ALERT_LAMP, OUTPUT); digitalWrite(ALERT_LAMP, HIGH); pinMode(SSR_PIN, OUTPUT); SetTemp=cfg.DispTemp; myPID.SetMode(AUTOMATIC); LCD.drawBitmap(0, 0, arduino_logo, 84, 48); delay(2000); LCD.invert(true); delay(500); LCD.invert(false); delay(500); digitalWrite(ALERT_LAMP, LOW); }
static void BluetoothStateChangeHandler(tMessage *pMsg) { if (Splashing) { if (pMsg->Options == On) { Splashing = pdFALSE; RtcUpdateEnabled = pdTRUE; DetermineIdlePage(); IdleUpdateHandler(); pMsg->Options = MUSIC_MODE | (TMPL_MUSIC_MODE << 4); LoadTemplateHandler(pMsg); pMsg->Options = NOTIF_MODE | (TMPL_NOTIF_MODE << 4); LoadTemplateHandler(pMsg); InitButton(); } } else { //decide which idle page to be DetermineIdlePage(); if (CurrentMode == IDLE_MODE) { if (PageType == PAGE_TYPE_IDLE) { if (OnceConnected()) { //#if COUNTDOWN_TIMER // if (Connected(CONN_TYPE_MAIN)) CreateAndSendMessage(CountDownMsg, MSG_OPT_NONE); //#endif UpdateClock(); } else DrawConnectionScreen(); } else if (PageType == PAGE_TYPE_MENU) MenuModeHandler(0); else if (CurrentPage[PAGE_TYPE_INFO] == StatusPage) DrawWatchStatusScreen(); } } }
BOOL CBackstagePageSave::OnInitDialog() { CXTPRibbonBackstagePage::OnInitDialog(); ModifyStyleEx(0, WS_EX_CONTROLPARENT); m_lblSaveAndSend.SetFont(&m_fntCaption); m_lblSaveAndSend.SetTextColor(RGB(94, 94, 94)); m_lblFileTypes.SetFont(&m_fntCaption); m_lblFileTypes.SetTextColor(RGB(94, 94, 94)); m_lblSeparator4.SetVerticalStyle(TRUE); InitButton(m_btnSendEmail); InitButton(m_btnSaveToWeb); InitButton(m_btnSaveToSharePoint); InitButton(m_btnPublish); InitButton(m_btnChangeFileType); InitButton(m_btnCreatePDF); SetResize(IDC_SEPARATOR_4, XTP_ANCHOR_TOPLEFT, XTP_ANCHOR_BOTTOMLEFT); CXTPWindowRect rcPage(GetDlgItem(IDC_STATIC_PAGE)); ScreenToClient(rcPage); m_pageSaveEmail.Create(CBackstagePageSaveEmail::IDD, this); m_pageSaveEmail.SetDlgCtrlID(CBackstagePageSaveEmail::IDD); m_pageSaveEmail.MoveWindow(rcPage); m_pageSaveEmail.ShowWindow(SW_SHOWNORMAL); m_pageSaveWeb.Create(CBackstagePageSaveWeb::IDD, this); m_pageSaveWeb.MoveWindow(rcPage); m_pageSaveWeb.SetDlgCtrlID(CBackstagePageSaveWeb::IDD); SetResize(CBackstagePageSaveEmail::IDD, XTP_ANCHOR_TOPLEFT, XTP_ANCHOR_BOTTOMRIGHT); SetResize(CBackstagePageSaveWeb::IDD, XTP_ANCHOR_TOPLEFT, XTP_ANCHOR_BOTTOMRIGHT); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE }
void main( void ) { /* Configure the peripherals used by this demo application. This includes configuring the joystick input select button to generate interrupts. */ prvSetupHardware(); InitButton(); InitLCD(); InitADC(); /* Create the other task in exactly the same way. */ xTaskCreate( ReadButton, "Button", 100, NULL, 1, NULL ); xTaskCreate( ReadADC, "ADC", 100, NULL, 1, NULL ); xTaskCreate( DisplaySignal, "Signal", 100, NULL, 2, NULL ); xTaskCreate( DisplayMenu, "Menu", 100, NULL, 3, NULL ); xTaskCreate( DisplayInfo, "Info", 100, NULL, 3, NULL ); /* Start the scheduler. */ vTaskStartScheduler(); for( ;; ); }
static void BluetoothStateChangeHandler(tMessage *pMsg) { if (Splashing) { if (pMsg->Options == On) { Splashing = pdFALSE; RtcUpdateEnabled = pdTRUE; DetermineIdlePage(); IdleUpdateHandler(); pMsg->Options = MUSIC_MODE | (TMPL_MUSIC_MODE << 4); LoadTemplateHandler(pMsg); pMsg->Options = NOTIF_MODE | (TMPL_NOTIF_MODE << 4); LoadTemplateHandler(pMsg); InitButton(); } } else { //decide which idle page to be DetermineIdlePage(); if (CurrentMode == IDLE_MODE) { if (PageType == PAGE_TYPE_IDLE) { if (!OnceConnected()) DrawConnectionScreen(); else UpdateClock(); } else if (PageType == PAGE_TYPE_MENU) MenuModeHandler(0); else if (CurrentPage[PAGE_TYPE_INFO] == StatusPage) DrawWatchStatusScreen(); } } }
int main(void) { /*!< At this stage the microcontroller clock setting is already configured, this is done through SystemInit() function which is called from startup file (startup_stm32l1xx_md.s) before to branch to application main. To reconfigure the default setting of SystemInit() function, refer to system_stm32l1xx.c file */ /* Configure Clocks for Application need */ RCC_Configuration(); uint8_t rxBuf[4]; uint8_t txBuf[16]; uint8_t chByte[2]; uint8_t chMainStep=MAIN_STEP_IDLE; int16_t* iCurentAdcValue=(int16_t*)chByte; // теперь тут будет лежать последнее измеренное число /* Configure RTC Clocks */ RTC_Configuration(); /* Enable debug features in low power modes (Sleep, STOP and STANDBY) */ #ifdef DEBUG_SWD_PIN DBGMCU_Config(DBGMCU_SLEEP | DBGMCU_STOP | DBGMCU_STANDBY, ENABLE); #endif /* Configure SysTick IRQ and SysTick Timer to generate interrupts */ RCC_GetClocksFreq(&RCC_Clocks); SysTick_Config(RCC_Clocks.HCLK_Frequency / 500); /* Init I/O ports */ conf_analog_all_GPIOS(); /* configure all GPIOs as analog input */ InitButton(); MesureCurInit(); LCD_GLASS_Init();/* Initializes the LCD glass */ // RCC_AHBPeriphClockCmd(LD_GPIO_PORT_CLK , ENABLE); //RCC_AHBPeriphClockCmd(LD_GPIO_PORT_CLK | P_GATE1_GPIO_PORT_CLK | /// P_GATE2_GPIO_PORT_CLK | N_GATE1_GPIO_PORT_CLK | // N_GATE2_GPIO_PORT_CLK , ENABLE); Delay.Init(); DbgUART.UART_Init(USART3); i2cMgr.SetDbgUART(&DbgUART); i2cMgr.Init(); calipers.Init(); calipers.Callback=CallBackCalipers; // Setup i2cCmd to write config data to ADC txBuf[0]=0x88; //Bits 3 and 2 control the ADS1100Тs data rate "1 0"= 16SPS I2C_command.Address=0x48; I2C_command.DataToRead.Length = 0; I2C_command.DataToRead.Buf=rxBuf; I2C_command.DataToWrite.Buf = txBuf; I2C_command.DataToWrite.Length = 1; I2C_command.Callback=CallBackI2C; i2cMgr.AddCmd(I2C_command); // Setup i2cCmd to read data from ADC I2C_command.Address=0x48; I2C_command.DataToRead.Length = 4; I2C_command.DataToRead.Buf=rxBuf; I2C_command.DataToWrite.Buf = txBuf; I2C_command.DataToWrite.Length = 0; I2C_command.Callback=CallBackI2C; /* Display Welcome message */ // LCD_GLASS_ScrollSentence((uint8_t*)" CELESTIA ONLINE ",1,SCROLL_SPEED); Delay.Reset(&TimeDelay); Delay.Reset(&DbgDelay); MesureCurStop(); char chI2cCounter=0; MesureCurUpward(); chflagI2C=1; while(1){ i2cMgr.Task(); calipers.Task(); switch (chMainStep) { case MAIN_STEP_IDLE: if (calipers.GetState()==SPI_END_RX) //при выходе из холостго режима пропускаем первый отсчет со штангена, чтобы ток в датчике { chMainStep=MAIN_STEP_WAIT_CALIPERS_START; DbgUART.SendPrintF("OUT IDLE \n"); MesureCurUpward(); // включаем ток chflagI2C=0; } break; case MAIN_STEP_WAIT_CALIPERS_START: if (calipers.GetState()==SPI_IDLE) // давно небыло посылок с штангена, { DbgUART.SendPrintF("IN IDLE \n"); chMainStep=MAIN_STEP_IDLE; // переходим в холостой режим MesureCurStop(); //отключаем ток в датчике. } if (calipers.GetState()==SPI_START_RX) // начало приема данных со штангена { //DbgUART.SendPrintF("IN I2C \n"); chMainStep=MAIN_STEP_WAIT_I2C; i2cMgr.AddCmd(I2C_command); } break; case MAIN_STEP_WAIT_I2C: if (chflagI2C==1) // закончилась работа с I2C { chMainStep=MAIN_STEP_WAIT_CALIPERS_END; MesureCurToggle(); // переключаем направление тока } break; case MAIN_STEP_WAIT_CALIPERS_END: if (calipers.GetState()==SPI_END_RX) // закончилcz прием данных о штангена { chByte[0]=rxBuf[1]; chByte[1]=rxBuf[0]; DbgUART.SendPrintF("ACD_VAL=%d \n",*iCurentAdcValue); LCD_GLASS_Clear(); tiny_sprintf(strDisp, " %d ", calipers.iSpiDataRx ); LCD_GLASS_DisplayString( (unsigned char *) strDisp ); DbgUART.SendPrintF("CALIPERS_VAL=%d \n",calipers.iSpiDataRx); DbgUART.SendPrintF("OUT I2CE \n"); chMainStep=MAIN_STEP_WAIT_CALIPERS_START; } break; } //switch // if (Delay.Elapsed(&DbgDelay,100)) DbgUART.SendPrintF("i2c flag=%d main_state=%d \n ",chflagI2C, chMainStep) ; /* if (chflagI2C==1) // закончилась работа с I2C { MesureCurToggle(); chflagI2C=0; } if (Delay.Elapsed(&DbgDelay,250)) { if (chI2cCounter<=10) { //MesureCurToggle(); chByte[0]=rxBuf[1]; chByte[1]=rxBuf[0]; DbgUART.SendPrintF("ACD_VAL=%d \n",*iCurentAdcValue); rxBuf[0]=0; rxBuf[1]=0; chI2cCounter++; //chflagI2C=0; i2cMgr.AddCmd(I2C_command); } } */ if (flag_UserButton == TRUE) { clearUserButtonFlag(); chI2cCounter=0; } } }
/** * @brief Main program * @param None * @retval None */ int main(void) { SysTick_Config(SystemCoreClock / 1000); RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOE, ENABLE); GPIO_InitTypeDef GPIO_InitStructure; GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT; GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz; GPIO_Init(GPIOE, &GPIO_InitStructure); GPIO_ResetBits(GPIOE, GPIO_Pin_2); //start with gps off to make sure it activates when wanted GPIO_Start(); ADC_Start(); Flash_Start(); unsigned long tickey = getSysTick()+1000; GPIO_ResetBits(GPIOA, GPIO_Pin_10); //LCD Reset must be held 10us GPIO_SetBits(GPIOG, GPIO_Pin_3); //flash deselect GPIO_SetBits(GPIOC, GPIO_Pin_8); //flash #hold off, we have dedicated pins GPIO_SetBits(GPIOC, GPIO_Pin_1); //osc enable GPIO_ResetBits(GPIOC, GPIO_Pin_11); //xbee reset GPIO_SetBits(GPIOE, GPIO_Pin_6); //buck enable while(getSysTick()<tickey); GPIO_SetBits(GPIOE, GPIO_Pin_2); //gps on/off GPIO_SetBits(GPIOC, GPIO_Pin_11); //xbee reset GPIO_SetBits(GPIOA, GPIO_Pin_10); //LCD unreset UART4_Start(); UART5_Start(); MPU_Start(); //========================BUTTONS==================== InitButton(&button1, GPIOE, GPIO_Pin_4); #ifdef BOARD_V1 InitButton(&button2, GPIOE, GPIO_Pin_5); #else InitButton(&button2, GPIOA, GPIO_Pin_9); #endif //=======================END BUTTONS================== /* LCD Configuration */ LCD_Config(); /* Enable The LCD */ LTDC_Cmd(ENABLE); LCD_SetLayer(LCD_FOREGROUND_LAYER); GUI_ClearBackground(); int count = 0; delay(20000); #ifndef ORIGIN GUI_InitNode(1, 72, 83, 0xe8ec); GUI_InitNode(2, 86, 72, 0xfd20); GUI_InitNode(3, 'R', 'F', 0x001f); #endif int screencount = 0; #ifdef INSIDE origin_state.lati=KRESGE_LAT; origin_state.longi=KRESGE_LONG; origin_state.gpslock=1; #endif unsigned long tickey2 = getSysTick()+2000; //2 second counter unsigned long tickey3 = getSysTick()+4000; //4 second delay to check gps state /* Infinite loop */ while (1) { UpdateButton(&button1); UpdateButton(&button2); if( buttonRisingEdge(&button1)){//right GPIO_ToggleBits(GPIOC, GPIO_Pin_3);//yellow //UART_Transmit(&huart4, gps_init_msg, cmdData1Len, 500); origin_state.pingnum+=1; origin_state.pingactive=1; origin_state.whodunnit = origin_state.id; origin_state.pingclearedby = 0; } if(buttonRisingEdge(&button2)){//left //UART_Transmit(&huart4, gps_get_time_msg, cmdData2Len, 500); GPIO_ToggleBits(GPIOA, GPIO_Pin_2); //green if(origin_state.pingactive&&(origin_state.whodunnit != origin_state.id)){ origin_state.pingactive=0; } } if(origin_state.gpson>2 &&(getSysTick()>tickey3)){ GPIO_ResetBits(GPIOE, GPIO_Pin_2); delay(20000); GPIO_SetBits(GPIOE, GPIO_Pin_2); delay(20000); char setme[80]; sprintf(setme, "%s%c%c", gps_init_msg, 0x0D, 0x0A); UART_Transmit(UART4, setme, sizeof(setme)/sizeof(setme[0]), 5000); origin_state.gpson=0; tickey3+=4000; } if(getReset()){ NVIC_SystemReset(); } #ifdef ORIGIN // long actHeading=0; // inv_get_sensor_type_heading(&actHeading, &headingAcc, &headingTime); // degrees=((double)actHeading)/((double)65536.0); // origin_state.heading=degrees; long actHeading[3] = {0,0,0}; inv_get_sensor_type_euler(actHeading, &headingAcc, &headingTime); degrees=((double)actHeading[2])/((double)65536.0); //origin_state.heading=degrees; long tempyraiture; mpu_get_temperature(&tempyraiture, NULL); // short garbage[3]; // mpu_get_compass_reg(garbage, NULL); // double compass_angle = atan2(-garbage[0], -garbage[1])*180/3.1415; // //origin_state.heading = .9*degrees + .1*compass_angle; // origin_state.heading = compass_angle; #endif if(getSysTick()>tickey2){ tickey2 +=2000; sendMessage(); } processGPS(); processXbee(); if(getSysTick()>tickey){ tickey +=53; GPIO_ToggleBits(GPIOC, GPIO_Pin_3); #ifndef ORIGIN GUI_UpdateNode(1, degrees*3.1415/180.0+3.14*1.25, screencount, (screencount>10), 0); GUI_UpdateNode(2, degrees*3.1415/180.0+3.14, screencount, (screencount>30), 0); GUI_UpdateNode(3, degrees*3.1415/180.0+0, screencount, (screencount>50), 0); #else GUI_UpdateNodes(); #endif GUI_UpdateArrow(-degrees*3.1415/180.0); GUI_UpdateBattery(getBatteryStatus()); GUI_DrawTime(); if (count > 50){ GUI_UpdateBottomButton(1, 0xe8ec); } else { GUI_UpdateBottomButton(0, 0); } GUI_Redraw(); screencount += 1; #ifndef ORIGIN degrees += 3.6; if (screencount%100 == 0){ screencount = 0; degrees = 0; } #else if (screencount%100 == 0){ screencount = 0; } #endif } //Sensors_I2C_ReadRegister((unsigned char)0x68, (unsigned char)MPU_WHOAMI, 1, inImu); //==================================IMU================================ unsigned long sensor_timestamp; int new_data = 0; get_tick_count(×tamp); #ifdef COMPASS_ENABLED /* We're not using a data ready interrupt for the compass, so we'll * make our compass reads timer-based instead. */ if ((timestamp > hal.next_compass_ms) && !hal.lp_accel_mode && hal.new_gyro && (hal.sensors & COMPASS_ON)) { hal.next_compass_ms = timestamp + COMPASS_READ_MS; new_compass = 1; } #endif /* Temperature data doesn't need to be read with every gyro sample. * Let's make them timer-based like the compass reads. */ if (timestamp > hal.next_temp_ms) { hal.next_temp_ms = timestamp + TEMP_READ_MS; new_temp = 1; } if (hal.motion_int_mode) { /* Enable motion interrupt. */ mpu_lp_motion_interrupt(500, 1, 5); /* Notify the MPL that contiguity was broken. */ inv_accel_was_turned_off(); inv_gyro_was_turned_off(); inv_compass_was_turned_off(); inv_quaternion_sensor_was_turned_off(); /* Wait for the MPU interrupt. */ while (!hal.new_gyro) {} /* Restore the previous sensor configuration. */ mpu_lp_motion_interrupt(0, 0, 0); hal.motion_int_mode = 0; } if (!hal.sensors || !hal.new_gyro) { continue; } if (hal.new_gyro && hal.lp_accel_mode) { short accel_short[3]; long accel[3]; mpu_get_accel_reg(accel_short, &sensor_timestamp); accel[0] = (long)accel_short[0]; accel[1] = (long)accel_short[1]; accel[2] = (long)accel_short[2]; inv_build_accel(accel, 0, sensor_timestamp); new_data = 1; hal.new_gyro = 0; } else if (hal.new_gyro && hal.dmp_on) { short gyro[3], accel_short[3], sensors; unsigned char more; long accel[3], quat[4], temperature; /* This function gets new data from the FIFO when the DMP is in * use. The FIFO can contain any combination of gyro, accel, * quaternion, and gesture data. The sensors parameter tells the * caller which data fields were actually populated with new data. * For example, if sensors == (INV_XYZ_GYRO | INV_WXYZ_QUAT), then * the FIFO isn't being filled with accel data. * The driver parses the gesture data to determine if a gesture * event has occurred; on an event, the application will be notified * via a callback (assuming that a callback function was properly * registered). The more parameter is non-zero if there are * leftover packets in the FIFO. */ dmp_read_fifo(gyro, accel_short, quat, &sensor_timestamp, &sensors, &more); if (!more) hal.new_gyro = 0; if (sensors & INV_XYZ_GYRO) { /* Push the new data to the MPL. */ inv_build_gyro(gyro, sensor_timestamp); new_data = 1; if (new_temp) { new_temp = 0; /* Temperature only used for gyro temp comp. */ mpu_get_temperature(&temperature, &sensor_timestamp); inv_build_temp(temperature, sensor_timestamp); } } if (sensors & INV_XYZ_ACCEL) { accel[0] = (long)accel_short[0]; accel[1] = (long)accel_short[1]; accel[2] = (long)accel_short[2]; inv_build_accel(accel, 0, sensor_timestamp); new_data = 1; } if (sensors & INV_WXYZ_QUAT) { inv_build_quat(quat, 0, sensor_timestamp); new_data = 1; } } else if (hal.new_gyro) { short gyro[3], accel_short[3]; unsigned char sensors, more; long accel[3], temperature; /* This function gets new data from the FIFO. The FIFO can contain * gyro, accel, both, or neither. The sensors parameter tells the * caller which data fields were actually populated with new data. * For example, if sensors == INV_XYZ_GYRO, then the FIFO isn't * being filled with accel data. The more parameter is non-zero if * there are leftover packets in the FIFO. The HAL can use this * information to increase the frequency at which this function is * called. */ hal.new_gyro = 0; mpu_read_fifo(gyro, accel_short, &sensor_timestamp, &sensors, &more); if (more) hal.new_gyro = 1; if (sensors & INV_XYZ_GYRO) { /* Push the new data to the MPL. */ inv_build_gyro(gyro, sensor_timestamp); new_data = 1; if (new_temp) { new_temp = 0; /* Temperature only used for gyro temp comp. */ mpu_get_temperature(&temperature, &sensor_timestamp); inv_build_temp(temperature, sensor_timestamp); } } if (sensors & INV_XYZ_ACCEL) { accel[0] = (long)accel_short[0]; accel[1] = (long)accel_short[1]; accel[2] = (long)accel_short[2]; inv_build_accel(accel, 0, sensor_timestamp); new_data = 1; } } #ifdef COMPASS_ENABLED if (new_compass) { short compass_short[3]; long compass[3]; new_compass = 0; /* For any MPU device with an AKM on the auxiliary I2C bus, the raw * magnetometer registers are copied to special gyro registers. */ if (!mpu_get_compass_reg(compass_short, &sensor_timestamp)) { compass[0] = (long)compass_short[0]; compass[1] = (long)compass_short[1]; compass[2] = (long)compass_short[2]; /* NOTE: If using a third-party compass calibration library, * pass in the compass data in uT * 2^16 and set the second * parameter to INV_CALIBRATED | acc, where acc is the * accuracy from 0 to 3. */ inv_build_compass(compass, 0, sensor_timestamp); } new_data = 1; } #endif if (new_data) { inv_execute_on_data(); /* This function reads bias-compensated sensor data and sensor * fusion outputs from the MPL. The outputs are formatted as seen * in eMPL_outputs.c. This function only needs to be called at the * rate requested by the host. */ read_from_mpl(); } //========================================IMU================================== } }
// ============================================================================ // InitButton -- Initialize all the buttons void configButtons( void ) { for ( int idx=0; idx<BTN_COUNT; ++idx ) { InitButton( idx ); } }
LRESULT CALLBACK MainWndMsgProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { switch(uMsg) { case WM_POWERBROADCAST: { SYSTEMTIME st; GetSystemTime(&st); switch(wParam) { /* Power status has changed. */ case PBT_APMPOWERSTATUSCHANGE: { TCHAR szTime[MAX_PATH] = { 0 }; _stprintf(szTime, TEXT("PBT_APMPOWERSTATUSCHANGE %d-%d-%d %d:%d:%d"), st.wYear, st.wMonth, st.wDay, st.wHour, st.wMinute, st.wSecond); MessageBox(hWnd, szTime, TEXT("1"), MB_OK); break; } /* Operation is resuming automatically from a low-power state. */ /* This message is sent every time the system resumes. */ case PBT_APMRESUMEAUTOMATIC: { TCHAR szTime[MAX_PATH] = { 0 }; _stprintf(szTime, TEXT("PBT_APMRESUMEAUTOMATIC %d-%d-%d %d:%d:%d"), st.wYear, st.wMonth, st.wDay, st.wHour, st.wMinute, st.wSecond); MessageBox(hWnd, szTime, TEXT("2"), MB_OK); break; } /* Operation is resuming from a low-power state. */ /* This message is sent after PBT_APMRESUMEAUTOMATIC if the resume is triggered by user input, such as pressing a key. */ case PBT_APMRESUMESUSPEND: { TCHAR szTime[MAX_PATH] = { 0 }; _stprintf(szTime, TEXT("PBT_APMRESUMESUSPEND %d-%d-%d %d:%d:%d"), st.wYear, st.wMonth, st.wDay, st.wHour, st.wMinute, st.wSecond); MessageBox(hWnd, szTime, TEXT("3"), MB_OK); break; } /* System is suspending operation. */ case PBT_APMSUSPEND: { TCHAR szTime[MAX_PATH] = { 0 }; _stprintf(szTime, TEXT("PBT_APMSUSPEND %d-%d-%d %d:%d:%d"), st.wYear, st.wMonth, st.wDay, st.wHour, st.wMinute, st.wSecond); MessageBox(hWnd, szTime, TEXT("4"), MB_OK); break; } /* A power setting change event has been received. */ case PBT_POWERSETTINGCHANGE: { TCHAR szTime[MAX_PATH] = { 0 }; _stprintf(szTime, TEXT("PBT_POWERSETTINGCHANGE %d-%d-%d %d:%d:%d"), st.wYear, st.wMonth, st.wDay, st.wHour, st.wMinute, st.wSecond); MessageBox(hWnd, szTime, TEXT("5"), MB_OK); break; } /* Battery power is low. In Windows Server 2008 and Windows Vista, use PBT_APMPOWERSTATUSCHANGE instead. */ case PBT_APMBATTERYLOW: { TCHAR szTime[MAX_PATH] = { 0 }; _stprintf(szTime, TEXT("PBT_APMBATTERYLOW %d-%d-%d %d:%d:%d"), st.wYear, st.wMonth, st.wDay, st.wHour, st.wMinute, st.wSecond); MessageBox(hWnd, szTime, TEXT("6"), MB_OK); break; } /* OEM-defined event occurred. /* In Windows Server 2008 and Windows Vista, this event is not available because these operating systems support only ACPI; /* APM BIOS events are not supported. */ case PBT_APMOEMEVENT: { TCHAR szTime[MAX_PATH] = { 0 }; _stprintf(szTime, TEXT("PBT_APMOEMEVENT %d-%d-%d %d:%d:%d"), st.wYear, st.wMonth, st.wDay, st.wHour, st.wMinute, st.wSecond); MessageBox(hWnd, szTime, TEXT("7"), MB_OK); break; } /* Request for permission to suspend. In Windows Server 2008 and Windows Vista, use the SetThreadExecutionState function instead. */ case PBT_APMQUERYSUSPEND: { TCHAR szTime[MAX_PATH] = { 0 }; _stprintf(szTime, TEXT("PBT_APMQUERYSUSPEND %d-%d-%d %d:%d:%d"), st.wYear, st.wMonth, st.wDay, st.wHour, st.wMinute, st.wSecond); MessageBox(hWnd, szTime, TEXT("8"), MB_OK); break; } /* Suspension request denied. In Windows Server 2008 and Windows Vista, use SetThreadExecutionState instead. */ case PBT_APMQUERYSUSPENDFAILED: { TCHAR szTime[MAX_PATH] = { 0 }; _stprintf(szTime, TEXT("PBT_APMQUERYSUSPENDFAILED %d-%d-%d %d:%d:%d"), st.wYear, st.wMonth, st.wDay, st.wHour, st.wMinute, st.wSecond); MessageBox(hWnd, szTime, TEXT("9"), MB_OK); break; } /* Operation resuming after critical suspension. In Windows Server 2008 and Windows Vista, use PBT_APMRESUMEAUTOMATIC instead. */ case PBT_APMRESUMECRITICAL: { TCHAR szTime[MAX_PATH] = { 0 }; _stprintf(szTime, TEXT("PBT_APMRESUMECRITICAL %d-%d-%d %d:%d:%d"), st.wYear, st.wMonth, st.wDay, st.wHour, st.wMinute, st.wSecond); MessageBox(hWnd, szTime, TEXT("10"), MB_OK); break; } default: { break; } } return 0; break; } case WM_COMMAND: { if (HIWORD(wParam) == BN_CLICKED) { //SendMessage(hWndSpeedMultipleComboBox, CB_SHOWDROPDOWN, (WPARAM) TRUE, 0); } if ( HIWORD(wParam) == CBN_SELCHANGE) { LRESULT sel = SendMessage(hWndSpeedMultipleComboBox, CB_GETCURSEL, 0, 0); //SetWindowText(hwndStatic, items[sel]); //SetFocus(hwnd); } break; } case WM_CREATE: { /* 为窗口添加扩展风格 WS_EX_LAYERED,从而为实现窗口透明做准备 */ LONG lExStyle = GetWindowLong(hWnd, GWL_EXSTYLE); lExStyle = lExStyle | WS_EX_LAYERED; SetWindowLong(hWnd, GWL_EXSTYLE, lExStyle); /* 实现窗口透明 - 设置窗口透明度为 220 */ SetLayeredWindowAttributes(hWnd, 0, WND_TRANSPARENCY, LWA_ALPHA); InitSpeedMultipleComboBox(((LPCREATESTRUCT)lParam)->hInstance, hWnd); /* 初始化 Tracker Bar */ InitSpeedMultipleTrackBar(((LPCREATESTRUCT)lParam)->hInstance, hWnd); /* 初始化按钮 */ InitButton(((LPCREATESTRUCT)lParam)->hInstance, hWnd); /* 初始化速度未改变的进程列表框 */ InitNotSpeedMultipleListView(((LPCREATESTRUCT)lParam)->hInstance, hWnd); /* 初始化速度已改变的进程列表框 */ InitHasSpeedMultipleListView(((LPCREATESTRUCT)lParam)->hInstance, hWnd); /* 绑定数据到速度未改变的进程列表框 */ BindData2NotSpeedMultipleListView(((LPCREATESTRUCT)lParam)->hInstance); break; } case WM_CTLCOLORSTATIC: { /* 使得静态文本框使用透明背景色 */ return (DWORD)GetStockObject(NULL_BRUSH); } /*case WM_COMMAND: { switch (wParam) { case ID_BUTTON_INSERT_PROCESS: { DestroyWindow(hWnd); break; } case ID_BUTTON_REMOVE_PROCESS: { break; } case ID_BUTTON_REFRESH_PROCESS: { break; } default: { break; } } break; }*/ case WM_CLOSE: { DestroyWindow(hWnd); break; } case WM_DESTROY: { PostQuitMessage(0); break; } default: { break; } } return DefWindowProc(hWnd, uMsg, wParam, lParam); }