-
Data: 2016-04-23 12:05:21
Temat: Re: Ku potomności lcd 2,4cala z mcu friend jest na...
Od: "Bo(o)t manager" <b...@W...wp.pl> szukaj wiadomości tego autora
[ pokaż wszystkie nagłówki ]On Fri, 22 Apr 2016 08:06:57 +0200, ww napisał/a:
> W dniu 2016-04-22 o 00:00, Bo(o)t manager pisze:
>> On Mon, 18 Apr 2016 11:02:54 +0200, ww napisał/a:
[ciach]
> Jakość obrazu. Zero kontrastu, kolory kompletnie bez życia, brak
> jakiejkolwiek czerni, migające linie na "czarnych" tłach, dziwnie
> widoczne piksele, podświetlenie walące po oczach a przy tym nierówne i
> pulsujące, kanciaste gradienty (fakt, używam tylko 16 bitów).
>
> Może na to trzeba nałożyć jakiś filtr ? Tylko nie wiem czy to znowu nie
> wpłynie negatywnie na działanie dotyku.
Obraz u mnie ok. Ale proc chyba nie wyrabia, Jak dobrze spojrzałem to:
JAKIŚ_PORT->BRRSL to 6 cykli zegara a jest w komplecie z BRRSH i to
trzeba wysłać 2 razy na jeden piksel + wystawienie danych na port.
Chyba będę się musiał przeprosić z FSMC czy jak to tam zwą.
Jak korzystasz z stm32 to do testowania LCD stosuję ten program:
//By AtomSoft : AKA Jason Lopez
// Enjoy
/* Includes */
/* WAŻNE!!! PODPIĄĆ RESET OD LCD DO +3V!!!*/
#include <stdlib.h>
#include <string.h>
#include "stm32f4xx_conf.h"
#include "stm32f4xx.h"
#include "font.h"
#include "stlinky.h"
void SysTick_Handler(void);
void CONFIG_LCD_PINS(void);
char buff[64];
char buff2[];
char spacja[1] = " ";
char koniecLinii[2] = "\n";
struct stlinky stlinky_buff;
#define LCD_DB 8
#define LCD_IOP GPIOE
#define LCD_CTP GPIOD
//#define LCD_RESET GPIOD
#define LCD_PINS (GPIO_Pin_8 | GPIO_Pin_9 | GPIO_Pin_10 | GPIO_Pin_11 |
GPIO_Pin_12 | GPIO_Pin_13 | GPIO_Pin_14 | GPIO_Pin_15)
#define LCD_CONT (GPIO_Pin_2 | GPIO_Pin_12 | GPIO_Pin_13 | GPIO_Pin_14 |
GPIO_Pin_15)
//#define LCD_RST (GPIO_Pin_15)
#define RST GPIO_Pin_2
#define CS GPIO_Pin_12
#define RS GPIO_Pin_13
#define WR GPIO_Pin_14
#define RD GPIO_Pin_15
#define RST_LOW GPIO_ResetBits(LCD_CTP, RST);
#define CS_LOW GPIO_ResetBits(LCD_CTP, CS);
#define RS_LOW GPIO_ResetBits(LCD_CTP, RS);
#define RD_LOW GPIO_ResetBits(LCD_CTP, RD);
#define WR_LOW GPIO_ResetBits(LCD_CTP, WR);
#define RST_HIGH GPIO_SetBits(LCD_CTP, RST);
#define CS_HIGH GPIO_SetBits(LCD_CTP, CS);
#define RS_HIGH GPIO_SetBits(LCD_CTP, RS);
#define RD_HIGH GPIO_SetBits(LCD_CTP, RD);
#define WR_HIGH GPIO_SetBits(LCD_CTP, WR);
unsigned int IC_CODE; //Stores Driver IC ID (either SPFD5408A or ST7781R)
//Basic Colors
#define RED 0xf800
#define GREEN 0x7e00
#define BLUE 0x001f
#define BLACK 0x0000
#define YELLOW 0xffe0
#define WHITE 0xffff
//Other Colors
#define CYAN 0x07ff
#define BRIGHT_RED 0xf810
#define GRAY1 0x8410
#define GRAY2 0x4208
//TFT resolution 240*320
#define MIN_X 0
#define MIN_Y 0
#define MAX_X 239
#define MAX_Y 319
void init (void);
void sendCommand(unsigned int index);
void sendData(unsigned int data);
void pushData(unsigned char data);
unsigned char getData(void);
unsigned int readRegister(unsigned int index);
void setXY(unsigned int poX, unsigned int poY);
void setPixel(unsigned int poX, unsigned int poY,unsigned int color);
void drawLine(unsigned int x0,unsigned int y0,unsigned int x1,unsigned
int y1,unsigned int color);
void drawVerticalLine(unsigned int poX, unsigned int poY,unsigned int
length,unsigned int color);
void drawHorizontalLine(unsigned int poX, unsigned int poY,unsigned int
length,unsigned int color);
void drawRectangle(unsigned int poX, unsigned int poY, unsigned int
length,unsigned int width,unsigned int color);
void fillRectangle(unsigned int poX, unsigned int poY, unsigned int
length, unsigned int width, unsigned int color);
void drawCircle(int poX, int poY, int r,unsigned int color);
void fillCircle(int poX, int poY, int r,unsigned int color);
void drawChar(unsigned char ascii,unsigned int poX, unsigned int
poY,unsigned int size, unsigned int fgcolor);
void drawString(char *string,unsigned int poX, unsigned int poY,unsigned
int size,unsigned int fgcolor);
unsigned char drawNumber(long long_num,unsigned int poX, unsigned int
poY,unsigned int size,unsigned int fgcolor);
unsigned char drawFloat(float floatNumber,unsigned char decimal,unsigned
int poX, unsigned int poY,unsigned int size,unsigned int fgcolor);
void delay(unsigned char time, int unit);
void all_pin_input(void);
void all_pin_output(void);
void all_pin_low(void);
void setOrientation(unsigned int HV);
void LCD_WriteReg(unsigned int INDEX, unsigned int DATA);
GPIO_InitTypeDef LCDCTR_Setup;
GPIO_InitTypeDef LCDIO_Setup;
int color = WHITE;
#define us 1
#define ms 1000
#define sec 100000
void uart(char tekst[]){
stlinky_buff.magic = STLINKY_MAGIC;
stlinky_buff.bufsize = CONFIG_LIB_STLINKY_BSIZE;
stlinky_tx(&stlinky_buff, tekst, strlen(tekst));
}
int main(void)
{
uint32_t licznik;
unsigned int cur = 0,rejestr,i;
unsigned int nColor = 1;
uart("odpalam program\n");
/* Configure SysTick for 1ms interrupts: */
SysTick_Config(SystemCoreClock/1000000);
uart("ustawiam opóźnienia\n");
CONFIG_LCD_PINS();
uart("konfiguruję piny\n");
init(); //init TFT library
setOrientation(1);
//drawString("Ale sie ciesze",10,10,2,WHITE);
// drawString("z uruchomienia ",10,30,2,WHITE);
// drawString("maszyny",10,50,2,WHITE);
// drawString("A Morus to drze chorus",10,70,1,RED);
// drawString("Ja pierdykam, alem szczesliwy",10,80,1,WHITE);
for(;;){
drawHorizontalLine(50,i,30,BLACK);
i++;
}
return(0);
}
unsigned int TimeCount = 0;
unsigned char IsTimeUp = 0;
void SysTick_Handler(void)
{
static unsigned int n16Count = 0;
if(!IsTimeUp)
{
if (TimeCount == n16Count)
{
IsTimeUp = 1;
n16Count = -1;
}
else
{
n16Count = n16Count + 1;
}
}
}
void CONFIG_LCD_PINS(void)
{
//RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOB, ENABLE);
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOE, ENABLE);
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOD, ENABLE);
/* Configure GPIOs to drive LCD: */
LCDIO_Setup.GPIO_Pin = LCD_PINS;
LCDIO_Setup.GPIO_Mode = GPIO_Mode_OUT;
LCDIO_Setup.GPIO_OType = GPIO_OType_PP;
LCDIO_Setup.GPIO_Speed = GPIO_Speed_50MHz;
LCDIO_Setup.GPIO_PuPd = GPIO_PuPd_NOPULL;
GPIO_Init(LCD_IOP, &LCDIO_Setup);
LCDCTR_Setup.GPIO_Pin = LCD_CONT;
LCDCTR_Setup.GPIO_Mode = GPIO_Mode_OUT;
LCDCTR_Setup.GPIO_OType = GPIO_OType_PP;
LCDCTR_Setup.GPIO_Speed = GPIO_Speed_50MHz;
LCDCTR_Setup.GPIO_PuPd = GPIO_PuPd_NOPULL;
GPIO_Init(LCD_CTP, &LCDCTR_Setup);
GPIO_ResetBits(LCD_CTP, LCD_CONT);
GPIO_ResetBits(LCD_IOP, LCD_PINS);
}
void pushData(unsigned char data)
{
all_pin_low();
LCD_IOP->ODR = (int)((int)data << LCD_DB);
}
void delay(unsigned char time, int unit)
{
TimeCount=time * unit;
IsTimeUp = 0;
while(!IsTimeUp);
}
unsigned char getData(void)
{
unsigned char data=0;
//delay(1,ms);
data = (LCD_IOP->IDR >> 8);
return data;
}
void sendCommand(unsigned int index)
{
CS_LOW;
RS_LOW;
RD_HIGH;
WR_HIGH;
WR_LOW;
pushData(index>>8);
//delay(10,us);
WR_HIGH;
WR_LOW;
pushData(index);
//delay(10,us);
WR_HIGH;
CS_HIGH;
}
void sendData(unsigned int data)
{
CS_LOW;
RS_HIGH;
RD_HIGH;
WR_LOW;
pushData(data>>8);
//delay(10,us);
WR_HIGH;
WR_LOW;
pushData(data);
//delay(10,us);
WR_HIGH;
CS_HIGH;
}
unsigned int readRegister(unsigned int index)
{
unsigned int data=0;
CS_LOW;
RS_LOW;
RD_HIGH;
all_pin_output();
//delay(50,us);
WR_LOW;
//delay(50,us);
pushData(index>>8);
WR_HIGH;
//delay(50,us);
WR_LOW;
//delay(50,us);
pushData(index);
WR_HIGH;
all_pin_input();
all_pin_low();
RS_HIGH;
//delay(50,us);
RD_LOW;
//delay(50,us);
data = (int)getData()<<8;
RD_HIGH;
delay(50,us);
RD_LOW;
delay(50,us);
data |= getData();
RD_HIGH;
CS_HIGH;
all_pin_output();
return data;
}
void init (void)
{
unsigned char i;
unsigned int f;
uart("resetuje LCD\n");
uart("chuj resetuję LCD \n");
RST_HIGH;
delay(1000,ms);
RST_LOW;
delay(300,ms);
RST_HIGH;
uart("skończyłem resetowanie LCD\n");
CS_HIGH;
//all_pin_output();
//all_pin_low();
delay(100,us);
uart("odczyt IC_CODE\n");
IC_CODE = readRegister(0x0);
uart("Odczytałem IC_CODE\n");
itoa(IC_CODE, buff,10);
uart(buff);
uart("\n");
if(!IC_CODE){
while(!IC_CODE)
{
uart("ponowne odczytanie IC_CODE\n");
IC_CODE = readRegister(0x0); //WAIT UNTIL KNOWN LCD
itoa(IC_CODE, buff,10);
uart(buff);
uart("\n");
}
}
if(IC_CODE == 0x6809) //SPFD5408B
{
uart("To jest RM68090\n");
LCD_WriteReg(0x00E3, 0x3008); // Set
internal timing
LCD_WriteReg(0x00E7, 0x0012); // Set
internal timing
LCD_WriteReg(0x00EF, 0x1231); // Set
internal timing
LCD_WriteReg(0x0001, 0x0100); // set SS and
SM bit
LCD_WriteReg(0x0002, 0x0700); // set 1 line
inversion
LCD_WriteReg(0x0003, 0x1030); // set GRAM
write direction and BGR=1.
LCD_WriteReg(0x0004, 0x0000); // Resize
register
LCD_WriteReg(0x0008, 0x0207); // set the back porch
and front porch
LCD_WriteReg(0x0009, 0x0000); // set non-
display area refresh cycle ISC[3:0]
LCD_WriteReg(0x000A, 0x0000); // FMARK function
LCD_WriteReg(0x000C, 0x0000); // RGB interface
setting
LCD_WriteReg(0x000D, 0x0000); // Frame marker
Position
LCD_WriteReg(0x000F, 0x0000); // RGB
interface polarity
//*************Power On sequence ****************//
LCD_WriteReg(0x0010, 0x0000); // SAP, BT
[3:0], AP, DSTB, SLP, STB
LCD_WriteReg(0x0011, 0x0007); // DC1[2:0],
DC0[2:0], VC[2:0]
LCD_WriteReg(0x0012, 0x0000); // VREG1OUT
voltage
LCD_WriteReg(0x0013, 0x0000); // VDV[4:0]
for VCOM amplitude
delay
(200,ms); // Dis-
charge capacitor power voltage
LCD_WriteReg(0x0010, 0x1490); // SAP, BT
[3:0], AP, DSTB, SLP, STB
LCD_WriteReg(0x0011, 0x0227); // DC1[2:0],
DC0[2:0], VC[2:0]
delay(50,ms);
// Delay 50ms
LCD_WriteReg(0x0012, 0x001C); // Internal
reference voltage= Vci;
delay(50,ms);
// Delay 50ms
LCD_WriteReg(0x0013, 0x1A00); // Set VDV
[4:0] for VCOM amplitude
LCD_WriteReg(0x0029, 0x0025); // Set VCM
[5:0] for VCOMH
LCD_WriteReg(0x002B, 0x000C); // Set Frame
Rate
delay(50,ms); // Delay 50ms
LCD_WriteReg(0x0020, 0x0000); // GRAM
horizontal Address
LCD_WriteReg(0x0021, 0x0000); // GRAM
Vertical Address
// ----------- Adjust the Gamma Curve ----------//
LCD_WriteReg(0x0030, 0x0000);
LCD_WriteReg(0x0031, 0x0506);
LCD_WriteReg(0x0032, 0x0104);
LCD_WriteReg(0x0035, 0x0207);
LCD_WriteReg(0x0036, 0x000F);
LCD_WriteReg(0x0037, 0x0306);
LCD_WriteReg(0x0038, 0x0102);
LCD_WriteReg(0x0039, 0x0707);
LCD_WriteReg(0x003C, 0x0702);
LCD_WriteReg(0x003D, 0x1604);
//------------------ Set GRAM area ---------------//
LCD_WriteReg(0x0050, 0x0000); // Horizontal
GRAM Start Address
LCD_WriteReg(0x0051, 0x00EF); // Horizontal
GRAM End Address
LCD_WriteReg(0x0052, 0x0000); // Vertical
GRAM Start Address
LCD_WriteReg(0x0053, 0x013F); // Vertical
GRAM Start Address
LCD_WriteReg(0x0060, 0xA700); // Gate Scan
Line
LCD_WriteReg(0x0061, 0x0001); // NDL,VLE, REV
LCD_WriteReg(0x006A, 0x0000); // set
scrolling line
//-------------- Partial Display Control ---------//
LCD_WriteReg(0x0080, 0x0000);
LCD_WriteReg(0x0081, 0x0000);
LCD_WriteReg(0x0082, 0x0000);
LCD_WriteReg(0x0083, 0x0000);
LCD_WriteReg(0x0084, 0x0000);
LCD_WriteReg(0x0085, 0x0000);
//-------------- Panel Control -------------------//
LCD_WriteReg(0x0090, 0x0010);
LCD_WriteReg(0x0092, 0x0600);
LCD_WriteReg(0x0007, 0x0133); // 262K color
and display ON
}
if(IC_CODE == 0x5408B) //SPFD5408B
{
uart("To jest SPFD5408B");
sendCommand(0x0000);
sendData(0x0001);
delay(100,ms);
sendCommand(0x0001);
sendData(0x0000);
sendCommand(0x0002);
sendData(0x0700);
sendCommand(0x0003);
sendData(0x1030);
sendCommand(0x0004);
sendData(0x0000);
sendCommand(0x0008);
sendData(0x0207);
sendCommand(0x0009);
sendData(0x0000);
sendCommand(0x000A);
sendData(0x0000);
sendCommand(0x000C);
sendData(0x0000);
sendCommand(0x000D);
sendData(0x0000);
sendCommand(0x000F);
sendData(0x0000);
//power on sequence VGHVGL
sendCommand(0x0010);
sendData(0x0000);
sendCommand(0x0011);
sendData(0x0007);
sendCommand(0x0012);
sendData(0x0000);
sendCommand(0x0013);
sendData(0x0000);
//vgh
sendCommand(0x0010);
sendData(0x1290);
sendCommand(0x0011);
sendData(0x0227);
delay(100,ms);
//vregiout
sendCommand(0x0012);
sendData(0x001d); //0x001b
delay(100,ms);
//vom amplitude
sendCommand(0x0013);
sendData(0x1500);
delay(100,ms);
//vom H
sendCommand(0x0029);
sendData(0x0018);
sendCommand(0x002B);
sendData(0x000D);
//gamma
sendCommand(0x0030);
sendData(0x0004);
sendCommand(0x0031);
sendData(0x0307);
sendCommand(0x0032);
sendData(0x0002);// 0006
sendCommand(0x0035);
sendData(0x0206);
sendCommand(0x0036);
sendData(0x0408);
sendCommand(0x0037);
sendData(0x0507);
sendCommand(0x0038);
sendData(0x0204);//0200
sendCommand(0x0039);
sendData(0x0707);
sendCommand(0x003C);
sendData(0x0405);// 0504
sendCommand(0x003D);
sendData(0x0F02);
//ram
sendCommand(0x0050);
sendData(0x0000);
sendCommand(0x0051);
sendData(0x00EF);
sendCommand(0x0052);
sendData(0x0000);
sendCommand(0x0053);
sendData(0x013F);
sendCommand(0x0060);
sendData(0xA700);
sendCommand(0x0061);
sendData(0x0001);
sendCommand(0x006A);
sendData(0x0000);
//
sendCommand(0x0080);
sendData(0x0000);
sendCommand(0x0081);
sendData(0x0000);
sendCommand(0x0082);
sendData(0x0000);
sendCommand(0x0083);
sendData(0x0000);
sendCommand(0x0084);
sendData(0x0000);
sendCommand(0x0085);
sendData(0x0000);
//
sendCommand(0x0090);
sendData(0x0010);
sendCommand(0x0092);
sendData(0x0600);
sendCommand(0x0093);
sendData(0x0003);
sendCommand(0x0095);
sendData(0x0110);
sendCommand(0x0097);
sendData(0x0000);
sendCommand(0x0098);
sendData(0x0000);
sendCommand(0x0007);
sendData(0x0133);
sendCommand(0x0022);//Start to write to display RAM
}
else
{
sendCommand(0x0001);
sendData(0x0100);
sendCommand(0x0002);
sendData(0x0700);
sendCommand(0x0003);
sendData(0x1030);
sendCommand(0x0004);
sendData(0x0000);
sendCommand(0x0008);
sendData(0x0302);
sendCommand(0x000A);
sendData(0x0000);
sendCommand(0x000C);
sendData(0x0000);
sendCommand(0x000D);
sendData(0x0000);
sendCommand(0x000F);
sendData(0x0000);
delay(100,ms);
sendCommand(0x0030);
sendData(0x0000);
sendCommand(0x0031);
sendData(0x0405);
sendCommand(0x0032);
sendData(0x0203);
sendCommand(0x0035);
sendData(0x0004);
sendCommand(0x0036);
sendData(0x0B07);
sendCommand(0x0037);
sendData(0x0000);
sendCommand(0x0038);
sendData(0x0405);
sendCommand(0x0039);
sendData(0x0203);
sendCommand(0x003c);
sendData(0x0004);
sendCommand(0x003d);
sendData(0x0B07);
sendCommand(0x0020);
sendData(0x0000);
sendCommand(0x0021);
sendData(0x0000);
sendCommand(0x0050);
sendData(0x0000);
sendCommand(0x0051);
sendData(0x00ef);
sendCommand(0x0052);
sendData(0x0000);
sendCommand(0x0053);
sendData(0x013f);
delay(100,ms);
sendCommand(0x0060);
sendData(0xa700);
sendCommand(0x0061);
sendData(0x0001);
sendCommand(0x0090);
sendData(0x003A);
sendCommand(0x0095);
sendData(0x021E);
sendCommand(0x0080);
sendData(0x0000);
sendCommand(0x0081);
sendData(0x0000);
sendCommand(0x0082);
sendData(0x0000);
sendCommand(0x0083);
sendData(0x0000);
sendCommand(0x0084);
sendData(0x0000);
sendCommand(0x0085);
sendData(0x0000);
sendCommand(0x00FF);
sendData(0x0001);
sendCommand(0x00B0);
sendData(0x140D);
sendCommand(0x00FF);
sendData(0x0000);
delay(100,ms);
sendCommand(0x0007);
sendData(0x0133);
delay(50,ms);
//exit standby
sendCommand(0x0010);
sendData(0x14E0);
delay(100,ms);
sendCommand(0x0007);
sendData(0x0133);
sendCommand(0x0022);
}
//paint screen black
for(i=0;i<2;i++)
{
for(f=0;f<38400;f++)
{
sendData(GREEN);
}
}
}
void LCD_WriteReg(unsigned int INDEX, unsigned int DATA)
{
sendCommand(INDEX);
sendData(DATA);
}
void setOrientation(unsigned int HV)//horizontal or vertical
{
sendCommand(0x03);
if(HV==1)//vertical
{
if(IC_CODE == 0x5408) { sendData(0x1038); }
else { sendData(0x5038); }
}
else//horizontal
{
if(IC_CODE == 0x5408) { sendData(0x1030); }
else { sendData(0x5030); }
}
sendCommand(0x0022); //Start to write to display RAM
}
void setXY(unsigned int poX, unsigned int poY)
{
if(poX <0)
poX = 0;
if(poX>239)
poX = 239;
if(poY <0)
poY = 0;
if(poY>319)
poY = 319;
//poX = constrain(poX,MIN_X,MAX_X); //Limits the pixel range to 0 - 239
//poY = constrain(poY,MIN_Y,MAX_Y); //Limits the pixel range to 0 - 319
/* Writing to GRAM beyond the range gives unpredictable results. The
above code
is to limit this. This might also slow down the writing to TFT. You
can
remove the above two lines of code, if you think your application
code
does not write beyond this range. This would speed up TFT writing.
*/
sendCommand(0x0020);//X
sendData(poX);
sendCommand(0x0021);//Y
sendData(poY);
sendCommand(0x0022);//Start to write to display RAM
}
void setPixel(unsigned int poX, unsigned int poY,unsigned int color)
{
setXY(poX,poY);
sendData(color);
}
void drawCircle(int poX, int poY, int r,unsigned int color)
{
int x = -r, y = 0, err = 2-2*r, e2;
do {
setPixel(poX-x, poY+y,color);
setPixel(poX+x, poY+y,color);
setPixel(poX+x, poY-y,color);
setPixel(poX-x, poY-y,color);
e2 = err;
if (e2 <= y) {
err += ++y*2+1;
if (-x == y && e2 <= x) e2 = 0;
}
if (e2 > x) err += ++x*2+1;
}
while (x <= 0);
}
void fillCircle(int poX, int poY, int r,unsigned int color)
{
int x = -r, y = 0, err = 2-2*r, e2;
do {
drawVerticalLine(poX-x,poY-y,2*y,color);
drawVerticalLine(poX+x,poY-y,2*y,color);
e2 = err;
if (e2 <= y) {
err += ++y*2+1;
if (-x == y && e2 <= x) e2 = 0;
}
if (e2 > x) err += ++x*2+1;
}
while (x <= 0);
}
void drawLine(unsigned int x0,unsigned int y0,unsigned int x1,unsigned
int y1,unsigned int color)
{
int dx = (x1-x0), sx = x0<x1 ? 1 : -1;
int dy = -(y1-y0), sy = y0<y1 ? 1 : -1;
int err = dx+dy, e2; /* error value e_xy */
for (;;){ /* loop */
setPixel(x0,y0,color);
e2 = 2*err;
if (e2 >= dy) { /* e_xy+e_x > 0 */
if (x0 == x1) break;
err += dy;
x0 += sx;
}
if (e2 <= dx) { /* e_xy+e_y < 0 */
if (y0 == y1) break;
err += dx;
y0 += sy;
}
}
}
void drawVerticalLine(unsigned int poX, unsigned int poY,unsigned int
length,unsigned int color)
{
unsigned int i;
if(poX <0)
poX = 0;
if(poX>239)
poX = 239;
if(poY <0)
poY = 0;
if(poY>319)
poY = 319;
//poX = constrain(poX,MIN_X,MAX_X); //Limits the pixel range to 0 -
239
//poY = constrain(poY,MIN_Y,MAX_Y); //Limits the pixel range to 0 -
319
setXY(poX,poY);
setOrientation(1);
if(length+poY>MAX_Y)
{
length=MAX_Y-poY;
}
for(i=0;i<length;i++)
{
sendData(color);
}
}
void drawHorizontalLine(unsigned int poX, unsigned int poY,unsigned int
length,unsigned int color)
{
unsigned int i;
if(poX <0)
poX = 0;
if(poX>239)
poX = 239;
if(poY <0)
poY = 0;
if(poY>319)
poY = 319;
//poX = constrain(poX,MIN_X,MAX_X); //Limits the pixel range to 0 -
239
//poY = constrain(poY,MIN_Y,MAX_Y); //Limits the pixel range to 0 -
319
setXY(poX,poY);
setOrientation(0);
if(length+poX>MAX_X)
{
length=MAX_X-poX;
}
for(i=0;i<length;i++)
{
sendData(color);
}
}
void drawRectangle(unsigned int poX, unsigned int poY, unsigned int
length,unsigned int width,unsigned int color)
{
drawHorizontalLine(poX, poY, length, color);
drawHorizontalLine(poX, poY+width, length, color);
drawVerticalLine(poX, poY, width,color);
drawVerticalLine(poX + length, poY, width,color);
}
void fillRectangle(unsigned int poX, unsigned int poY, unsigned int
length, unsigned int width, unsigned int color)
{
unsigned int i;
for(i=0;i<width;i++)
{
drawHorizontalLine(poX, poY+i, length, color);
}
}
void drawChar(unsigned char ascii,unsigned int poX, unsigned int
poY,unsigned int size, unsigned int fgcolor)
{
unsigned char i;
unsigned char temp;
unsigned char f;
setXY(poX,poY);
setOrientation(0);
if((ascii < 0x20)||(ascii > 0x7e))//Unsupported char.
{
ascii = '?';
}
for(i=0;i<8;i++)
{
temp = simpleFont[ascii-0x20][i];
for(f=0;f<8;f++)
{
if((temp>>f)&0x01)
{
fillRectangle(poX+i*size, poY+f*size, size, size,
fgcolor);
}
}
}
}
void drawString(char *string,unsigned int poX, unsigned int poY,unsigned
int size,unsigned int fgcolor)
{
while(*string)
{
drawChar(*string, poX, poY, size, fgcolor);
string++;
if(poX < MAX_X)
{
poX+=8*size; // Move cursor right
}
}
}
unsigned char drawNumber(long long_num,unsigned int poX, unsigned int
poY,unsigned int size,unsigned int fgcolor)
{
unsigned char char_buffer[10]="";
unsigned char i = 0;
unsigned char f = 0;
if (long_num < 0)
{
f=1;
drawChar('-',poX, poY, size, fgcolor);
long_num = -long_num;
if(poX < MAX_X)
{
poX+=8*size; // Move cursor right
}
}
else if (long_num == 0)
{
f=1;
drawChar('0',poX, poY, size, fgcolor);
return f;
if(poX < MAX_X)
{
poX+=8*size; // Move cursor right
}
}
while (long_num > 0)
{
char_buffer[i++] = long_num % 10;
long_num /= 10;
}
f=f+i;
for(; i > 0; i--)
{
drawChar('0'+ char_buffer[i - 1],poX, poY, size, fgcolor);
if(poX < MAX_X)
{
poX+=8*size; // Move cursor right
}
}
return f;
}
unsigned char drawFloat(float floatNumber,unsigned char decimal,unsigned
int poX, unsigned int poY,unsigned int size,unsigned int fgcolor)
{
unsigned int temp=0;
float decy=0.0;
float rounding = 0.5;
unsigned char f=0;
unsigned char i;
unsigned char howlong;
if(floatNumber<0.0)
{
drawChar('-',poX, poY, size, fgcolor);
floatNumber = -floatNumber;
if(poX < MAX_X)
{
poX+=8*size; // Move cursor right
}
f =1;
}
for (i=0; i<decimal; ++i)
{
rounding /= 10.0;
}
floatNumber += rounding;
temp = (unsigned int)floatNumber;
howlong=drawNumber(temp,poX, poY, size, fgcolor);
f += howlong;
if((poX+8*size*howlong) < MAX_X)
{
poX+=8*size*howlong; // Move cursor right
}
if(decimal>0)
{
drawChar('.',poX, poY, size, fgcolor);
if(poX < MAX_X)
{
poX+=8*size; // Move cursor right
}
f +=1;
}
decy = floatNumber-temp;//decimal part,
for(i=0;i<decimal;i++)//4
{
decy *=10;// for the next decimal
temp = decy;//get the decimal
drawNumber(temp,poX, poY, size, fgcolor);
floatNumber = -floatNumber;
if(poX < MAX_X)
{
poX+=8*size; // Move cursor right
}
decy -= temp;
}
f +=decimal;
return (unsigned char)f;
}
void all_pin_input(void)
{
LCDIO_Setup.GPIO_Mode = GPIO_Mode_IN; //SET PORT AS INPUT
GPIO_Init(LCD_IOP, &LCDIO_Setup); //Re-Init Port
//LCDCTR_Setup.GPIO_Mode = GPIO_Mode_IN; //SET PORT AS INPUT
//GPIO_Init(LCD_CTP, &LCDCTR_Setup); //Re-Init Port
}
void all_pin_output(void)
{
LCDIO_Setup.GPIO_Mode = GPIO_Mode_OUT; //SET PORT AS INPUT
GPIO_Init(LCD_IOP, &LCDIO_Setup); //Re-Init Port
//LCDCTR_Setup.GPIO_Mode = GPIO_Mode_OUT; //SET PORT AS INPUT
//GPIO_Init(LCD_CTP, &LCDCTR_Setup); //Re-Init Port
}
void all_pin_low(void)
{
LCD_IOP->BSRRH = LCD_PINS;
// LCD_CTP->BSRRH = LCD_CONT;
}
Wytnij tylko wszystko co dotyczy stlinky.
--
Pozdrawiam
Bo(o)t manager
Następne wpisy z tego wątku
- 25.04.16 08:14 ww
- 26.04.16 19:28 Bo(o)t manager
- 26.04.16 20:09 Bo(o)t manager
- 26.04.16 20:14 ww
- 29.04.16 20:33 Bo(o)t manager
- 04.05.16 10:04 ww
- 05.05.16 22:58 Bo(o)t manager
- 19.05.16 14:48 ww
- 19.05.16 18:43 Pszemol
- 20.05.16 08:02 ww
- 20.05.16 11:47 MiSter
- 20.05.16 13:38 Pszemol
- 23.05.16 13:17 ww
- 23.05.16 20:31 AlexY
Najnowsze wątki z tej grupy
- jak szybko plynie prad
- Płytki Milkv-Duo
- Światłowód między budynkami
- POtrzebny bufor 3.3<>5V, jedonkieruowy, trójstanowy, wąski
- retro
- Bezprzewodowe polączenie Windows z projektorem
- rozklejanie obudowy
- Prośba o identyfikację komponentu
- Smart gniazdko straciło na zasięgu wifi?
- Smart gniazdko straciło zasięg wifi?
- nurtuje mnie
- dziwna sprawa...
- Laptop MSI się nie uruchamia.
- Dobra listwa LED (CRI 90-95, bez migotania)
- masowe programowanie AVR
Najnowsze wątki
- 2024-11-04 GNSS Motorola G85 vs Redmi Note 9 pro
- 2024-11-04 Katowice => SAP BTP Consultant (mid/senior) <=
- 2024-11-04 Katowice => Spedytor międzynarodowy <=
- 2024-11-04 Warszawa => Specjalista/tka ds. Zamówień publicznych <=
- 2024-11-04 Poznań => QA Engineer <=
- 2024-11-04 Poznań => QA Inżynier <=
- 2024-11-04 Polskie sądy są bardzo wyrozumiałe...
- 2024-11-04 Wrocław => SAP Project System/EPPM Consultant <=
- 2024-11-04 Gliwice => Team Lead / Tribe Lead FrontEnd <=
- 2024-11-04 Kraków => Programista Full Stack (.Net Core) <=
- 2024-11-04 Kraków => Software .Net Developer <=
- 2024-11-04 Kraków => Programista Full Stack .Net <=
- 2024-11-04 Warszawa => Key Account Manager <=
- 2024-11-04 Warszawa => Spedytor Międzynarodowy <=
- 2024-11-04 Warszawa => E-COMMERCE specialist <=