<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="bbPress/1.0.2" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title>LeafLabs Garden &#187; Topic: Library ready( (ish) for Maple and colour lcd ILI9163 and HX8353 (128x160)</title>
		<link>http://forums.leaflabs.com/topic.php?id=74086</link>
		<description>A place to share, learn, and grow...</description>
		<language>en-US</language>
		<pubDate>Fri, 22 Jan 2016 00:04:35 +0000</pubDate>
		<generator>http://bbpress.org/?v=1.0.2</generator>
		<textInput>
			<title><![CDATA[Search]]></title>
			<description><![CDATA[Search all topics from these forums.]]></description>
			<name>q</name>
			<link>http://forums.leaflabs.com/search.php</link>
		</textInput>
		<atom:link href="http://forums.leaflabs.com/rss.php?topic=74086" rel="self" type="application/rss+xml" />

		<item>
			<title>Magician on "Library ready( (ish) for Maple and colour lcd ILI9163 and HX8353 (128x160)"</title>
			<link>http://forums.leaflabs.com/topic.php?id=74086#post-104997</link>
			<pubDate>Sun, 01 Dec 2013 18:03:46 +0000</pubDate>
			<dc:creator>Magician</dc:creator>
			<guid isPermaLink="false">104997@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;&#34;So are you saying your library uses hardware SPI or digitalWrite?&#34; Yes, hardware SPI. At 18 MHz:&#60;br /&#62;
  myTFT.begin(SPI_18MHZ, MSBFIRST, 0);&#60;br /&#62;
I was not so lucky to keep adafruit's library intact, something goes wrong with initialization a class, I received a buch of error from compliler, that I cann't do:&#60;br /&#62;
&#60;pre&#62;&#60;code&#62;Adafruit_ILI9340::Adafruit_ILI9340(uint8_t cs, uint8_t dc, uint8_t rst) : Adafruit_GFX(ILI9340_TFTWIDTH, ILI9340_TFTHEIGHT) {
  _cs   = cs;
  _dc   = dc;
  _rst  = rst;
  hwSPI = true;
  _mosi  = _sclk = 0;
}&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;and I'm not so good in C++ to fix it, probably there is a big difference in construction of arduino IDE 1.5 and maple 0.0.12, but leaving this out of scope for a moment, I stack everything in single sketch which become huge ~600 lines -);&#60;/p&#62;
&#60;p&#62; Two their's most important functions:&#60;br /&#62;
&#60;pre&#62;&#60;code&#62;void Adafruit_ILI9340::writecommand(uint8_t c) {
  CLEAR_BIT(dcport, dcpinmask);
  //digitalWrite(_dc, LOW);
  CLEAR_BIT(clkport, clkpinmask);
  //digitalWrite(_sclk, LOW);
  CLEAR_BIT(csport, cspinmask);
  //digitalWrite(_cs, LOW);

  spiwrite(c);

  SET_BIT(csport, cspinmask);
  //digitalWrite(_cs, HIGH);
}

void Adafruit_ILI9340::writedata(uint8_t c) {
  SET_BIT(dcport,  dcpinmask);
  //digitalWrite(_dc, HIGH);
  CLEAR_BIT(clkport, clkpinmask);
  //digitalWrite(_sclk, LOW);
  CLEAR_BIT(csport, cspinmask);
  //digitalWrite(_cs, LOW);

  spiwrite(c);

  //digitalWrite(_cs, HIGH);
  SET_BIT(csport, cspinmask);
}&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;become:&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;void LCDCommand(unsigned char data)
{
  digitalWrite(DSS, LOW);
  digitalWrite(CSS, LOW);		//
  myTFT.write(data);
  digitalWrite(CSS, HIGH);
}

void LCDData(unsigned char data) // Send hex data through the serial port (MOSI 1 first)
{
  digitalWrite(DSS, HIGH);
  digitalWrite(CSS, LOW);
  myTFT.write(data);
  digitalWrite(CSS, HIGH);
}&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62; and using this approach I get 30 millisec. Next step, after digging up a little this (helpful !) forum, it become:&#60;br /&#62;
&#60;pre&#62;&#60;code&#62;void LCDCommand(unsigned char data)
{
  GPIOB_BASE-&#38;gt;BRR  = 0x00000003;
    myTFT.write(data);
  GPIOB_BASE-&#38;gt;BSRR = 0x00000003;
}

void LCDData(unsigned char data) // Send hex data through the serial port (MOSI 1 first)
{
  GPIOB_BASE-&#38;gt;BRR  = 0x00000001;
    myTFT.write(data);
  GPIOB_BASE-&#38;gt;BSRR = 0x00000001;
}&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;and I can see on my scope right now 18.1 milliseconds.&#60;br /&#62;
As you can see, I optimized away adafruit's 4 SET/CLEAR in just 2 access to ports in each function.&#60;/p&#62;
&#60;p&#62; Probably, there is nothing can be improved. I did some test, trying to run SPI 16-bit ( a lot of data lengh 16 or even 32-bits), but unsuccessfully. Actually data sheet ILI9340 says it's oly support 8-bit's or 9-bit's.&#60;br /&#62;
 Driving this two digital pins CS and D/C &#34;manually&#34; gives no chance to run SPI with DMA, I'm right?
&#60;/p&#62;</description>
		</item>
		<item>
			<title>gbulmer on "Library ready( (ish) for Maple and colour lcd ILI9163 and HX8353 (128x160)"</title>
			<link>http://forums.leaflabs.com/topic.php?id=74086#post-104996</link>
			<pubDate>Sun, 01 Dec 2013 13:17:59 +0000</pubDate>
			<dc:creator>gbulmer</dc:creator>
			<guid isPermaLink="false">104996@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Magician - &#60;em&#62;&#34;Hope, I can make drawCicle ( which is use a lot of addressing singular pixels ) twice faster, using direct port manipulation instead of digital write.&#34;&#60;/em&#62;&#60;/p&#62;
&#60;p&#62;So are you saying your library uses hardware SPI or digitalWrite?&#60;/p&#62;
&#60;p&#62;If the library is using hardware SPI, and the SPI is running as fast as the display can go, then there is no way to go any faster by using direct GPIO port manipulation.&#60;br /&#62;
Direct GPIO will take 3 writes to GPIO; one to set the data-out-pin and two to toggle the clock-pin, which takes 6 clock cycles. Then probably 2 or 3 cycles to extract the data bit from the byte being written (at best one cycle, but unlikely), and a couple more cycles for looping around (though you could unroll it). So probably 8-12 cycles, no better, and probably worse than 9MHz SPI.&#60;/p&#62;
&#60;p&#62;If you are using digitalWrite(), then have a look at &#60;a href=&#34;http://forums.leaflabs.com/topic.php?id=11844&#34; rel=&#34;nofollow&#34;&#62;http://forums.leaflabs.com/topic.php?id=11844&#60;/a&#62;&#60;br /&#62;
I wrote some example code in a thread which the very helpful tlgosser expanded, tidied up, tested and put on github.&#60;/p&#62;
&#60;p&#62;That code uses a nifty ARM trick (bit band addressing) to write directly to a single pin, and is, maybe, 6x faster than a digitalWrite.&#60;br /&#62;
(I can't remember what the tests indicated, but IIRC digitalWrite was about 0.5us, 36 cycles, and digitalWriteFaster was about 6 cycles, or less if its in a loop that doesn't use lots of registers).&#60;/p&#62;
&#60;p&#62;Another way to go faster is to minimise the use of global variables and volatile, and only use them when it makes sense. The compiler will update volatile and global variables much more than local non-volatile, which can instead be retained in registers.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Magician on "Library ready( (ish) for Maple and colour lcd ILI9163 and HX8353 (128x160)"</title>
			<link>http://forums.leaflabs.com/topic.php?id=74086#post-104995</link>
			<pubDate>Sun, 01 Dec 2013 11:04:01 +0000</pubDate>
			<dc:creator>Magician</dc:creator>
			<guid isPermaLink="false">104995@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Well, I have my ILI9340 working, not too complicate as I initially thought. Adafruit's library code re-written to use HardwareSpi of the maple IDE, I find out display only support 9 and 18 MHz, mode 0 and 3, MSB. First test shows&#60;br /&#62;
              drawRect( 120, 120, 100, 100, ILI9340_YELLOW); - 1.8 millisec&#60;br /&#62;
              drawCircle( 120, 120, 100, ILI9340_YELLOW);    - 30 millisec.&#60;br /&#62;
quite slow.&#60;br /&#62;
 Hope, I can make drawCicle ( which is use a lot of addressing singular pixels ) twice faster, using direct port manipulation instead of digital write.&#60;br /&#62;
 I was wander, if someone have a timing performance for library running on DUE, is it the same ?
&#60;/p&#62;</description>
		</item>
		<item>
			<title>hihohoho on "Library ready( (ish) for Maple and colour lcd ILI9163 and HX8353 (128x160)"</title>
			<link>http://forums.leaflabs.com/topic.php?id=74086#post-104994</link>
			<pubDate>Sat, 30 Nov 2013 20:03:56 +0000</pubDate>
			<dc:creator>hihohoho</dc:creator>
			<guid isPermaLink="false">104994@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;When I get the time I'll post a quick setup().
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Magician on "Library ready( (ish) for Maple and colour lcd ILI9163 and HX8353 (128x160)"</title>
			<link>http://forums.leaflabs.com/topic.php?id=74086#post-104992</link>
			<pubDate>Fri, 29 Nov 2013 23:53:10 +0000</pubDate>
			<dc:creator>Magician</dc:creator>
			<guid isPermaLink="false">104992@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Hi, have you find a way to post a library?&#60;br /&#62;
I'm tweaking adafruit's ILI9340 to make it run on my olimexino, have a lot of questions, would be helpful to get an working example...
&#60;/p&#62;</description>
		</item>
		<item>
			<title>hihohoho on "Library ready( (ish) for Maple and colour lcd ILI9163 and HX8353 (128x160)"</title>
			<link>http://forums.leaflabs.com/topic.php?id=74086#post-104848</link>
			<pubDate>Sat, 02 Nov 2013 07:54:39 +0000</pubDate>
			<dc:creator>hihohoho</dc:creator>
			<guid isPermaLink="false">104848@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Hi all,&#60;/p&#62;
&#60;p&#62;I've recently purchased a small 262k colour lcd module from ebay for about £3. There are lots of them around but drivers are mostly for Arduino. They're designed for 3.3V or 5V and have 8 pins exposed in breadboard friendly format, programmable via SPI, though only 4 maple pins are needed(minimum). The main driver is a HX8353 ic which is ILI9163 compatible.&#60;/p&#62;
&#60;p&#62;It came with some code, but not really Arduino or Maple compatible. There are other Arduino libraries around but most seem to be for specific boards from Adafruit and such and looked a pain to get working, if at all.&#60;/p&#62;
&#60;p&#62;Anyway, after a bit of head scratching I thought it'd be easier (and more fun) to write my own, specifically for the maple. I think it's more suited to the maple rather than Arduino cause of the maples speed.&#60;/p&#62;
&#60;p&#62;( search ebay for 128x160 lcd )&#60;/p&#62;
&#60;p&#62;My question is, can it be uploaded to the Maple wiki? The libraries sections is still looking rather sparse. I've got a small bit of testing to do, and maybe I might add a small 'game' demo, but it should be available in a couple of days.
&#60;/p&#62;</description>
		</item>

	</channel>
</rss>
