Пример #1
0
static void setDuty(Motor *motor, s32 duty) {
  if (duty < 0) {
    setCompare(motor->TIMx, motor->upChannel, 0);
    setCompare(motor->TIMx, motor->downChannel, (u16)-duty);
  } else {
    setCompare(motor->TIMx, motor->downChannel, 0);
    setCompare(motor->TIMx, motor->upChannel, (u16)duty);
  }
}
void Adafruit_ZeroTimer::setPeriodMatch(uint32_t period, uint32_t match, uint8_t channum) {
  if (_countersize == TC_COUNTER_SIZE_8BIT) {
    config_tc.counter_8_bit.period = period;
    tc_set_top_value(&tc_instance, period);
    setCompare(channum, match);
  }
  else if (_countersize == TC_COUNTER_SIZE_16BIT) {
    setCompare(0, period);
    setCompare(1, match);
  }
  else if (_countersize == TC_COUNTER_SIZE_32BIT) {
    setCompare(0, period);
    setCompare(1, match);
  }
}
Пример #3
0
void TBAssociate::printTest()
{
    int  array[] = {1, 2, 6, 3, 5 ,5};
    set<int> cset(array, array + 5);
    std::sort(array, array+5, setCompare());
    printIterator(cset.begin(),cset.end());
    cset.insert(5);
    cset.insert(10);
   
//    printIterator(cset.begin(),cset.end());
    
    if(cset.find(5) != cset.end())
    {
        cout << "找到了5" << endl;
    }
    cout << "5的个数--->" << cset.count(5) << endl;
//    cset.erase(5);
    printIterator(cset.begin(),cset.end());
    
    set<int>::iterator iterLower, itUp;
    iterLower = cset.lower_bound(2);
    itUp = cset.upper_bound(5);
    
//    cset.erase(iterLower, itUp);
    printIterator(cset.begin(), cset.end());
    
    std::pair<set<int>::iterator, set<int>::iterator> ret;
    ret = cset.equal_range(5);
    cout << "ret.first::" << *ret.first << endl;
    cout << "ret.second::"<< *ret.second<< endl;
    printIterator(cset.begin(), cset.end());

//    cset.insert(5);
}
Пример #4
0
bool startCompare()
{
	LRESULT RODoc1;
	LRESULT RODoc2;
    int win = 3;

    ::SendMessage(nppData._nppHandle, NPPM_GETCURRENTSCINTILLA, 0, (LPARAM)&win);
    HWND window = getCurrentHScintilla(win);

    if(!IsWindowVisible(nppData._scintillaMainHandle) || !IsWindowVisible(nppData._scintillaSecondHandle))
    {	
        SendMessage(nppData._nppHandle, WM_COMMAND, IDM_VIEW_GOTO_ANOTHER_VIEW, 0);
        panelsOpened = true;
    }

    if(!IsWindowVisible(nppData._scintillaMainHandle) || !IsWindowVisible(nppData._scintillaSecondHandle))
    {	
        panelsOpened = false;
        ::MessageBox(nppData._nppHandle, TEXT("Nothing to compare!"), TEXT("Error"), MB_OK);
        return true;
    }

    if(!notepadVersionOk)
    {
        int version = ::SendMessage(nppData._nppHandle,NPPM_GETNPPVERSION, 0, 0);
        if(version > 0)
        {
            notepadVersionOk = true;
        }
    }

    if(Settings.AddLine && !notepadVersionOk)
    {
        ::MessageBox(nppData._nppHandle, TEXT("Notepad v4.5 or higher is required to line up matches. This feature will be turned off"), TEXT("Incorrect Version"), MB_OK);
        Settings.AddLine = false;
        ::SendMessage(nppData._nppHandle, NPPM_SETMENUITEMCHECK, funcItem[CMD_ALIGN_MATCHES]._cmdID, (LPARAM)Settings.AddLine);
    }

	// Remove read-only attribute
	if ((RODoc1 = SendMessage(nppData._scintillaMainHandle, SCI_GETREADONLY, 0, 0)) == 1)
		SendMessage(nppData._scintillaMainHandle, SCI_SETREADONLY, false, 0);

	if ((RODoc2 = SendMessage(nppData._scintillaSecondHandle, SCI_GETREADONLY, 0, 0)) == 1)
		SendMessage(nppData._scintillaSecondHandle, SCI_SETREADONLY, false, 0);

    SendMessageA(nppData._scintillaMainHandle, SCI_SETWRAPMODE, SC_WRAP_NONE, 0);
    SendMessageA(nppData._scintillaSecondHandle, SCI_SETWRAPMODE, SC_WRAP_NONE, 0);

    setStyles(Settings);

    int doc1 = SendMessageA(nppData._scintillaMainHandle, SCI_GETDOCPOINTER, 0, 0);
    int doc2 = SendMessageA(nppData._scintillaSecondHandle, SCI_GETDOCPOINTER, 0, 0);

    setCompare(doc1);
    setCompare(doc2);

    /* sync pannels */
    HMENU hMenu = ::GetMenu(nppData._nppHandle);

    if ((::GetMenuState(hMenu, IDM_VIEW_SYNSCROLLV, MF_BYCOMMAND) & MF_CHECKED) != 0)
    {
        ::SendMessage(nppData._nppHandle, WM_COMMAND, MAKELONG(IDM_VIEW_SYNSCROLLV, 0), 0);
    }

    if ((::GetMenuState(hMenu, IDM_VIEW_SYNSCROLLH, MF_BYCOMMAND) & MF_CHECKED) != 0)
    {
        ::SendMessage(nppData._nppHandle, WM_COMMAND, MAKELONG(IDM_VIEW_SYNSCROLLH, 0), 0);
    }

    ::SendMessageA(nppData._scintillaMainHandle, SCI_GOTOPOS, 1, 0);
    ::SendMessageA(nppData._scintillaSecondHandle, SCI_GOTOPOS, 1, 0);
    ::SendMessage(nppData._nppHandle, WM_COMMAND, MAKELONG(IDM_VIEW_SYNSCROLLV, 0), 0);
    ::SendMessage(nppData._nppHandle, WM_COMMAND, MAKELONG(IDM_VIEW_SYNSCROLLH, 0), 0);
    ::SendMessageA(nppData._scintillaMainHandle, SCI_SETUNDOCOLLECTION, FALSE, 0);
    ::SendMessageA(nppData._scintillaSecondHandle, SCI_SETUNDOCOLLECTION, FALSE, 0);

    bool result = compareNew();

    ::SendMessageA(nppData._scintillaMainHandle, SCI_SETUNDOCOLLECTION, TRUE, 0);
    ::SendMessageA(nppData._scintillaSecondHandle, SCI_SETUNDOCOLLECTION, TRUE, 0);
    ::SendMessageA(nppData._scintillaSecondHandle/*window*/, SCI_GRABFOCUS, 0, (LPARAM)1);

	// Restore previous read-only attribute
	if (RODoc1 == 1) SendMessage(nppData._scintillaMainHandle, SCI_SETREADONLY, true, 0);
	if (RODoc2 == 1) SendMessage(nppData._scintillaSecondHandle, SCI_SETREADONLY, true, 0);

    if (!result)
	{
        if(Settings.UseNavBar)
		{
			// Save current N++ focus
			HWND hwnd = GetFocus();

			// Configure NavBar
			NavDlg.SetColor(
				Settings.ColorSettings.added, 
				Settings.ColorSettings.deleted, 
				Settings.ColorSettings.changed, 
				Settings.ColorSettings.moved, 
				Settings.ColorSettings.blank);

			// Display Navbar
			NavDlg.doDialog(true);
			start_old = -1;

			// Restore N++ focus
			SetFocus(hwnd);

		}
		// Enable Prev/Next menu entry
		::EnableMenuItem(hMenu, funcItem[CMD_NEXT]._cmdID, MF_BYCOMMAND | MF_ENABLED);
		::EnableMenuItem(hMenu, funcItem[CMD_PREV]._cmdID, MF_BYCOMMAND | MF_ENABLED);
		::EnableMenuItem(hMenu, funcItem[CMD_FIRST]._cmdID, MF_BYCOMMAND | MF_ENABLED);
		::EnableMenuItem(hMenu, funcItem[CMD_LAST]._cmdID, MF_BYCOMMAND | MF_ENABLED);
	}

	return result;
}