void DisplayTwoDigits (HDC hdc, int iNumber, BOOL fSuppress) { if (!fSuppress || (iNumber / 10 != 0)) DisplayDigit (hdc, iNumber / 10) ; OffsetWindowOrgEx (hdc, -42, 0, NULL) ; DisplayDigit (hdc, iNumber % 10) ; OffsetWindowOrgEx (hdc, -42, 0, NULL) ; }
void TIM4_IRQHandler(void) { OS_CPU_SR cpu_sr = 0; OS_ENTER_CRITICAL(); /* Tell uC/OS-II that we are starting an ISR */ OSIntNesting++; OS_EXIT_CRITICAL(); //Szemafort le kéne foglalni a displayValue -hoz OSSemAccept, OSSemPost if ( TIM_GetITStatus( TIM4, TIM_IT_Update ) ) { TIM_ClearITPendingBit( TIM4, TIM_IT_Update ); switch (digit) { case 0: displayValue = *pDisplayVal; digitValue = displayValue / 1000; break; case 1: digitValue = (displayValue % 1000) / 100; break; case 2: digitValue = (displayValue % 100) / 10; break; case 3: digitValue = displayValue % 10; break; } DisplayDigit( digit, digitValue, 0); digit = (digit==3) ? 0 : digit+1; } OSIntExit(); /* Tell uC/OS-II that we are leaving the ISR */ }
void Display3Segs::Update(void) { // calcula os 3 digitos (unidade, dezena e centana) int digit[3]; digit[0] = value / 100; digit[1] = (value - digit[0] * 100) / 10; digit[2] = (value - digit[0] * 100 - digit[1] * 10); // varre os 3 digitos do display for (int d=0; d<3; d++) { // Liga o display 'd', // ao mesmo tempo em que desliga os outros 2 for (int i=0; i<3; i++) { digitalWrite(sel[i], d == i); } // exibe o caracter correspondente ao display 'd' // (unidade, dezena ou centena) DisplayDigit(digit[d]); delay(10); } }
// // Takes a digit and a number, and displays the number at the // specified digit on the 7-segment display // void DisplayTime(int digit, int number) { DisplayDigit(digit); DisplayNumber(number); }