آی پی امداد
آی پی امداد
آریا الکترونیک parcham تکشو

آموزشی: راه اندازی مازول ال ای دی تابلو چینی با PIC و همراه با سورس کد C

jfrras

مدير انجمن تخصصی الکترونیک
مدیر تالار
2007-04-13
3,095
74,081
48
ایران
سلام دوستان عزیز
با این مدار می توانید ماژول های تابلو های چینی را بدون نیاز به مادر برد راه اندازی کنید . امیدوارم این مطالب مفید واقع بشه!


[h=2]Led Panel P10 CCS C Library[/h]

p10-led- DRIVER.jpg Hello Friends.
In this article I will give information on the expulsion of P10 panels with a microcontroller.
Panels P10 was in vogue the past few years, and became the owner of a foothold in the market. Almost everywhere, large and small, these panels are made using graphics really come across screens.
Normally you can find this driver boards for panels with various features. Our goal is to use these cards yapamıyacağı their specific projects, these panels. I set out from that point.
Before getting into details I want to express some of the technical details of the work anyway. This is a business that has the density of panels to control the process, so the microcontroller board will have to work very high frequencies. So I chose the 18F series, and an operating frequency of 40Mhz. 2-3 or 4 panel can handle these speeds, but the speed must be increased for more.
Communicating with Spi Panel. there are over 16 pieces 74595 Shift Register. Each with a separate section for the sake of this shift register sequence is controlled LEDs.
74,595 s in the structure of the panel is in the picture.
[hide]p10-led-pic18f4620.png[/hide]
If you look at the picture above 74,595 koyulduğunu the bottom of the panel you will see the bottom 4. As each of these sub-bottom 74 595 4-line controls are lined up. (4 × 4 = 16Satır), but can not control the line at the same time 4. This selection procedure is performed through scanning.

A and B are used in the scanning process terminators. This value is given to the pins 0-3 line is selected.
Pins A and B are given in the following table according to the values ​​shown in the active lines.
2.PNG

Displays data are sent to drive 74,595 lere OE pin is positioned after the first trip A and B outputs are activated by pulling Display. Pending, until a certain time and then pulled back to the 0 position data is sent to the OE pin. Then again, the OE pin 1 to the A and B pins are positioned and pulled the display is activated again. This is the style of the panel is driven.
To give an example from the table above, for example, A = 0, B = 0 ike renklendirdiğim with red lines only becomes active.
Blue A = 1, B = 0, A = 0, B = 1 Green, A = 1, B = 1, while the yellow lines will be active. Scanning and Data submission process carried out accordingly.
Panel data of the previous bit of a wait between sending the next data transmission is essential. Display brightness increases to expect too much too. But the panel is lit 5Ampere all current draws near. Not much of a value. Normally the panel to prevent the need to pull more current 4 amps. Otherwise, an integrated rear drive a little getting warm. With this said, 2000uS 500US between periods.
Normally 800uS 1000US, but I waited for the ideal.
Now that we know a little bit about the panel by the hardware and software you can look now.
Here I used 18F4620. I ran at 40Mhz with 4xPLL. Also sending data using hardware spi module max. I tried to reach top speed. Oladukça of spi spi hardware and software have much of a speed difference.
Pic of the connections between the panel gave the following as the schema.

Panel on driving in the first place obviously had no idea when I received. Once you know how it works for the screen by myself, take a ram in the ram region with the Timer Interrupt constantly mirrored on the screen. I used two-dimensional array for the job.
The structure of the display RAM can be found below.
3.PNG

Timer interrupt this ram used to reflect the screen area. After setting the timer interrupt to occur 800uS a region of interest of each of the named directory screen displaya_ram send interrupt occurs, the information is displayed when the active line. This process must continue constantly.
The display area of ​​the timer interrupt function in the following code to send and ram have the function of sending data prepared Spi.
Timer Interrupt Function

# Int_timer0 / / Timer0 Interrupt Timer0_int void () { set_timer0 (133); / / set up timer for the delay 800us .. switch (int_syc) / / Skip to the next line a in every 800us { case 0: output_low (Pino); WRITE_DATA (int_syc); output_low (Pina); output_low (PinB); output_high (Pino); break; case 1: output_low (Pino); WRITE_DATA (int_syc); output_high (Pina); output_low (PinB); output_high (Pino); break; case 2: output_low (Pino); WRITE_DATA (int_syc); output_low (Pina); output_high (PinB); output_high (Pino); break; case 3: output_low (Pino); WRITE_DATA (int_syc); output_high (Pina); output_high (PinB); output_high (Pino); break; } int_syc + +; if (int_syc> 3) int_syc = 0; } Sending Spi Data Function

WRITE_DATA void (unsigned int8 row_adr) { int8 i = 0, j = 0; int8 k = 3; while (k! = 255) / / This loop if you count forward from the right panel {J = 15-k, / / ​​Left Right installed. for (i = 0; i <4; i + +) / / rows filled .. { spi_write (display_ram [j] [row_adr]); j-= 4; } k -; } output_high (LATCH); delay_cycles (2); output_low (LATCH); } This functions in the above table with the ram area continuously projected onto the screen. Examine your code a little bit of work but it does not seem complicated if you follow a step by step easy to understand the logic.
Now let's look at the library Yazıdığım. Frankly, I did not write all the library functions. Basically, Flat Boots, line drawing, and drawing functions in rectangular bookshelf ili9325 bought Keil. In addition, PutPixel, GetPixel, Bargraph, clear_display, invert_display and Text Printing functions such as scrolling text I have prepared.
P10 Panel Library

/ ************************************************* ****************************** * File Name: P10_Panel_Driver.c * Author: Ferhat ROAD * Version: V1.0 * Date: 13/07/2013 * Description: P10 Panel library. *: ************************************************** ***************************** / # Include <font1.h> # Include <font2.h> # Include <font3.h> # Include <font4.h> # Define Pina pin_c0 # Define PinB pin_c1 # Define Pino pin_c4 / / OE = 0, Display OFF, ON OE = 1 Display # Define LATCH pin_c6 / / / / PinSCK pin_c3 / / Spi Clock Line / / PinData pin_c5 / / Spi Data Line / / PWM_Pin pin_c2 / / / / _____ / / PWM__ | \ / / OE___ | AND} ---- Disp_Enable / / | _____ / / / / / P10 Led Board / / 1 2 / / OE - | oo | - A / / GND - | oo | - B / / GND - | oo | - / / GND - | oo | - SCK / / GND - | oo | - LATCH / / GND - | oo | - DATA / / GND - | oo | - / / GND - | oo | - / / 15 16 / / # Define Font1H 8 # Define Font2H 12 # Define Font3H 14 # Define Font4H 16 # Define Panel 1 / / Number P10 Panel # Define RIGHT 0 / / # Define LEFT 1 / / # Define WIDTH 31 # Define HEIGHT 15 display_ram unsigned int8 [16] [4]; / ​​/ This indicates Region Area Display Ram unsigned char value [100] = ""; imageBuffer unsigned int8 [64]; int1 LineScroll (unsigned int line, int1 Zerobit); void clear_display (int1 fill); invert_screen void (void); void Set_Brightness (int8 value); SetTextFont void (unsigned int Font); void PutPixel (Xpos unsigned int, unsigned int ypos, int1 fill); int1 GetPixel (Xpos unsigned int, unsigned int ypos); void Line (unsigned int x1, unsigned int y1, unsigned int x2, unsigned int y2, int1 fill); void Rectangle (unsigned int x1, unsigned int y1, unsigned int x2, unsigned int y2, int1 fill); void Circle (unsigned int x, unsigned int y, unsigned int size, int1 fill); Bargraph void (unsigned int x1, unsigned int y1, unsigned int x2, unsigned int y2, int1 contempt, unsigned int value); ShowString void (unsigned int x, unsigned int y, unsigned int size, int1 fill); void TextToLeftScroll (Line unsigned int, unsigned int Size, unsigned int speed, int1 fill); Writeimage void (void); / *********************** Characters here, divided into Turkish ********************** / int CharAdres (char c) { int addr = 0; switch (c) { case 'U': adr = 96; break; case 'o': adr = 97; break; case 's': adr = 98; break; default: addr = c-32; break; } return addr; } / ************************************************* ****************************** * Line Shift Function * * Parameter: Line, ZeroBit * * Return: OVERFLOW * ************************************************** ***************************** / int1 LineScroll (unsigned int line, int1 ZeroBit) { Full unsigned int32 = 0; unsigned int y1 = Line 4%; unsigned int y2 = Line / 4; OVERFLOW int1; ZeroBit = 1-Zerobit; OVERFLOW = (display_ram [(y2 * 4)] [y1] / 128) &0x01; Display_ram full = [(y 2 * 4)] [h1]; Full = Full << 8; Full = Full + display_ram [(y2 * 4) +1] [h1]; Full = Full << 8; Full = Full + display_ram [(y2 * 4) +2] [h1]; Full = Full << 8; Full = Full + display_ram [(y2 * 4) +3] [h1]; Full = Full << 1; Full = Full + ZeroBit; display_ram [(y2 * 4)] [y1] = (int32) (full >> 24) &0xFF; display_ram [(y2 * 4) +1] [h1] = (int32) (full >> 16) &0xFF; display_ram [(y2 * 4) +2] [h1] = (int32) (Full >> 8) &0xFF; display_ram [(y2 * 4) +3] [h1] = (int32) (Full & 0xFF); Return OVERFLOW; } / ************************************************* ****************************** * Text Compression Function Font1 * * Parameter: x, y, Fill * * Return: * ************************************************** ***************************** / DrawCharFont1 void (unsigned x, unsigned y, int1 fill) { unsigned int a = 0, b = 0, i = 0; CDATA unsigned int = 0; unsigned int clm = x, row = y; While (value ! = '\ 0') { if (clm +5> WIDTH) / / end of the line to the bottom line of a late gelindimi { CLM = 0; +8 row = row; if (row +8> HEIGHT +1) break; } for (b = 0, b <5, b + +) { Font_5x7 CDATA = [value -32] ; for (a = 0, a <8, a + +) { PutPixel (clm + b + a row, (fill-in (cdata >> a) & 0x01)); } } i + +; clm clm = +6; } } / ************************************************* ****************************** * Text Compression Function font2 * * Parameter: x, y, Fill * * Return: * ************************************************** ***************************** / DrawCharFont2 void (unsigned int x, unsigned int y, int1 fill) { unsigned int a = 0, b = 0, i = 0; CDATA unsigned int = 0; unsigned int clm = x, row = y; while (value ! = '\ 0') { if (clm +8> WIDTH) / / end of the line to the bottom line of a late gelindimi { CLM = 0; row = row +12; if (row +12> HEIGHT +1) break; } for (b = 0, b <16, b = b +2) { Font_8x12 CDATA = [value -32] ; for (a = 0, a <8, a + +) { PutPixel (clm + (b / 2), row + a, (fill-in (cdata >> a) & 0x01)); } cdata = Font_8x12 [Text -32] [b +1]; for (a = 0, a <4, a + +) { PutPixel (clm + (b / 2), row +8 + a, (fill-in (cdata >> a) & 0x01)); } } clm clm = +8; i + +; } } / ************************************************* ****************************** * Text Compression Function font3 * * Parameter: x, y, Fill * * Return: * ************************************************** ***************************** / DrawCharFont3 void (unsigned int x, unsigned int y, int1 fill) { unsigned int a = 0, b = 0, i = 0; CDATA unsigned int = 0; unsigned int clm = x, row = y; while (value ! = '\ 0') { if (clm +12> WIDTH) / / end of the line to the bottom line of a late gelindimi { CLM = 0; +14 row = row; if (row +14> HEIGHT +1) break; } for (b = 0, b <24, b = b +2) { Font_12x14 CDATA = [value -32] ; for (a = 0, a <8, a + +) { PutPixel (clm + (b / 2), row + a, (fill-in (cdata >> a) & 0x01)); } cdata = Font_12x14 [Text -32] [b +1]; for (a = 0, a <6; A + +) { PutPixel (clm + (b / 2), row +8 + a, (fill-in (cdata >> a) & 0x01)); } } clm clm = +12; i + +; } } / ************************************************* ****************************** * Text Compression Function Font4 * * Parameter: x, y, Fill * * Return: * ************************************************** ***************************** / DrawCharFont4 void (unsigned int x, unsigned int y, int1 fill) { unsigned int a = 0, b = 0, i = 0; CDATA unsigned int = 0; cadr unsigned int = 0; unsigned int clm = x, row = y; while (value ! = '\ 0') { if (clm +12> WIDTH) / / end of the line to the bottom line of a late gelindimi { CLM = 0; +16 row = row; if (row +16> HEIGHT +1) break; } cadr = CharAdres (Text ); for (b = 0, b <24, b = b +2) { cdata = Font_12x16 [cadr] ; for (a = 0, a <8, a + +) { PutPixel (clm + (b / 2), row + a, (fill-in (cdata >> a) & 0x01)); } cdata = Font_12x16 [cadr] [b +1]; for (a = 0, a <8, a + +) { PutPixel (clm + (b / 2), row +8 + a, (fill-in (cdata >> a) & 0x01)); } } clm clm = +12; i + +; } } / ************************************************* ****************************** * Text Scrolling Function Font1 * * Parameter: Line, Speed, Fill * * Return: * ************************************************** ***************************** / void ScrollTextFont1 (Line unsigned int, unsigned int speed, int1 fill) { unsigned int a = 0, b = 0, i = 0; CDATA unsigned int = 0; unsigned int16 delay = speed * 20; int1 ZeroBit = 0; While (value ! = '\ 0') { if (Line + Font1H-1> HEIGHT) break; for (b = 0, b <5, b + +) { Font_5x7 CDATA = [value -32] ; for (a = 0, a <8, a + +) { ZeroBit = fill-in (cdata >> a) & 0x01; LineScroll (Line + a, ZeroBit); } delay_ms (210-delay); } for (a = 0, a <8, a + +) { LineScroll (Line + a, 0); } delay_ms (210-delay); i + +; } } / ************************************************* ****************************** * Text Scrolling Function font2 * * Parameter: Line, Speed, Fill * * Return: * ************************************************** ***************************** / void ScrollTextFont2 (Line unsigned int, unsigned int Speed, int1 fill) { unsigned int a = 0, b = 0, i = 0; CDATA unsigned int = 0; unsigned int16 delay = speed * 20; unsigned int16 counter = 0; int1 ZeroBit = 0; while (value ! = '\ 0') { if (Line + Font2H-1> HEIGHT) break; for (b = 0, b <16, b = b +2) { Font_8x12 CDATA = [value -32] ; for (a = 0, a <8, a + +) { ZeroBit = fill-in (cdata >> a) & 0x01; LineScroll (Line + a, ZeroBit); } cdata = Font_8x12 [Text -32] [b +1]; for (a = 0, a <4, a + +) { ZeroBit = fill-in (cdata >> a) & 0x01; LineScroll (Line +8 + a, ZeroBit); } for (counter = 0; counter <210-delay, counter + +) { delay_ms (1); } } i + +; } } / ************************************************* ****************************** * Text Scrolling Function font3 * * Parameter: Line, Speed, Fill * * Return: * ************************************************** ***************************** / void ScrollTextFont3 (Line unsigned int, unsigned int Speed, int1 fill) { unsigned int a = 0, b = 0, i = 0; CDATA unsigned int = 0; unsigned int16 delay = speed * 20; unsigned int16 counter = 0; int1 ZeroBit = 0; while (value ! = '\ 0') { if (Line + Font3H-1> HEIGHT) break; for (b = 0, b <24, b = b +2) { Font_12x14 CDATA = [value -32] ; for (a = 0, a <8, a + +) { ZeroBit = fill-in (cdata >> a) & 0x01; LineScroll (Line + a, ZeroBit); } cdata = Font_12x14 [Text -32] [b +1]; for (a = 0, a <6; A + +) { ZeroBit = fill-in (cdata >> a) & 0x01; LineScroll (Line +8 + a, ZeroBit); } for (counter = 0; counter <210-delay, counter + +) { delay_ms (1); } } i + +; } } / ************************************************* ****************************** * Text Scrolling Function Font4 * * Parameter: Line, Speed, Fill * * Return: * ************************************************** ***************************** / void ScrollTextFont4 (Line unsigned int, unsigned int Speed, int1 fill) { unsigned int a = 0, b = 0, i = 0; CDATA unsigned int = 0, cadr = 0;; unsigned int16 delay = speed * 20; unsigned int16 counter = 0; int1 ZeroBit = 0; while (value ! = '\ 0') { if (Line + Font4H-1> HEIGHT) break; cadr = CharAdres (Text ); for (b = 0, b <24, b = b +2) { cdata = Font_12x16 [cadr] ; for (a = 0, a <8, a + +) { ZeroBit = fill-in (cdata >> a) & 0x01; LineScroll (a, ZeroBit); } cdata = Font_12x16 [cadr] [b +1]; for (a = 0, a <8, a + +) { ZeroBit = fill-in (cdata >> a) & 0x01; LineScroll (8 + a, ZeroBit); } for (counter = 0; counter <210-delay, counter + +) { delay_ms (1); } } i + +; } } / ************************************************* ****************************** * Screen Cleaning Function * * Parameter: fill * * Return: * ************************************************** ***************************** / void clear_display (int1 fill) { int8 i = 0, j = 0, fdata = 0; if (fill) { fdata = 0x00; Else {} fdata = 0xFF; } for (i = 0, i <4; i + +) { for (j = 0, j <16, j + +) { display_ram [j] = fdata; } } } / ************************************************* ****************************** * Display Inverse Function * * Parameter: * * Return: * ************************************************** ***************************** / invert_screen void (void) { int8 i = 0, j = 0; for (i = 0, i <4; i + +) { for (j = 0, j <16, j + +) { display_ram [j] = ~ display_ram [j] ; / / cache value is written back to değillenip } } } / ************************************************* ****************************** * Brightness Adjustment Function * * Parameter: value (0-100) * * Return: * ************************************************** ***************************** / void Set_Brightness (int8 value) { set_pwm1_duty ((int16) value * 10); } / ************************************************* ****************************** * Pixel Function * * Parameter: Xpos, ypos, fill * * Return: * ************************************************** ***************************** / void PutPixel (Xpos unsigned int, unsigned int ypos, int1 fill) { int8 y1 = 0, x1 = 0; int8 y2 = 0, x2 = 0; int8 temp = 0; y1 = ypos 4%; y2 = ypos / 4; x1 = Xpos 8%; x2 = Xpos / 8; if (fill) / / Spot Bay { display_ram temp = [(y2 * 4) + x2] [y1]; / / RAM being cached value. display_ram [(y2 * 4) + x2] [y1] = (temp & (255 - (128 >> ​​x1))); / / x'inci bit is set to 0 } else / / Point Clear { display_ram temp = [(y2 * 4) + x2] [y1]; / / RAM being cached value. display_ram [(y2 * 4) + x2] [y1] = (temp | (128 >> ​​x1)); / / x'inci bit is set to 1 } } / ************************************************* ****************************** * Pixel Reading Function * * Parameter: Xpos, ypos * * Return: value * ************************************************** ***************************** / int1 GetPixel (Xpos unsigned int, unsigned int ypos) { int8 y1 = 0, x1 = 0; int8 y2 = 0, x2 = 0; int8 temp = 0; int1 value = 0; y1 = ypos 4%; y2 = ypos / 4; x1 = Xpos 8%; x2 = Xpos / 8; display_ram temp = [(y2 * 4) + x2] [y1]; / / RAM being cached value. value = 1 - (0x80 & temp << x1) / 128; / / Ram sent back at the bit return value; } / ************************************************* ****************************** * Line Drawing Function * * Parameter: x1, x2, y1, y2, fill * * Return: * ************************************************** ***************************** / void Line (unsigned int x1, unsigned int y1, unsigned int x2, unsigned int y2, int1 fill) { int16 signed addx = 1, Addy = 1, P; signed int16 i, dy, dx, diff; if (x2> x1) { dx = x2 - x1; Else {} dx = x1 - x2; addx = -1; } if (y2> y1) { dy = y2 - y1; Else {} dy = y1 - y2; addy = -1; } if (dx> = dy) { dy * = 2; P = dy - dx; diff = P - dx; for (i = 0; i <= dx: i + +) { PutPixel (x1, y1, fill); if (P <0) { P + = dy; x1 + = addx; } else { P + = diff; x1 + = addx; y1 + = addy; } } } else { dx * = 2; P = dx - dy; diff = P - dy; for (i = 0; i <= dy; + + i) { PutPixel (x1, y1, fill); if (P <0) { P + = dx; y1 + = addy; } else { P + = diff; x1 + = addx; y1 + = addy; } } } } / ************************************************* ****************************** * Rectangle Boot Function * * Parameter: x1, x2, y1, y2, fill * * Return: * ************************************************** ***************************** / void Rectangle (unsigned int x1, unsigned int y1, unsigned int x2, unsigned int y2, int1 fill) { unsigned int16 i, Xmin, xmax, yMin, ymax; if (fill) { if (x1 <x2) { Xmin = x1; xmax = x2; } else { Xmin = x2; xmax = x1; } if (y1 <y2) { yMin = y1; ymax = y2; } else { yMin = y2; ymax = y1; } for (; Xmin <= xmax; + + Xmin) { for (i = yMin; i <= ymax; + + i) { PutPixel (Xmin, i, 1); } } } else { Line (x1, y1, x2, y1, 1); Line (x2, y1, x2, y2, 1); Line (x2, y2, x1, y2, 1); Line (x1, y2, x1, y1, 1); } } / ************************************************* ****************************** * Strap Boots Function * * Parameter: x, y, you, fill * * Return: * ************************************************** ***************************** / void Circle (unsigned int x, unsigned int y, unsigned int size, int1 fill) { signed int a, b, P; a = 0; b = size; P = one-size; do { if (fill) { Line (x, y + b x + a, y + b, 1); Line (xa, yb, x + a, yb, 1); Line (xb, y + a, x + b, y + a, 1); Line (xb, or, x + b, or, 1); } else { PutPixel (a + x, b + y, 1); PutPixel (B + x, a + y, 1); PutPixel (xa, b + y, 1); PutPixel (xb, a + y, 1); PutPixel (B + x, or, 1); PutPixel (a + x, yb, 1); PutPixel (xa, yb, 1); PutPixel (xb, either, 1); } if (P <0) P + = 3 + 2 * A + +; else P + = 5 + 2 * (a + + - B -); } While (a <= b); } / ************************************************* ****************************** * Bargraph Boot Function * * Parameter: x1, y1, x2, y2, Mode, Value * * Return: * ************************************************** ***************************** / Bargraph void (unsigned int x1, unsigned int y1, unsigned int x2, unsigned int y2, int1 contempt, unsigned int value,) { unsigned int w = 0; unsigned int h = 0; unsigned int a = 0, b = 0; barval unsigned int16 = 0; if (x1> x2) w = x1-x2; if (X1 <X2) w = x2-x1; if (y1> y2) h = y1-y2; if (y1 <y2) h = y2-y1; if (value> 100) value = 100; if (hor) / / Create Bar Vertically { barval = ((int16) value * h) / 100; for (a = 0, a <h +1, a + +) { for (b = 0, b <w +1, B + +) { if (barval> = a) { PutPixel (x1 + b ,15-a + y 1, 1); Else {} PutPixel (x1 + b ,15-a + y 1, 0); } } } } Else {/ / Create the Horizontal Bar barval = ((int16) value * w) / 100; for (a = 0, a <w +1, a + +) { for (b = 0, b <h +1, b + +) { if (barval> = a) { PutPixel (x1 + a, y1 + B, 1); Else {} PutPixel (x1 + a, y1 + b, 0); } } } } } / ************************************************* ****************************** * Text Compression Function * * Parameter: x, y, you, fill * * Return: * ************************************************** ***************************** / ShowString void (unsigned int x, unsigned int y, unsigned int size, int1 fill) { switch (size) { case 1: DrawCharFont1 (x, y, fill); break; case 2: DrawCharFont2 (x, y, fill); break; case 3: DrawCharFont3 (x, y, fill); break; case 4: DrawCharFont4 (x, y, fill); break; default: break; } } / ************************************************* ****************************** * Text Scrolling Function * * Parameter: Line, Size, Speed, Fill * * Return: * ************************************************** ***************************** / void TextToLeftScroll (Line unsigned int, unsigned int Size, unsigned int Speed, int1 fill) { switch (size) { case 1: ScrollTextFont1 (Line, Speed, fill); Break; case 2: ScrollTextFont2 (Line, Speed, fill); Break; case 3: ScrollTextFont3 (Line, Speed, fill); Break; case 4: ScrollTextFont4 (Line, Speed, fill); Break; default: break; } } Writeimage void () { int8 a = 0, b = 0, i = 0; int8 cdata = 0; for (a = 0, a <32, A + +) { cdata = imageBuffer ; for (b = 0, b <8, b + +) { PutPixel (a, b, (CDATA >> b) & 0x01); } i + +; cdata = imageBuffer ; for (b = 0, b <8, b + +) { PutPixel (a, 8 + B, (CDATA >> b) & 0x01); } i + +; } } Library is very simple to use. PutPixel, GetPixel, Line, Rectangle, Circle, TFT screens, as well as functions such use. Printing and writing functions such as scrolling text prepared not only want to mention your own.
Press or to scroll the contents of the function of preparing these functions, Text, tried to send. To do this, need to make use of the demonstrators ccs c. I could use a pointer, even though I tried quite a few.
TEXT I saved you a separate ram area. Area of ​​the ram that you need to write string to be written, or shifted. Then press the function of the text to be printed text, scrolling text scrolling function call is required to be made.
To give an example,
Text = "ABCDEFGH";
ShowString (Xpos, ypos, Size, Fill);
This function coordinates the Text Basar. Xpos and ypos parameters coordinate information.
Font Size parameter in the parameter selection. I buried the program has four built-in font. So you need to give the parameter a value between 1 and 4.
Speaking of Font 2 And 3 More fonts could care less. Need to be adjusted a bit.
Fill basılmayacağının pressed the parameter is set to invert the text parameter. 1 tersleyip send text prints. 0 send prints normally.
TextToLeftScroll (Line, Size, Speed, fill);
This function starts scrolling the text from the line. The whole text is lost until the processor can not function. This was the worst sides of this function.
Fortunately, when it comes to Parameters
Line, line selection parameter. Which lines are shifted from the text indicates.
Size, Text Compression Function paramteresidir as font selection.
Speed, Text Rate parameter, Gets a value between 1 and 10.
Fill, Text Compression function plays the same role.
Printing works fine, but text scrolling text that fetched me. All of the text is to be moved to the System RTOS-like structure that can not get out until the end of the program text scroll function. But the program would not be solved by using a flexible cutting.
Bargraph on the reference to the bird.
Create a bargraph fonksiyonunuda I wrote it. The use as
Bargraph (unsigned int x1, unsigned int y1, unsigned int x2, unsigned int y2, int1 contempt, unsigned int value);
x1, y1, x2 and y2 are determined by parameters bargraph size.
contempt; This parameter specifies the Bar yataymı work or dikeymi.
Value: The value of the value of the bar. Gets a value between 0-100.
There are examples on the demo program bargraph.
Finally, I want to touch upon the Brightness setting.
Displayrs hardware PWM module used to adjust the brightness. After setting the processor to 10Khz Frequency PWM signal from the OE must overlap. To do this I used the integration of the 7408 one. 7408 and that the door to one of the entries in the output of the PWM signal, the panel diğerinede OE OE control signal pin hooked up after 7408. Then the brightness of the PWM signal duty cycle value, set it up by playing. I did it this way. Frankly, I do not know is how the other driver cards.
I made a sample test program. I tried to show all the characteristics of this test program library

# Include <18F4620.h> # Device adc = 10 # Fuses NOWDT / / No Watch Dog Timer # Fuses WDT128 / / Watch Dog Timer uses 1:128 Postscale # Fuses H4 / / High speed osc with HW enabled 4X PLL # Fuses NOBROWNOUT / / No brownout reset # Fuses NOLVP / / No low voltage prgming, B3 (PIC16) or B5 (PIC18) used for I / O # Fuses NOXINST / / Extended set extension and Indexed Addressing mode disabled (Legacy mode) # Use delay (clock = 40000000) # Use fast_io (a) # Use fast_io (b) # Use fast_io (c) # Use fast_io (d) # Use fast_io (e) # Include <math.h> / ******************************* P10 Panel library *************** *********** / # Include <P10_Panel_Driver.c> / ******************************** Global Variables *************** ************* / unsigned int8 int_syc = 0; int i = 0, w = 0; / ********************************** Functions ************** ****************** / WRITE_DATA void (unsigned int8 row_adr); FontTest void (void); NumberTest void (void); ScrollTest void (void); BrightTest void (void); GeoShapes void (void); SineWawe void (void); BarTest void (void); / ******************************** Cutting Sub-Programme ************** ************** / # Int_timer0 / / Timer0 Interrupt Timer0_int void () { set_timer0 (133); / / set up timer for the delay 800us .. switch (int_syc) / / Skip to the next line a in every 800us { case 0: output_low (Pino); WRITE_DATA (int_syc); output_low (Pina); output_low (PinB); output_high (Pino); break; case 1: output_low (Pino); WRITE_DATA (int_syc); output_high (Pina); output_low (PinB); output_high (Pino); break; case 2: output_low (Pino); WRITE_DATA (int_syc); output_low (Pina); output_high (PinB); output_high (Pino); break; case 3: output_low (Pino); WRITE_DATA (int_syc); output_high (Pina); output_high (PinB); output_high (Pino); break; } int_syc + +; if (int_syc> 3) int_syc = 0; } / ********************************** Main Program ************* ******************** / void main () { set_tris_a (0x03); set_tris_b (0x00); set_tris_c (0x00); set_tris_d (0x00); set_tris_e (0x00); setup_spi (SPI_MASTER | SPI_L_TO_H | SPI_SS_DISABLED); setup_adc (ADC_OFF); setup_ccp1 (CCP_PWM); setup_ccp2 (CCP_OFF); setup_timer_0 (T0_INTERNAl | T0_8_BIT | T0_DIV_64); setup_timer_2 (T2_DIV_BY_4, 249.1); enable_interrupts (INT_timer0); enable_interrupts (GLOBAL); set_timer0 (133); output_a (0x00); output_b (0x00); output_c (0x00); output_d (0x00); output_e (0x00); Set_Brightness (10); / / Brightness is given. clear_display (0); / / Clear the screen Text = "P10"; ShowString (7,0,1,0); Text = "Test"; ShowString (4,8,1,0); delay_ms (1500); for (i = 0: i <32: i + +) { for (w = 0, and w is <16, and w + +) { LineScroll (w, 0); } delay_ms (30); } while (TRUE) { FontTest (); delay_ms (1000); NumberTest (); delay_ms (1000); ScrollTest (); delay_ms (1000); BrightTest (); delay_ms (1000); GeoShapes (); delay_ms (1000); SineWawe (); delay_ms (1000); BarTest (); delay_ms (2000); Text = "www.arectron.com"; TextToLeftScroll (4,1,9,0); delay_ms (2000); } } WRITE_DATA void (unsigned int8 row_adr) { int8 i = 0, j = 0; int8 k = 3; while (k! = 255) / / This loop if you count forward from the right panel {J = 15-k, / / ​​Left Right installed. for (i = 0; i <4; i + +) / / rows filled .. { spi_write (display_ram [j] [row_adr]); j-= 4; } k -; } output_high (LATCH); delay_cycles (2); output_low (LATCH); } FontTest void (void) { Text = "Font"; ShowString (3,0,1,0); Text = "Test"; ShowString (3,8,1,0); delay_ms (1500); clear_display (0); delay_ms (100); Text = "A"; for (i = 1, i <5; i + +) { ShowString (0,0, i, 0); delay_ms (400); clear_display (0); } Text = "B"; for (i = 1, i <5; i + +) { ShowString (0,0, i, 0); delay_ms (400); clear_display (0); } Text = "C"; for (i = 1, i <5; i + +) { ShowString (0,0, i, 0); delay_ms (400); clear_display (0); } Text = "D"; for (i = 1, i <5; i + +) { ShowString (0,0, i, 0); delay_ms (400); clear_display (0); } } NumberTest void (void) { Text = "Numbr"; ShowString (0,0,1,0); Text = "Test"; ShowString (0,8,1,0); delay_ms (1000); clear_display (0); delay_ms (100); for (i = 0, i <100; i + +) { sprintf (Text, "% 02d", i); ShowString (4,0,4,0); delay_ms (100); } for (i = 0; i <3; i + +) { Text = "-" ;/ / ShowString (4,0,4,0); delay_ms (700); clear_display (0); delay_ms (500); } clear_display (0); Text = "iNVRT"; ShowString (0,4,1,0); delay_ms (1000); clear_display (1); delay_ms (100); for (i = 0, i <100; i + +) { sprintf (Text, "% 02d", i); ShowString (4,0,4,1); delay_ms (100); } for (i = 0; i <3; i + +) { Text = "-" ;/ / ShowString (4,0,4,1); delay_ms (700); clear_display (1); delay_ms (500); } delay_ms (500); for (i = 0: i <32: i + +) { for (w = 0, and w is <16, and w + +) { LineScroll (w, 0); } delay_ms (15); } } ScrollTest void (void) { Text = "Scroll Wheel"; ShowString (0,0,1,0); Text = "Test"; ShowString (0,8,1,0); delay_ms (1000); clear_display (0); delay_ms (100); Text = "FONT 1"; TextToLeftScroll (0,1,9,0); delay_ms (800); Text = "FONT 2"; TextToLeftScroll (0,2,9,0); delay_ms (700); Text = "FONT 3"; TextToLeftScroll (0,3,9,0); delay_ms (600); Text = "FONT 4"; TextToLeftScroll (0,4,9,0); delay_ms (500); clear_display (1); Text = "Hardware Pic18F4620 & 40Mhz, 64Kb Flash, 3968Byte Ram etc. .."; TextToLeftScroll (0,4,9,1); clear_display (0); } BrightTest void (void) { for (i = 1, i <100; i + +) { Text = "Brigt"; ShowString (0,0,1,0); sprintf (Text, "% 02d", i); ShowString (10,8,1,0); Set_Brightness (i); delay_ms (150); } Set_Brightness (100); clear_display (0); Text = "MAX"; for (i = 0, i <4; i + +) { ShowString (4,3,2,0); delay_ms (800); clear_display (0); delay_ms (500); } Set_Brightness (10); } GeoShapes void (void) { Rectangle (14,6,17,9,0); delay_ms (600); clear_display (0); Rectangle (11,3,20,12,0); delay_ms (600); clear_display (0); Rectangle (8,0,23,15,0); delay_ms (600); clear_display (0); Rectangle (14,6,17,9,1); delay_ms (600); clear_display (0); Rectangle (11,3,20,12,1); delay_ms (600); clear_display (0); Rectangle (8,0,23,15,1); delay_ms (1000); clear_display (0); Circle (16,8,2,0); delay_ms (600); clear_display (0); Circle (16,8,4,0); delay_ms (600); clear_display (0); Circle (16,8,7,0); delay_ms (600); clear_display (0); Circle (16,8,2,1); delay_ms (600); clear_display (0); Circle (16,8,4,1); delay_ms (600); clear_display (0); Circle (16,8,7,1); delay_ms (1000); clear_display (0); delay_ms (100); Line (0,0,31,15,1); delay_ms (600); Line (0,15,31,0,1); delay_ms (600); Line (5,0,8,15,1); delay_ms (600); Line (31,8,0,4,1); delay_ms (600); Line (29,0,10,15,1); delay_ms (600); Line (31,13,0,8,1); delay_ms (1000); clear_display (0); } SineWawe void (void) { float ax = 0; int16 xpos = 0; int8 ypos = 0, counter = 0; Text = "Sine"; ShowString (0,0,1,0); Text = "Wave"; ShowString (0,8,1,0); delay_ms (1000); clear_display (0); delay_ms (100); while (true) { for (xpos = 0; xpos <19; xpos + +) { for (i = 0: i <16: i + +) { LineScroll (i, 0); } ax = (pi * xpos) / 180; ypos = 8 + (7 * sin (19 * ax)); PutPixel (31, ypos, 1); delay_ms (30); } counter + +; if (counter == 10) break; } clear_display (0); } BarTest void (void) { xstart int = 0, xend = 3; Text = "bar"; ShowString (0,0,1,0); Text = "Test"; ShowString (0,8,1,0); delay_ms (1000); clear_display (0); delay_ms (100); for (w = 0; w <8; w + +) { for (i = 0, i <101; i + +) { Bargraph (xstart, 0, xend-1, 15.1, i); delay_ms (2); } xstart = xstart +4; xend = xend +4; } xstart = 0; xend = 3; for (w = 0; w <8; w + +) { for (i = 0, i <101; i + +) { Bargraph (xstart, 0, ,15,1,100 xend-1-yl); delay_ms (2); } xstart = xstart +4; xend = xend +4; } clear_display (0); xstart = 0; xend = 3; for (w = 0, and w is <4, and w + +) { for (i = 0, i <101; i + +) { Bargraph(0,xstart,31,xend-1,0,i); delay_ms(2); } xstart=xstart+4;xend=xend+4; } xstart=0;xend=3; for (w=0;w<4;w++) { for (i=0;i<101;i++) { Bargraph(0,xstart,31,xend-1,0,100-i); delay_ms(2); } xstart=xstart+4;xend=xend+4; } clear_display(0); for(w=0;w<2;w++) { for(i=0;i<101;i++) { Bargraph(0,0,31,15,1,i); delay_ms(1); } for(i=0;i<101;i++) { Bargraph(0,0,31,15,1,100-i); delay_ms(1); } } clear_display(0); for(w=0;w<2;w++) { for(i=0;i<101;i++) { Bargraph(0,0,31,15,0,i); delay_ms(1); } for(i=0;i<101;i++) { Bargraph(0,0,31,15,0,100-i); delay_ms(1); } clear_display(0); } }
 

Irandvb

کاربر vip
کاربر
2018-01-06
24
14
پروژه جالبیه . فقط چطور میشه به بیش از یک ماژول وصلش کرد و همچنین فونت فارسی را چطور میشه باهاش راه انداخت ؟
 
بالا