Revert "These are the DMA ILI9341 library and Extra fonts GFX"
This reverts commit 7e41e0d11b
.
This commit is contained in:
parent
7e41e0d11b
commit
6cc87e88bb
|
@ -31,7 +31,7 @@ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
POSSIBILITY OF SUCH DAMAGE.
|
POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "Adafruit_GFX.h"
|
#include "Adafruit_GFX_AS.h"
|
||||||
|
|
||||||
#ifdef LOAD_GLCD
|
#ifdef LOAD_GLCD
|
||||||
#include "glcdfont.c"
|
#include "glcdfont.c"
|
||||||
|
@ -59,7 +59,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
#define pgm_read_byte(addr) (*(const unsigned char *)(addr))
|
#define pgm_read_byte(addr) (*(const unsigned char *)(addr))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Adafruit_GFX::Adafruit_GFX(int16_t w, int16_t h):
|
Adafruit_GFX_AS::Adafruit_GFX_AS(int16_t w, int16_t h):
|
||||||
WIDTH(w), HEIGHT(h)
|
WIDTH(w), HEIGHT(h)
|
||||||
{
|
{
|
||||||
_width = WIDTH;
|
_width = WIDTH;
|
||||||
|
@ -72,7 +72,7 @@ Adafruit_GFX::Adafruit_GFX(int16_t w, int16_t h):
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw a circle outline
|
// Draw a circle outline
|
||||||
void Adafruit_GFX::drawCircle(int16_t x0, int16_t y0, int16_t r,
|
void Adafruit_GFX_AS::drawCircle(int16_t x0, int16_t y0, int16_t r,
|
||||||
uint16_t color) {
|
uint16_t color) {
|
||||||
int16_t f = 1 - r;
|
int16_t f = 1 - r;
|
||||||
int16_t ddF_x = 1;
|
int16_t ddF_x = 1;
|
||||||
|
@ -106,7 +106,7 @@ void Adafruit_GFX::drawCircle(int16_t x0, int16_t y0, int16_t r,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Adafruit_GFX::drawCircleHelper( int16_t x0, int16_t y0,
|
void Adafruit_GFX_AS::drawCircleHelper( int16_t x0, int16_t y0,
|
||||||
int16_t r, uint8_t cornername, uint16_t color) {
|
int16_t r, uint8_t cornername, uint16_t color) {
|
||||||
int16_t f = 1 - r;
|
int16_t f = 1 - r;
|
||||||
int16_t ddF_x = 1;
|
int16_t ddF_x = 1;
|
||||||
|
@ -142,14 +142,14 @@ void Adafruit_GFX::drawCircleHelper( int16_t x0, int16_t y0,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Adafruit_GFX::fillCircle(int16_t x0, int16_t y0, int16_t r,
|
void Adafruit_GFX_AS::fillCircle(int16_t x0, int16_t y0, int16_t r,
|
||||||
uint16_t color) {
|
uint16_t color) {
|
||||||
drawFastVLine(x0, y0-r, 2*r+1, color);
|
drawFastVLine(x0, y0-r, 2*r+1, color);
|
||||||
fillCircleHelper(x0, y0, r, 3, 0, color);
|
fillCircleHelper(x0, y0, r, 3, 0, color);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Used to do circles and roundrects
|
// Used to do circles and roundrects
|
||||||
void Adafruit_GFX::fillCircleHelper(int16_t x0, int16_t y0, int16_t r,
|
void Adafruit_GFX_AS::fillCircleHelper(int16_t x0, int16_t y0, int16_t r,
|
||||||
uint8_t cornername, int16_t delta, uint16_t color) {
|
uint8_t cornername, int16_t delta, uint16_t color) {
|
||||||
|
|
||||||
int16_t f = 1 - r;
|
int16_t f = 1 - r;
|
||||||
|
@ -180,7 +180,7 @@ void Adafruit_GFX::fillCircleHelper(int16_t x0, int16_t y0, int16_t r,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Bresenham's algorithm - thx wikpedia
|
// Bresenham's algorithm - thx wikpedia
|
||||||
void Adafruit_GFX::drawLine(int16_t x0, int16_t y0,
|
void Adafruit_GFX_AS::drawLine(int16_t x0, int16_t y0,
|
||||||
int16_t x1, int16_t y1,
|
int16_t x1, int16_t y1,
|
||||||
uint16_t color) {
|
uint16_t color) {
|
||||||
int16_t steep = abs(y1 - y0) > abs(x1 - x0);
|
int16_t steep = abs(y1 - y0) > abs(x1 - x0);
|
||||||
|
@ -222,7 +222,7 @@ void Adafruit_GFX::drawLine(int16_t x0, int16_t y0,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw a rectangle
|
// Draw a rectangle
|
||||||
void Adafruit_GFX::drawRect(int16_t x, int16_t y,
|
void Adafruit_GFX_AS::drawRect(int16_t x, int16_t y,
|
||||||
int16_t w, int16_t h,
|
int16_t w, int16_t h,
|
||||||
uint16_t color) {
|
uint16_t color) {
|
||||||
drawFastHLine(x, y, w, color);
|
drawFastHLine(x, y, w, color);
|
||||||
|
@ -231,19 +231,19 @@ void Adafruit_GFX::drawRect(int16_t x, int16_t y,
|
||||||
drawFastVLine(x+w-1, y, h, color);
|
drawFastVLine(x+w-1, y, h, color);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Adafruit_GFX::drawFastVLine(int16_t x, int16_t y,
|
void Adafruit_GFX_AS::drawFastVLine(int16_t x, int16_t y,
|
||||||
int16_t h, uint16_t color) {
|
int16_t h, uint16_t color) {
|
||||||
// Update in subclasses if desired!
|
// Update in subclasses if desired!
|
||||||
drawLine(x, y, x, y+h-1, color);
|
drawLine(x, y, x, y+h-1, color);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Adafruit_GFX::drawFastHLine(int16_t x, int16_t y,
|
void Adafruit_GFX_AS::drawFastHLine(int16_t x, int16_t y,
|
||||||
int16_t w, uint16_t color) {
|
int16_t w, uint16_t color) {
|
||||||
// Update in subclasses if desired!
|
// Update in subclasses if desired!
|
||||||
drawLine(x, y, x+w-1, y, color);
|
drawLine(x, y, x+w-1, y, color);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Adafruit_GFX::fillRect(int16_t x, int16_t y, int16_t w, int16_t h,
|
void Adafruit_GFX_AS::fillRect(int16_t x, int16_t y, int16_t w, int16_t h,
|
||||||
uint16_t color) {
|
uint16_t color) {
|
||||||
// Update in subclasses if desired!
|
// Update in subclasses if desired!
|
||||||
for (int16_t i=x; i<x+w; i++) {
|
for (int16_t i=x; i<x+w; i++) {
|
||||||
|
@ -251,12 +251,12 @@ void Adafruit_GFX::fillRect(int16_t x, int16_t y, int16_t w, int16_t h,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Adafruit_GFX::fillScreen(uint16_t color) {
|
void Adafruit_GFX_AS::fillScreen(uint16_t color) {
|
||||||
fillRect(0, 0, _width, _height, color);
|
fillRect(0, 0, _width, _height, color);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw a rounded rectangle
|
// Draw a rounded rectangle
|
||||||
void Adafruit_GFX::drawRoundRect(int16_t x, int16_t y, int16_t w,
|
void Adafruit_GFX_AS::drawRoundRect(int16_t x, int16_t y, int16_t w,
|
||||||
int16_t h, int16_t r, uint16_t color) {
|
int16_t h, int16_t r, uint16_t color) {
|
||||||
// smarter version
|
// smarter version
|
||||||
drawFastHLine(x+r , y , w-2*r, color); // Top
|
drawFastHLine(x+r , y , w-2*r, color); // Top
|
||||||
|
@ -271,7 +271,7 @@ void Adafruit_GFX::drawRoundRect(int16_t x, int16_t y, int16_t w,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fill a rounded rectangle
|
// Fill a rounded rectangle
|
||||||
void Adafruit_GFX::fillRoundRect(int16_t x, int16_t y, int16_t w,
|
void Adafruit_GFX_AS::fillRoundRect(int16_t x, int16_t y, int16_t w,
|
||||||
int16_t h, int16_t r, uint16_t color) {
|
int16_t h, int16_t r, uint16_t color) {
|
||||||
// smarter version
|
// smarter version
|
||||||
fillRect(x+r, y, w-2*r, h, color);
|
fillRect(x+r, y, w-2*r, h, color);
|
||||||
|
@ -282,7 +282,7 @@ void Adafruit_GFX::fillRoundRect(int16_t x, int16_t y, int16_t w,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw a triangle
|
// Draw a triangle
|
||||||
void Adafruit_GFX::drawTriangle(int16_t x0, int16_t y0,
|
void Adafruit_GFX_AS::drawTriangle(int16_t x0, int16_t y0,
|
||||||
int16_t x1, int16_t y1,
|
int16_t x1, int16_t y1,
|
||||||
int16_t x2, int16_t y2, uint16_t color) {
|
int16_t x2, int16_t y2, uint16_t color) {
|
||||||
drawLine(x0, y0, x1, y1, color);
|
drawLine(x0, y0, x1, y1, color);
|
||||||
|
@ -291,7 +291,7 @@ void Adafruit_GFX::drawTriangle(int16_t x0, int16_t y0,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fill a triangle
|
// Fill a triangle
|
||||||
void Adafruit_GFX::fillTriangle ( int16_t x0, int16_t y0,
|
void Adafruit_GFX_AS::fillTriangle ( int16_t x0, int16_t y0,
|
||||||
int16_t x1, int16_t y1,
|
int16_t x1, int16_t y1,
|
||||||
int16_t x2, int16_t y2, uint16_t color) {
|
int16_t x2, int16_t y2, uint16_t color) {
|
||||||
|
|
||||||
|
@ -368,7 +368,7 @@ void Adafruit_GFX::fillTriangle ( int16_t x0, int16_t y0,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Adafruit_GFX::drawBitmap(int16_t x, int16_t y,
|
void Adafruit_GFX_AS::drawBitmap(int16_t x, int16_t y,
|
||||||
const uint8_t *bitmap, int16_t w, int16_t h,
|
const uint8_t *bitmap, int16_t w, int16_t h,
|
||||||
uint16_t color) {
|
uint16_t color) {
|
||||||
|
|
||||||
|
@ -384,9 +384,9 @@ void Adafruit_GFX::drawBitmap(int16_t x, int16_t y,
|
||||||
}
|
}
|
||||||
|
|
||||||
//#if ARDUINO >= 100
|
//#if ARDUINO >= 100
|
||||||
size_t Adafruit_GFX::write(uint8_t c) {
|
size_t Adafruit_GFX_AS::write(uint8_t c) {
|
||||||
//#else
|
//#else
|
||||||
//void Adafruit_GFX::write(uint8_t c) {
|
//void Adafruit_GFX_AS::write(uint8_t c) {
|
||||||
//#endif
|
//#endif
|
||||||
if (c == '\n') {
|
if (c == '\n') {
|
||||||
cursor_y += textsize*8;
|
cursor_y += textsize*8;
|
||||||
|
@ -407,7 +407,7 @@ size_t Adafruit_GFX::write(uint8_t c) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw a character
|
// Draw a character
|
||||||
void Adafruit_GFX::drawChar(int16_t x, int16_t y, unsigned char c,
|
void Adafruit_GFX_AS::drawChar(int16_t x, int16_t y, unsigned char c,
|
||||||
uint16_t color, uint16_t bg, uint8_t size) {
|
uint16_t color, uint16_t bg, uint8_t size) {
|
||||||
#ifdef LOAD_GLCD
|
#ifdef LOAD_GLCD
|
||||||
if((x >= _width) || // Clip right
|
if((x >= _width) || // Clip right
|
||||||
|
@ -442,35 +442,35 @@ void Adafruit_GFX::drawChar(int16_t x, int16_t y, unsigned char c,
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void Adafruit_GFX::setCursor(int16_t x, int16_t y) {
|
void Adafruit_GFX_AS::setCursor(int16_t x, int16_t y) {
|
||||||
cursor_x = x;
|
cursor_x = x;
|
||||||
cursor_y = y;
|
cursor_y = y;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Adafruit_GFX::setTextSize(uint8_t s) {
|
void Adafruit_GFX_AS::setTextSize(uint8_t s) {
|
||||||
textsize = (s > 0) ? s : 1;
|
textsize = (s > 0) ? s : 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Adafruit_GFX::setTextColor(uint16_t c) {
|
void Adafruit_GFX_AS::setTextColor(uint16_t c) {
|
||||||
// For 'transparent' background, we'll set the bg
|
// For 'transparent' background, we'll set the bg
|
||||||
// to the same as fg instead of using a flag
|
// to the same as fg instead of using a flag
|
||||||
textcolor = textbgcolor = c;
|
textcolor = textbgcolor = c;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Adafruit_GFX::setTextColor(uint16_t c, uint16_t b) {
|
void Adafruit_GFX_AS::setTextColor(uint16_t c, uint16_t b) {
|
||||||
textcolor = c;
|
textcolor = c;
|
||||||
textbgcolor = b;
|
textbgcolor = b;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Adafruit_GFX::setTextWrap(boolean w) {
|
void Adafruit_GFX_AS::setTextWrap(boolean w) {
|
||||||
wrap = w;
|
wrap = w;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t Adafruit_GFX::getRotation(void) {
|
uint8_t Adafruit_GFX_AS::getRotation(void) {
|
||||||
return rotation;
|
return rotation;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Adafruit_GFX::setRotation(uint8_t x) {
|
void Adafruit_GFX_AS::setRotation(uint8_t x) {
|
||||||
rotation = (x & 3);
|
rotation = (x & 3);
|
||||||
switch(rotation) {
|
switch(rotation) {
|
||||||
case 0:
|
case 0:
|
||||||
|
@ -487,15 +487,15 @@ void Adafruit_GFX::setRotation(uint8_t x) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return the size of the display (per current rotation)
|
// Return the size of the display (per current rotation)
|
||||||
int16_t Adafruit_GFX::width(void) {
|
int16_t Adafruit_GFX_AS::width(void) {
|
||||||
return _width;
|
return _width;
|
||||||
}
|
}
|
||||||
|
|
||||||
int16_t Adafruit_GFX::height(void) {
|
int16_t Adafruit_GFX_AS::height(void) {
|
||||||
return _height;
|
return _height;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Adafruit_GFX::invertDisplay(boolean i) {
|
void Adafruit_GFX_AS::invertDisplay(boolean i) {
|
||||||
// Do nothing, must be subclassed if supported
|
// Do nothing, must be subclassed if supported
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -503,7 +503,7 @@ void Adafruit_GFX::invertDisplay(boolean i) {
|
||||||
** Function name: drawUnicode
|
** Function name: drawUnicode
|
||||||
** Descriptions: draw a unicode
|
** Descriptions: draw a unicode
|
||||||
***************************************************************************************/
|
***************************************************************************************/
|
||||||
int16_t Adafruit_GFX::drawUnicode(uint16_t uniCode, int16_t x, int16_t y, int16_t size)
|
int16_t Adafruit_GFX_AS::drawUnicode(uint16_t uniCode, int16_t x, int16_t y, int16_t size)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (size) uniCode -= 32;
|
if (size) uniCode -= 32;
|
||||||
|
@ -615,7 +615,7 @@ return (width+gap)*textsize; // x +
|
||||||
** Function name: drawNumber unsigned with size
|
** Function name: drawNumber unsigned with size
|
||||||
** Descriptions: drawNumber
|
** Descriptions: drawNumber
|
||||||
***************************************************************************************/
|
***************************************************************************************/
|
||||||
int16_t Adafruit_GFX::drawNumber(long long_num,int16_t poX, int16_t poY, int16_t size)
|
int16_t Adafruit_GFX_AS::drawNumber(long long_num,int16_t poX, int16_t poY, int16_t size)
|
||||||
{
|
{
|
||||||
char tmp[10];
|
char tmp[10];
|
||||||
if (long_num < 0) sprintf(tmp, "%li", long_num);
|
if (long_num < 0) sprintf(tmp, "%li", long_num);
|
||||||
|
@ -627,7 +627,7 @@ int16_t Adafruit_GFX::drawNumber(long long_num,int16_t poX, int16_t poY, int16_t
|
||||||
** Function name: drawChar
|
** Function name: drawChar
|
||||||
** Descriptions: draw char
|
** Descriptions: draw char
|
||||||
***************************************************************************************/
|
***************************************************************************************/
|
||||||
int16_t Adafruit_GFX::drawChar(char c, int16_t x, int16_t y, int16_t size)
|
int16_t Adafruit_GFX_AS::drawChar(char c, int16_t x, int16_t y, int16_t size)
|
||||||
{
|
{
|
||||||
return drawUnicode(c, x, y, size);
|
return drawUnicode(c, x, y, size);
|
||||||
}
|
}
|
||||||
|
@ -636,7 +636,7 @@ int16_t Adafruit_GFX::drawChar(char c, int16_t x, int16_t y, int16_t size)
|
||||||
** Function name: drawString
|
** Function name: drawString
|
||||||
** Descriptions: draw string
|
** Descriptions: draw string
|
||||||
***************************************************************************************/
|
***************************************************************************************/
|
||||||
int16_t Adafruit_GFX::drawString(char *string, int16_t poX, int16_t poY, int16_t size)
|
int16_t Adafruit_GFX_AS::drawString(char *string, int16_t poX, int16_t poY, int16_t size)
|
||||||
{
|
{
|
||||||
int16_t sumX = 0;
|
int16_t sumX = 0;
|
||||||
|
|
||||||
|
@ -654,7 +654,7 @@ int16_t Adafruit_GFX::drawString(char *string, int16_t poX, int16_t poY, int16_t
|
||||||
** Function name: drawCentreString
|
** Function name: drawCentreString
|
||||||
** Descriptions: draw string across centre
|
** Descriptions: draw string across centre
|
||||||
***************************************************************************************/
|
***************************************************************************************/
|
||||||
int16_t Adafruit_GFX::drawCentreString(char *string, int16_t dX, int16_t poY, int16_t size)
|
int16_t Adafruit_GFX_AS::drawCentreString(char *string, int16_t dX, int16_t poY, int16_t size)
|
||||||
{
|
{
|
||||||
int16_t sumX = 0;
|
int16_t sumX = 0;
|
||||||
int16_t len = 0;
|
int16_t len = 0;
|
||||||
|
@ -703,7 +703,7 @@ int16_t Adafruit_GFX::drawCentreString(char *string, int16_t dX, int16_t poY, in
|
||||||
** Function name: drawRightString
|
** Function name: drawRightString
|
||||||
** Descriptions: draw string right justified
|
** Descriptions: draw string right justified
|
||||||
***************************************************************************************/
|
***************************************************************************************/
|
||||||
int16_t Adafruit_GFX::drawRightString(char *string, int16_t dX, int16_t poY, int16_t size)
|
int16_t Adafruit_GFX_AS::drawRightString(char *string, int16_t dX, int16_t poY, int16_t size)
|
||||||
{
|
{
|
||||||
int16_t sumX = 0;
|
int16_t sumX = 0;
|
||||||
int16_t len = 0;
|
int16_t len = 0;
|
||||||
|
@ -754,7 +754,7 @@ int16_t Adafruit_GFX::drawRightString(char *string, int16_t dX, int16_t poY, int
|
||||||
** Function name: drawFloat
|
** Function name: drawFloat
|
||||||
** Descriptions: drawFloat
|
** Descriptions: drawFloat
|
||||||
***************************************************************************************/
|
***************************************************************************************/
|
||||||
int16_t Adafruit_GFX::drawFloat(float floatNumber, int16_t decimal, int16_t poX, int16_t poY, int16_t size)
|
int16_t Adafruit_GFX_AS::drawFloat(float floatNumber, int16_t decimal, int16_t poX, int16_t poY, int16_t size)
|
||||||
{
|
{
|
||||||
unsigned long temp=0;
|
unsigned long temp=0;
|
||||||
float decy=0.0;
|
float decy=0.0;
|
|
@ -1,5 +1,5 @@
|
||||||
#ifndef _ADAFRUIT_GFX_H
|
#ifndef _ADAFRUIT_GFX_AS_H
|
||||||
#define _ADAFRUIT_GFX_H
|
#define _ADAFRUIT_GFX_AS_H
|
||||||
|
|
||||||
#include "Load_fonts.h"
|
#include "Load_fonts.h"
|
||||||
|
|
||||||
|
@ -12,11 +12,11 @@
|
||||||
|
|
||||||
#define swap(a, b) { int16_t t = a; a = b; b = t; }
|
#define swap(a, b) { int16_t t = a; a = b; b = t; }
|
||||||
|
|
||||||
class Adafruit_GFX : public Print {
|
class Adafruit_GFX_AS : public Print {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
Adafruit_GFX(int16_t w, int16_t h); // Constructor
|
Adafruit_GFX_AS(int16_t w, int16_t h); // Constructor
|
||||||
|
|
||||||
// This MUST be defined by the subclass:
|
// This MUST be defined by the subclass:
|
||||||
virtual void drawPixel(int16_t x, int16_t y, uint16_t color) = 0;
|
virtual void drawPixel(int16_t x, int16_t y, uint16_t color) = 0;
|
||||||
|
@ -32,7 +32,7 @@ class Adafruit_GFX : public Print {
|
||||||
fillScreen(uint16_t color),
|
fillScreen(uint16_t color),
|
||||||
invertDisplay(boolean i);
|
invertDisplay(boolean i);
|
||||||
|
|
||||||
// These exist only with Adafruit_GFX (no subclass overrides)
|
// These exist only with Adafruit_GFX_AS (no subclass overrides)
|
||||||
void
|
void
|
||||||
drawCircle(int16_t x0, int16_t y0, int16_t r, uint16_t color),
|
drawCircle(int16_t x0, int16_t y0, int16_t r, uint16_t color),
|
||||||
drawCircleHelper(int16_t x0, int16_t y0, int16_t r, uint8_t cornername,
|
drawCircleHelper(int16_t x0, int16_t y0, int16_t r, uint8_t cornername,
|
||||||
|
@ -94,4 +94,4 @@ class Adafruit_GFX : public Print {
|
||||||
wrap; // If set, 'wrap' text at right edge of display
|
wrap; // If set, 'wrap' text at right edge of display
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // _ADAFRUIT_GFX_H
|
#endif // _ADAFRUIT_GFX_AS_H
|
|
@ -1,16 +1,24 @@
|
||||||
/*
|
/***************************************************
|
||||||
See rights and use declaration in License.h
|
This is our library for the Adafruit ILI9341 Breakout and Shield
|
||||||
This library has been modified for the Maple Mini
|
----> http://www.adafruit.com/products/1651
|
||||||
*/
|
|
||||||
|
Check out the links above for our tutorials and wiring diagrams
|
||||||
|
These displays use SPI to communicate, 4 or 5 pins are required to
|
||||||
|
interface (RST is optional)
|
||||||
|
Adafruit invests time and resources providing this open source code,
|
||||||
|
please support Adafruit and open-source hardware by purchasing
|
||||||
|
products from Adafruit!
|
||||||
|
|
||||||
|
Written by Limor Fried/Ladyada for Adafruit Industries.
|
||||||
|
MIT license, all text above must be included in any redistribution
|
||||||
|
****************************************************/
|
||||||
|
|
||||||
#include "Adafruit_ILI9341.h"
|
#include "Adafruit_ILI9341.h"
|
||||||
#include <avr/pgmspace.h>
|
#include <avr/pgmspace.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <libmaple/dma.h>
|
|
||||||
#include "pins_arduino.h"
|
#include "pins_arduino.h"
|
||||||
#include "wiring_private.h"
|
#include "wiring_private.h"
|
||||||
#include <SPI.h> // Using library SPI in folder: D:\Documents\Arduino\hardware\STM32\STM32F1XX\libraries\SPI
|
#include <SPI.h>
|
||||||
|
|
||||||
volatile bool dma1_ch3_Active = false;
|
|
||||||
|
|
||||||
// Constructor when using software SPI. All output pins are configurable.
|
// Constructor when using software SPI. All output pins are configurable.
|
||||||
Adafruit_ILI9341::Adafruit_ILI9341(int8_t cs, int8_t dc, int8_t mosi,
|
Adafruit_ILI9341::Adafruit_ILI9341(int8_t cs, int8_t dc, int8_t mosi,
|
||||||
|
@ -35,17 +43,11 @@ Adafruit_ILI9341::Adafruit_ILI9341(int8_t cs, int8_t dc, int8_t rst) : Adafruit_
|
||||||
_mosi = _sclk = 0;
|
_mosi = _sclk = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void DMA1_CH3_Event() {
|
|
||||||
dma1_ch3_Active = 0;
|
|
||||||
dma_disable(DMA1, DMA_CH3);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Adafruit_ILI9341::spiwrite(uint8_t c) {
|
void Adafruit_ILI9341::spiwrite(uint8_t c) {
|
||||||
|
|
||||||
//Serial.print("0x"); Serial.print(c, HEX); Serial.print(", ");
|
//Serial.print("0x"); Serial.print(c, HEX); Serial.print(", ");
|
||||||
|
|
||||||
if (hwSPI)
|
if (hwSPI) {
|
||||||
{
|
|
||||||
#if defined (__AVR__)
|
#if defined (__AVR__)
|
||||||
uint8_t backupSPCR = SPCR;
|
uint8_t backupSPCR = SPCR;
|
||||||
SPCR = mySPCR;
|
SPCR = mySPCR;
|
||||||
|
@ -55,13 +57,12 @@ void Adafruit_ILI9341::spiwrite(uint8_t c) {
|
||||||
#elif defined(TEENSYDUINO)
|
#elif defined(TEENSYDUINO)
|
||||||
SPI.transfer(c);
|
SPI.transfer(c);
|
||||||
#elif defined (__STM32F1__)
|
#elif defined (__STM32F1__)
|
||||||
SPI.transfer(c);
|
SPI.write(c);// Faster than transfer as we don't need to read
|
||||||
#elif defined (__arm__)
|
#elif defined (__arm__)
|
||||||
SPI.setClockDivider(11); // 8-ish MHz (full! speed!)
|
SPI.setClockDivider(11); // 8-ish MHz (full! speed!)
|
||||||
SPI.setBitOrder(MSBFIRST);
|
SPI.setBitOrder(MSBFIRST);
|
||||||
SPI.setDataMode(SPI_MODE0);
|
SPI.setDataMode(SPI_MODE0);
|
||||||
SPI.transfer(c);
|
SPI.transfer(c);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
} else {
|
} else {
|
||||||
// Fast SPI bitbang swiped from LPD8806 library
|
// Fast SPI bitbang swiped from LPD8806 library
|
||||||
|
@ -84,30 +85,16 @@ void Adafruit_ILI9341::spiwrite(uint8_t c) {
|
||||||
|
|
||||||
void Adafruit_ILI9341::writecommand(uint8_t c) {
|
void Adafruit_ILI9341::writecommand(uint8_t c) {
|
||||||
*dcport &= ~dcpinmask;
|
*dcport &= ~dcpinmask;
|
||||||
//digitalWrite(_dc, LOW);
|
|
||||||
//*clkport &= ~clkpinmask; // clkport is a NULL pointer when hwSPI==true
|
|
||||||
//digitalWrite(_sclk, LOW);
|
|
||||||
*csport &= ~cspinmask;
|
*csport &= ~cspinmask;
|
||||||
//digitalWrite(_cs, LOW);
|
SPI.write(c);
|
||||||
|
|
||||||
spiwrite(c);
|
|
||||||
|
|
||||||
*csport |= cspinmask;
|
*csport |= cspinmask;
|
||||||
//digitalWrite(_cs, HIGH);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Adafruit_ILI9341::writedata(uint8_t c) {
|
void Adafruit_ILI9341::writedata(uint8_t c) {
|
||||||
*dcport |= dcpinmask;
|
*dcport |= dcpinmask;
|
||||||
//digitalWrite(_dc, HIGH);
|
|
||||||
//*clkport &= ~clkpinmask; // clkport is a NULL pointer when hwSPI==true
|
|
||||||
//digitalWrite(_sclk, LOW);
|
|
||||||
*csport &= ~cspinmask;
|
*csport &= ~cspinmask;
|
||||||
//digitalWrite(_cs, LOW);
|
SPI.write(c);
|
||||||
|
|
||||||
spiwrite(c);
|
|
||||||
|
|
||||||
//digitalWrite(_cs, HIGH);
|
|
||||||
*csport |= cspinmask;
|
*csport |= cspinmask;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -143,6 +130,12 @@ void Adafruit_ILI9341::commandList(uint8_t *addr) {
|
||||||
uint8_t numCommands, numArgs;
|
uint8_t numCommands, numArgs;
|
||||||
uint16_t ms;
|
uint16_t ms;
|
||||||
|
|
||||||
|
*dcport |= dcpinmask;
|
||||||
|
*csport &= ~cspinmask;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
numCommands = pgm_read_byte(addr++); // Number of commands to follow
|
numCommands = pgm_read_byte(addr++); // Number of commands to follow
|
||||||
while(numCommands--) { // For each command...
|
while(numCommands--) { // For each command...
|
||||||
writecommand(pgm_read_byte(addr++)); // Read, issue command
|
writecommand(pgm_read_byte(addr++)); // Read, issue command
|
||||||
|
@ -150,7 +143,7 @@ void Adafruit_ILI9341::commandList(uint8_t *addr) {
|
||||||
ms = numArgs & DELAY; // If hibit set, delay follows args
|
ms = numArgs & DELAY; // If hibit set, delay follows args
|
||||||
numArgs &= ~DELAY; // Mask out delay bit
|
numArgs &= ~DELAY; // Mask out delay bit
|
||||||
while(numArgs--) { // For each argument...
|
while(numArgs--) { // For each argument...
|
||||||
writedata(pgm_read_byte(addr++)); // Read, issue argument
|
SPI.write(pgm_read_byte(addr++)); // Read, issue argument
|
||||||
}
|
}
|
||||||
|
|
||||||
if(ms) {
|
if(ms) {
|
||||||
|
@ -159,6 +152,7 @@ void Adafruit_ILI9341::commandList(uint8_t *addr) {
|
||||||
delay(ms);
|
delay(ms);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*csport |= cspinmask;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -182,24 +176,11 @@ void Adafruit_ILI9341::begin(void) {
|
||||||
SPI.setBitOrder(MSBFIRST);
|
SPI.setBitOrder(MSBFIRST);
|
||||||
SPI.setDataMode(SPI_MODE0);
|
SPI.setDataMode(SPI_MODE0);
|
||||||
mySPCR = SPCR;
|
mySPCR = SPCR;
|
||||||
#elif defined(TEENSYDUINO)
|
#elif defined(TEENSYDUINO) || defined (__STM32F1__)
|
||||||
SPI.begin();
|
SPI.begin();
|
||||||
SPI.setClockDivider(SPI_CLOCK_DIV2); // 8 MHz (full! speed!)
|
SPI.setClockDivider(SPI_CLOCK_DIV2); // 8 MHz (full! speed!)
|
||||||
SPI.setBitOrder(MSBFIRST);
|
SPI.setBitOrder(MSBFIRST);
|
||||||
SPI.setDataMode(SPI_MODE0);
|
SPI.setDataMode(SPI_MODE0);
|
||||||
#elif defined (__STM32F1__)
|
|
||||||
SPI.begin();
|
|
||||||
SPI.setClockDivider(SPI_CLOCK_DIV2);
|
|
||||||
SPI.setBitOrder(MSBFIRST);
|
|
||||||
SPI.setDataMode(SPI_MODE0);
|
|
||||||
// DMA setup stuff. We use a line buffer and usa DMA for filling lines and blocks.
|
|
||||||
spi_tx_dma_enable(SPI1);
|
|
||||||
dma_init(DMA1);
|
|
||||||
dma_attach_interrupt(DMA1, DMA_CH3, DMA1_CH3_Event);
|
|
||||||
dma_setup_transfer(DMA1, DMA_CH3, &SPI1->regs->DR, DMA_SIZE_8BITS,
|
|
||||||
lineBuffer, DMA_SIZE_8BITS, (DMA_MINC_MODE | DMA_FROM_MEM | DMA_TRNS_CMPLT));
|
|
||||||
|
|
||||||
|
|
||||||
#elif defined (__arm__)
|
#elif defined (__arm__)
|
||||||
SPI.begin();
|
SPI.begin();
|
||||||
SPI.setClockDivider(11); // 8-ish MHz (full! speed!)
|
SPI.setClockDivider(11); // 8-ish MHz (full! speed!)
|
||||||
|
@ -228,19 +209,6 @@ void Adafruit_ILI9341::begin(void) {
|
||||||
delay(150);
|
delay(150);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
uint8_t x = readcommand8(ILI9341_RDMODE);
|
|
||||||
Serial.print("\nDisplay Power Mode: 0x"); Serial.println(x, HEX);
|
|
||||||
x = readcommand8(ILI9341_RDMADCTL);
|
|
||||||
Serial.print("\nMADCTL Mode: 0x"); Serial.println(x, HEX);
|
|
||||||
x = readcommand8(ILI9341_RDPIXFMT);
|
|
||||||
Serial.print("\nPixel Format: 0x"); Serial.println(x, HEX);
|
|
||||||
x = readcommand8(ILI9341_RDIMGFMT);
|
|
||||||
Serial.print("\nImage Format: 0x"); Serial.println(x, HEX);
|
|
||||||
x = readcommand8(ILI9341_RDSELFDIAG);
|
|
||||||
Serial.print("\nSelf Diagnostic: 0x"); Serial.println(x, HEX);
|
|
||||||
*/
|
|
||||||
//if(cmdList) commandList(cmdList);
|
|
||||||
|
|
||||||
if (hwSPI) spi_begin();
|
if (hwSPI) spi_begin();
|
||||||
writecommand(0xEF);
|
writecommand(0xEF);
|
||||||
|
@ -285,7 +253,7 @@ void Adafruit_ILI9341::begin(void) {
|
||||||
writedata(0x10); //SAP[2:0];BT[3:0]
|
writedata(0x10); //SAP[2:0];BT[3:0]
|
||||||
|
|
||||||
writecommand(ILI9341_VMCTR1); //VCM control
|
writecommand(ILI9341_VMCTR1); //VCM control
|
||||||
writedata(0x3e); //<EFBFBD>Աȶȵ<EFBFBD><EFBFBD><EFBFBD>
|
writedata(0x3e); //¶Ô±È¶Èµ÷½Ú
|
||||||
writedata(0x28);
|
writedata(0x28);
|
||||||
|
|
||||||
writecommand(ILI9341_VMCTR2); //VCM control2
|
writecommand(ILI9341_VMCTR2); //VCM control2
|
||||||
|
@ -360,16 +328,20 @@ void Adafruit_ILI9341::setAddrWindow(uint16_t x0, uint16_t y0, uint16_t x1,
|
||||||
uint16_t y1) {
|
uint16_t y1) {
|
||||||
|
|
||||||
writecommand(ILI9341_CASET); // Column addr set
|
writecommand(ILI9341_CASET); // Column addr set
|
||||||
writedata(x0 >> 8);
|
*dcport |= dcpinmask;
|
||||||
writedata(x0 & 0xFF); // XSTART
|
*csport &= ~cspinmask;
|
||||||
writedata(x1 >> 8);
|
SPI.write(x0 >> 8);
|
||||||
writedata(x1 & 0xFF); // XEND
|
SPI.write(x0 & 0xFF); // XSTART
|
||||||
|
SPI.write(x1 >> 8);
|
||||||
|
SPI.write(x1 & 0xFF); // XEND
|
||||||
|
|
||||||
writecommand(ILI9341_PASET); // Row addr set
|
writecommand(ILI9341_PASET); // Row addr set
|
||||||
writedata(y0 >> 8);
|
*dcport |= dcpinmask;
|
||||||
writedata(y0); // YSTART
|
*csport &= ~cspinmask;
|
||||||
writedata(y1 >> 8);
|
SPI.write(y0>>8);
|
||||||
writedata(y1); // YEND
|
SPI.write(y0); // YSTART
|
||||||
|
SPI.write(y1>>8);
|
||||||
|
SPI.write(y1); // YEND
|
||||||
|
|
||||||
writecommand(ILI9341_RAMWR); // write to RAM
|
writecommand(ILI9341_RAMWR); // write to RAM
|
||||||
}
|
}
|
||||||
|
@ -377,13 +349,13 @@ void Adafruit_ILI9341::setAddrWindow(uint16_t x0, uint16_t y0, uint16_t x1,
|
||||||
|
|
||||||
void Adafruit_ILI9341::pushColor(uint16_t color) {
|
void Adafruit_ILI9341::pushColor(uint16_t color) {
|
||||||
if (hwSPI) spi_begin();
|
if (hwSPI) spi_begin();
|
||||||
//digitalWrite(_dc, HIGH);
|
|
||||||
*dcport |= dcpinmask;
|
*dcport |= dcpinmask;
|
||||||
//digitalWrite(_cs, LOW);
|
|
||||||
*csport &= ~cspinmask;
|
*csport &= ~cspinmask;
|
||||||
|
|
||||||
spiwrite(color >> 8);
|
SPI.write(color >> 8);
|
||||||
spiwrite(color);
|
SPI.write(color);
|
||||||
|
|
||||||
*csport |= cspinmask;
|
*csport |= cspinmask;
|
||||||
//digitalWrite(_cs, HIGH);
|
//digitalWrite(_cs, HIGH);
|
||||||
|
@ -397,16 +369,13 @@ void Adafruit_ILI9341::drawPixel(int16_t x, int16_t y, uint16_t color) {
|
||||||
if (hwSPI) spi_begin();
|
if (hwSPI) spi_begin();
|
||||||
setAddrWindow(x,y,x+1,y+1);
|
setAddrWindow(x,y,x+1,y+1);
|
||||||
|
|
||||||
//digitalWrite(_dc, HIGH);
|
|
||||||
*dcport |= dcpinmask;
|
*dcport |= dcpinmask;
|
||||||
//digitalWrite(_cs, LOW);
|
|
||||||
*csport &= ~cspinmask;
|
*csport &= ~cspinmask;
|
||||||
|
|
||||||
spiwrite(color >> 8);
|
SPI.write(color >> 8);
|
||||||
spiwrite(color);
|
SPI.write(color);
|
||||||
|
|
||||||
*csport |= cspinmask;
|
*csport |= cspinmask;
|
||||||
//digitalWrite(_cs, HIGH);
|
|
||||||
if (hwSPI) spi_end();
|
if (hwSPI) spi_end();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -415,50 +384,35 @@ void Adafruit_ILI9341::drawFastVLine(int16_t x, int16_t y, int16_t h,
|
||||||
uint16_t color) {
|
uint16_t color) {
|
||||||
|
|
||||||
// Rudimentary clipping
|
// Rudimentary clipping
|
||||||
if ((x >= _width) || (y >= _height || h < 1)) return;
|
if((x >= _width) || (y >= _height)) return;
|
||||||
|
|
||||||
if((y+h-1) >= _height)
|
if((y+h-1) >= _height)
|
||||||
h = _height - y;
|
|
||||||
|
|
||||||
// if (hwSPI) spi_begin();
|
|
||||||
setAddrWindow(x, y, x, y + h - 1);
|
|
||||||
|
|
||||||
uint8_t hi = color >> 8, lo = color;
|
|
||||||
|
|
||||||
*dcport |= dcpinmask;
|
|
||||||
//digitalWrite(_dc, HIGH);
|
|
||||||
*csport &= ~cspinmask;
|
|
||||||
//digitalWrite(_cs, LOW);
|
|
||||||
|
|
||||||
#if defined (__STM32F1__)
|
|
||||||
for (int i = 0; i < (h * 2) - 1 ; i = i + 2)
|
|
||||||
{
|
{
|
||||||
lineBuffer[i] = hi;
|
h = _height-y;
|
||||||
lineBuffer[i + 1] = lo;
|
|
||||||
}
|
}
|
||||||
dma_set_num_transfers(DMA1, DMA_CH3, h * 2); // 2 bytes per pixel
|
|
||||||
dma1_ch3_Active = true;
|
|
||||||
dma_enable(DMA1, DMA_CH3);
|
|
||||||
while (dma1_ch3_Active);
|
|
||||||
|
|
||||||
#else
|
if (hwSPI) spi_begin();
|
||||||
while (h--) {
|
setAddrWindow(x, y, x, y+h-1);
|
||||||
spiwrite(hi);
|
uint8_t hi = color >> 8, lo = color;
|
||||||
spiwrite(lo);
|
*dcport |= dcpinmask;
|
||||||
|
*csport &= ~cspinmask;
|
||||||
|
|
||||||
|
while (h--)
|
||||||
|
{
|
||||||
|
SPI.write(hi);
|
||||||
|
SPI.write(lo);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
*csport |= cspinmask;
|
*csport |= cspinmask;
|
||||||
//digitalWrite(_cs, HIGH);
|
|
||||||
// if (hwSPI) spi_end();
|
if (hwSPI) spi_end();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Adafruit_ILI9341::drawFastHLine(int16_t x, int16_t y, int16_t w,
|
void Adafruit_ILI9341::drawFastHLine(int16_t x, int16_t y, int16_t w,
|
||||||
uint16_t color) {
|
uint16_t color) {
|
||||||
|
|
||||||
|
|
||||||
// Rudimentary clipping
|
// Rudimentary clipping
|
||||||
if ((x >= _width) || (y >= _height || w < 1)) return;
|
if((x >= _width) || (y >= _height)) return;
|
||||||
if((x+w-1) >= _width) w = _width-x;
|
if((x+w-1) >= _width) w = _width-x;
|
||||||
if (hwSPI) spi_begin();
|
if (hwSPI) spi_begin();
|
||||||
setAddrWindow(x, y, x+w-1, y);
|
setAddrWindow(x, y, x+w-1, y);
|
||||||
|
@ -466,28 +420,11 @@ void Adafruit_ILI9341::drawFastHLine(int16_t x, int16_t y, int16_t w,
|
||||||
uint8_t hi = color >> 8, lo = color;
|
uint8_t hi = color >> 8, lo = color;
|
||||||
*dcport |= dcpinmask;
|
*dcport |= dcpinmask;
|
||||||
*csport &= ~cspinmask;
|
*csport &= ~cspinmask;
|
||||||
//digitalWrite(_dc, HIGH);
|
|
||||||
//digitalWrite(_cs, LOW);
|
|
||||||
#if defined (__STM32F1__)
|
|
||||||
|
|
||||||
for (int i = 0; i < (w * 2) - 1 ; i = i + 2)
|
|
||||||
{
|
|
||||||
lineBuffer[i] = hi;
|
|
||||||
lineBuffer[i + 1] = lo;
|
|
||||||
}
|
|
||||||
dma_set_num_transfers(DMA1, DMA_CH3, w * 2); // 2 bytes per pixel
|
|
||||||
dma1_ch3_Active = true;
|
|
||||||
dma_enable(DMA1, DMA_CH3);
|
|
||||||
while (dma1_ch3_Active) delayMicroseconds(1);
|
|
||||||
|
|
||||||
#else
|
|
||||||
while (w--) {
|
while (w--) {
|
||||||
spiwrite(hi);
|
SPI.write(hi);
|
||||||
spiwrite(lo);
|
SPI.write(lo);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
*csport |= cspinmask;
|
*csport |= cspinmask;
|
||||||
//digitalWrite(_cs, HIGH);
|
|
||||||
if (hwSPI) spi_end();
|
if (hwSPI) spi_end();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -498,9 +435,9 @@ void Adafruit_ILI9341::fillScreen(uint16_t color) {
|
||||||
// fill a rectangle
|
// fill a rectangle
|
||||||
void Adafruit_ILI9341::fillRect(int16_t x, int16_t y, int16_t w, int16_t h,
|
void Adafruit_ILI9341::fillRect(int16_t x, int16_t y, int16_t w, int16_t h,
|
||||||
uint16_t color) {
|
uint16_t color) {
|
||||||
|
int numPixels;
|
||||||
// rudimentary clipping (drawChar w/big text requires this)
|
// rudimentary clipping (drawChar w/big text requires this)
|
||||||
if ((x >= _width) || (y >= _height || h < 1 || w < 1)) return;
|
if((x >= _width) || (y >= _height)) return;
|
||||||
if((x + w - 1) >= _width) w = _width - x;
|
if((x + w - 1) >= _width) w = _width - x;
|
||||||
if((y + h - 1) >= _height) h = _height - y;
|
if((y + h - 1) >= _height) h = _height - y;
|
||||||
|
|
||||||
|
@ -510,29 +447,8 @@ void Adafruit_ILI9341::fillRect(int16_t x, int16_t y, int16_t w, int16_t h,
|
||||||
uint8_t hi = color >> 8, lo = color;
|
uint8_t hi = color >> 8, lo = color;
|
||||||
|
|
||||||
*dcport |= dcpinmask;
|
*dcport |= dcpinmask;
|
||||||
//digitalWrite(_dc, HIGH);
|
|
||||||
*csport &= ~cspinmask;
|
*csport &= ~cspinmask;
|
||||||
//digitalWrite(_cs, LOW);
|
|
||||||
#if defined (__STM32F1__)
|
|
||||||
|
|
||||||
//moved this loop outside as we can fill the buffer once and send it multiple times.
|
|
||||||
for (int i = 0; i < (w * 2) - 1 ; i = i + 2)
|
|
||||||
{
|
|
||||||
lineBuffer[i] = hi;
|
|
||||||
lineBuffer[i + 1] = lo;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (y = h; y > 0; y--) {
|
|
||||||
// for(x=w; x>0; x--) {
|
|
||||||
// spiwrite(hi);
|
|
||||||
// spiwrite(lo);
|
|
||||||
// }
|
|
||||||
dma_set_num_transfers(DMA1, DMA_CH3, w * 2); // 2 bytes per pixel
|
|
||||||
dma1_ch3_Active = true;
|
|
||||||
dma_enable(DMA1, DMA_CH3);
|
|
||||||
while (dma1_ch3_Active) delayMicroseconds(1);
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
for(y=h; y>0; y--)
|
for(y=h; y>0; y--)
|
||||||
{
|
{
|
||||||
for(x=w; x>0; x--)
|
for(x=w; x>0; x--)
|
||||||
|
@ -541,11 +457,9 @@ void Adafruit_ILI9341::fillRect(int16_t x, int16_t y, int16_t w, int16_t h,
|
||||||
SPI.write(lo);
|
SPI.write(lo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
//digitalWrite(_cs, HIGH);
|
|
||||||
*csport |= cspinmask;
|
|
||||||
if (hwSPI) spi_end();
|
if (hwSPI) spi_end();
|
||||||
|
*csport |= cspinmask;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -615,9 +529,7 @@ uint8_t Adafruit_ILI9341::spiread(void) {
|
||||||
while(!(SPSR & _BV(SPIF)));
|
while(!(SPSR & _BV(SPIF)));
|
||||||
r = SPDR;
|
r = SPDR;
|
||||||
SPCR = backupSPCR;
|
SPCR = backupSPCR;
|
||||||
#elif defined(TEENSYDUINO)
|
#elif defined(TEENSYDUINO) || defined (__STM32F1__)
|
||||||
r = SPI.transfer(0x00);
|
|
||||||
#elif defined (__STM32F1__)
|
|
||||||
r = SPI.transfer(0x00);
|
r = SPI.transfer(0x00);
|
||||||
#elif defined (__arm__)
|
#elif defined (__arm__)
|
||||||
SPI.setClockDivider(11); // 8-ish MHz (full! speed!)
|
SPI.setClockDivider(11); // 8-ish MHz (full! speed!)
|
||||||
|
@ -654,15 +566,15 @@ uint8_t Adafruit_ILI9341::readcommand8(uint8_t c, uint8_t index) {
|
||||||
if (hwSPI) spi_begin();
|
if (hwSPI) spi_begin();
|
||||||
digitalWrite(_dc, LOW); // command
|
digitalWrite(_dc, LOW); // command
|
||||||
digitalWrite(_cs, LOW);
|
digitalWrite(_cs, LOW);
|
||||||
spiwrite(0xD9); // woo sekret command?
|
SPI.write(0xD9); // woo sekret command?
|
||||||
digitalWrite(_dc, HIGH); // data
|
digitalWrite(_dc, HIGH); // data
|
||||||
spiwrite(0x10 + index);
|
SPI.write(0x10 + index);
|
||||||
digitalWrite(_cs, HIGH);
|
digitalWrite(_cs, HIGH);
|
||||||
|
|
||||||
digitalWrite(_dc, LOW);
|
digitalWrite(_dc, LOW);
|
||||||
digitalWrite(_sclk, LOW);
|
digitalWrite(_sclk, LOW);
|
||||||
digitalWrite(_cs, LOW);
|
digitalWrite(_cs, LOW);
|
||||||
spiwrite(c);
|
SPI.write(c);
|
||||||
|
|
||||||
digitalWrite(_dc, HIGH);
|
digitalWrite(_dc, HIGH);
|
||||||
uint8_t r = spiread();
|
uint8_t r = spiread();
|
||||||
|
|
|
@ -1,16 +1,31 @@
|
||||||
/*
|
/***************************************************
|
||||||
See rights and use declaration in License.h
|
This is our library for the Adafruit ILI9341 Breakout and Shield
|
||||||
This library has been modified for the Maple Mini
|
----> http://www.adafruit.com/products/1651
|
||||||
*/
|
|
||||||
|
Check out the links above for our tutorials and wiring diagrams
|
||||||
|
These displays use SPI to communicate, 4 or 5 pins are required to
|
||||||
|
interface (RST is optional)
|
||||||
|
Adafruit invests time and resources providing this open source code,
|
||||||
|
please support Adafruit and open-source hardware by purchasing
|
||||||
|
products from Adafruit!
|
||||||
|
|
||||||
|
Written by Limor Fried/Ladyada for Adafruit Industries.
|
||||||
|
MIT license, all text above must be included in any redistribution
|
||||||
|
****************************************************/
|
||||||
|
|
||||||
#ifndef _ADAFRUIT_ILI9341H_
|
#ifndef _ADAFRUIT_ILI9341H_
|
||||||
#define _ADAFRUIT_ILI9341H_
|
#define _ADAFRUIT_ILI9341H_
|
||||||
|
|
||||||
|
#if ARDUINO >= 100
|
||||||
#include "Arduino.h"
|
#include "Arduino.h"
|
||||||
#include "Print.h"
|
#include "Print.h"
|
||||||
#include "Adafruit_GFX.h"
|
#else
|
||||||
|
#include "WProgram.h"
|
||||||
|
#endif
|
||||||
|
#include <Adafruit_GFX.h>
|
||||||
#include <avr/pgmspace.h>
|
#include <avr/pgmspace.h>
|
||||||
|
|
||||||
|
|
||||||
#define ILI9341_TFTWIDTH 240
|
#define ILI9341_TFTWIDTH 240
|
||||||
#define ILI9341_TFTHEIGHT 320
|
#define ILI9341_TFTHEIGHT 320
|
||||||
|
|
||||||
|
@ -128,23 +143,22 @@ class Adafruit_ILI9341 : public Adafruit_GFX {
|
||||||
commandList(uint8_t *addr);
|
commandList(uint8_t *addr);
|
||||||
uint8_t spiread(void);
|
uint8_t spiread(void);
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
uint8_t tabcolor;
|
uint8_t tabcolor;
|
||||||
|
|
||||||
volatile byte lineBuffer[640];
|
|
||||||
|
|
||||||
|
|
||||||
boolean hwSPI;
|
boolean hwSPI;
|
||||||
|
#if defined (__STM32F1__)
|
||||||
|
#define RwReg uint32
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#if defined (__AVR__) || defined(TEENSYDUINO)
|
#if defined (__AVR__) || defined(TEENSYDUINO)
|
||||||
uint8_t mySPCR;
|
uint8_t mySPCR;
|
||||||
volatile uint8_t *mosiport, *clkport, *dcport, *rsport, *csport;
|
volatile uint8_t *mosiport, *clkport, *dcport, *rsport, *csport;
|
||||||
int8_t _cs, _dc, _rst, _mosi, _miso, _sclk;
|
int8_t _cs, _dc, _rst, _mosi, _miso, _sclk;
|
||||||
uint8_t mosipinmask, clkpinmask, cspinmask, dcpinmask;
|
uint8_t mosipinmask, clkpinmask, cspinmask, dcpinmask;
|
||||||
#elif defined (__STM32F1__)
|
|
||||||
volatile uint32 *mosiport, *clkport, *dcport, *rsport, *csport;
|
|
||||||
uint32_t _cs, _dc, _rst, _mosi, _miso, _sclk;
|
|
||||||
uint32_t mosipinmask, clkpinmask, cspinmask, dcpinmask;
|
|
||||||
#elif defined (__arm__)
|
#elif defined (__arm__)
|
||||||
volatile RwReg *mosiport, *clkport, *dcport, *rsport, *csport;
|
volatile RwReg *mosiport, *clkport, *dcport, *rsport, *csport;
|
||||||
uint32_t _cs, _dc, _rst, _mosi, _miso, _sclk;
|
uint32_t _cs, _dc, _rst, _mosi, _miso, _sclk;
|
||||||
|
|
|
@ -1,99 +0,0 @@
|
||||||
// License.h
|
|
||||||
// All tab licenses are here
|
|
||||||
// This library was modified to support DMA in Maple Mini by Victor Perez in 03/17/2015
|
|
||||||
|
|
||||||
/***************************************************
|
|
||||||
This is our GFX example for the Adafruit ILI9341 Breakout and Shield
|
|
||||||
----> http://www.adafruit.com/products/1651
|
|
||||||
Check out the links above for our tutorials and wiring diagrams
|
|
||||||
These displays use SPI to communicate, 4 or 5 pins are required to
|
|
||||||
interface (RST is optional)
|
|
||||||
/*
|
|
||||||
This is the core graphics library for all our displays, providing a common
|
|
||||||
set of graphics primitives (points, lines, circles, etc.). It needs to be
|
|
||||||
paired with a hardware-specific library for each display device we carry
|
|
||||||
(to handle the lower-level functions).
|
|
||||||
|
|
||||||
Adafruit invests time and resources providing this open source code, please
|
|
||||||
support Adafruit & open-source hardware by purchasing products from Adafruit!
|
|
||||||
|
|
||||||
Copyright (c) 2013 Adafruit Industries. All rights reserved.
|
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
|
||||||
modification, are permitted provided that the following conditions are met:
|
|
||||||
|
|
||||||
- Redistributions of source code must retain the above copyright notice,
|
|
||||||
this list of conditions and the following disclaimer.
|
|
||||||
- Redistributions in binary form must reproduce the above copyright notice,
|
|
||||||
this list of conditions and the following disclaimer in the documentation
|
|
||||||
and/or other materials provided with the distribution.
|
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
||||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
|
||||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
||||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
||||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
||||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
||||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
||||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
||||||
POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/***************************************************
|
|
||||||
This is our library for the Adafruit ILI9341 Breakout and Shield
|
|
||||||
----> http://www.adafruit.com/products/1651
|
|
||||||
|
|
||||||
Check out the links above for our tutorials and wiring diagrams
|
|
||||||
These displays use SPI to communicate, 4 or 5 pins are required to
|
|
||||||
interface (RST is optional)
|
|
||||||
Adafruit invests time and resources providing this open source code,
|
|
||||||
please support Adafruit and open-source hardware by purchasing
|
|
||||||
products from Adafruit!
|
|
||||||
|
|
||||||
Written by Limor Fried/Ladyada for Adafruit Industries.
|
|
||||||
MIT license, all text above must be included in any redistribution
|
|
||||||
****************************************************/
|
|
||||||
|
|
||||||
/*
|
|
||||||
Roughly based on Adafruit example sketch: "parsing"
|
|
||||||
Utilizes the (modified) Adafruit_GPS library https://github.com/adafruit/Adafruit-GPS-Library
|
|
||||||
20131204: GPS TimeDate with Temperature
|
|
||||||
Heavily mucked by M. Ray Burnette to simply use (most) any dumb serial TTL GPS for time-date
|
|
||||||
Tested with unit#28146 Parallax module @4800 BAUD http://www.abra-electronics.com/products/28146-Parallax-GPS-Receiver-Module.html
|
|
||||||
Tested with uBlox and external antenna @9600 BAUD http://www.ebay.com/itm/390647042336
|
|
||||||
Tested with uBlox and internal antenna @9600 BAUD http://www.ebay.com/itm/181219728986
|
|
||||||
|
|
||||||
*/
|
|
||||||
/*
|
|
||||||
SoftwareSerial.h (formerly NewSoftSerial.h) -
|
|
||||||
Multi-instance software serial library for Arduino/Wiring
|
|
||||||
-- Interrupt-driven receive and other improvements by ladyada
|
|
||||||
(http://ladyada.net)
|
|
||||||
-- Tuning, circular buffer, derivation from class Print/Stream,
|
|
||||||
multi-instance support, porting to 8MHz processors,
|
|
||||||
various optimizations, PROGMEM delay tables, inverse logic and
|
|
||||||
direct port writing by Mikal Hart (http://www.arduiniana.org)
|
|
||||||
-- Pin change interrupt macros by Paul Stoffregen (http://www.pjrc.com)
|
|
||||||
-- 20MHz processor support by Garrett Mace (http://www.macetech.com)
|
|
||||||
-- ATmega1280/2560 support by Brett Hagman (http://www.roguerobotics.com/)
|
|
||||||
|
|
||||||
This library is free software; you can redistribute it and/or
|
|
||||||
modify it under the terms of the GNU Lesser General Public
|
|
||||||
License as published by the Free Software Foundation; either
|
|
||||||
version 2.1 of the License, or (at your option) any later version.
|
|
||||||
|
|
||||||
This library is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
Lesser General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public
|
|
||||||
License along with this library; if not, write to the Free Software
|
|
||||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
||||||
|
|
||||||
The latest version of this library can always be found at
|
|
||||||
http://arduiniana.org.
|
|
||||||
*/
|
|
||||||
|
|
|
@ -1,5 +1,19 @@
|
||||||
It has minor modifications to support STM32. It has been tested with the Maple Mini.
|
This library is based on the Adafruit ILI9341 (see original Adafuit text description below)
|
||||||
Further modifications to support DMA transfers in the STM32F1xx by Victor Perez 3/17/2015
|
|
||||||
|
|
||||||
|
It has minor modifications to support STM32 and also one small change to use spi.write(byte) instead of spi.transfer(byte) as this gave
|
||||||
|
a useful speed improvement.
|
||||||
|
|
||||||
|
It has been tested with standard ILI9341 from various suppliers e.g on eBay
|
||||||
|
|
||||||
|
This library requires the Adafruit GFC library, https://github.com/adafruit/Adafruit-GFX-Library
|
||||||
|
|
||||||
|
An addition example stm32_graphicstest has been added to show how to configure for stm32 - which uses hardware SPI and hence its not possible to
|
||||||
|
set the SCK MISO and MOSI pins.
|
||||||
|
|
||||||
|
_________________________ Original text from Adafruit ____________________________________________
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
This is a library for the Adafruit ILI9341 display products
|
This is a library for the Adafruit ILI9341 display products
|
||||||
|
|
||||||
|
|
|
@ -1,124 +0,0 @@
|
||||||
/*
|
|
||||||
An example showing rainbow colours on a 2.2" TFT LCD screen
|
|
||||||
and to show a basic example of font use.
|
|
||||||
|
|
||||||
The existing Adafruit font is still in the library
|
|
||||||
Only new font sizes 2,4,6 and 7 are implemented in the Adafruit_GFX library.
|
|
||||||
|
|
||||||
This examples uses the hardware SPI only. Non-hardware SPI
|
|
||||||
is just too slow (~8 times slower!)
|
|
||||||
|
|
||||||
Alan Senior 18/1/2015
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
// These are the connections for the UNO
|
|
||||||
//#define sclk 13 // Don't change
|
|
||||||
//#define mosi 11 // Don't change
|
|
||||||
#define cs 8
|
|
||||||
#define dc 10
|
|
||||||
#define rst 9 // you can also connect this to the Arduino reset
|
|
||||||
#include <Adafruit_GFX.h> // Core graphics library
|
|
||||||
#include <Adafruit_ILI9341.h> // Hardware-specific library
|
|
||||||
#include <SPI.h>
|
|
||||||
|
|
||||||
Adafruit_ILI9341 tft = Adafruit_ILI9341(cs, dc, rst); // Invoke custom library
|
|
||||||
|
|
||||||
unsigned long targetTime = 0;
|
|
||||||
byte red = 31;
|
|
||||||
byte green = 0;
|
|
||||||
byte blue = 0;
|
|
||||||
byte state = 0;
|
|
||||||
unsigned int colour = red << 11;
|
|
||||||
|
|
||||||
void setup(void) {
|
|
||||||
tft.begin();
|
|
||||||
tft.setRotation(2);
|
|
||||||
tft.fillScreen(ILI9341_BLACK);
|
|
||||||
|
|
||||||
targetTime = millis() + 1000;
|
|
||||||
}
|
|
||||||
|
|
||||||
void loop() {
|
|
||||||
|
|
||||||
if (targetTime < millis()) {
|
|
||||||
targetTime = millis()+10000;
|
|
||||||
for (int i = 0; i<240; i++) {
|
|
||||||
tft.drawFastVLine(i, 0, tft.height(), colour);
|
|
||||||
switch (state) {
|
|
||||||
case 0:
|
|
||||||
green +=2;
|
|
||||||
if (green == 64) {
|
|
||||||
green=63;
|
|
||||||
state = 1;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
red--;
|
|
||||||
if (red == 255) {
|
|
||||||
red = 0;
|
|
||||||
state = 2;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
blue ++;
|
|
||||||
if (blue == 32) {
|
|
||||||
blue=31;
|
|
||||||
state = 3;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
green -=2;
|
|
||||||
if (green ==255) {
|
|
||||||
green=0;
|
|
||||||
state = 4;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 4:
|
|
||||||
red ++;
|
|
||||||
if (red == 32) {
|
|
||||||
red = 31;
|
|
||||||
state = 5;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 5:
|
|
||||||
blue --;
|
|
||||||
if (blue == 255) {
|
|
||||||
blue = 0;
|
|
||||||
state = 0;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
colour = red<<11 | green<<5 | blue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// The standard ADAFruit font still works as berfore
|
|
||||||
tft.setTextColor(ILI9341_BLACK, ILI9341_BLACK); // Note these fonts do not plot the background colour
|
|
||||||
tft.setCursor (68, 5);
|
|
||||||
tft.print("Original ADAfruit font!");
|
|
||||||
|
|
||||||
// The new larger fonts do not use the .setCursor call, coords are embedded
|
|
||||||
tft.setTextColor(ILI9341_BLACK); // Do not plot the background colour
|
|
||||||
// Overlay the black text on top of the rainbow plot (the advantage of not drawing the backgorund colour!)
|
|
||||||
tft.drawCentreString("Font size 2",120,14,2); // Draw text centre at position 120, 14 using font 2
|
|
||||||
tft.drawCentreString("Font size 4",120,30,4); // Draw text centre at position 120, 30 using font 4
|
|
||||||
tft.drawCentreString("12.34",120,54,6); // Draw text centre at position 120, 54 using font 6
|
|
||||||
tft.drawCentreString("12.34 is in font size 6",120,92,2); // Draw text centre at position 120, 92 using font 2
|
|
||||||
// Note the x position is the top of the font!
|
|
||||||
|
|
||||||
// draw a floating point number
|
|
||||||
float pi = 3.14159; // Value to print
|
|
||||||
int precision = 3; // Number of digits after decimal point
|
|
||||||
int xpos = 90; // x position
|
|
||||||
int ypos = 110; // y position
|
|
||||||
int font = 2; // font number only 2,4,6,7 valid. Font 6 only contains characters [space] 0 1 2 3 4 5 6 7 8 9 0 : . a p m
|
|
||||||
xpos+=tft.drawFloat(pi,precision,xpos,ypos,font); // Draw rounded number and return new xpos delta for next print position
|
|
||||||
tft.drawString(" is pi",xpos,ypos,font); // Continue printing from new x position
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
It has minor modifications to support STM32. It has been tested with the Maple Mini.
|
||||||
|
|
||||||
|
This is a library for the Adafruit ILI9341 display products
|
||||||
|
|
||||||
|
This library works with the Adafruit 2.8" Touch Shield V2 (SPI)
|
||||||
|
----> http://www.adafruit.com/products/1651
|
||||||
|
|
||||||
|
Check out the links above for our tutorials and wiring diagrams.
|
||||||
|
These displays use SPI to communicate, 4 or 5 pins are required
|
||||||
|
to interface (RST is optional).
|
||||||
|
|
||||||
|
Adafruit invests time and resources providing this open source code,
|
||||||
|
please support Adafruit and open-source hardware by purchasing
|
||||||
|
products from Adafruit!
|
||||||
|
|
||||||
|
Written by Limor Fried/Ladyada for Adafruit Industries.
|
||||||
|
MIT license, all text above must be included in any redistribution
|
||||||
|
|
||||||
|
To download. click the DOWNLOADS button in the top right corner, rename the uncompressed folder Adafruit_ILI9341. Check that the Adafruit_ILI9341 folder contains Adafruit_ILI9341.cpp and Adafruit_ILI9341.
|
||||||
|
|
||||||
|
Place the Adafruit_ILI9341 library folder your arduinosketchfolder/libraries/ folder. You may need to create the libraries subfolder if its your first library. Restart the IDE
|
||||||
|
|
||||||
|
Also requires the Adafruit_GFX library for Arduino.
|
|
@ -31,19 +31,19 @@ code color
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// These are the connections for the UNO
|
// These are the connections for the UNO
|
||||||
//#define sclk 6 // Don't change
|
#define sclk 6 // Don't change
|
||||||
//#define mosi 4 // Don't change
|
#define mosi 4 // Don't change
|
||||||
#define cs 8
|
#define cs 8
|
||||||
#define dc 10
|
#define dc 10
|
||||||
#define rst 9 // you can also connect this to the Arduino reset
|
#define rst 9 // you can also connect this to the Arduino reset
|
||||||
|
|
||||||
#include <Adafruit_GFX.h> // Core graphics library
|
#include <Adafruit_GFX_AS.h> // Core graphics library
|
||||||
#include <Adafruit_ILI9341.h> // Hardware-specific library
|
#include <Adafruit_ILI9341_AS.h> // Hardware-specific library
|
||||||
#include <SPI.h>
|
#include <SPI.h>
|
||||||
|
|
||||||
#define ILI9341_GREY 0x5AEB
|
#define ILI9341_GREY 0x5AEB
|
||||||
|
|
||||||
Adafruit_ILI9341 tft = Adafruit_ILI9341(cs, dc, rst); // Invoke custom library
|
Adafruit_ILI9341_AS tft = Adafruit_ILI9341_AS(cs, dc, rst); // Invoke custom library
|
||||||
|
|
||||||
uint32_t targetTime = 0; // for next 1 second timeout
|
uint32_t targetTime = 0; // for next 1 second timeout
|
||||||
uint8_t hh=conv2d(__TIME__), mm=conv2d(__TIME__+3), ss=conv2d(__TIME__+6); // Get H, M, S from compile time
|
uint8_t hh=conv2d(__TIME__), mm=conv2d(__TIME__+3), ss=conv2d(__TIME__+6); // Get H, M, S from compile time
|
|
@ -11,19 +11,19 @@
|
||||||
Updated by Alan Senior 18/1/2015
|
Updated by Alan Senior 18/1/2015
|
||||||
*/
|
*/
|
||||||
|
|
||||||
//#define sclk 6 // Don't change
|
#define sclk 6 // Don't change
|
||||||
//#define mosi 4 // Don't change
|
#define mosi 4 // Don't change
|
||||||
#define cs 8
|
#define cs 8
|
||||||
#define dc 10
|
#define dc 10
|
||||||
#define rst 9 // you can also connect this to the Arduino reset
|
#define rst 9 // you can also connect this to the Arduino reset
|
||||||
|
|
||||||
#include <Adafruit_GFX.h> // Core graphics library
|
#include <Adafruit_GFX_AS.h> // Core graphics library
|
||||||
#include <Adafruit_ILI9341.h> // Hardware-specific library
|
#include <Adafruit_ILI9341_AS.h> // Hardware-specific library
|
||||||
#include <SPI.h>
|
#include <SPI.h>
|
||||||
|
|
||||||
#define ILI9341_GREY 0x5AEB
|
#define ILI9341_GREY 0x5AEB
|
||||||
|
|
||||||
Adafruit_ILI9341 tft = Adafruit_ILI9341(cs, dc, rst); // Invoke custom library
|
Adafruit_ILI9341_AS tft = Adafruit_ILI9341_AS(cs, dc, rst); // Invoke custom library
|
||||||
|
|
||||||
float sx = 0, sy = 1, mx = 1, my = 0, hx = -1, hy = 0; // Saved H, M, S x & y multipliers
|
float sx = 0, sy = 1, mx = 1, my = 0, hx = -1, hy = 0; // Saved H, M, S x & y multipliers
|
||||||
float sdeg=0, mdeg=0, hdeg=0;
|
float sdeg=0, mdeg=0, hdeg=0;
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
Sow all the fonts.
|
Sow all the fonts.
|
||||||
|
|
||||||
Only font sizes 2, 4, 6 and 7 are implemented in the Adafruit_GFX library.
|
Only font sizes 2, 4, 6 and 7 are implemented in the Adafruit_GFX_AS library.
|
||||||
|
|
||||||
This examples uses the hardware SPI only. Non-hardware SPI
|
This examples uses the hardware SPI only. Non-hardware SPI
|
||||||
is just too slow (~8 times slower!)
|
is just too slow (~8 times slower!)
|
||||||
|
@ -26,17 +26,17 @@
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
//#define sclk 6 // Don't change
|
#define sclk 6 // Don't change
|
||||||
//#define mosi 4 // Don't change
|
#define mosi 4 // Don't change
|
||||||
#define cs 8
|
#define cs 8
|
||||||
#define dc 10
|
#define dc 10
|
||||||
#define rst 9 // you can also connect this to the Arduino reset
|
#define rst 9 // you can also connect this to the Arduino reset
|
||||||
|
|
||||||
#include <Adafruit_GFX.h> // Core graphics library
|
#include <Adafruit_GFX_AS.h> // Core graphics library
|
||||||
#include <Adafruit_ILI9341.h> // Hardware-specific library
|
#include <Adafruit_ILI9341_AS.h> // Hardware-specific library
|
||||||
#include <SPI.h>
|
#include <SPI.h>
|
||||||
|
|
||||||
Adafruit_ILI9341 tft = Adafruit_ILI9341(cs, dc, rst); // Invoke custom library
|
Adafruit_ILI9341_AS tft = Adafruit_ILI9341_AS(cs, dc, rst); // Invoke custom library
|
||||||
|
|
||||||
unsigned long targetTime = 0;
|
unsigned long targetTime = 0;
|
||||||
byte red = 31;
|
byte red = 31;
|
Binary file not shown.
Loading…
Reference in New Issue