• Announcements

    • bluehash

      Forum Upgrade   03/11/2017

      Hello Everyone, Thanks for being patient while the forums were being fixed and upgraded. Please see details and report issues in this thread. Thanks!
RobG

(Universal) Color LCD graphics library (2)

118 posts in this topic

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

 

post-73-0-72979800-1378985978_thumb.jpg

 

 

 

ugl8msp.zip (name change 4/18/14)

ugl16msp.zip (updated 4/19/14)

GeekDoc, bluehash, Druzyek and 6 others like this

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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);

Share this post


Link to post
Share on other sites

...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.)

Share this post


Link to post
Share on other sites

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

post-30958-0-88051900-1379466311_thumb.jpg

Share this post


Link to post
Share on other sites

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...

Share this post


Link to post
Share on other sites

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.)

 

ugl16stella.zip

Donzap likes this

Share this post


Link to post
Share on other sites

It works!!!

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

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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
/////////////////////////////////////////

Share this post


Link to post
Share on other sites

Draw TI Logo function

 

post-73-0-88751900-1381240782_thumb.jpg

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;
	}
}

Share this post


Link to post
Share on other sites

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. 

Share this post


Link to post
Share on other sites

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?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now