Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of UniGraphic by
Revision 4:12ba0ecc2c1f, committed 2015-02-15
- Comitter:
- Geremia
- Date:
- Sun Feb 15 20:06:07 2015 +0000
- Parent:
- 3:48f3282c2be8
- Child:
- 5:b222a9461d6b
- Commit message:
- Added PAR16, separated 16bit writes for cmd parameters and pixeldata
Changed in this revision
--- a/Display/LCD.cpp Sat Feb 14 17:42:21 2015 +0000
+++ b/Display/LCD.cpp Sun Feb 15 20:06:07 2015 +0000
@@ -1,4 +1,10 @@
-/* mbed library for the mbed Lab Board 128*32 pixel LCD
+/* mbed UniGraphic library - universal LCD driver class
+ * Copyright (c) 2015 Giuliano Dianda
+ * Released under the MIT License: http://mbed.org/license/mit
+ *
+ * Derived work of:
+ *
+ * mbed library for the mbed Lab Board 128*32 pixel LCD
* use C12832 controller
* Copyright (c) 2012 Peter Drescher - DC2PD
* Released under the MIT License: http://mbed.org/license/mit
@@ -36,8 +42,8 @@
buffer16 = (unsigned short*)buffer;
draw_mode = NORMAL;
set_orientation(1);
- foreground(Black);
- background(White);
+ foreground(White);
+ background(Black);
set_auto_up(true);
// cls();
// locate(0,0);
@@ -64,8 +70,8 @@
draw_mode = NORMAL;
// cls();
set_orientation(1);
- foreground(Black);
- background(White);
+ foreground(White);
+ background(Black);
set_auto_up(true);
// locate(0,0);
@@ -84,25 +90,17 @@
{
proto->wr_data8(data);
}
-void LCD::wr_data8(unsigned char data, unsigned int count)
- {
- proto->wr_data8(data, count);
- }
-void LCD::wr_data8buf(unsigned char* data, unsigned int lenght)
- {
- proto->wr_data8buf(data, lenght);
- }
void LCD::wr_cmd16(unsigned short cmd)
{
proto->wr_cmd16(cmd);
}
-void LCD::wr_data16(unsigned short data, unsigned int count)
+void LCD::wr_gram(unsigned short data, unsigned int count)
{
- proto->wr_data16(data, count);
+ proto->wr_gram(data, count);
}
-void LCD::wr_data16buf(unsigned short* data, unsigned int lenght)
+void LCD::wr_grambuf(unsigned short* data, unsigned int lenght)
{
- proto->wr_data16buf(data, lenght);
+ proto->wr_grambuf(data, lenght);
}
void LCD::hw_reset()
{
@@ -257,8 +255,8 @@
// if(draw_mode == NORMAL)
// {
- if(color == Black) buffer[(x + ((y>>3)*LCDSIZE_X))^1] &= ~(1 << (y&7)); // erase pixel
- else buffer[(x + ((y>>3)*LCDSIZE_X))^1] |= (1 << (y&7)); // set pixel
+ if(color) buffer[(x + ((y>>3)*LCDSIZE_X))^1] &= ~(1 << (y&7)); // erase pixel
+ else buffer[(x + ((y>>3)*LCDSIZE_X))^1] |= (1 << (y&7)); //Black=0000, set pixel
// }
// else
// { // XOR mode
@@ -275,13 +273,14 @@
// wr_cmd8(0x10|(col_offset>>4)); // set column hi nibble
wr_cmd16(setcolcmd);
wr_cmd8(0xB0|(page+page_offset)); // set page
- wr_data16buf(buffer16+i, LCDSIZE_X>>1); // send whole page pixels
+ wr_grambuf(buffer16+i, LCDSIZE_X>>1); // send whole page pixels
i+=LCDSIZE_X>>1;
}
}
void LCD::cls(void)
{
- memset(buffer,0x00,LCDSIZE_X*LCDPAGES); // clear display buffer
+ unsigned short tmp = _background^0xFFFF;
+ memset(buffer,tmp,LCDSIZE_X*LCDPAGES); // clear display buffer
unsigned short setcolcmd = 0x0010 | ((col_offset&0xF)<<8) | (col_offset>>4);
for(int page=0; page<LCDPAGES; page++)
{
@@ -289,6 +288,6 @@
// wr_cmd8(0x10|(col_offset>>4)); // set column hi nibble
wr_cmd16(setcolcmd);
wr_cmd8(0xB0|(page+page_offset)); // set page
- wr_data16(0, LCDSIZE_X>>1); // send whole page pixels =0
+ wr_gram(tmp, LCDSIZE_X>>1); // send whole page pixels =0
}
}
\ No newline at end of file
--- a/Display/LCD.h Sat Feb 14 17:42:21 2015 +0000
+++ b/Display/LCD.h Sun Feb 15 20:06:07 2015 +0000
@@ -161,22 +161,6 @@
*/
void wr_data8(unsigned char data);
- /** Send same 8bit data to display controller multiple times
- *
- * @param data: byte to send
- * @param count: how many
- *
- */
- void wr_data8(unsigned char data, unsigned int count);
-
- /** Send array of data bytes to display controller
- *
- * @param data: unsigned char data array
- * @param lenght: lenght of array
- *
- */
- void wr_data8buf(unsigned char* data, unsigned int lenght);
-
/** Send 16bit command to display controller
*
* @param cmd: halfword to send
@@ -184,28 +168,21 @@
*/
void wr_cmd16(unsigned short cmd);
- /** Send 16bit data to display controller
- *
- * @param data: halfword to send
- *
- */
- //void wr_data16(unsigned short data);
-
- /** Send same 16bit data to display controller multiple times
+ /** Send same 16bit pixeldata to display controller multiple times
*
* @param data: halfword to send
* @param count: how many
*
*/
- void wr_data16(unsigned short data, unsigned int count);
+ virtual void wr_gram(unsigned short data, unsigned int count);
- /** Send array of data shorts to display controller
+ /** Send array of pixeldata shorts to display controller
*
- * @param data: unsigned short data array
+ * @param data: unsigned short pixeldata array
* @param lenght: lenght (in shorts)
*
*/
- void wr_data16buf(unsigned short* data, unsigned int lenght);
+ virtual void wr_grambuf(unsigned short* data, unsigned int lenght);
/** HW reset sequence (without display init commands)
*/
--- a/Display/TFT.cpp Sat Feb 14 17:42:21 2015 +0000
+++ b/Display/TFT.cpp Sun Feb 15 20:06:07 2015 +0000
@@ -1,4 +1,10 @@
-/* mbed library for 240*320 pixel display TFT based on ILI9341 LCD Controller
+ /* mbed UniGraphic library - universal TFT driver class
+ * Copyright (c) 2015 Giuliano Dianda
+ * Released under the MIT License: http://mbed.org/license/mit
+ *
+ * Derived work of:
+ *
+ * mbed library for 240*320 pixel display TFT based on ILI9341 LCD Controller
* Copyright (c) 2013 Peter Drescher - DC2PD
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
@@ -20,12 +26,14 @@
: GraphicsDisplay(name), LCDSIZE_X(lcdsize_x), LCDSIZE_Y(lcdsize_y)
{
if(displayproto==PAR_8) proto = new PAR8(port, CS, reset, DC, WR, RD);
+ else if(displayproto==PAR_16) proto = new PAR16(port, CS, reset, DC, WR, RD);
useNOP=false;
+ scrollbugfix=0;
+ mipistd=false;
set_orientation(0);
foreground(White);
background(Black);
set_auto_up(false); //we don't have framebuffer
- mipistd=false;
// cls();
// locate(0,0);
}
@@ -42,12 +50,12 @@
proto = new SPI16(Hz, mosi, miso, sclk, CS, reset, DC);
useNOP=true;
}
- // cls();
+ scrollbugfix=0;
+ mipistd=false;
set_orientation(0);
foreground(White);
background(Black);
set_auto_up(false);
- mipistd=false;
// locate(0,0);
}
void TFT::wr_cmd8(unsigned char cmd)
@@ -59,29 +67,34 @@
{
proto->wr_data8(data);
}
-void TFT::wr_data8(unsigned char data, unsigned int count)
- {
- proto->wr_data8(data, count);
- }
-void TFT::wr_data8buf(unsigned char* data, unsigned int lenght)
- {
- proto->wr_data8buf(data, lenght);
- }
-void TFT::wr_cmd16(unsigned short cmd)
- {
- proto->wr_cmd16(cmd);
- }
void TFT::wr_data16(unsigned short data)
{
proto->wr_data16(data);
}
-void TFT::wr_data16(unsigned short data, unsigned int count)
+void TFT::wr_gram(unsigned short data)
+ {
+ proto->wr_gram(data);
+ }
+void TFT::wr_gram(unsigned short data, unsigned int count)
{
- proto->wr_data16(data, count);
+ proto->wr_gram(data, count);
+ }
+void TFT::wr_grambuf(unsigned short* data, unsigned int lenght)
+ {
+ proto->wr_grambuf(data, lenght);
}
-void TFT::wr_data16buf(unsigned short* data, unsigned int lenght)
+//for TFT, just send data, position counters are in hw
+void TFT::window_pushpixel(unsigned short color)
+{
+ proto->wr_gram(color);
+}
+void TFT::window_pushpixel(unsigned short color, unsigned int count)
+{
+ proto->wr_gram(color, count);
+}
+void TFT::window_pushpixelbuf(unsigned short* color, unsigned int lenght)
{
- proto->wr_data16buf(data, lenght);
+ proto->wr_grambuf(color, lenght);
}
void TFT::hw_reset()
{
@@ -139,29 +152,16 @@
wr_cmd8(0x2C); //write mem, just send pixels color next
}
-//for TFT, just send data, position counters are in hw
-void TFT::window_pushpixel(unsigned short color)
-{
- proto->wr_data16(color);
-}
-void TFT::window_pushpixel(unsigned short color, unsigned int count)
-{
- proto->wr_data16(color, count);
-}
-void TFT::window_pushpixelbuf(unsigned short* color, unsigned int lenght)
- {
- proto->wr_data16buf(color, lenght);
- }
void TFT::pixel(int x, int y, unsigned short color)
{
window(x,y,1,1);
- wr_data16(color); // 2C expects 16bit parameters
- //proto->wr_data16(color);
+ // proto->wr_gram(color); // 2C expects 16bit parameters
+ wr_gram(color);
}
void TFT::cls (void)
{
WindowMax();
- // wr_data16(_background,pixels);
- wr_data16(0,LCDSIZE_X*LCDSIZE_Y);
- //proto->wr_data16(_background,pixels);
+ // proto->wr_gram(_background,LCDSIZE_X*LCDSIZE_Y);
+ // proto->wr_gram(0,LCDSIZE_X*LCDSIZE_Y);
+ wr_gram(_background,LCDSIZE_X*LCDSIZE_Y);
}
\ No newline at end of file
--- a/Display/TFT.h Sat Feb 14 17:42:21 2015 +0000
+++ b/Display/TFT.h Sun Feb 15 20:06:07 2015 +0000
@@ -3,6 +3,7 @@
#include "GraphicsDisplay.h"
#include "PAR8.h"
+#include "PAR16.h"
#include "SPI8.h"
#include "SPI16.h"
#include "Protocols.h"
@@ -123,56 +124,42 @@
*/
void wr_data8(unsigned char data);
- /** Send same 8bit data to display controller multiple times
- *
- * @param data: byte to send
- * @param count: how many
- *
- */
- void wr_data8(unsigned char data, unsigned int count);
-
- /** Send array of data bytes to display controller
- *
- * @param data: unsigned char data array
- * @param lenght: lenght of array
- *
- */
- void wr_data8buf(unsigned char* data, unsigned int lenght);
-
- /** Send 16bit command to display controller
- *
- * @param cmd: halfword to send
- *
- */
- void wr_cmd16(unsigned short cmd);
-
- /** Send 16bit data to display controller
+ /** Send 2x8bit data to display controller
*
* @param data: halfword to send
*
*/
void wr_data16(unsigned short data);
- /** Send same 16bit data to display controller multiple times
+ /** Send 16bit pixeldata to display controller
+ *
+ * @param data: halfword to send
+ *
+ */
+ virtual void wr_gram(unsigned short data);
+
+ /** Send same 16bit pixeldata to display controller multiple times
*
* @param data: halfword to send
* @param count: how many
*
*/
- void wr_data16(unsigned short data, unsigned int count);
+ virtual void wr_gram(unsigned short data, unsigned int count);
- /** Send array of data shorts to display controller
+ /** Send array of pixeldata shorts to display controller
*
- * @param data: unsigned short data array
+ * @param data: unsigned short pixeldata array
* @param lenght: lenght (in shorts)
*
*/
- void wr_data16buf(unsigned short* data, unsigned int lenght);
+ virtual void wr_grambuf(unsigned short* data, unsigned int lenght);
/** HW reset sequence (without display init commands)
*/
void hw_reset();
-
+
+ unsigned int scrollbugfix;
+ bool mipistd;
private:
@@ -196,7 +183,6 @@
int win_y2;
int orientation;
unsigned int tftID;
- bool mipistd;
bool useNOP;
};
--- a/Graphics/GraphicsDisplay.cpp Sat Feb 14 17:42:21 2015 +0000
+++ b/Graphics/GraphicsDisplay.cpp Sun Feb 15 20:06:07 2015 +0000
@@ -1,5 +1,14 @@
-
- /* mbed library for 240*320 pixel display TFT based on ILI9341 LCD Controller
+/* mbed UniGraphic library - Graphics class
+ * Copyright (c) 2015 Giuliano Dianda
+ * Released under the MIT License: http://mbed.org/license/mit
+ *
+ * Derived work of:
+ *
+ * mbed GraphicsDisplay Display Library Base Class
+ * Copyright (c) 2007-2009 sford
+ * Released under the MIT License: http://mbed.org/license/mit
+ *
+ * mbed library for 240*320 pixel display TFT based on ILI9341 LCD Controller
* Copyright (c) 2013 Peter Drescher - DC2PD
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
@@ -11,10 +20,7 @@
* THE SOFTWARE.
*/
- /* mbed GraphicsDisplay Display Library Base Class
- * Copyright (c) 2007-2009 sford
- * Released under the MIT License: http://mbed.org/license/mit
- */
+
#include "GraphicsDisplay.h"
#define SWAP(a, b) { a ^= b; b ^= a; a ^= b; }
--- a/Graphics/TextDisplay.h Sat Feb 14 17:42:21 2015 +0000
+++ b/Graphics/TextDisplay.h Sun Feb 15 20:06:07 2015 +0000
@@ -98,8 +98,8 @@
int _row;
// colours
- uint16_t _foreground;
- uint16_t _background;
+ volatile uint16_t _foreground;
+ volatile uint16_t _background;
char *_path;
};
--- a/Inits/ILI9341.cpp Sat Feb 14 17:42:21 2015 +0000
+++ b/Inits/ILI9341.cpp Sun Feb 15 20:06:07 2015 +0000
@@ -1,3 +1,8 @@
+ /* mbed UniGraphic library - Device specific class
+ * Copyright (c) 2015 Giuliano Dianda
+ * Released under the MIT License: http://mbed.org/license/mit
+ */
+
#include "Protocols.h"
#include "ILI9341.h"
@@ -16,8 +21,9 @@
hw_reset();
BusEnable(true);
init();
+ mipistd=false;
+ set_orientation(0);
cls();
- set_orientation(0);
locate(0,0);
}
ILI9341::ILI9341(proto_t displayproto, int Hz, PinName mosi, PinName miso, PinName sclk, PinName CS, PinName reset, PinName DC, const char *name)
@@ -26,8 +32,9 @@
hw_reset(); //TFT class forwards to Protocol class
BusEnable(true); //TFT class forwards to Protocol class
init(); // per display custom init cmd sequence, implemented here
+ mipistd=false;
+ set_orientation(0); //TFT class does for MIPI standard and some ILIxxx
cls();
- set_orientation(1); //TFT class does for MIPI standard and some ILIxxx
locate(0,0);
}
// reset and init the lcd controller
@@ -78,11 +85,7 @@
wr_cmd8(0xC7); // VCOM_CONTROL_2
wr_data8(0x86); // AN A7, was BE
- wr_cmd8(0x36); // MEMORY_ACCESS_CONTROL
- wr_data8(0x48);
- wr_cmd8(0x3A); // COLMOD_PIXEL_FORMAT_SET, not present in AN
- wr_data8(0x55); // 16 bit pixel
wr_cmd8(0xB1); // Frame Rate
wr_data8(0x00);
@@ -140,13 +143,19 @@
// wr_cmd8(0xB7); // ENTRY_MODE_SET
// wr_data8(0x07);
-
+
+ wr_cmd8(0x36); // MEMORY_ACCESS_CONTROL (orientation stuff)
+ wr_data8(0x48);
+
+ wr_cmd8(0x3A); // COLMOD_PIXEL_FORMAT_SET
+ wr_data8(0x55); // 16 bit pixel
+
+ wr_cmd8(0x13); // Nomal Displaymode
+
wr_cmd8(0x11); // sleep out
-
wait_ms(150);
wr_cmd8(0x29); // display on
-
wait_ms(150);
}
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Inits/ILI9486.cpp Sun Feb 15 20:06:07 2015 +0000
@@ -0,0 +1,150 @@
+ /* mbed UniGraphic library - Device specific class
+ * Copyright (c) 2015 Giuliano Dianda
+ * Released under the MIT License: http://mbed.org/license/mit
+ */
+#include "Protocols.h"
+#include "ILI9486.h"
+
+//////////////////////////////////////////////////////////////////////////////////
+// display settings ///////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////
+
+#define LCDSIZE_X 320 // display X pixels, TFTs are usually portrait view
+#define LCDSIZE_Y 480 // display Y pixels
+
+
+
+ILI9486::ILI9486(proto_t displayproto, PortName port, PinName CS, PinName reset, PinName DC, PinName WR, PinName RD, const char *name)
+ : TFT(displayproto, port, CS, reset, DC, WR, RD, LCDSIZE_X, LCDSIZE_Y, name)
+{
+ hw_reset();
+ BusEnable(true);
+ init();
+ mipistd=false;
+ scrollbugfix=1; // when scrolling 1 line, the last line disappears, set to 1 to fix it
+ set_orientation(0);
+ cls();
+ locate(0,0);
+}
+ILI9486::ILI9486(proto_t displayproto, int Hz, PinName mosi, PinName miso, PinName sclk, PinName CS, PinName reset, PinName DC, const char *name)
+ : TFT(displayproto, Hz, mosi, miso, sclk, CS, reset, DC, LCDSIZE_X, LCDSIZE_Y, name)
+{
+ hw_reset(); //TFT class forwards to Protocol class
+ BusEnable(true); //TFT class forwards to Protocol class
+ init(); // per display custom init cmd sequence, implemented here
+ mipistd=false;
+ scrollbugfix=1; // when scrolling 1 line, the last line disappears, set to 1 to fix it
+ set_orientation(0); //TFT class does for MIPI standard and some ILIxxx
+ cls();
+ locate(0,0);
+}
+// reset and init the lcd controller
+void ILI9486::init()
+{
+ /* Start Initial Sequence ----------------------------------------------------*/
+
+ wr_cmd8(0xF1);
+ wr_data8(0x36);
+ wr_data8(0x04);
+ wr_data8(0x00);
+ wr_data8(0x3C);
+ wr_data8(0x0F);
+ wr_data8(0x8F);
+
+
+ wr_cmd8(0xF2);
+ wr_data8(0x18);
+ wr_data8(0xA3);
+ wr_data8(0x12);
+ wr_data8(0x02);
+ wr_data8(0xb2);
+ wr_data8(0x12);
+ wr_data8(0xFF);
+ wr_data8(0x10);
+ wr_data8(0x00);
+
+ wr_cmd8(0xF8);
+ wr_data8(0x21);
+ wr_data8(0x04);
+
+ wr_cmd8(0xF9);
+ wr_data8(0x00);
+ wr_data8(0x08);
+
+ wr_cmd8(0xC0);
+ wr_data8(0x0f); //13
+ wr_data8(0x0f); //10
+
+ wr_cmd8(0xC1);
+ wr_data8(0x42); //43
+
+ wr_cmd8(0xC2);
+ wr_data8(0x22);
+
+ wr_cmd8(0xC5);
+ wr_data8(0x01); //00
+ wr_data8(0x29); //4D
+ wr_data8(0x80);
+
+ wr_cmd8(0xB6);
+ wr_data8(0x00);
+ wr_data8(0x02); //42
+ wr_data8(0x3b);
+
+ wr_cmd8(0xB1);
+ wr_data8(0xB0); //C0
+ wr_data8(0x11);
+
+ wr_cmd8(0xB4);
+ wr_data8(0x02); //01
+
+ wr_cmd8(0xE0);
+ wr_data8(0x0F);
+ wr_data8(0x18);
+ wr_data8(0x15);
+ wr_data8(0x09);
+ wr_data8(0x0B);
+ wr_data8(0x04);
+ wr_data8(0x49);
+ wr_data8(0x64);
+ wr_data8(0x3D);
+ wr_data8(0x08);
+ wr_data8(0x15);
+ wr_data8(0x06);
+ wr_data8(0x12);
+ wr_data8(0x07);
+ wr_data8(0x00);
+
+ wr_cmd8(0xE1);
+ wr_data8(0x0F);
+ wr_data8(0x38);
+ wr_data8(0x35);
+ wr_data8(0x0a);
+ wr_data8(0x0c);
+ wr_data8(0x03);
+ wr_data8(0x4A);
+ wr_data8(0x42);
+ wr_data8(0x36);
+ wr_data8(0x04);
+ wr_data8(0x0F);
+ wr_data8(0x03);
+ wr_data8(0x1F);
+ wr_data8(0x1B);
+ wr_data8(0x00);
+
+ wr_cmd8(0x20); // display inversion OFF
+
+ wr_cmd8(0x36); // MEMORY_ACCESS_CONTROL (orientation stuff)
+ wr_data8(0x48);
+
+ wr_cmd8(0x3A); // COLMOD_PIXEL_FORMAT_SET
+ wr_data8(0x55); // 16 bit pixel
+
+ wr_cmd8(0x13); // Nomal Displaymode
+
+ wr_cmd8(0x11); // sleep out
+ wait_ms(150);
+
+ wr_cmd8(0x29); // display on
+ wait_ms(150);
+}
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Inits/ILI9486.h Sun Feb 15 20:06:07 2015 +0000
@@ -0,0 +1,54 @@
+#ifndef MBED_ILI9486_H
+#define MBED_ILI9486_H
+
+
+
+#include "mbed.h"
+#include "TFT.h"
+
+/** Class for ILI9486 tft display controller
+* to be copypasted and adapted for other controllers
+*/
+class ILI9486 : public TFT
+{
+
+ public:
+
+ /** Create a PAR display interface
+ * @param displayproto only supports PAR_8
+ * @param port GPIO port name to use
+ * @param CS pin connected to CS of display
+ * @param reset pin connected to RESET of display
+ * @param DC pin connected to data/command of display
+ * @param WR pin connected to SDI of display
+ * @param RD pin connected to RS of display
+ * @param name The name used by the parent class to access the interface
+ */
+ ILI9486(proto_t displayproto, PortName port, PinName CS, PinName reset, PinName DC, PinName WR, PinName RD, const char* name);
+
+ /** Create an SPI display interface
+ * @param displayproto only supports SPI_8
+ * @param Hz SPI speed in Hz
+ * @param mosi SPI pin
+ * @param miso SPI pin
+ * @param sclk SPI pin
+ * @param CS pin connected to CS of display
+ * @param reset pin connected to RESET of display
+ * @param DC pin connected to data/command of display
+ * @param name The name used by the parent class to access the interface
+ */
+ ILI9486(proto_t displayproto, int Hz, PinName mosi, PinName miso, PinName sclk, PinName CS, PinName reset, PinName DC, const char* name);
+
+
+
+protected:
+
+
+ /** Init command sequence
+ */
+ void init();
+
+
+
+};
+#endif
\ No newline at end of file
--- a/Inits/IST3020.cpp Sat Feb 14 17:42:21 2015 +0000 +++ b/Inits/IST3020.cpp Sun Feb 15 20:06:07 2015 +0000 @@ -1,3 +1,7 @@ + /* mbed UniGraphic library - Device specific class + * Copyright (c) 2015 Giuliano Dianda + * Released under the MIT License: http://mbed.org/license/mit + */ #include "Protocols.h" #include "IST3020.h"
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Inits/TFT_MIPI.cpp Sun Feb 15 20:06:07 2015 +0000
@@ -0,0 +1,102 @@
+ /* mbed UniGraphic library - Device specific class
+ * Copyright (c) 2015 Giuliano Dianda
+ * Released under the MIT License: http://mbed.org/license/mit
+ */
+#include "Protocols.h"
+#include "TFT_MIPI.h"
+
+//////////////////////////////////////////////////////////////////////////////////
+// display settings ///////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////
+
+#define LCDSIZE_X 320 // display X pixels, TFTs are usually portrait view
+#define LCDSIZE_Y 480 // display Y pixels
+
+
+
+TFT_MIPI::TFT_MIPI(proto_t displayproto, PortName port, PinName CS, PinName reset, PinName DC, PinName WR, PinName RD, const char *name)
+ : TFT(displayproto, port, CS, reset, DC, WR, RD, LCDSIZE_X, LCDSIZE_Y, name)
+{
+ hw_reset();
+ BusEnable(true);
+ init();
+ mipistd=true;
+ set_orientation(0);
+ cls();
+ locate(0,0);
+}
+TFT_MIPI::TFT_MIPI(proto_t displayproto, int Hz, PinName mosi, PinName miso, PinName sclk, PinName CS, PinName reset, PinName DC, const char *name)
+ : TFT(displayproto, Hz, mosi, miso, sclk, CS, reset, DC, LCDSIZE_X, LCDSIZE_Y, name)
+{
+ hw_reset(); //TFT class forwards to Protocol class
+ BusEnable(true); //TFT class forwards to Protocol class
+ init(); // per display custom init cmd sequence, implemented here
+ mipistd=true;
+ set_orientation(0); //TFT class does for MIPI standard and some ILIxxx
+ cls();
+ locate(0,0);
+}
+// reset and init the lcd controller
+void TFT_MIPI::init()
+{
+ /* Start Initial Sequence ----------------------------------------------------*/
+
+ /* Start Initial Sequence ----------------------------------------------------*/
+ wr_cmd8(0xD0); // POWER SETTING
+ wr_data8(0x07);
+ wr_data8(0x42);
+ wr_data8(0x18);
+
+ wr_cmd8(0xD1); // VCOM control
+ wr_data8(0x00);
+ wr_data8(0x07);
+ wr_data8(0x10);
+
+ wr_cmd8(0xD2); // Power_Setting for Normal Mode
+ wr_data8(0x01); // LCD power supply current
+ wr_data8(0x02); // charge pumps
+
+ wr_cmd8(0xC0); // Panel Driving Setting
+ wr_data8(0x10); // 10 orig
+ wr_data8(0x3B); //number of lines+1 *8
+ wr_data8(0x00);
+ wr_data8(0x02);
+ wr_data8(0x11);
+
+ // C1 missing? Display_Timing_Setting for Normal Mode
+
+ //renesas does not have this
+ // wr_cmd8(0xC5); // Frame Rate and Inversion Control
+ // wr_data8(0x03); // 72hz, datashet tells default 02=85hz
+
+ wr_cmd8(0xC8); // Gamma settings
+ wr_data8(0x00);
+ wr_data8(0x32);
+ wr_data8(0x36);
+ wr_data8(0x45);
+ wr_data8(0x06);
+ wr_data8(0x16);
+ wr_data8(0x37);
+ wr_data8(0x75);
+ wr_data8(0x77);
+ wr_data8(0x54);
+ wr_data8(0x0C);
+ wr_data8(0x00);
+
+
+
+ wr_cmd8(0x36); // MEMORY_ACCESS_CONTROL (orientation stuff)
+ wr_data8(0x0A); // 0A as per chinese example (vertical flipped)
+
+ wr_cmd8(0x3A); // COLMOD_PIXEL_FORMAT_SET, not present in AN
+ wr_data8(0x55); // 16 bit pixel
+
+ wr_cmd8(0x13); // Nomal Displaymode
+
+ wr_cmd8(0x11); // sleep out
+ wait_ms(150);
+
+ wr_cmd8(0x29); // display on
+ wait_ms(150);
+
+}
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Inits/TFT_MIPI.h Sun Feb 15 20:06:07 2015 +0000
@@ -0,0 +1,55 @@
+#ifndef MBED_TFT_MIPI_H
+#define MBED_TFT_MIPI_H
+
+
+
+#include "mbed.h"
+#include "TFT.h"
+
+/** Class for (quite)standard MIPI-DBI TypeB (parallel) and TypeC (spi) TFT display controller
+* for Ilitek ILI9481, Renesas R61581, Raydium RM68042
+* to be copypasted and adapted for other controllers
+*/
+class TFT_MIPI : public TFT
+{
+
+ public:
+
+ /** Create a PAR display interface
+ * @param displayproto only supports PAR_8
+ * @param port GPIO port name to use
+ * @param CS pin connected to CS of display
+ * @param reset pin connected to RESET of display
+ * @param DC pin connected to data/command of display
+ * @param WR pin connected to SDI of display
+ * @param RD pin connected to RS of display
+ * @param name The name used by the parent class to access the interface
+ */
+ TFT_MIPI(proto_t displayproto, PortName port, PinName CS, PinName reset, PinName DC, PinName WR, PinName RD, const char* name);
+
+ /** Create an SPI display interface
+ * @param displayproto only supports SPI_8
+ * @param Hz SPI speed in Hz
+ * @param mosi SPI pin
+ * @param miso SPI pin
+ * @param sclk SPI pin
+ * @param CS pin connected to CS of display
+ * @param reset pin connected to RESET of display
+ * @param DC pin connected to data/command of display
+ * @param name The name used by the parent class to access the interface
+ */
+ TFT_MIPI(proto_t displayproto, int Hz, PinName mosi, PinName miso, PinName sclk, PinName CS, PinName reset, PinName DC, const char* name);
+
+
+
+protected:
+
+
+ /** Init command sequence
+ */
+ void init();
+
+
+
+};
+#endif
\ No newline at end of file
--- a/Inits/UC1608.cpp Sat Feb 14 17:42:21 2015 +0000 +++ b/Inits/UC1608.cpp Sun Feb 15 20:06:07 2015 +0000 @@ -1,3 +1,7 @@ + /* mbed UniGraphic library - Device specific class + * Copyright (c) 2015 Giuliano Dianda + * Released under the MIT License: http://mbed.org/license/mit + */ #include "Protocols.h" #include "UC1608.h"
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Protocols/PAR16.cpp Sun Feb 15 20:06:07 2015 +0000
@@ -0,0 +1,172 @@
+ /* mbed UniGraphic library - PAR16 protocol class
+ * Copyright (c) 2015 Giuliano Dianda
+ * Released under the MIT License: http://mbed.org/license/mit
+ *
+ * Derived work of:
+ *
+ * mbed library for 240*320 pixel display TFT based on ILI9341 LCD Controller
+ * Copyright (c) 2013 Peter Drescher - DC2PD
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+#include "PAR16.h"
+
+PAR16::PAR16(PortName port, PinName CS, PinName reset, PinName DC, PinName WR, PinName RD)
+ : _port(port,0xFFFF), _CS(CS), _reset(reset), _DC(DC), _WR(WR), _RD(RD)
+{
+ _reset = 1;
+ _DC=1;
+ _WR=1;
+ _RD=1;
+ _CS=1;
+#ifdef STMPORTDEBUG
+ findport(port); //on return, GPIO get disabled
+#endif
+ _port.mode(PullNone);
+ _port.output(); // will re-enable our GPIO port
+ hw_reset();
+}
+
+#ifdef STMPORTDEBUG
+// create a port obj with STM HAL drivers, just to collect memorymapped regs
+void PAR16::findport(PortName port)
+{
+ port_t tempport;
+ port_init(&tempport, port, 0xFF, PIN_INPUT);
+ outreg = tempport.reg_out;
+ inreg = tempport.reg_in;
+ // debug("out 0x%.8X in 0x%.8X\r\n", outreg, inreg);
+}
+#endif
+void PAR16::wr_cmd8(unsigned char cmd)
+{
+#ifdef USE_CS
+ _CS = 0;
+#endif
+ _DC = 0; // 0=cmd
+ _port.write(cmd); // write 8bit
+ _WR=0;
+ _WR=1;
+#ifdef USE_CS
+ _CS = 1;
+#endif
+}
+void PAR16::wr_data8(unsigned char data)
+{
+#ifdef USE_CS
+ _CS = 0;
+#endif
+ _DC = 1; // 1=data
+ _port.write(data); // write 8bit
+ _WR=0;
+ _WR=1;
+#ifdef USE_CS
+ _CS = 1;
+#endif
+}
+void PAR16::wr_cmd16(unsigned short cmd)
+{
+#ifdef USE_CS
+ _CS = 0;
+#endif
+ _DC = 0; // 0=cmd
+ _port.write(cmd>>8); // write 8bit
+ _WR=0;
+ _WR=1;
+ _port.write(cmd&0xFF); // write 8bit
+ _WR=0;
+ _WR=1;
+#ifdef USE_CS
+ _CS = 1;
+#endif
+}
+void PAR16::wr_data16(unsigned short data)
+{
+#ifdef USE_CS
+ _CS = 0;
+#endif
+ _DC = 1; // 1=data
+ _port.write(data>>8); // write 8bit
+ _WR=0;
+ _WR=1;
+ _port.write(data&0xFF); // write 8bit
+ _WR=0;
+ _WR=1;
+#ifdef USE_CS
+ _CS = 1;
+#endif
+}
+void PAR16::wr_gram(unsigned short data)
+{
+#ifdef USE_CS
+ _CS = 0;
+#endif
+ _DC = 1; // 1=data
+ _port.write(data); // write 16bit
+ _WR=0;
+ _WR=1;
+#ifdef USE_CS
+ _CS = 1;
+#endif
+}
+void PAR16::wr_gram(unsigned short data, unsigned int count)
+{
+#ifdef USE_CS
+ _CS = 0;
+#endif
+ _DC = 1; // 1=data
+ while(count)
+ {
+ _port.write(data); // write 16bit
+ _WR=0;
+ _WR=1;
+ count--;
+ }
+#ifdef USE_CS
+ _CS = 1;
+#endif
+}
+void PAR16::wr_grambuf(unsigned short* data, unsigned int lenght)
+{
+#ifdef USE_CS
+ _CS = 0;
+#endif
+ _DC = 1; // 1=data
+ while(lenght)
+ {
+ _port.write(*data); // write 16bit
+ _WR=0;
+ _WR=1;
+ data++;
+ lenght--;
+ }
+#ifdef USE_CS
+ _CS = 1;
+#endif
+}
+
+void PAR16::hw_reset()
+{
+ wait_ms(15);
+ _DC = 1;
+ _CS = 1;
+ _WR = 1;
+ _RD = 1;
+ _reset = 0; // display reset
+ wait_us(50);
+ _reset = 1; // end reset
+ wait_ms(15);
+#ifndef USE_CS
+ _CS=0; // put CS low now and forever
+#endif
+}
+void PAR16::BusEnable(bool enable)
+{
+ _CS = enable ? 0:1;
+}
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Protocols/PAR16.h Sun Feb 15 20:06:07 2015 +0000
@@ -0,0 +1,97 @@
+#ifndef PAR16_H
+#define PAR16_H
+
+#include "mbed.h"
+#include "Protocols.h"
+//#include "GraphicsDisplay.h"
+
+class PAR16 : public Protocols
+{
+ public:
+
+ /** Create a PAR16 display interface with a GPIO port and 5 control pins
+ *
+ * @param port GPIO port to use
+ * @param CS pin connected to CS of display
+ * @param reset pin connected to RESET of display
+ * @param DC pin connected to data/command of display
+ * @param WR pin connected to SDI of display
+ * @param RD pin connected to RS of display
+ */
+ PAR16(PortName port, PinName CS, PinName reset, PinName DC, PinName WR, PinName RD);
+
+protected:
+
+ /** Send 8bit command to display controller
+ *
+ * @param cmd: byte to send
+ *
+ */
+ virtual void wr_cmd8(unsigned char cmd);
+
+ /** Send 8bit data to display controller
+ *
+ * @param data: byte to send
+ *
+ */
+ virtual void wr_data8(unsigned char data);
+
+ /** Send 2x8bit command to display controller
+ *
+ * @param cmd: halfword to send
+ * @note 2cycles using pins[7:0]
+ */
+ virtual void wr_cmd16(unsigned short cmd);
+
+ /** Send 2x8bit data to display controller
+ *
+ * @param data: halfword to send
+ * @note 2cycles using pins[7:0], only gram write cmd uses pins[15:8]
+ */
+ virtual void wr_data16(unsigned short data);
+
+ /** Send 16bit pixeldata to display controller
+ *
+ * @param data: halfword to send
+ * @note here using all pins[15:0]
+ */
+ virtual void wr_gram(unsigned short data);
+
+ /** Send same 16bit pixeldata to display controller multiple times
+ *
+ * @param data: halfword to send
+ * @param count: how many
+ * @note here using all pins[15:0]
+ */
+ virtual void wr_gram(unsigned short data, unsigned int count);
+
+ /** Send array of pixeldata shorts to display controller
+ *
+ * @param data: unsigned short pixeldata array
+ * @param lenght: lenght (in shorts)
+ * @note here using all pins[15:0]
+ */
+ virtual void wr_grambuf(unsigned short* data, unsigned int lenght);
+
+ /** HW reset sequence (without display init commands)
+ */
+ virtual void hw_reset();
+
+ /** Set ChipSelect high or low
+ * @param enable 0/1
+ */
+ virtual void BusEnable(bool enable);
+
+
+
+private:
+
+ PortInOut _port;
+ DigitalOut _CS;
+ DigitalOut _reset;
+ DigitalOut _DC;
+ DigitalOut _WR;
+ DigitalOut _RD;
+
+};
+#endif
\ No newline at end of file
--- a/Protocols/PAR8.cpp Sat Feb 14 17:42:21 2015 +0000
+++ b/Protocols/PAR8.cpp Sun Feb 15 20:06:07 2015 +0000
@@ -1,3 +1,21 @@
+ /* mbed UniGraphic library - PAR8 protocol class
+ * Copyright (c) 2015 Giuliano Dianda
+ * Released under the MIT License: http://mbed.org/license/mit
+ *
+ * Derived work of:
+ *
+ * mbed library for 240*320 pixel display TFT based on ILI9341 LCD Controller
+ * Copyright (c) 2013 Peter Drescher - DC2PD
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
#include "PAR8.h"
PAR8::PAR8(PortName port, PinName CS, PinName reset, PinName DC, PinName WR, PinName RD)
@@ -53,41 +71,6 @@
_CS = 1;
#endif
}
-void PAR8::wr_data8(unsigned char data, unsigned int count)
-{
-#ifdef USE_CS
- _CS = 0;
-#endif
- _DC = 1; // 1=data
- _port.write(data); // write 8bit
- while(count)
- {
- _WR=0;
- // _WR=0;
- _WR=1;
- count--;
- }
-#ifdef USE_CS
- _CS = 1;
-#endif
-}
-void PAR8::wr_data8buf(unsigned char* data, unsigned int lenght)
-{
-#ifdef USE_CS
- _CS = 0;
-#endif
- _DC = 1; // 1=data
- while(lenght)
- {
- _WR=0;
- _port.write(*data++); // write 8bit
- _WR=1;
- lenght--;
- }
-#ifdef USE_CS
- _CS = 1;
-#endif
-}
void PAR8::wr_cmd16(unsigned short cmd)
{
#ifdef USE_CS
@@ -120,7 +103,23 @@
_CS = 1;
#endif
}
-void PAR8::wr_data16(unsigned short data, unsigned int count)
+void PAR8::wr_gram(unsigned short data)
+{
+#ifdef USE_CS
+ _CS = 0;
+#endif
+ _DC = 1; // 1=data
+ _WR=0;
+ _port.write(data>>8); // write 8bit
+ _WR=1;
+ _WR=0;
+ _port.write(data&0xFF); // write 8bit
+ _WR=1;
+#ifdef USE_CS
+ _CS = 1;
+#endif
+}
+void PAR8::wr_gram(unsigned short data, unsigned int count)
{
#ifdef USE_CS
_CS = 0;
@@ -154,7 +153,7 @@
_CS = 1;
#endif
}
-void PAR8::wr_data16buf(unsigned short* data, unsigned int lenght)
+void PAR8::wr_grambuf(unsigned short* data, unsigned int lenght)
{
#ifdef USE_CS
_CS = 0;
@@ -175,6 +174,7 @@
_CS = 1;
#endif
}
+
void PAR8::hw_reset()
{
wait_ms(15);
--- a/Protocols/PAR8.h Sat Feb 14 17:42:21 2015 +0000
+++ b/Protocols/PAR8.h Sun Feb 15 20:06:07 2015 +0000
@@ -36,51 +36,42 @@
*/
virtual void wr_data8(unsigned char data);
- /** Send same 8bit data to display controller multiple times
- *
- * @param data: byte to send
- * @param count: how many
- *
- */
- virtual void wr_data8(unsigned char data, unsigned int count);
-
- /** Send array of data bytes to display controller
- *
- * @param data: unsigned char data array
- * @param lenght: lenght of array
- *
- */
- virtual void wr_data8buf(unsigned char* data, unsigned int lenght);
-
- /** Send 16bit command to display controller
+ /** Send 2x8bit command to display controller
*
* @param cmd: halfword to send
*
*/
virtual void wr_cmd16(unsigned short cmd);
- /** Send 16bit data to display controller
+ /** Send 2x8bit data to display controller
*
* @param data: halfword to send
*
*/
virtual void wr_data16(unsigned short data);
- /** Send same 16bit data to display controller multiple times
+ /** Send 16bit pixeldata to display controller
+ *
+ * @param data: halfword to send
+ *
+ */
+ virtual void wr_gram(unsigned short data);
+
+ /** Send same 16bit pixeldata to display controller multiple times
*
* @param data: halfword to send
* @param count: how many
*
*/
- virtual void wr_data16(unsigned short data, unsigned int count);
+ virtual void wr_gram(unsigned short data, unsigned int count);
- /** Send array of data shorts to display controller
+ /** Send array of pixeldata shorts to display controller
*
- * @param data: unsigned short data array
+ * @param data: unsigned short pixeldata array
* @param lenght: lenght (in shorts)
*
*/
- virtual void wr_data16buf(unsigned short* data, unsigned int lenght);
+ virtual void wr_grambuf(unsigned short* data, unsigned int lenght);
/** HW reset sequence (without display init commands)
*/
--- a/Protocols/Protocols.h Sat Feb 14 17:42:21 2015 +0000
+++ b/Protocols/Protocols.h Sun Feb 15 20:06:07 2015 +0000
@@ -1,3 +1,8 @@
+ /* mbed UniGraphic library - Abstract protocol class
+ * Copyright (c) 2015 Giuliano Dianda
+ * Released under the MIT License: http://mbed.org/license/mit
+ */
+
/** @file Protocols.h
*/
#ifndef Protocols_H
@@ -37,51 +42,42 @@
*/
virtual void wr_data8(unsigned char data) = 0;
- /** Send same 8bit data to display controller multiple times
- *
- * @param data: byte to send
- * @param count: how many
- *
- */
- virtual void wr_data8(unsigned char data, unsigned int count) = 0;
-
- /** Send array of data bytes to display controller
- *
- * @param data: unsigned char data array
- * @param lenght: lenght
- *
- */
- virtual void wr_data8buf(unsigned char* data, unsigned int lenght) = 0;
-
- /** Send 16bit command to display controller
+ /** Send 2x8bit command to display controller
*
* @param cmd: halfword to send
*
*/
virtual void wr_cmd16(unsigned short cmd) = 0;
- /** Send 16bit data to display controller
+ /** Send 2x8bit data to display controller
*
* @param data: halfword to send
*
*/
virtual void wr_data16(unsigned short data) = 0;
- /** Send same 16bit data to display controller multiple times
+ /** Send 16bit pixeldata to display controller
+ *
+ * @param data: halfword to send
+ *
+ */
+ virtual void wr_gram(unsigned short data) = 0;
+
+ /** Send same 16bit pixeldata to display controller multiple times
*
* @param data: halfword to send
* @param count: how many
*
*/
- virtual void wr_data16(unsigned short data, unsigned int count) = 0;
+ virtual void wr_gram(unsigned short data, unsigned int count) = 0;
- /** Send array of data shorts to display controller
+ /** Send array of pixeldata shorts to display controller
*
- * @param data: unsigned short data array
+ * @param data: unsigned short pixeldata array
* @param lenght: lenght (in shorts)
*
*/
- virtual void wr_data16buf(unsigned short* data, unsigned int lenght) = 0;
+ virtual void wr_grambuf(unsigned short* data, unsigned int lenght) = 0;
/** HW reset sequence (without display init commands)
*/
--- a/Protocols/SPI16.cpp Sat Feb 14 17:42:21 2015 +0000
+++ b/Protocols/SPI16.cpp Sun Feb 15 20:06:07 2015 +0000
@@ -1,3 +1,21 @@
+ /* mbed UniGraphic library - SPI16 protocol class
+ * Copyright (c) 2015 Giuliano Dianda
+ * Released under the MIT License: http://mbed.org/license/mit
+ *
+ * Derived work of:
+ *
+ * mbed library for 240*320 pixel display TFT based on ILI9341 LCD Controller
+ * Copyright (c) 2013 Peter Drescher - DC2PD
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
#include "SPI16.h"
//#define USE_CS
@@ -39,41 +57,6 @@
_CS = 1;
#endif
}
-void SPI16::wr_data8(unsigned char data, unsigned int count)
-{
-#ifdef USE_CS
- _CS = 0;
-#endif
- _spi.format(8,0);
- _DC.write(1); // 1=data
- while(count)
- {
- _spi.write(data); // write 8bit
- count--;
- }
- _spi.format(16,0);
-#ifdef USE_CS
- _CS = 1;
-#endif
-}
-void SPI16::wr_data8buf(unsigned char* data, unsigned int lenght)
-{
-#ifdef USE_CS
- _CS = 0;
-#endif
- _spi.format(8,0);
- _DC.write(1); // 1=data
- while(lenght)
- {
- _spi.write(*data++); // write 8bit
- // data++;
- lenght--;
- }
- _spi.format(16,0);
-#ifdef USE_CS
- _CS = 1;
-#endif
-}
void SPI16::wr_cmd16(unsigned short cmd)
{
#ifdef USE_CS
@@ -96,7 +79,18 @@
_CS = 1;
#endif
}
-void SPI16::wr_data16(unsigned short data, unsigned int count)
+void SPI16::wr_gram(unsigned short data)
+{
+#ifdef USE_CS
+ _CS = 0;
+#endif
+ _DC.write(1); // 1=data
+ _spi.write(data); // write 16bit
+#ifdef USE_CS
+ _CS = 1;
+#endif
+}
+void SPI16::wr_gram(unsigned short data, unsigned int count)
{
#ifdef USE_CS
_CS = 0;
@@ -111,7 +105,7 @@
_CS = 1;
#endif
}
-void SPI16::wr_data16buf(unsigned short* data, unsigned int lenght)
+void SPI16::wr_grambuf(unsigned short* data, unsigned int lenght)
{
#ifdef USE_CS
_CS = 0;
--- a/Protocols/SPI16.h Sat Feb 14 17:42:21 2015 +0000
+++ b/Protocols/SPI16.h Sun Feb 15 20:06:07 2015 +0000
@@ -38,53 +38,42 @@
*/
virtual void wr_data8(unsigned char data);
- /** Send same 8bit data to display controller multiple times
- *
- * @note switches spi format 16->8->16, better use wr_data16
- * @param data: byte to send
- * @param count: how many
- *
- */
- virtual void wr_data8(unsigned char data, unsigned int count);
-
- /** Send array of data bytes to display controller
- *
- * @note switches spi format 16->8->16, better use wr_data16
- * @param data: unsigned char data array
- * @param lenght: lenght of array
- *
- */
- virtual void wr_data8buf(unsigned char* data, unsigned int lenght);
-
- /** Send 16bit command to display controller
+ /** Send 2x8bit command to display controller
*
* @param cmd: halfword to send
- *
+ * @note in SPI_16 mode a single 16bit transfer will be done
*/
virtual void wr_cmd16(unsigned short cmd);
- /** Send 16bit data to display controller
+ /** Send 2x8bit data to display controller
+ *
+ * @param data: halfword to send
+ * @note in SPI_16 mode a single 16bit transfer will be done
+ */
+ virtual void wr_data16(unsigned short data);
+
+ /** Send 16bit pixeldata to display controller
*
* @param data: halfword to send
*
*/
- virtual void wr_data16(unsigned short data);
+ virtual void wr_gram(unsigned short data);
- /** Send same 16bit data to display controller multiple times
+ /** Send same 16bit pixeldata to display controller multiple times
*
* @param data: halfword to send
* @param count: how many
*
*/
- virtual void wr_data16(unsigned short data, unsigned int count);
+ virtual void wr_gram(unsigned short data, unsigned int count);
- /** Send array of data shorts to display controller
+ /** Send array of pixeldata shorts to display controller
*
- * @param data: unsigned short data array
+ * @param data: unsigned short pixeldata array
* @param lenght: lenght (in shorts)
*
*/
- virtual void wr_data16buf(unsigned short* data, unsigned int lenght);
+ virtual void wr_grambuf(unsigned short* data, unsigned int lenght);
/** HW reset sequence (without display init commands)
*/
--- a/Protocols/SPI8.cpp Sat Feb 14 17:42:21 2015 +0000
+++ b/Protocols/SPI8.cpp Sun Feb 15 20:06:07 2015 +0000
@@ -1,3 +1,21 @@
+ /* mbed UniGraphic library - SPI8 protocol class
+ * Copyright (c) 2015 Giuliano Dianda
+ * Released under the MIT License: http://mbed.org/license/mit
+ *
+ * Derived work of:
+ *
+ * mbed library for 240*320 pixel display TFT based on ILI9341 LCD Controller
+ * Copyright (c) 2013 Peter Drescher - DC2PD
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
#include "SPI8.h"
//#define USE_CS
@@ -36,37 +54,6 @@
_CS = 1;
#endif
}
-void SPI8::wr_data8(unsigned char data, unsigned int count)
-{
-#ifdef USE_CS
- _CS = 0;
-#endif
- _DC.write(1); // 1=data
- while(count)
- {
- _spi.write(data); // write 8bit
- count--;
- }
-#ifdef USE_CS
- _CS = 1;
-#endif
-}
-void SPI8::wr_data8buf(unsigned char* data, unsigned int lenght)
-{
-#ifdef USE_CS
- _CS = 0;
-#endif
- _DC.write(1); // 1=data
- while(lenght)
- {
- _spi.write(*data++); // write 8bit
- // data++;
- lenght--;
- }
-#ifdef USE_CS
- _CS = 1;
-#endif
-}
void SPI8::wr_cmd16(unsigned short cmd)
{
#ifdef USE_CS
@@ -91,7 +78,19 @@
_CS = 1;
#endif
}
-void SPI8::wr_data16(unsigned short data, unsigned int count)
+void SPI8::wr_gram(unsigned short data)
+{
+#ifdef USE_CS
+ _CS = 0;
+#endif
+ _DC.write(1); // 1=data
+ _spi.write(data>>8); // write 8bit
+ _spi.write(data&0xFF); // write 8bit
+#ifdef USE_CS
+ _CS = 1;
+#endif
+}
+void SPI8::wr_gram(unsigned short data, unsigned int count)
{
#ifdef USE_CS
_CS = 0;
@@ -119,7 +118,7 @@
_CS = 1;
#endif
}
-void SPI8::wr_data16buf(unsigned short* data, unsigned int lenght)
+void SPI8::wr_grambuf(unsigned short* data, unsigned int lenght)
{
#ifdef USE_CS
_CS = 0;
--- a/Protocols/SPI8.h Sat Feb 14 17:42:21 2015 +0000
+++ b/Protocols/SPI8.h Sun Feb 15 20:06:07 2015 +0000
@@ -36,51 +36,41 @@
*/
virtual void wr_data8(unsigned char data);
- /** Send same 8bit data to display controller multiple times
- *
- * @param data: byte to send
- * @param count: how many
- *
- */
- virtual void wr_data8(unsigned char data, unsigned int count);
-
- /** Send array of data bytes to display controller
- *
- * @param data: unsigned char data array
- * @param lenght: lenght of array
- *
- */
- virtual void wr_data8buf(unsigned char* data, unsigned int lenght);
-
- /** Send 16bit command to display controller
+ /** Send 2x8bit command to display controller
*
* @param cmd: halfword to send
- *
*/
virtual void wr_cmd16(unsigned short cmd);
- /** Send 16bit data to display controller
+ /** Send 2x8bit data to display controller
*
* @param data: halfword to send
*
*/
virtual void wr_data16(unsigned short data);
- /** Send same 16bit data to display controller multiple times
+ /** Send 16bit pixeldata to display controller
+ *
+ * @param data: halfword to send
+ *
+ */
+ virtual void wr_gram(unsigned short data);
+
+ /** Send same 16bit pixeldata to display controller multiple times
*
* @param data: halfword to send
* @param count: how many
*
*/
- virtual void wr_data16(unsigned short data, unsigned int count);
+ virtual void wr_gram(unsigned short data, unsigned int count);
- /** Send array of data shorts to display controller
+ /** Send array of pixeldata shorts to display controller
*
- * @param data: unsigned short data array
+ * @param data: unsigned short pixeldata array
* @param lenght: lenght (in shorts)
*
*/
- virtual void wr_data16buf(unsigned short* data, unsigned int lenght);
+ virtual void wr_grambuf(unsigned short* data, unsigned int lenght);
/** HW reset sequence (without display init commands)
*/
