Jump to content
43oh

(Universal) Color LCD graphics library (2)


Recommended Posts

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)

Link to post
Share on other sites
  • Replies 127
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Popular Posts

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 MSP430

This was the case, at least for me. According to the datasheet I have for this display, the RGB/BGR direction is controlled by HW pin, so I made the following changes to the code in graphics.c file.

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

Posted Images

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.

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

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

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

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