Jump to content
43oh

Color LCD Booster Pack


Recommended Posts

  • Replies 94
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Popular Posts

@Kabron  First of all, welcome to the forum.,   Based on your posts thus far, it appears that you may not fully understand what this board/community is all about. It is a forum for sharing experienc

Here's some basic JD-T1800 code for testing purposes...   ...and a short video     main.c #include #include "ST7735.h" #define JDT1800_WIDTH 128 #define JDT1800_HEIGHT 160 #define JD

First try, we've got color! Well, it's all gibberish now, but it's a start. ST7735's documentation has 167 pages   The display below is 1.8" TFT 128 x 160, JD-T1800  

Posted Images

Cheap Color LCD Displays are pretty much a dime a dozen and you can find 100s of different phone LCD displays on ebay. What would be most impressive though would be actually getting one of those confounded things to work. =) Most people would be willing to pay a decent amount for a screen that works then for one that doesn't. ;)

Link to post
Share on other sites

While working on the software tonight, my display became unresponsive. I thought it got zapped by ESD or something so I ordered a new one. Before chucking it, I figured I will run a soldering iron through the contacts just to make sure. Well, that was it, cold solder! I hate when that happens.

 

In any case, I made some progress.

 

post-197-135135542327_thumb.jpg

Link to post
Share on other sites

Here's some basic JD-T1800 code for testing purposes...

 

...and a short video

 

 

main.c

#include 
#include "ST7735.h"

#define JDT1800_WIDTH  128
#define JDT1800_HEIGHT 160
#define JDT1800_SCL_PIN BIT5
#define JDT1800_SDA_PIN BIT7
#define JDT1800_CS_PIN BIT2
#define JDT1800_RS_PIN BIT4
#define JDT1800_SELECT P1OUT &= ~JDT1800_CS_PIN
#define JDT1800_DESELECT P1OUT |= JDT1800_CS_PIN
#define JDT1800_SET_COMMAND P1OUT &= ~JDT1800_RS_PIN
#define JDT1800_SET_DATA P1OUT |= JDT1800_RS_PIN
#define JDT1800_COMMAND 0
#define JDT1800_DATA 1

void initLCD();
void delay(char x10ms);
void write(char data, char registerSelect);
void setAddr(char xStart, char yStart, char xEnd, char yEnd);
void fillScreen(unsigned int color_16);
void writeConfig(char command, char numberOfArgs, const char *args);
void writeConfigWithDelay(char command, char x10ms);

#define writeData(data) write(data, JDT1800_DATA);
#define writeCommand(command) write(command, JDT1800_COMMAND);

// convenience color table
const int color[] = { ST7735_16_BLACK, ST7735_16_WHITE, ST7735_16_YELLOW,
	ST7735_16_RED, ST7735_16_MAGENTA, ST7735_16_BLUE, ST7735_16_CYAN,
	ST7735_16_GREEN };

void main(void) {

WDTCTL = WDTPW + WDTHOLD; // disable WDT
BCSCTL1 = CALBC1_16MHZ; // 16MHz clock
DCOCTL = CALDCO_16MHZ;

P1OUT |= JDT1800_CS_PIN + JDT1800_RS_PIN;
P1DIR |= JDT1800_CS_PIN + JDT1800_RS_PIN;

P1SEL |= JDT1800_SCL_PIN + JDT1800_SDA_PIN;
P1SEL2 |= JDT1800_SCL_PIN + JDT1800_SDA_PIN;

UCB0CTL0 |= UCCKPH + UCMSB + UCMST + UCSYNC; // 3-pin, 8-bit SPI master
UCB0CTL1 |= UCSSEL_2; // SMCLK
UCB0BR0 |= 0x01; // 1:1
UCB0BR1 = 0;
UCB0CTL1 &= ~UCSWRST; // clear SW

initLCD();
// clear screen
fillScreen(ST7735_16_BLACK);

// cycle through 8 colors
char c = 0;
while (c < 8) {
	_delay_cycles(1000000);
	fillScreen(color[c]);
	c++;
}
}

void setAddr(char xStart, char yStart, char xEnd, char yEnd) {

writeCommand(ST7735_CASET);
writeData(0x00);
writeData(xStart);
writeData(0x00);
writeData(xEnd);

writeCommand(ST7735_RASET);
writeData(0x00);
writeData(yStart);
writeData(0x00);
writeData(yEnd);

writeCommand(ST7735_RAMWR);
// data to follow
}

void fillScreen(unsigned int color_16) {

char colorHighByte = color_16 >> 8;
char colorLowByte = color_16;
char x = JDT1800_WIDTH;
char y = JDT1800_HEIGHT;

setAddr(0, 0, x - 1, y - 1);

while (y-- > 0) {
	while (x-- > 0) {
		writeData(colorHighByte);
		writeData(colorLowByte);
	}
}
}

void write(char data, char registerSelect) {
registerSelect ? (JDT1800_SET_DATA) : (JDT1800_SET_COMMAND);
JDT1800_SELECT;
UCB0TXBUF = data;
while (!(IFG2 & UCB0TXIFG))
	;
JDT1800_DESELECT;
}

void writeConfig(char command, char numberOfArgs, const char *args) {
writeCommand(command);
while (numberOfArgs--) {
	writeData(*args++);
}
}

void writeConfigWithDelay(char command, char x10ms) {
writeCommand(command);
delay(x10ms);
}

void delay(char x10ms) {
while (x10ms > 0) {
	_delay_cycles(160000);
	x10ms--;
}
}

// *************
// Config section
// *************
const char frmctr[] = { 0x01, 0x2C, 0x2D, 0x01, 0x2C, 0x2D };
const char invctr[] = { 0x07 };
const char pwctr1[] = { 0xA2, 0x02, 0x84 };
const char pwctr2[] = { 0xC5 };
const char pwctr3[] = { 0x0A, 0x00 };
const char pwctr4[] = { 0x8A, 0x2A };
const char pwctr5[] = { 0x8A, 0xEE };
const char vmctr1[] = { 0x0E };
const char madctl[] = { 0xC8 };
const char colmod[] = { 0x05 }; // 16-bit color

void initLCD() {

writeConfigWithDelay(ST7735_SLPOUT, 50); // sleep out
writeConfig(ST7735_FRMCTR1, 3, frmctr); // frame rate in normal mode
writeConfig(ST7735_FRMCTR2, 3, frmctr); // frame rate in idle mode
writeConfig(ST7735_FRMCTR3, 6, frmctr); // frame rate in partial mode
writeConfig(ST7735_INVCTR, 1, invctr); // display inversion control
writeConfig(ST7735_PWCTR1, 3, pwctr1); // power control settings
writeConfig(ST7735_PWCTR2, 1, pwctr2); // power control settings
writeConfig(ST7735_PWCTR3, 2, pwctr3); // power control settings
writeConfig(ST7735_PWCTR4, 2, pwctr4); // power control settings
writeConfig(ST7735_PWCTR5, 2, pwctr5); // power control settings
writeConfig(ST7735_VMCTR1, 1, vmctr1); // power control settings
writeConfig(ST7735_INVOFF, 0, 0); // display inversion off
writeConfig(ST7735_MADCTL, 1, madctl); // memory data access control
writeConfig(ST7735_COLMOD, 1, colmod); // color mode
writeConfigWithDelay(ST7735_NORON, 1); // normal display on
writeConfigWithDelay(ST7735_DISPON, 10); // display on
}

 

ST7735.h

#ifndef ST7735_H_
#define ST7735_H_

#define ST7735_16_BLACK   0x0000
#define ST7735_16_BLUE    0x001F
#define ST7735_16_RED     0xF800
#define ST7735_16_GREEN   0x07E0
#define ST7735_16_CYAN    0x07FF
#define ST7735_16_MAGENTA 0xF81F
#define ST7735_16_YELLOW  0xFFE0
#define ST7735_16_WHITE   0xFFFF

#define ST7735_NOP     0x00
#define ST7735_SWRESET 0x01
#define ST7735_RDDID   0x04
#define ST7735_RDDST   0x09
#define ST7735_SLPIN   0x10
#define ST7735_SLPOUT  0x11
#define ST7735_PTLON   0x12
#define ST7735_NORON   0x13
#define ST7735_INVOFF  0x20
#define ST7735_INVON   0x21
#define ST7735_DISPOFF 0x28
#define ST7735_DISPON  0x29
#define ST7735_CASET   0x2A
#define ST7735_RASET   0x2B
#define ST7735_RAMWR   0x2C
#define ST7735_RAMRD   0x2E
#define ST7735_PTLAR   0x30
#define ST7735_COLMOD  0x3A
#define ST7735_MADCTL  0x36
#define ST7735_FRMCTR1 0xB1
#define ST7735_FRMCTR2 0xB2
#define ST7735_FRMCTR3 0xB3
#define ST7735_INVCTR  0xB4
#define ST7735_DISSET5 0xB6
#define ST7735_PWCTR1  0xC0
#define ST7735_PWCTR2  0xC1
#define ST7735_PWCTR3  0xC2
#define ST7735_PWCTR4  0xC3
#define ST7735_PWCTR5  0xC4
#define ST7735_VMCTR1  0xC5
#define ST7735_RDID1   0xDA
#define ST7735_RDID2   0xDB
#define ST7735_RDID3   0xDC
#define ST7735_RDID4   0xDD
#define ST7735_GMCTRP1 0xE0
#define ST7735_GMCTRN1 0xE1
#define ST7735_PWCTR6  0xFC

#endif /*ST7735_H_*/

Link to post
Share on other sites
I can buy you some. What's the cost of these things? Also link me to them.

Thanks for the offer, but I already have few coming so I am good.

This will also give me some time to concentrate on the Nokia part of this booster.

 

Here's my initial Nokia code which allows display/chip identification.

 

The 3 displays I have are (phone - driver):

298303 - N6100 - LDS176(PCF8833 comp)?

FE903C - N6101? - SPFD54124B com?

7C8066 - N6085? - SPFD54124B comp?

 

All displays seem to initiate fine, now time to draw something :)

 

post-197-135135543013_thumb.jpeg

 

main.c

/*
* Nokia Color LCD
*
* Created on: Mar 19, 2012
*      Author: RobG
*
* main.c
*/
#include "msp430g2553.h"
#include "nokiaColor.h"

#define NokiaLCD_SCLK_PIN BIT5
#define NokiaLCD_SD_PIN BIT7
#define NokiaLCD_SCE_PIN BIT2
#define NokiaLCD_SELECT P1OUT &= ~NokiaLCD_SCE_PIN
#define NokiaLCD_DESELECT P1OUT |= NokiaLCD_SCE_PIN

void write(char data, char dataCommand);
long readLong(char command);
char readChar(char command);

void main(void) {

WDTCTL = WDTPW + WDTHOLD; // disable WDT
BCSCTL1 = CALBC1_16MHZ; // 16MHz clock
DCOCTL = CALDCO_16MHZ;

P1OUT |= NokiaLCD_SCLK_PIN + NokiaLCD_SCE_PIN + NokiaLCD_SD_PIN;
P1DIR |= NokiaLCD_SCLK_PIN + NokiaLCD_SCE_PIN + NokiaLCD_SD_PIN;

_delay_cycles(160000); // wait before reading IDs

write(SLEEPOUT, COMMAND);
_delay_cycles(1000);

// read display ID
long rddidif = readLong(RDDIDIF);

// read display status
long status = readLong(RDDST);

// this is pretty much same as RDDIDIF, just split into 3 separate reads
char rdid1 = readChar(RDID1);
char rdid2 = readChar(RDID2);
char rdid3 = readChar(RDID3);

//initLCD();

//main loop
while (1)
	;
}

char readChar(char command) {
char a = 0;
char c = 0;
NokiaLCD_SELECT;
P1OUT &= ~NokiaLCD_SD_PIN;
P1OUT |= NokiaLCD_SCLK_PIN;
P1OUT &= ~NokiaLCD_SCLK_PIN;
while (c < 8) {
	(command & BIT7) ? (P1OUT |= NokiaLCD_SD_PIN) : (P1OUT &=
								~NokiaLCD_SD_PIN);
	P1OUT |= NokiaLCD_SCLK_PIN;
	P1OUT &= ~NokiaLCD_SCLK_PIN;
	command <<= 1;
	c++;
}
P1DIR &= ~NokiaLCD_SD_PIN;

while (c < 16) {
	a <<= 1;
	P1OUT |= NokiaLCD_SCLK_PIN;
	if (P1IN & NokiaLCD_SD_PIN)
		a |= BIT0;
	P1OUT &= ~NokiaLCD_SCLK_PIN;
	c++;
}

NokiaLCD_DESELECT;
P1DIR |= NokiaLCD_SD_PIN;
return a;
}

long readLong(char command) {
long a = 0;
char b = 0;
char c = 0;
if (command == RDDIDIF) {
	b = 32;
} else if (command == RDDST) {
	b = 40;
} else
	return 0;
NokiaLCD_SELECT;
P1OUT &= ~NokiaLCD_SD_PIN;
P1OUT |= NokiaLCD_SCLK_PIN;
P1OUT &= ~NokiaLCD_SCLK_PIN;
while (c < 8) {
	(command & BIT7) ? (P1OUT |= NokiaLCD_SD_PIN) : (P1OUT &=
								~NokiaLCD_SD_PIN);
	P1OUT |= NokiaLCD_SCLK_PIN;
	P1OUT &= ~NokiaLCD_SCLK_PIN;
	command <<= 1;
	c++;
}
P1DIR &= ~NokiaLCD_SD_PIN;
P1OUT |= NokiaLCD_SCLK_PIN;
P1OUT &= ~NokiaLCD_SCLK_PIN;

while (c <  {
	a <<= 1;
	P1OUT |= NokiaLCD_SCLK_PIN;
	if (P1IN & NokiaLCD_SD_PIN)
		a |= BIT0;
	P1OUT &= ~NokiaLCD_SCLK_PIN;
	c++;
}

NokiaLCD_DESELECT;
P1DIR |= NokiaLCD_SD_PIN;
return a;
}

void write(char data, char dataCommand) {
char c = 0;
NokiaLCD_SELECT;
dataCommand ? (P1OUT |= NokiaLCD_SD_PIN) : (P1OUT &= ~NokiaLCD_SD_PIN);
P1OUT |= NokiaLCD_SCLK_PIN;
P1OUT &= ~NokiaLCD_SCLK_PIN;
while (c < 8) {
	(data & BIT7) ?
			(P1OUT |= NokiaLCD_SD_PIN) : (P1OUT &= ~NokiaLCD_SD_PIN);
	P1OUT |= NokiaLCD_SCLK_PIN;
	P1OUT &= ~NokiaLCD_SCLK_PIN;
	data <<= 1;
	c++;
}
NokiaLCD_DESELECT;
}

 

nokiaColor.h

/*
* nokiaColor.h
*
*  Created on: Mar 19, 2012
*      Author: RobG
*/

#ifndef NOKIACOLOR_H_
#define NOKIACOLOR_H_

#define COMMAND 0
#define DATA 1

#define RDDIDIF	0x04
#define RDDST	0x09
#define	SLEEPOUT	0x11
#define RDID1	0xDA
#define RDID2	0xDB
#define RDID3	0xDC

#endif /* NOKIACOLOR_H_ */

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...