T35-based tft LCD screen implementation:
1. Draw a calculator interface on the screen, including 0-9, + ,-,*,/;
2. Implement numbers and operators on the touch selection interface,
3. The result is displayed in the displayed box.
Note: Only the integer function is implemented and decimal places are not involved. Only one operation is performed and the result of the previous operation is not saved.
Implementation interface:
Implementation process:
Enable LCD Power, initialize LCD> LCD fill interface picture> enable touch screen interrupt> get key value> differentiate numbers and functions to call digital image display.
Digital Image:
Blank figure: divisor 0 prompt figure:
Digital image:
Figure showing the long value:
1. Enable LCD Power and initialize LCD
Where: Time Series generator (timegen)
Timegen generates control signals for LCD drivers, such as vframe, vline, vclk, and VM. These control signals are closely related to the configuration of the lcdcon1/2/3/4/5 registers in regbank. Based on the preparation of these programmable LCD control registers in regbank, timegen can generate suitable programmable control signals to support various types of LCD drivers.
Time Sequence of tftscreen:
Vsync indicates the frame synchronization signal. Each time a pulse is sent, the new image data is transmitted.
VSF = HSF pipeline [(vspw + 1) + (vbpd + 1) + (vfpd + 1) + (lineval + 1)]
Hsync is a synchronous line signal. Each time a pulse is sent, the new line of image data starts to be transmitted.
HSF = vclk records [(hspw + 1) + (HSPD + 1) + (hfpd + 1) + (hozval + 1)]
Vclk is a pixel synchronous signal. Each time a pulse is sent, the data of a new vertex image is transmitted.
Vclk = hclk merge [(clkval + 1) × 2]
The LCD display is a frame (a screen). Each frame is displayed from top to bottom, and each line is displayed from left to right at a point.
Vsync, hsync, and vclk determine their display speed.
In the figure, the vspw and hspw determine the pulse width. vbpd and hbpd determine the delay time.
The settings of these parameters are determined by lcdconn.
Initialize LCD: (set timegen)
/*************************************** * ********************* Tft LCD function module initialization // This function does not enable the shielding function **** **************************************** * *****************/void LCD _init (void) {# definem5d (N) (n) & 0x1fffff) # define LCD _addr (u32) LCD _buffer) // con1 [] select the display mode as tft LCD Panel mode [] select the 16bpp pixel mode as TFT rlcdcon1 = (LCD _pixclock <8) | (3 <5) | (12 <1); // con2 [] sets the height of 320 vspw [] to determine the width of the corresponding pulse; vfpd [], vbpd [31: 24] determines the delay time. select option. in the hfile, The t35 parameter rlcdcon2 = (LCD _upper_margin <24) | (LCD _height-1) <14) | (LCD _lower_margin <6) | (LCD _vsync_len <0 ); // con3 [] setting the height of 240 hfpd and hbpd determines the delay time. select option. in the hfile, The t35 parameter rlcdcon3 = (LCD _right_margin <19) | (LCD _width-1) <8) | (LCD _left_margin <0 ); // con4 hspw [8: 0] determines the pulse width. select option. in the hfile, The t35 parameter rlcdcon4 = (13 <8) | (LCD _hsync_len <0); # If! Defined (LCD _con5) # define LCD _con5 (1 <11) | (1 <9) | (1 <8) | (1 <3) | (1 <0) # endif rlcdcon5 = LCD _con5; rlcdsaddr1 = (LCD _addr> 22) <21) | (m5d (LCD _addr> 1 )) <0); rlcdsaddr2 = m5d (LCD _addr + LCD _width * LCD _height * 2)> 1); rlcdsaddr3 = LCD _width; rlcdintmsk | = 3; // interrupt shielding rtconsel & = (~ 7); rtpal = 0x0; rtconsel & = ~ (1 <4) | 1 );}
Enable LCD
/*************************************** * ********************* LCD video and control signal output or stop, 1. Enable video output ************************************ * ************************/void LCD _envidonoff (INT Onoff) {If (Onoff = 1) rlcdcon1 | = 1; // ENVID = on else rlcdcon1 = rlcdcon1 & 0x3fffe; // ENVID off}
Enable LCD Power Supply
/*************************************** ********** **************************************** * ***********/Void LCD _powerenable (INT invpwren, int pwren) {// gpg4 is setted as LCD _pwren rgpgup = rgpgup | (1 <4); // pull-up disable rgpgcon = rgpgcon | (3 <8 ); // gpg4 = LCD _pwren // enable LCD power enable function rlcdcon5 = rlcdcon5 &(~ (1 <3) | (pwren <3); // pwren rlcdcon5 = rlcdcon5 &(~ (1 <5) | (invpwren <5); // invpwren}
2. Enable touch screen interruption
/*************************************** * ********************** Tft LCD * Touch Screen interrupt function *********** **************************************** * ***********/void _ IRQ adc_tc_handler (void) {radctsc | = (1 <3) | (1 <2); // the pull-up resistance of XP is invalid. The X and Y coordinates are automatically measured continuously. radccon | = (1 <0); // ADC conversion starts rsubsrcpnd | = (0x1 <9); rsrcpnd | = (u32) 0x1 <31); rintpnd | = (u32) 0x1 <31); radctsc = 0xd3; // ADC pending interrupt mode radctsc | = (0x1 <8); // adctsc [8] = 1, set to lift the interrupt signal rADC TSC & = ~ (0x1 <8); // adctsc [8] = 0 cursor press interrupt signal rsubsrcpnd | = (0x1 <9); rsrcpnd | = (u32) 0x1 <31); rintpnd | = (u32) 0x1 <31);} void touch_init (void) {radccon = (1 <14) | (9 <6); // the/D frequency clock is valid, and its value is 9 radctsc = 0xd3; // The ym is valid when the cursor presses the interrupt signal, and YP is invalid, XM effective, XP ineffective, XP pull-up resistor, normal ADC conversion, waiting for interrupt mode radcdly = 50000; // the delay of Normal conversion mode conversion is about (1/3. 6864 m) * 50000 = 13.56 Ms rintsubmsk & = ~ (0x1 <9); // TC interrupt enabling rintmsk & = ~ (U32) 0x1 <31); // total ADC interruption enabling pisr_adc = (u32) adc_tc_handler; // point to the interrupt vector table}
3. Get the key value
And define the variable botten1 storage key value, flag1 key tag, flag2 operation tag
/*************************************** * ********************* ---------- Obtain the key value --------------************ **************************************** * *********/void get_key (void) {// numeric block if (xdata >=70 & xdata <= 285 & ydata >=100 & ydata <262) // 0 {BEEP (2000,100 ); botten1 = 0; flag1 = 1; xdata = ydata = 0;} else if (xdata> = 70 & xdata <= 285 & ydata> = 263 & ydata <425) /// 1 {BEEP (2000,100); botten1 = 1; flag1 = 1; xdata = ydata = 0 ;} else if (xdata> = 285 & xdata <= 500 & ydata> = 263 & ydata <425) // 2 {BEEP (2000,100); botten1 = 2; flag1 = 1; xdata = ydata = 0;} else if (xdata> = 500 & xdata <= 715 & ydata> = 263 & ydata <425) // 3 {BEEP (2000,100); botten1 = 3; flag1 = 1; xdata = ydata = 0 ;} else if (xdata> = 70 & xdata <= 285 & ydata> = 425 & ydata <587) // 4 {BEEP (2000,100); botten1 = 4; flag1 = 1; xdata = ydata = 0;} else if (xdata> = 285 & xdata <= 500 & ydata> = 425 & ydata <587) // 5 {BEEP (2000,100); botten1 = 5; flag1 = 1; xdata = ydata = 0 ;} else if (xdata> = 500 & xdata <= 715 & ydata> = 425 & ydata <587) // 6 {BEEP (2000,100); botten1 = 6; flag1 = 1; xdata = ydata = 0;} else if (xdata >=70 & xdata <= 285 & ydata> = 587 & ydata <750) // 7 {BEEP (2000,100); botten1 = 7; flag1 = 1; xdata = ydata = 0 ;} else if (xdata> = 285 & xdata <= 500 & ydata> = 587 & ydata <750) // 8 {BEEP (2000,100); botten1 = 8; flag1 = 1; xdata = ydata = 0;} else if (xdata> = 500 & xdata <= 715 & ydata> = 587 & ydata <750) // 9 {BEEP (2000,100); botten1 = 9; flag1 = 1; xdata = ydata = 0 ;} else // function compute block if (xdata> = 715 & xdata <= 930 & ydata> = 100 & ydata <262) // except {BEEP (2000,100 ); botten1 = '/'; flag1 = 1; flag2 = 1; xdata = ydata = 0 ;} else if (xdata> = 715 & xdata <= 930 & ydata> = 263 & ydata <425) // multiply by {BEEP (2000,100); botten1 = '*'; flag1 = 1; flag2 = 2; xdata = ydata = 0;} else if (xdata> = 715 & xdata <= 930 & ydata> = 425 & ydata <587) // subtraction {BEEP (2000,100); botten1 = '-'; flag1 = 1; flag2 = 3; xdata = ydata = 0 ;} else if (xdata> = 715 & xdata <= 930 & ydata> = 587 & ydata <750) // addition {BEEP (2000,100); botten1 = '+ '; flag1 = 1; flag2 = 4; xdata = ydata = 0;} else if (xdata> = 500 & xdata <= 715 & ydata> = 100 & ydata <262) // equal to {BEEP (2000,100); botten1 = '; flag1 = 1; xdata = ydata = 0 ;} else if (xdata> = 285 & xdata <= 500 & ydata> = 100 & ydata <262) // clear {BEEP (2000,100); botten1 = 'C '; flag1 = 1; xdata = ydata = 0 ;}}
4. differentiate key values to call Digital Image Display
/*************************************** * ********************* ---------- Process the key value --------------************ **************************************** * ********/void resout () {If (flag2 = 4) {sum1 = sum1 + sum2; show_picturu (sum1); sum1 = 0; sum2 = 0; flag2 = 0 ;} // according to the flag flag2, perform the corresponding sum1 = sum1? Sum2 operation, after sum1 sum2 is completed, set the zero else if (flag2 = 3) {sum1 = sum1-sum2; show_picturu (sum1); sum1 = 0; sum2 = 0; flag2 = 0;} else if (flag2 = 2) {sum1 = sum1 * sum2; show_picturu (sum1); sum1 = 0; sum2 = 0; flag2 = 0 ;} else if (flag2 = 1) {If (sum2 = 0) {sum1 = 0; sum2 = 0; flag2 = 0; pait_bmp (1, 34,236, 30, error ); delay (500); show_picturu (0) ;}// the division number is 0. Else {sum1 = sum1/sum2; show_picturu (sum1); sum1 = 0; sum2 = 0; flag2 = 0 ;}// note: the division operation result will show the fractional part} void cleaning () {sum1 = 0, sum2 = 0; flag2 = 0; show_picturu (0);} void show_num (void) {While (flag1) {flag1 = 0; // flag 0 switch (botten1) {Case 0: Case 1: Case 2: Case 3: Case 4: Case 5: case 6: Case 7: Case 8: Case 9: {sum2 = sum2 * 10 + botten1; If (sum2> 999999999) {sum2 = 0; pait_bmp (2, 34,236, 30, numerror); delay( 500); show_picturu (Sum2);} else show_picturu (sum2);} break; // the key value is stored in sum2 case '+': Case '-': Case '*': Case '/': sum1 = sum2, sum2 = 0; break; // The sum2 value is converted to sum1, and sum2 is set to zero case '=': resout (); break; // put the following section here before, observe the variable and find that sum1 and sum2 are set to zero here (Press = and always equal to 0 ), try to put the judgment into a function resout. The result is successful !!! /* If (flag2 = 4) {show_picturu (sum1 + sum2); sum2 = 0; flag2 = 0;} // perform the corresponding sum1 = sum1 according to flag2? Sum2 operation else if (flag2 = 3) {show_picturu (sum1-sum2); sum2 = 0; flag2 = 0;} else if (flag2 = 2) {show_picturu (sum1 * sum2); sum2 = 0; flag2 = 0;} else if (flag2 = 1) {If (sum2 = 0) {sum1 = 0; sum2 = 0; flag2 = 0; pait_bmp (1, 34,236, 30, error); delay (500); show_picturu (0);} // The divisor is 0. Else {show_picturu (sum1/sum2); sum2 = 0; flag2 = 0 ;}/// note: the division operation result will remove the fractional part */case 'C ': cleaning (); break ;}}}
5. Call Images
<Span style = "font-size: 10px; "> /************************************* * *********************** ---------- call the image function --------------********** **************************************** * ***********/void show_picturu (INT sum) {int K = 0, j = 0; pait_bmp (1, 34,238, 30, clean); If (sum> 0) {// if the value is greater than 0, (; sum> 0;) {k = sum % 10; // K is used to obtain the remainder sum = sum/10; // num is used to round the last digit ++ J; // J is used to mark the remainder of K in the original number of digits numtopic (K, J);} else if (sum = 0) {// when the value is equal to 0, numtopic (0, 1);} else if (sum <0) {// when the value is smaller than 0, sum =-sum; For (; sum> 0 ;) {k = sum % 10; // K is used to obtain the remainder sum = sum/10; // num is used to remove the last digit ++ J; // J indicates the actual number of digits of the remainder of K in the original value numtopic (K, J);} pait_bmp (238-13 * (J + 1), 34, 13, 30, num _) ;}} void numtopic (int m, int N) {Switch (m) {Case 0: pait_bmp (238-13 * n, 34, 13, 30, num0); break; Case 1: pait_bmp (238-13 * n, 34, 13, 30, num1); break; Case 2: pait_bmp (238-13 * n, 34, 13, 30, num2); break; Case 3: pait_bmp (238-13 * n, 34, 13, 30, num3); break; Case 4: pait_bmp (238-13 * n, 34, 13, 30, num4); break; Case 5: pait_bmp (238-13 * n, 34, 13, 30, num5 ); break; Case 6: pait_bmp (238-13 * n, 34, 13, 30, num6); break; Case 7: pait_bmp (238-13 * n, 34, 13, 30, num7); break; case 8: pait_bmp (238-13 * n, 34, 13, 30, num8); break; Case 9: pait_bmp (238-13 * n, 34, 13, 30, num9); break ;}</span>
Appendix:
Hardware environment: J-link V8, mini2440, J-link adapter board, USB series, t35 tft LCD screen
Software environment: Windows 7 (32-bit), Development Board uboot (nandflash), J-Link driver (J-link arm v4.10i), securecrt, and ads1.2
Download complete project
Mini2440 bare metal trial-calculator (LCD display, touch screen interruption)