/******************************************************************************* * MAIN FUNCTION * *******************************************************************************/ int main(void) { //unsigned int data[22] = {0}; unsigned int data_in = 0; unsigned char data_out = 0; unsigned char data_chk = 0; unsigned int data_ver = 0; unsigned char i = 0; unsigned char value = 0; // declare a variable to store // ensure all the hardware port in zero initially PORTA = 0; PORTB = 0; PORTC = 0; PORTD = 0; PORTE = 0; // Initialize the I/O port direction, this must be configured according to circuit // please refer to PTK40A schematic for details // TRISX control pin direction, output pin must be configure as '0' // while input must be configure as '1' TRISA = 0b00110001; TRISB = 0b00001111; TRISC = 0b10011011; TRISD = 0; TRISE = 0; //Initialize LCD to be use lcd_initialize(); lcd_goto(0x82); lcd_putstr("Cytron Tech"); lcd_goto(0xc4); lcd_putstr("PS/2"); delay_ms(1000); lcd_clear(); while(1) // create an infinite loop { while(RC3==1); { for(i=0;i<=10;i++) { while(RC3==1); while(RC3==0); data_in = (data_in | RC4) << 1; } data_in >>=1; //shift back the data once to become 8 bits data_out=data_in>>2 ; //shift out the parity bit and put to char to cancel up the first bits data_chk=conv(data_out); //turn the data to become normal data lcd_goto(0x00); lcd_bcd(5,data_chk); //convert and display the original data value data_ver=(data_in & 0x0002)>>1; chk(data_chk,data_ver); } AtoZ(data_chk); delay_ms(500); } while(1) continue; // infinite loop to prevent PIC from reset if there is no more program }
void TextEditorStc::Restyle(int position) { int endStyled = edwnd->GetEndStyled(); int lineNumber = edwnd->LineFromPosition(endStyled); int startPos = edwnd->PositionFromLine(lineNumber); int chPos = startPos; int ch = edwnd->GetCharAt(chPos); while (chPos < position) { if (strchr(",;{}[]():=", ch) != 0) { if (startPos != chPos) { edwnd->StartStyling(startPos, 0x1F); edwnd->SetStyling(chPos - startPos, NLSTYLE_DEFAULT); } edwnd->StartStyling(chPos, 0x1F); int lenPos = 0; do { lenPos++; ch = edwnd->GetCharAt(++chPos); } while (ch > 0 && strchr(",;{}[]():=", ch) != 0 && chPos < position); edwnd->SetStyling(lenPos, NLSTYLE_DELIM); startPos = chPos; } else if (ch == '!' || ch == '\'') { if (startPos != chPos) { edwnd->StartStyling(startPos, 0x1F); edwnd->SetStyling(chPos - startPos, NLSTYLE_DEFAULT); } int eol = edwnd->GetLineEndPosition(edwnd->LineFromPosition(chPos)); edwnd->StartStyling(chPos, 0x1F); edwnd->SetStyling(eol - chPos, NLSTYLE_COMMENT); chPos = eol+1; ch = edwnd->GetCharAt(chPos); startPos = chPos; } else if (ch == '"') { if (startPos != chPos) { edwnd->StartStyling(startPos, 0x1F); edwnd->SetStyling(chPos - startPos, NLSTYLE_DEFAULT); } startPos = chPos; do { ch = edwnd->GetCharAt(++chPos); } while (ch > 0 && ch != '"' && ch != '\n' && chPos < position); if (ch == '"') ch = edwnd->GetCharAt(++chPos); edwnd->StartStyling(startPos, 0x1F); edwnd->SetStyling(chPos - startPos, NLSTYLE_QUOTE); startPos = chPos; } else if (AtoZ(ch)) { // possible keyword char kwbuf[KWMAXLEN+1]; int kwpos = 0; int kwStart = chPos; do { kwbuf[kwpos++] = ch; ch = edwnd->GetCharAt(++chPos); } while (ch > 0 && AtoZ(ch) && kwpos <= KWMAXLEN && chPos < position); kwbuf[kwpos] = '\0'; if (nlLex::IsKeyword(kwbuf) != T_ENDOF) { if (startPos != kwStart) { edwnd->StartStyling(startPos, 0x1F); edwnd->SetStyling(kwStart - startPos, NLSTYLE_DEFAULT); } edwnd->StartStyling(kwStart, 0x1F); edwnd->SetStyling(chPos - kwStart, NLSTYLE_KEYWORD); startPos = chPos; } } else ch = edwnd->GetCharAt(++chPos); } if (startPos != chPos) { edwnd->StartStyling(startPos, 0x1F); edwnd->SetStyling(chPos - startPos, NLSTYLE_DEFAULT); } }