Jump to content


Photo

(Universal) Color LCD graphics library (2)

Color lcd ili9340 ili9342 ili9225 hx8340

  • Please log in to reply
116 replies to this topic

#1 RobG

RobG

    Level 5

  • Members
  • 2,999 posts
  • LocationCary, NC, US


Posted 12 September 2013 - 11:41 AM

This is my new universal graphics library (original one is here.)

 

Supported boards (this is out of the "box" support, but the library will work with any board after small changes.)

 

TI's MSP430FR5969 LaunchPad (ugl16msp only for now)

TI's MSP430F5529 LaunchPad

TI's MSP430G2 LaunchPad with G2553 chip

RobG's MSP430G2955 Dev Board

RobG's MSP430F5172 Dev Board

RobG's MSP430F5510 Dev Board

 

Supported displays

 

1.8" ST7735 based JD-T1800 - ugl8

2.2" HX8340 based displays - ugl8

2.2" ILI9225 based displays (touch panel) - ugl8

2.2" ILI9341 based displays 320x240 pixels - ugl16

 

Tiva versions are right here

 

Attached File  allBPs.JPG   279.49KB   122 downloads

 

 

 

Attached File  ugl8msp.zip   15.65KB   447 downloads (name change 4/18/14)

Attached File  ugl16msp.zip   16.09KB   643 downloads (updated 4/19/14)


  • bluehash, GeekDoc, PTB and 6 others like this

#2 bluehash

bluehash

    Site Admin

  • Administrators
  • 6,429 posts

Posted 12 September 2013 - 09:09 PM

Pretty!


43oh - MSP430, TivaC, ARM-Sitara and C2000 Discussion, News, Projects and Hacks

 

 


#3 dpharris

dpharris

    Level 1

  • Members
  • 78 posts
  • LocationBC Canada

Posted 15 September 2013 - 11:03 PM

Hi Rob ---

 

I have your latest 2.2 240x320 ...
however, I only have MSP430G2452 and Stellaris/Tiva...

is it worth me trying to port this code over to one of those?  

 

Thanks,

David



#4 RobG

RobG

    Level 5

  • Members
  • 2,999 posts
  • LocationCary, NC, US


Posted 16 September 2013 - 01:53 AM

Porting to Stellaris/Tiva would require many changes.

G2452 should work as is in software SPI mode (use G2553.)

If you want to use hardware SPI, you only need to update SPI configuration (change from USCI to USI.)

I will try to find some time this week and add G2452.



#5 dpharris

dpharris

    Level 1

  • Members
  • 78 posts
  • LocationBC Canada

Posted 17 September 2013 - 04:57 AM

Thanks! I will try the software SPI. I am new to msp430-Dom, and am missing the subtleties ... Too many salta sheets, too little time.

David

#6 dpharris

dpharris

    Level 1

  • Members
  • 78 posts
  • LocationBC Canada

Posted 17 September 2013 - 06:50 AM

Yay!  Success with the softSPI on the G2452.    Drawing a diagonal line of pixels erases the surrounding pixels.  Fixing that will need a R/modify/W, I think 

David

PS -- the swallow is nice, too!  drawBitmap(blackbird_96_64, 96, 64/8, 0, 0);



#7 RobG

RobG

    Level 5

  • Members
  • 2,999 posts
  • LocationCary, NC, US


Posted 17 September 2013 - 11:25 AM

...Drawing a diagonal line of pixels erases the surrounding pixels.  Fixing that will need a R/modify/W, I think 

 

Can you attach screen shot of the problem? Line is made up of single pixels, so no surrounding pixels should be affected.

In any case, r/m/w is possible on 320x240 (ILI934x.)



#8 dpharris

dpharris

    Level 1

  • Members
  • 78 posts
  • LocationBC Canada

Posted 18 September 2013 - 01:07 AM

Can you attach screen shot of the problem? Line is made up of single pixels, so no surrounding pixels should be affected.

In any case, r/m/w is possible on 320x240 (ILI934x.)

 

I have attached a screen shot.  Since we are writing a full byte, I would expect it to overwrite the bits.  Perhaps I have missed a mode setting?  

 

My code is: 
 

          setpixelmode(0);
          for(int i=0; i<64; i++) setpixel(i,i);

Thanks,

David

Attached Files



#9 RobG

RobG

    Level 5

  • Members
  • 2,999 posts
  • LocationCary, NC, US


Posted 18 September 2013 - 01:16 AM

This library is for color displays, not Nokia B&W :) 

 

@bluehash, can we move last few posts to the appropriate thread?



#10 dpharris

dpharris

    Level 1

  • Members
  • 78 posts
  • LocationBC Canada

Posted 18 September 2013 - 01:26 AM

oops, sorry! 

David



#11 Donzap

Donzap

    Noob Class

  • Members
  • 4 posts
  • LocationSpain

Posted 19 September 2013 - 12:38 PM

Is there any library to manage 2.2" ILI9340/ILI9342 based displays on stellaris?

I don't mind if not everything is ported... Is only for investigate and learn...



#12 RobG

RobG

    Level 5

  • Members
  • 2,999 posts
  • LocationCary, NC, US


Posted 19 September 2013 - 04:10 PM

Is there any library to manage 2.2" ILI9340/ILI9342 based displays on stellaris?

I don't mind if not everything is ported... Is only for investigate and learn...

 

Here's something you can use for testing (software SPI only.)

 

Attached File  ugl16stella.zip   13.38KB   163 downloads


  • Donzap likes this

#13 Donzap

Donzap

    Noob Class

  • Members
  • 4 posts
  • LocationSpain

Posted 19 September 2013 - 07:49 PM

It works!!!

But after some seconds running, first time in drawLogicLines(), I get a white screen. 



#14 RobG

RobG

    Level 5

  • Members
  • 2,999 posts
  • LocationCary, NC, US


Posted 19 September 2013 - 08:32 PM

Hmmm, this sounds like a bug I had and fixed in main (attached code runs on my LP for few minutes w/o any issues.)

This can also happen if you read some memory addresses. Disable drawLogicLines() and see if that fixes it.



#15 Donzap

Donzap

    Noob Class

  • Members
  • 4 posts
  • LocationSpain

Posted 20 September 2013 - 08:38 AM

Hmmm, this sounds like a bug I had and fixed in main (attached code runs on my LP for few minutes w/o any issues.)

This can also happen if you read some memory addresses. Disable drawLogicLines() and see if that fixes it.

Only works fine if I disable both shesGotColors() and drawLogicLines() if one of those is on, I get the white screen.

If I can help testing something, let me know ;-)

 

Thanks a lot for your work!!!!!!

 

That's the way it works. I use Energia, Did I Do something wrong?

/*
 * main.c
 *
 *  Created on: May 6, 2013
 *      Author: RobG
 */
#include "lm4f120h5qr.h"
#include "msp.h"
#include "lcd.h"
#include "graphics.h"
#include "color.h"
#include "typedefs.h"

u_char cc = 0;
u_char sx = 0;
u_char sy = 0;
u_char d = 0;
u_char o = 0;
u_char orientation = 0;

const u_char starty[13] = { 30, 48, 150, 50, 40, 85, 38, 105, 66, 130, 35, 71, 117 };
const u_char startx[17] = { 180, 30, 100, 96, 48, 50, 150, 70, 40, 38, 123, 132,
		80, 35, 110, 55, 99 };
const u_char dim[9] = { 20, 14, 5, 17, 10, 5, 3, 18, 12 };
const u_char offset[10] = { 6, 4, 1, 9, 7, 2, 8, 0, 3, 5 };
void drawLogicLines(u_char h);
void shesGotColors(u_int repeatTimes);

void setUpMCU();

void main(void) {

		SYSCTL_RCGC2_R |= SYSCTL_RCGC2_GPIOB;
		SYSCTL_RCGC2_R |= SYSCTL_RCGC2_GPIOE;
		long ulLoop = SYSCTL_RCGC2_R;

		GPIO_PORTB_DIR_R |= LCD_MOSI_PIN + LCD_SCLK_PIN + LCD_CS_PIN;
		GPIO_PORTB_DEN_R |= LCD_MOSI_PIN + LCD_SCLK_PIN + LCD_CS_PIN;
		GPIO_PORTB_DATA_R |= LCD_CS_PIN;

		GPIO_PORTE_DIR_R = LCD_DC_PIN;
		GPIO_PORTE_DEN_R = LCD_DC_PIN;
		initLCD();

		for (ulLoop = 0; ulLoop < 200; ulLoop++) {
		}

	initLCD();

	while (1) {
		delay(10);
		clearScreen(1);

		setColor(COLOR_16_RED);
		drawString(5, 5, FONT_SM, "Texas Instruments");
		setColor(COLOR_16_WHITE);
		drawString(5, 20, FONT_MD, "LaunchPad Booster Pack");
		setColor(COLOR_16_BLUE);
		drawString(5, 40, FONT_LG, "2.2\" Color LCD");
		setColor(COLOR_16_YELLOW);
		drawString(5, 60, FONT_LG, "MSP430, Stellaris, Tiva");
		setColor(COLOR_16_ORANGE);
		drawString(5, 80, FONT_MD, "240 x 320 pixels");
		setColor(COLOR_16_PURPLE);
		drawString(5, 100, FONT_MD, "16bit color");

//		delay(100);
		//
//		shesGotColors(50);
		//
//		delay(100);
		//
//		clearScreen(1);
		//
//		drawLogicLines(8);
//		delay(100);

//		setOrientation(++orientation & 0x03);
	}
}

///////////////////////////
// needed for test only
///////////////////////////
void drawLogicLines(u_char h) {
	u_char * addr = 0;
	u_int y = 0;
	u_char c = 1;
	while (y < getScreenHeight()) {
		setColor(colors[c]);
		drawLogicLine(1, y, getScreenWidth(), h, (u_char*) addr);
		y += (h + 2);
		c++;
		addr += getScreenWidth();
	}
}

u_int getColor() {
	cc++;
	if (cc == 43)
		cc = 0;
	return colors[cc];
}

u_char getX() {
	sx++;
	if (sx == 17)
		sx = 0;
	return startx[sx];
}

u_char getY() {
	sy++;
	if (sy == 13)
		sy = 0;
	return starty[sy];
}

u_char getD() {
	d++;
	if (d == 9)
		d = 0;
	return dim[d];
}

u_char getO() {
	o++;
	if (o == 10)
		o = 0;
	return offset[o];
}

void shesGotColors(u_int times) {

	u_char x;
	u_char y;
	u_char d;
	u_int repeatTimes = times;

	while (repeatTimes > 0) {
		setColor(getColor());
		x = getX();
		y = getY();
		d = getD();
		drawLine(x - d - getO(), y - d - getO(), x + d + getO(),
				y + d + getO());

		setColor(getColor());
		x = getX();
		y = getY();
		d = getD();
		fillRect(x - d - getO(), y - d - getO(), x + d + getO(),
				y + d + getO());

		setColor(getColor());
		x = getX();
		y = getY();
		d = getD();
		drawRect(x - d - getO(), y - d - getO(), x + d + getO(),
				y + d + getO());

		setColor(getColor());
		x = getX();
		y = getY();
		d = getD();
		fillCircle(x, y, d + getO());

		setColor(getColor());
		x = getX();
		y = getY();
		d = getD();
		drawLine(x - d - getO(), y + d + getO(), x + d + getO(),
				y - d - getO());

		setColor(getColor());
		x = getX();
		y = getY();
		d = getD();
		drawCircle(x, y, d + getO());

		repeatTimes--;
	}
}
/////////////////////////////////////////
// end of test
/////////////////////////////////////////



#16 RobG

RobG

    Level 5

  • Members
  • 2,999 posts
  • LocationCary, NC, US


Posted 20 September 2013 - 11:34 AM

I checked again and it works on Tiva and Stellaris boards. Can you attach main.c to your previous post?



#17 RobG

RobG

    Level 5

  • Members
  • 2,999 posts
  • LocationCary, NC, US


Posted 08 October 2013 - 02:03 PM

Draw TI Logo function

 

Attached File  til.jpg   144.71KB   37 downloads

const u_char ti1[10] = { 94, 36, 109, 36, 97, 92, 82, 92, 94, 36 };
const u_char ti2[82] = { 0, 58, 41, 58, 41, 0, 80, 0, 80, 25, 88, 28, 84, 47,
		72, 47, 68, 65, 80, 65, 76, 84, 75, 95, 76, 103, 82, 110, 94, 112, 110,
		107, 115, 93, 106, 93, 104, 90, 110, 65, 122, 65, 126, 47, 114, 47, 118,
		29, 148, 32, 148, 54, 156, 65, 154, 95, 130, 106, 116, 120, 111, 134,
		114, 149, 98, 150, 80, 138, 62, 104, 54, 97, 46, 99, 38, 106, 30, 104,
		20, 88, 0, 58 };

///////////////////////////
// TI Logo
///////////////////////////
void drawTILogo(u_int x, u_int y, u_int color) {
	u_char sx = 0;
	u_char sy = 0;
	u_int ax = 0;
	u_int ay = 0;
	setColor(color);
	drawCircle(105 + x, 23 + y, 8);
	u_char i = 0;
	sx = ti1[i++] + x;
	sy = ti1[i++] + y;
	while (i < 10) {
		ax = ti1[i++] + x;
		ay = ti1[i++] + y;
		drawLine(sx, sy, ax, ay);
		sx = ax;
		sy = ay;
	}
	i = 0;
	sx = ti2[i++] + x;
	sy = ti2[i++] + y;
	while (i < 82) {
		ax = ti2[i++] + x;
		ay = ti2[i++] + y;
		drawLine(sx, sy, ax, ay);
		sx = ax;
		sy = ay;
	}
}


#18 olajideolaolorun

olajideolaolorun

    Noob Class

  • Members
  • 9 posts

Posted 18 November 2013 - 09:44 PM

How can i run this in IAR. Using this for a project for school and teacher only wants IAR programs in assembly. 

The sample program that is.

Excuse my n0obness. 



#19 RobG

RobG

    Level 5

  • Members
  • 2,999 posts
  • LocationCary, NC, US


Posted 18 November 2013 - 10:02 PM

You could build it in CCS and then cleanup and copy asm. 



#20 olajideolaolorun

olajideolaolorun

    Noob Class

  • Members
  • 9 posts

Posted 20 November 2013 - 07:03 PM

So my school uses IAR and i get a "Fatal Error[e89]: Too much object code produced (more than 0x1000 bytes) for this package" error, which i googled and has to do with size.

Is there a way to shrink the size?







Also tagged with one or more of these keywords: Color, lcd, ili9340, ili9342, ili9225, hx8340

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users