/*lint -save -e970 Disable MISRA rule (6.3) checking. */ int main(void) /*lint -restore Enable MISRA rule (6.3) checking. */ { /* Write your local variable definition here */ enum logics{false, true}; uint16_t rotation = 0; /*** Processor Expert internal initialization. DON'T REMOVE THIS CODE!!! ***/ PE_low_level_init(); /*** End of Processor Expert internal initialization. ***/ /* Write your code here */ lcd_init(Background); add2display((unsigned char *)"University of Nairobi",0); add2display((unsigned char *)" Physics Department ",0); add2display((unsigned char *)" another string for ",0); add2display((unsigned char *)" another string menu ",0); selected=0; while(1){ if(rotation>3) rotation = 0; if(selected>3) selected=0; lcd_setOrientation(rotation); lcd_clear(Background); display(); //lcd_invert(rotation); lcd_fillrect(10,50,40,60, blue); lcd_drawrect(10,50,40,60, red); lcd_drawline(11,51,39,59, green); lcd_drawcircle(30, 100,10, red); lcd_fillcircle(30, 100,10, crimson); WAIT1_Waitms(1000); selected++; rotation++; } /*** Don't write any code pass this line, or it will be deleted during code generation. ***/ /*** RTOS startup code. Macro PEX_RTOS_START is defined by the RTOS component. DON'T MODIFY THIS CODE!!! ***/ #ifdef PEX_RTOS_START PEX_RTOS_START(); /* Startup of the selected RTOS. Macro is defined by the RTOS component. */ #endif /*** End of RTOS startup code. ***/ /*** Processor Expert end of main routine. DON'T MODIFY THIS CODE!!! ***/ for(;;){} /*** Processor Expert end of main routine. DON'T WRITE CODE BELOW!!! ***/ } /*** End of main routine. DO NOT MODIFY THIS TEXT!!! ***/
void cmd_tp_calibrate(uint_least16_t fgcolor, uint_least16_t bgcolor) { uint_least8_t i; CAL_POINT lcd_points[3] = {CAL_POINT1, CAL_POINT2, CAL_POINT3}; //calibration point postions CAL_POINT tp_points[3]; tp_init(); //enable/reset touch tp_read(); if(tp_rawz()) { lcd_clear(bgcolor); lcd_drawtext(10, 10, "Release Touchpanel.", 1, fgcolor, 0, 0); while(tp_rawz() > MIN_PRESSURE){ tp_read(); }; } do { //clear screen and wait for touch release lcd_clear(bgcolor); lcd_setorientation(180); lcd_drawtext(LCD_CENTER, (LCD_HEIGHT/2)+10, "Calibration", 2, RGB(128,128,128), 0, 0); lcd_setorientation(0); lcd_drawtext(LCD_CENTER, (LCD_HEIGHT/2)+10, "Calibration", 2, RGB(128,128,128), 0, 0); for(i=0; i<3; ) { //draw point lcd_drawcircle(lcd_points[i].x, lcd_points[i].y, 15, fgcolor); lcd_drawline(lcd_points[i].x-10, lcd_points[i].y, lcd_points[i].x-3, lcd_points[i].y, fgcolor); lcd_drawline(lcd_points[i].x+3, lcd_points[i].y, lcd_points[i].x+10, lcd_points[i].y, fgcolor); lcd_drawline(lcd_points[i].x, lcd_points[i].y-10, lcd_points[i].x, lcd_points[i].y-3, fgcolor); lcd_drawline(lcd_points[i].x, lcd_points[i].y+3, lcd_points[i].x, lcd_points[i].y+10, fgcolor); //touch detected? -> save point tp_read(); if(tp_getz() > (MIN_PRESSURE*1.5)) { //mark point lcd_fillcircle(lcd_points[i].x, lcd_points[i].y, 4, RGB(255,0,0)); //wait and clear point delay_ms(400); lcd_fillcircle(lcd_points[i].x, lcd_points[i].y, 15, bgcolor); //save point tp_points[i].x = tp_rawx(); tp_points[i].y = tp_rawy(); i++; //wait till press is over while(tp_rawz() > MIN_PRESSURE){ tp_read(); }; } //data available if(if_available()) { if(if_read8() == 0) { i = 0xFF; break; } } } } while((i!=0xFF) && (tp_calmatrix(lcd_points, tp_points)!=0)); //calculate calibration matrix tp_init(); //reset touch lcd_clear(bgcolor); return; }