void BH280::LoopOfflineExample() { /* ***************************** hand thread ***************************** */ Begin(VEL_CONTROL); double T=0.0; gettimeofday(&lc, NULL); while (shouldRun) { gettimeofday(&now, NULL); T+=diffclock(&now,&lc); ReadFromHand(); double f=0.2;//Hz double value = 0.8*PI/3 + (PI/4*sin( f* T*2*PI)); if(!pps) { int m=1; Cons.cValues[m]=value; int temp=(int)((PositionControlC(m) * props.scaleIN[m])+0.5); result=bh.RTSetVelocity(m + '1', temp); m=0; Cons.cValues[m]=value; temp=(int)((PositionControl(m) * props.scaleIN[m])+0.5); result=bh.RTSetVelocity(m + '1', temp); m=3; Cons.cValues[m]=1; temp=(int)((PositionControl(m) * props.scaleIN[m])+0.5); result=bh.RTSetVelocity(m + '1', temp); } bh.RTUpdate(); RememberData(); } bh.RTAbort(); result = bh.Command("t"); cout<<"Terminating thread bh280\n"; }
CSHInPlaceEdit* CSHListCtrl::ShowInPlaceEdit(int nItem, int nSubitem,DWORD dwStyle) { CSHInPlaceEdit* pListEdit = new CSHInPlaceEdit(nItem, nSubitem); // Start with a small rectangle. We'll change it later. CRect rect(0,0,1,1); dwStyle |= ES_LEFT | WS_BORDER | WS_CHILD | WS_VISIBLE | ES_MULTILINE | ES_AUTOVSCROLL | ES_AUTOHSCROLL; pListEdit->Create(dwStyle, rect, this, IDC_INPLACE_EDIT); // Have the Grid position and size the custom edit control PositionControl(pListEdit, nItem, nSubitem); // Have the edit box size itself to its content. pListEdit->CalculateSize(); CString sText = GetItemText(nItem, nSubitem); pListEdit->SetWindowText(sText); pListEdit->SetSel(0, -1); // Return TRUE so that the list control will hnadle NOT edit label itself. return pListEdit; }
void MainInterrupt(void) //100Hz { MainInt_Time.EntranceT = SYS_TIME; MainTntCounter++; GetReceiverInfo(); MPU9250_GetData(); EstimateAttitude(); //MS5803_GetData(); //EstimateHeight(); PositionControl(); HeightControl(); Pidcontrol(); DealCommunication(); MainInt_Time.ExitT = SYS_TIME; MainInt_Time.gap = MainInt_Time.ExitT - MainInt_Time.EntranceT; // uint8_t test[2]={0x05,0x09}; // uint8_t test2[2]={0x01,0x08}; // for(;;) // { // AT25512_PageWrite(0x00000,test,4); // LED1(OFF); // Delay(0xFFFFF); // AT25512_ReadData(0x00000,test2,4); // USART_SendBuffer[0]=test2[1]; // USART2_DMA_SendData(); // LED1(OFF); // Delay(0xFFFFF); // } }
CSHInPlaceEdit* CSHListCtrl::ShowInPlaceEditEx(int nItem, int nSubitem, DWORD dwStyle) { CSHInPlaceEdit* pEdit = new CSHInPlaceEdit(nItem, nSubitem); CRect rect(0,0,1,1); dwStyle |= ES_LEFT | WS_BORDER | WS_CHILD | WS_VISIBLE | ES_AUTOHSCROLL; pEdit->Create(dwStyle, rect, this, IDC_INPLACE_EDIT); CSHInPlaceButton* pButton = new CSHInPlaceButton(nItem, nSubitem); dwStyle = WS_CHILD | WS_VISIBLE; pButton->Create("...", dwStyle, rect, this, IDC_INPLACE_BUTTON); pEdit->SetButtonCtrl(pButton); pButton->SetEditCtrl(pEdit); // if (!EnsureVisible(nItem, TRUE)) return NULL; // Make sure that nCol is valid CHeaderCtrl* pHeader = (CHeaderCtrl*)GetDlgItem(0); int nColumnCount = pHeader->GetItemCount(); ASSERT(nSubitem >= 0 && nSubitem < nColumnCount); if (nSubitem >= nColumnCount || // We have to take into account that the header may be reordered GetColumnWidth(Header_OrderToIndex( pHeader->m_hWnd, nSubitem)) < 5) { return 0; } // Get the header order array to sum the column widths up to the selected cell. int *orderarray = new int[nColumnCount]; Header_GetOrderArray(pHeader->m_hWnd, nColumnCount, orderarray); int offset = 0; int i; for (i = 0; orderarray[i] != nSubitem; i++) offset += GetColumnWidth(orderarray[i]); int colwidth = GetColumnWidth(nSubitem); delete[] orderarray; GetItemRect(nItem, &rect, LVIR_BOUNDS); // Scroll if we need to expose the column CRect rcClient; GetClientRect(&rcClient); if (offset + rect.left < 0 || offset + colwidth + rect.left > rcClient.right) { CSize size; size.cx = offset + rect.left; size.cy = 0; Scroll( size ); rect.left -= size.cx; } rect.left += offset + 4; rect.right = rect.left + colwidth - 3; // The right end of the control should not go past the edge // of the grid control. if (rect.right > rcClient.right) rect.right = rcClient.right; rect.bottom--; CRect rcButton; rcButton = rect; rcButton.left = rcButton.right - rcButton.Height(); rect.right = rect.right - rect.Height(); pEdit->MoveWindow(&rect); pButton->MoveWindow(&rcButton); // PositionControl(pEdit, nItem, nSubitem); pEdit->CalculateSize(); pEdit->GetWindowRect( &rect ); rect.left = rect.right; rect.right += rect.Height(); ScreenToClient( &rect ); pButton->MoveWindow(&rect); CString sText = GetItemText(nItem, nSubitem); pEdit->SetWindowText(sText); pEdit->SetSel(0, -1); return pEdit; }