I've loaded the RA8875 library.
When I tried to compile one of the examples, I got error messages telling me that I needed other libraries so I loaded the GFX, the Robot Motor and the Robot Control libraries.
I got fewer errors but the compiler still can't find everything it wants.
GetHub seems like a nice place to put stuff but they've made up their own language and don't provide a dictionary.
I'm an old hardware guy but am a newbee to this software stuff.
If I can get one of the examples to compile, I can probably figure out how to write to the display.
RA8875 Libraries
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
- adafruit_support_mike
- Posts: 67485
- Joined: Thu Feb 11, 2010 2:51 pm
Re: RA8875 Libraries
The Robot control libraries contain an older version of the Adafruit_GFX library. You need this one: https://github.com/adafruit/Adafruit-GFX-Library
- bradv
- Posts: 35
- Joined: Sat Feb 22, 2014 2:38 am
Re: RA8875 Libraries
Thanks for the update.
Got it installed and still get many errors,
mainly LCD_xx and MUXxx not declared in this scope.
Do I need to change all the RA8875_xx references to LCD.xx's?
Got it installed and still get many errors,
mainly LCD_xx and MUXxx not declared in this scope.
Do I need to change all the RA8875_xx references to LCD.xx's?
- adafruit_support_mike
- Posts: 67485
- Joined: Thu Feb 11, 2010 2:51 pm
Re: RA8875 Libraries
The RA8875 doesn't work like a regular LCD, so you can't just replace one object with another.
What code are you trying to run?
What code are you trying to run?
- bradv
- Posts: 35
- Joined: Sat Feb 22, 2014 2:38 am
Re: RA8875 Libraries
Thanks Mike,
Figured out that I was not downloading the libraries from GitHub correctly.
Fixed that problem and now have a functioning display.
Next problem is that I can draw and write literal text to the screen but when I try to write a variable value I keep getting conversion errors in the compile.
Things like "invalid conversion from int to const char*"
I'm just trying to get the date and time from the DS1307 and print it on the screen.
Most of the documentation is great if you live and breathe "C++" but I'm learning and many of the compile errors I get are not mentioned in the Arduino Reference.
Any tips?
Thanks in advance,
Brad
Figured out that I was not downloading the libraries from GitHub correctly.
Fixed that problem and now have a functioning display.
Next problem is that I can draw and write literal text to the screen but when I try to write a variable value I keep getting conversion errors in the compile.
Things like "invalid conversion from int to const char*"
I'm just trying to get the date and time from the DS1307 and print it on the screen.
Most of the documentation is great if you live and breathe "C++" but I'm learning and many of the compile errors I get are not mentioned in the Arduino Reference.
Any tips?
Thanks in advance,
Brad
- adafruit_support_mike
- Posts: 67485
- Joined: Thu Feb 11, 2010 2:51 pm
Re: RA8875 Libraries
Post the code you're using and we'll see what we can find.
- bradv
- Posts: 35
- Joined: Sat Feb 22, 2014 2:38 am
Re: RA8875 Libraries
Just starting this sketch so most of this code is just a cut and paste from the examples in the RA8875 "buildtest" and "tccalibrate" along with the "DS1307" and "MotorShield" libraries.
I don't know how much you need and it isn't very long so I'll include the whole thing.
Errors are from lines 204 - 214 (most of the way to the bottom).
I'm attempting to write the time and date to the display.
I don't know how much you need and it isn't very long so I'll include the whole thing.
Errors are from lines 204 - 214 (most of the way to the bottom).
I'm attempting to write the time and date to the display.
Code: Select all
#include <SPI.h>
#include "Adafruit_GFX.h"
#include "Adafruit_RA8875.h"
#include <Wire.h>
#include <Adafruit_MotorShield.h>
#include "utility/Adafruit_PWMServoDriver.h"
#include <Wire.h>
#include "RTClib.h"
#define RA8875_INT 3
#define RA8875_CS 10
#define RA8875_RESET 9
Adafruit_RA8875 tft = Adafruit_RA8875(RA8875_CS, RA8875_RESET);
tsPoint_t _tsLCDPoints[3];
tsPoint_t _tsTSPoints[3];
tsMatrix_t _tsMatrix;
uint16_t tx, ty;
Adafruit_MotorShield AFMS = Adafruit_MotorShield(); // Create the motor shield object with the default I2C address
// Adafruit_MotorShield AFMS = Adafruit_MotorShield(0x61); // Or, create it with a different I2C address (say for stacking)
Adafruit_StepperMotor *pumpMotor1 = AFMS.getStepper(200, 1);
Adafruit_StepperMotor *pumpMotor2 = AFMS.getStepper(200, 2);
RTC_DS1307 rtc;
// ********************************** Get Time & Date *************************
// DateTime now = rtc.now();
// *********************************** Welcom Screen *************************
int welcomeScreen ()
{
tft.graphicsMode();
tft.fillRect(20, 380, 150, 50, RA8875_BLUE);
tft.fillRect(220, 380, 150, 50, RA8875_BLUE);
tft.fillRect(420, 380, 150, 50, RA8875_BLUE);
tft.fillRect(620, 380, 150, 50, RA8875_BLUE);
tft.textMode();
tft.textTransparent(RA8875_GREEN);
tft.textSetCursor(250, 50);
tft.textEnlarge(3);
tft.textWrite("Bio Droid");
tft.textTransparent(RA8875_WHITE);
tft.textSetCursor(100, 150);
tft.textEnlarge(2);
tft.textWrite("Aquaponics / Hydroponics");
tft.textSetCursor(200, 200);
tft.textEnlarge(2);
tft.textWrite("Control System");
tft.textTransparent(RA8875_WHITE);
tft.textSetCursor(58, 385);
tft.textEnlarge(1);
tft.textWrite("Setup");
tft.textSetCursor(238, 385);
tft.textWrite("Measure");
tft.textSetCursor(470, 385);
tft.textWrite("Run");
tft.textSetCursor(637, 385);
tft.textWrite("Display");
tft.textTransparent(RA8875_CYAN);
tft.textSetCursor(10, 440);
tft.textEnlarge(0);
tft.textWrite("Ver 1.0.0 Build 3/20/2014");
}
// *************** Get TouchScreen Calibratin Data ******************
/*
int setCalibrationMatrix( tsPoint_t * displayPtr, tsPoint_t * screenPtr, tsMatrix_t * matrixPtr)
{
int retValue = 0;
matrixPtr->Divider = ((screenPtr[0].x - screenPtr[2].x) * (screenPtr[1].y - screenPtr[2].y)) -
((screenPtr[1].x - screenPtr[2].x) * (screenPtr[0].y - screenPtr[2].y)) ;
if( matrixPtr->Divider == 0 )
{
retValue = -1 ;
}
else
{
matrixPtr->An = ((displayPtr[0].x - displayPtr[2].x) * (screenPtr[1].y - screenPtr[2].y)) -
((displayPtr[1].x - displayPtr[2].x) * (screenPtr[0].y - screenPtr[2].y)) ;
matrixPtr->Bn = ((screenPtr[0].x - screenPtr[2].x) * (displayPtr[1].x - displayPtr[2].x)) -
((displayPtr[0].x - displayPtr[2].x) * (screenPtr[1].x - screenPtr[2].x)) ;
matrixPtr->Cn = (screenPtr[2].x * displayPtr[1].x - screenPtr[1].x * displayPtr[2].x) * screenPtr[0].y +
(screenPtr[0].x * displayPtr[2].x - screenPtr[2].x * displayPtr[0].x) * screenPtr[1].y +
(screenPtr[1].x * displayPtr[0].x - screenPtr[0].x * displayPtr[1].x) * screenPtr[2].y ;
matrixPtr->Dn = ((displayPtr[0].y - displayPtr[2].y) * (screenPtr[1].y - screenPtr[2].y)) -
((displayPtr[1].y - displayPtr[2].y) * (screenPtr[0].y - screenPtr[2].y)) ;
matrixPtr->En = ((screenPtr[0].x - screenPtr[2].x) * (displayPtr[1].y - displayPtr[2].y)) -
((displayPtr[0].y - displayPtr[2].y) * (screenPtr[1].x - screenPtr[2].x)) ;
matrixPtr->Fn = (screenPtr[2].x * displayPtr[1].y - screenPtr[1].x * displayPtr[2].y) * screenPtr[0].y +
(screenPtr[0].x * displayPtr[2].y - screenPtr[2].x * displayPtr[0].y) * screenPtr[1].y +
(screenPtr[1].x * displayPtr[0].y - screenPtr[0].x * displayPtr[1].y) * screenPtr[2].y ;
// Persist data to EEPROM
long eepromRead(long CFG_EEPROM_TOUCHSCREEN_CAL_AN, matrixPtr->An);
long eepromRead(long CFG_EEPROM_TOUCHSCREEN_CAL_BN, matrixPtr->Bn);
long eepromRead(long CFG_EEPROM_TOUCHSCREEN_CAL_CN, matrixPtr->Cn);
long eepromRead(long CFG_EEPROM_TOUCHSCREEN_CAL_DN, matrixPtr->Dn);
long eepromRead(long CFG_EEPROM_TOUCHSCREEN_CAL_EN, matrixPtr->En);
long eepromRead(long CFG_EEPROM_TOUCHSCREEN_CAL_FN, matrixPtr->Fn);
long eepromRead(long CFG_EEPROM_TOUCHSCREEN_CAL_DIVIDER, matrixPtr->Divider);
int eepromRead(int CFG_EEPROM_TOUCHSCREEN_CALIBRATED, 1);
}
}
*/
/**************************************************************************/
/*!
@brief Waits for a touch event
*/
/**************************************************************************/
/*void waitForTouchEvent(tsPoint_t * point)
{
// Clear the touch data object and placeholder variables
memset(point, 0, sizeof(tsPoint_t));
// Clear any previous interrupts to avoid false buffered reads
uint16_t x, y;
tft.touchRead(&x, &y);
delay(1);
// Wait around for a new touch event (INT pin goes low)
while (digitalRead(RA8875_INT))
{
}
// Make sure this is really a touch event
if (tft.touched())
{
tft.touchRead(&x, &y);
point->x = x;
point->y = y;
Serial.print("Touch: ");
Serial.print(point->x); Serial.print(", "); Serial.println(point->y);
}
else
{
point->x = 0;
point->y = 0;
}
}
*/
void setup()
{
Serial.begin(9600);
Serial.println("Setup");
#ifdef AVR
Wire.begin();
#else
Wire1.begin(); // Shield I2C pins connect to alt I2C bus on Arduino Due
#endif
rtc.begin();
Serial.println("RA8875 start");
if (!tft.begin(RA8875_800x480)) {
Serial.println("RA8875 Not Found!");
while (1);
}
Serial.println("Found RA8875");
tft.displayOn(true);
tft.GPIOX(true); // Enable TFT - display enable tied to GPIOX
tft.PWM1config(true, RA8875_PWM_CLK_DIV1024); // PWM output for backlight
tft.PWM1out(50);
tft.fillScreen(RA8875_BLACK);
pinMode(RA8875_INT, INPUT);
digitalWrite(RA8875_INT, HIGH);
tft.touchEnable(true);
welcomeScreen();
// Serial.print("Status: "); Serial.println(tft.readStatus(), HEX);
// Serial.println("Waiting for touch events ...");
}
void loop()
{
DateTime now = rtc.now();
int Month = now.month();
int Day = now.day();
int Year = now.year();
int Hour = now.hour();
int Minute = now.minute();
int Second = now.second();
tft.textMode();
tft.textTransparent(RA8875_CYAN);
tft.textSetCursor(600, 440);
tft.textEnlarge(0);
tft.textWrite(Month);
tft.textWrite("/");
tft.textWrite(Day);
tft.textWrite("/");
tft.textWrite(Year);
tft.textWrite(" ");
tft.textWrite(Hour);
tft.textWrite(":");
tft.textWrite(Minute);
tft.textWrite(":");
tft.textWrite(Second);
tft.graphicsMode();
float xScale = 1024.0F/tft.width();
float yScale = 1024.0F/tft.height();
/* Wait around for touch events */
Serial.println("Waiting for touch events ...");
if (!digitalRead(RA8875_INT))
{
if (tft.touched())
{
Serial.print("Touch: ");
tft.touchRead(&tx, &ty);
Serial.print(tx); Serial.print(", "); Serial.println(ty);
/* Draw a circle */
tft.fillCircle((uint16_t)(tx/xScale), (uint16_t)(ty/yScale), 4, RA8875_WHITE);
}
}
}
- adafruit_support_mike
- Posts: 67485
- Joined: Thu Feb 11, 2010 2:51 pm
Re: RA8875 Libraries
The RA8875's 'textWrite()' function expects to get a C-style string as its argument.. an array of 8-bit integers that represent the characters which should appear on the screen. You're sending it numbers instead.
You can actually make the code a bit more compact using the standard C string formatting function:
You can actually make the code a bit more compact using the standard C string formatting function:
Code: Select all
char buffer[32];
sprintf( buffer,
"%02d/%02d%4d %02d:%02d:%02d",
Month, Day, Year, Hour, Minute, Second
);
tft.textWrite( buffer );
- bradv
- Posts: 35
- Joined: Sat Feb 22, 2014 2:38 am
Re: RA8875 Libraries
Thanks,
That got almost all of the errors.
Now all I get is that Month, Day, etc. were "not declared in this scope".
I've tried more than a couple of ways to declare these variables but the compiler doesn't like any of my ideas since they are multiple bytes.
Basically, how do I get 'rtc.now()' into 'buffer'?
Any recommendations on a C++ reference guide? The Arduino reference guide is OK for blinking LEDs but is a bit limited.
It looks like I'm going to get into pointers and arrays (for EEPROM R/W's) for this project so have a lot to learn. C++'s syntax is really different than the FORTRAN / PL1 / PASCAL / assembly stuff I've written before (1967 - 1980), guess I'm dating myself.
This is my second attempt at a sketch. It goes along with custom electronics and mechanical designs along with chemistry and botany.
That got almost all of the errors.
Now all I get is that Month, Day, etc. were "not declared in this scope".
I've tried more than a couple of ways to declare these variables but the compiler doesn't like any of my ideas since they are multiple bytes.
Basically, how do I get 'rtc.now()' into 'buffer'?
Any recommendations on a C++ reference guide? The Arduino reference guide is OK for blinking LEDs but is a bit limited.
It looks like I'm going to get into pointers and arrays (for EEPROM R/W's) for this project so have a lot to learn. C++'s syntax is really different than the FORTRAN / PL1 / PASCAL / assembly stuff I've written before (1967 - 1980), guess I'm dating myself.
This is my second attempt at a sketch. It goes along with custom electronics and mechanical designs along with chemistry and botany.
- adafruit_support_mike
- Posts: 67485
- Joined: Thu Feb 11, 2010 2:51 pm
Re: RA8875 Libraries
You still need to declare all the variables and assign values to them as before:
The 'sprintf()' function doesn't take that responsibility off your shoulders, it just copies the values in the variables to a string.
Code: Select all
DateTime now = rtc.now();
int Month = now.month();
int Day = now.day();
int Year = now.year();
int Hour = now.hour();
int Minute = now.minute();
int Second = now.second();
- bradv
- Posts: 35
- Joined: Sat Feb 22, 2014 2:38 am
Re: RA8875 Libraries
This great but I already figured that out.
The question on the table is how do I declare "buffer[xx]"?
My compiler says that it "was not declared in this scope".
My other question still stands as to where I can find a C++ reference guide so I can stop asking, what you must feel by now, are inane questions?
Thanks again,
Brad
The question on the table is how do I declare "buffer[xx]"?
My compiler says that it "was not declared in this scope".
My other question still stands as to where I can find a C++ reference guide so I can stop asking, what you must feel by now, are inane questions?
Thanks again,
Brad
- bradv
- Posts: 35
- Joined: Sat Feb 22, 2014 2:38 am
Re: RA8875 Libraries
Never mind,
I got ahead of myself again.
Problem solved.
Thanks so much.
Second question still stands unless you want to hear from me again with stupid questions.
Brad
I got ahead of myself again.
Problem solved.
Thanks so much.
Second question still stands unless you want to hear from me again with stupid questions.
Brad
- adafruit_support_mike
- Posts: 67485
- Joined: Thu Feb 11, 2010 2:51 pm
Re: RA8875 Libraries
There are thousands of programming tutorials online for just about any language.
If you're new to C programming in general, I'd suggest getting a copy of "The C Programming Language" by Kernighan and Ritchie. That's the original language manual, written by the guys who created C. It has an example-based approach to explaining how the language works, and the versions you can get now are compatible with the modern rules of C.
With that as a foundation, you'll be in a better position to learn C++, which simply adds a few more features to C. By design, C++ contains a subset of commands that will work on any standard C compiler. Again, my choice is to go straight to the source and get a copy of "The C++ Programming Language" by Bjarne Stroustrop.. the guy who created C++.
It takes a special degree of immersion to get truly fluent with a programming language, and most people just get comfortable flipping through the references to refresh their memory. Make that your target, because the rest will happen on its own. Once you get there, you might find yourself wanting ideas about how to arrange information better. If/when that happens, get a copy of "Introduction to Algorithms" by Cormen and Rivest. It shows you how to think about the structural building blocks of information handling.
IMO, "The Structure and Interpretation of Computer Programs" by Abelson and Sussman^2 is a great book if you find yourself wanting to know more about how programming works in general.
And no list of references is complete without "The Art of Computer Programming" by Don Knuth. Knuth nicely settles any potential spats about pecking order among programmers because the principle "there's always someone who knows more than you" pretty much stops at him. The books are intensely technical, but his writing style is so genial and charming that you forgive him for all the advanced math. Absolutely Do Not start with them, but remember the name when you're ready for "you know you've become a hopeless programming geek when..."
If you're new to C programming in general, I'd suggest getting a copy of "The C Programming Language" by Kernighan and Ritchie. That's the original language manual, written by the guys who created C. It has an example-based approach to explaining how the language works, and the versions you can get now are compatible with the modern rules of C.
With that as a foundation, you'll be in a better position to learn C++, which simply adds a few more features to C. By design, C++ contains a subset of commands that will work on any standard C compiler. Again, my choice is to go straight to the source and get a copy of "The C++ Programming Language" by Bjarne Stroustrop.. the guy who created C++.
It takes a special degree of immersion to get truly fluent with a programming language, and most people just get comfortable flipping through the references to refresh their memory. Make that your target, because the rest will happen on its own. Once you get there, you might find yourself wanting ideas about how to arrange information better. If/when that happens, get a copy of "Introduction to Algorithms" by Cormen and Rivest. It shows you how to think about the structural building blocks of information handling.
IMO, "The Structure and Interpretation of Computer Programs" by Abelson and Sussman^2 is a great book if you find yourself wanting to know more about how programming works in general.
And no list of references is complete without "The Art of Computer Programming" by Don Knuth. Knuth nicely settles any potential spats about pecking order among programmers because the principle "there's always someone who knows more than you" pretty much stops at him. The books are intensely technical, but his writing style is so genial and charming that you forgive him for all the advanced math. Absolutely Do Not start with them, but remember the name when you're ready for "you know you've become a hopeless programming geek when..."
Please be positive and constructive with your questions and comments.