Digistump Forums
The DigiX => DigiX Support => Topic started by: Amus3d on October 01, 2014, 03:14:53 pm
-
Hi i've bought some 2.8" tft from adafruit for my raspberrys and wonder if they could be connect to the digix since it that same screen and chip as the 2.8" arduino uno/mega version.
https://learn.adafruit.com/adafruit-pitft-28-inch-resistive-touchscreen-display-raspberry-pi
https://learn.adafruit.com/system/assets/assets/000/013/040/original/raspberry_pi_pitftschem.png?1387563188
if so any ideas how to connect it to digix and what lib i should use
cheers.
-
The screen seems to use SPI for communication, plus a couple of extra GPIOs, so it certainly *should* be possible. But my quick Googling didn't turn up any Arduino libraries or how-tos... :-\
-
i couldn't find anything either, other than the screen and chip is the same as the arduino version just different pcb board. and think the raspberry version, uses less pins than the arduino version.
cheers any way :)
-
not sure if iam on the right track,Using Example UTFT_Demo320x240_Serial chip ILI9341_S5P
Raspberry pi pins
| 3 | 5 | 19 | 21 | 23 | 24 |
| SDA | SCL | MOSI | MISO | SCLK | CE0 |
DigiX
DigiX pin 8 = pi : 19
DigiX pin 9 = pi : ?
DigiX pin 10 = pi : ?
DigiX pin 11 = pi : ?
DigiX pin 12 = pi : 24
-
Got picture :).
Raspberry Pins used
1,2 = due 3.3volts
6 = due gnd
19 due MOSI
21 due MISO
23 due SCK
22 due 9
24 due 10
26 due 11 not sure why pin 11 but if i use pin 8 picture is reversed as if youre looking from the other side of screen lol
using lib https://github.com/marekburiak/ILI9341_due/tree/master
-
Excellent! I have one of these in my parts collection, waiting for me to solder the headers on. Now I know that if I ever decide I don't need it for my RPi, I can repurpose it on my DigiX.
-
:) just need to figure out touch pad now
-
Wrote a little program that can draw from the Serial window,
clr(255,255,255) clears screen
setColor( 0 , 0 , 0 ) to setColor( 255 , 255 , 255 )
arc( posX , posY , size , lineThickness , startCircle , endcircle )
ie. arc( 100 , 100 , 50 , 1 , 40 , 360 )
will add more, text(), squ() etc..
#include <SPI.h>
#include <ILI_SdSpi.h>
#include <ILI_SdFatConfig.h>
#include <ILI9341_due_gText.h>
#include <ILI9341_due.h>
#include "fonts\Arial_bold_14.h"
#define TFT_DC 9
#define TFT_CS 10
ILI9341_due tft = ILI9341_due(TFT_CS, TFT_DC);
char textBuff[20];
char charTemp[20];
int color[3];
ILI9341_due_gText t1(&tft);
ILI9341_due_gText t2(&tft);
ILI9341_due_gText t3(&tft);
uint16_t colorLightGray = tft.color565(192,192,192);
uint16_t colorGray = tft.color565(127,127,127);
uint16_t colorDarkGray = tft.color565(64,64,64);
// Globals
uint16_t radius = 55;
uint16_t s1x = 0;
uint16_t s1y = 10;
int myDelay = 2000;
void setup() {
Serial.begin(9600);
tft.begin();
tft.setRotation(3);
delay(500);
screenLoading();
while(!Serial.available()){
Serial.println(F("Enter any key to begin"));
screenLoading();
delay(2000);
}
}
void loop() {
if( Serial.available() >0 ){
String str="";
while(Serial.available()>0){
str += char(Serial.read());
}
serialInput( str );
Serial.println();
}
}
void screenLoading(){
const uint16_t x = 159;
const uint16_t y = 149;
tft.fillScreen(ILI9341_BLACK);
t1.selectFont(roboto32);
t1.setFontLetterSpacing(5);
t1.setFontColor(ILI9341_WHITE, ILI9341_BLACK);
t1.defineArea(100, 85, 220, 140);
strcpy(textBuff, "Loading...");
t1.drawString(textBuff, gTextAlignTopCenter, 0, 0);
tft.drawArc(x, y, 10, 5, 0, 360, colorLightGray);
for(int i=0; i<2880; i+=4){
tft.drawArc(x, y, 10, 5, (i >> 1)-45, (i >> 1)+45, colorDarkGray);
tft.drawArc(x, y, 10, 5, (i >> 1)-45-4, (i >> 1)-45, colorLightGray);
tft.drawArc(x, y, 20, 5, 1440-i-45, 1440-i+45, colorDarkGray);
tft.drawArc(x, y, 20, 5, 1440-i+45, 1440-i+45+4, colorLightGray);
}
}
void serialInput( String str ){
int command = getCommandAsInt( str );
String variables = getDataAsString( str );
switch( command ){
case 321: // clr=321
clrScreen( variables );
break;
case 310: // clr=321
arc( variables );
break;
case 843: // clr=321
getColorData( variables );
break;
default:
Serial.println( command );
}
}
String getDataAsString( String str ){
int myStart = str.indexOf('(');
int myEnd = str.indexOf(')');
if(myStart==-1)
return "";
return str.substring( myStart+1 , myEnd );
}
int getCommandAsInt( String str ){
// convert a String value to a int ie abc a+b+c
int endCommandLetter = str.indexOf('(');
int stringValue=0;
if(endCommandLetter==-1)
endCommandLetter=str.length();
for(int i=0;i<endCommandLetter;i++){
stringValue+=str.charAt(i);
}
return stringValue;
}
int getDataCount( String str ){
String strTemp = str.substring( str.indexOf('(')+1 , str.indexOf(')') );
return findOutHowManyCharInAString( strTemp , ',' );
}
int findOutHowManyCharInAString(String str, char findChar){
int positionChar = 0, count=0;
while(positionChar != -1){
positionChar = str.indexOf( findChar , positionChar+1 );
if(positionChar!=-1)
count++;
}
return count;
}
int stringToInt(String thisString) {
int i, value, length;
length = thisString.length();
char blah[(length+1)];
for(i=0; i<length; i++) {
blah[i] = thisString.charAt(i);
}
blah[i]=0;
value = atoi(blah);
return value;
}
void setCharTemp( String str ){
String strTemp = str.substring( str.indexOf('(')+1 , str.indexOf(')') );
strTemp.toCharArray( textBuff , 20 );
}
int getIntData( String str ){
int value = stringToInt( str.substring( str.indexOf('(')+1 , str.indexOf(')') ));
if(value==0)
return myDelay;
else
return value;
}
String getStringData( String str ){
int myStart = str.indexOf('(');
int myEnd = str.indexOf(')');
return str.substring( myStart+1 , myEnd );
}
void clrScreen( String str ){
if(str.length()>0){
boolean isColor = getColorData( str );
uint16_t myColor = tft.color565(color[0],color[1],color[2]);
tft.fillScreen( myColor );
}
else
Serial.println("clr(r,g,b) ie clr( 255 , 255 , 255 ) ");
}
boolean getColorData( String str ){
int myLength = str.length();
if(myLength>0){
color[0] = stringToInt( str.substring(0 , str.indexOf( ',' )));
color[1] = stringToInt( str.substring(str.indexOf( ',' )+1 , str.lastIndexOf( ',' )));
color[2] = stringToInt( str.substring(str.lastIndexOf( ',' )+1 , myLength ));
}
else
return 0;
}
void arc(String str){
Serial.println( str );
Serial.println(findOutHowManyCharInAString( str , ',' )+1);
int x=stringToInt( str.substring( 0 , str.indexOf(',')));
str = str.substring( str.indexOf(',')+1 , str.length() );
int y=stringToInt( str.substring( 0 , str.indexOf(',')));
str = str.substring( str.indexOf(',')+1 , str.length() );
int sizeC=stringToInt( str.substring( 0 , str.indexOf(',')));
str = str.substring( str.indexOf(',')+1 , str.length() );
int thickness=stringToInt( str.substring( 0 , str.indexOf(',')));
str = str.substring( str.indexOf(',')+1 , str.length() );
int startC=stringToInt( str.substring( 0 , str.indexOf(',')));
str = str.substring( str.indexOf(',')+1 , str.length() );
int endC=stringToInt( str.substring( 0 , str.indexOf(',')));
str = str.substring( str.indexOf(',')+1 , str.length() );
Serial.println( str );
uint16_t myColor = tft.color565(color[0],color[1],color[2]);
tft.drawArc(x, y, sizeC, thickness, startC, endC, myColor);
}