Ejemplo n.º 1
0
void CPreferences::OnBnClickedOk()
{
	// Call the funtion
	/// check which check box is sleated
	// Load/Save
	if (IsDlgButtonChecked(IDC_RADIO_SAVE)) { // Save
		CString prefName;
		GetDlgItemText(IDC_EDIT_PREFERENCE_NAME, prefName);
		CListBox *listBox = (CListBox *)GetDlgItem(IDC_LIST_PREFERENCES);
		int indexInListBox = listBox->FindString(-1, prefName);
		if (indexInListBox >= 0) { // Already has this preference name
			if (MessageBox(prefName + _T(" already exists.\nDo you want to overwrite."),
				0, MB_YESNO) == IDNO) {
					CEdit *pEdit((CEdit*)GetDlgItem(IDC_EDIT_PREFERENCE_NAME));
					pEdit->SetFocus();
					pEdit->SetSel(0, -1);
					return;
			}
		}
		SavePreference(prefName);
		listBox->AddString(prefName);
		((CComboBox *)GetDlgItem(IDC_COMBO_DEFPREF))->AddString(prefName);
	}
	else if (IsDlgButtonChecked(IDC_RADIO_LOAD)) { // Load
		CListBox *listBox = (CListBox *)GetDlgItem(IDC_LIST_PREFERENCES);
		int curSel = listBox->GetCurSel();
		if (curSel >= 0) { // User has selected
			CString prefName;
			listBox->GetText(curSel, prefName);
			LoadPreference(prefName);
		}
	}
	else if (IsDlgButtonChecked(IDC_RADIO_DELETE)) { // Delete
		CListBox *listBox = (CListBox *)GetDlgItem(IDC_LIST_PREFERENCES);
		int curSel = listBox->GetCurSel();
		if (curSel >= 0) { // User has selected
			CString prefName;
			listBox->GetText(curSel, prefName);
			if (DeletePreference(prefName)) {
				listBox->DeleteString(curSel);
				CComboBox *pComboBox((CComboBox *)GetDlgItem(IDC_COMBO_DEFPREF));
				pComboBox->DeleteString(pComboBox->FindString(1, prefName));
			}
		}
	}
}
Ejemplo n.º 2
0
/**
  * @brief  This function handles TIM2 interrupt request.
  * @param  None
  * @retval None
  */
void TIM2_IRQHandler(void)
{
	static ButtonsPush_TypeDef prvsButtonPush = B_RESET;
	static uint8_t BtnPushRetentionCnt = 0;		//BtnResetRetentionCnt = 0;
	
	TIM2->SR &= ~TIM_SR_UIF;  // очищаем флаг прерывания
	
#ifndef __POWER_BUTTON_OFF__
	/* чтение кнопки питания */
	if(ON_OFF_button != 0)
	{
		/* если нажата и счетчик досчитал, то выключаем осциллограф */
		if(ON_OFF_counter++ > 5)
		{
			SavePreference();
			Beep_Start();
			Show_Message("Please release 'ON/OFF' button");

			while(ON_OFF_button != 0);
			delay_ms(300);
			GPIOC->BRR = GPIO_Pin_15;
		}
	}
	else ON_OFF_counter = 0;   // иначе сбрасываем счетчик
#endif

	/* If EPM registers not busy then read buttons register */
	if(EPM570_Registers_GetOperateStatus() == 0) ButtonsCode = EPM570_Read_Keys();
	
	/* If any button is pressed */
	if(ButtonsCode != NO_Push)
	{
		if(prvsButtonPush == B_RESET)
		{
			prvsButtonPush = ButtonPush = SHORT_SET;
		}
		else
		{
			if(BtnPushRetentionCnt++ > 2) ButtonPush = SHORT_SET;
			else ButtonPush = B_RESET;
		}

		if(EPM570_SRAM_GetWriteState() != COMPLETE)
		{
			if(btn == &btnRUN_HOLD)
			{
				if((ButtonsCode != DOWN) && (ButtonsCode != OK)) EPM570_SRAM_SetWriteState(STOP);
			}
			else EPM570_SRAM_SetWriteState(STOP);
		}

		/* Reset auto off timer */
		if(AutoOff_Timer.Vbatt != 1)
		{
			AutoOff_Timer.ResetTime = RTC_GetCounter();
		}
	}
	else
	{
		prvsButtonPush = ButtonPush = B_RESET;
		BtnPushRetentionCnt = 0;
		speed_up_cnt = 0;
	}
}
Ejemplo n.º 3
0
/**
  * @brief  This function handles RTC_IRQHandler .
  * @param  None
  * @retval : None
  */
void RTC_IRQHandler(void)
{
	uint32_t Curent_RTC_Counter;
	int32_t tTime, wTime;

	if (RTC_GetITStatus(RTC_IT_SEC) != RESET)
	{
		NVIC_ClearPendingIRQ(RTC_IRQn);
		RTC_ClearITPendingBit(RTC_IT_SEC);
		RTC_WaitForLastTask();

		if( HostMode == DISABLE ) {

			/* If counter is equal to 86399: one day was elapsed */
			if(RTC_GetCounter() == 86399)
			{
				/* Wait until last write operation on RTC registers has finished */
				RTC_WaitForLastTask();
				/* Reset counter value */
				RTC_SetCounter(0x0);
				/* Wait until last write operation on RTC registers has finished */
				RTC_WaitForLastTask();
			}


			Curent_RTC_Counter = RTC_GetCounter();

			// Set message event
			if(gMessage.Visible == TRUE)
			{
				tTime = Curent_RTC_Counter - gMessage.TimeOFF;
				if(tTime > 0)
				{
					MessageEvent = SET;
				}
			}

			// Verify auto power OFF
			if((AutoOff_Timer.State == ENABLE) && (HostMode != ENABLE))
			{
				tTime = Curent_RTC_Counter - AutoOff_Timer.ResetTime;
				wTime = AutoOff_Timer.Work_Minutes * 60;

				if(tTime >= wTime)
				{
					__disable_irq();
					SavePreference();
					Beep_Start();

					GPIOC->BRR = GPIO_Pin_15;
				}
			}

			// batt update
			if(show_ADC_flag != SET) {
				ADC_SoftwareStartConvCmd(ADC1, ENABLE);
			}
		}
//		else {

//			if (hostPackedRecived == 0) {
//				Host_IQueue_ClearAll();
//			}
//			else {
//				hostPackedRecived = 0;
//			}
//		}
	}
}