예제 #1
0
파일: view.cpp 프로젝트: oMystique/OOP
void CView::ProcessEvent() 
{
	m_command = None;
	AppPollEvent();
	CheckButtonEvents();
	if (m_pSelectedShape != nullptr) 
	{
		m_pFrame->ResetFigure({ m_pSelectedShape->GetRect().width, m_pSelectedShape->GetRect().height },
		{ m_pSelectedShape->GetRect().left, m_pSelectedShape->GetRect().top });
	}
}
예제 #2
0
int main()
{

    // Configure UART2 for no interrupts at 9600 baud. Include a reset of
    // the RX flag as required.
    OpenUART2(UART_EN, UART_TX_ENABLE, BRGVAL);
    IFS1bits.U2RXIF = 0;

    // This variable is defined as 2 to specify that UART2 will be used for
    // stdin/stdout.
    __C30_UART = 2;

    /******************************************************************************
     * Your code goes in between this comment and the following one with asterisks.
     *****************************************************************************/
    LcdInit();		//initialize our lcd
    InitButtons();	//initialize our buttons
    InitMorseDecoder();	//initialize morse tree

    printf("Type Morse With Buttons Above\n");
    SetTopLine(greet);
    while(1) {
        if(ReceivedInput(temp)) {				//check for user input
            printf("Your input: %c\n", temp);	//echo input
            EncodeCharacter(temp, out);		//encode the character then display
            printf("In Morse: %c%c%c%c%c%c\n", out[0], out[1], out[2], out[3], out[4], out[5]);
        }
        char x = CheckButtonEvents();					//check for button event
        if (x == 0x00) {								// check if no Buttons were pressed
            if(flag0 != 1) {
                SetTopLine(greet);
            }
            flag0 = 1;

        } else if (x & Button6DownEvent) {			// check if Button 6 was pressed
            if(flag1 != 1) {
                toDecode[position] = dash;	//save input to current slot
                toDecode[position+1] = space;
                position++;					//increment to next slot
                SetBottomLine(toDecode);	//display total line array
            }
            flag1 = 1;		//flag is on
        } else if (x & Button6UpEvent) {				// check if Button 6 was released
            flag1 = 0;		//clear flag
        } else if (x & Button5DownEvent) {			// check if Button 5 was pressed
            if(flag2 != 1) {
                toDecode = (char *)GetBottomLine();	//decode what ever is in bottom line
            }
            flag2 = 1;
        } else if (x & Button5UpEvent) {				// check if Button 5 was released
            decodeChar[0] = DecodeCharacter(toDecode);	// decode our input
            topline[Pos] = decodeChar[0];			// add next decoded char
            Pos++;
            SetTopLine(topline);
            SetBottomLine(empty);						// clear bottom line on LCD
            int i;
            for(i = 0; i < 16; i++) {
                toDecode[i] = ' ';						// clear bottom line
            }
            position = 0;								// start at new line of input
            flag2 = 0;
        } else if (x & Button4DownEvent) {			// check if Button 4 was pressed
            flag3 = 1;		//flag is on
        } else if (x & Button4UpEvent) {				// check if Button 3 was released
            topline[Pos] = ' ';						// add space for next decodedc char
            Pos++;
            SetTopLine(topline);
            SetBottomLine(empty);
            int i;
            for(i = 0; i < 16; i++) {
                toDecode[i] = ' ';						// clear bottom line
            }
            position = 0;								// start at new line of input
            flag3 = 0;
        } else if (x & Button3DownEvent) {			// check if Button 3 was pressed
            if(flag4 != 1) {
                toDecode[position] = dot;
                toDecode[position + 1] = space;
                position++;
                SetBottomLine(toDecode);
            }
            flag4 = 1;		//flag is on
        } else if (x & Button3UpEvent) {				// check if Button 3 was released
            flag4 = 0;		//clear flag
        }
    }


    /******************************************************************************
     * Your code goes in between this comment and the preceeding one with asterisks
     *****************************************************************************/

    while (1);
}