Go Down

Topic: Unable to use TFT library (Read 1 time) previous topic - next topic

sGerli

When I compile a the TFTDisplayText example for my MKR1000 I get the following error:

Code: [Select]
/Applications/Arduino.app/Contents/Java/libraries/TFT/src/utility/glcdfont.c:2:20: fatal error: avr/io.h: No such file or directory
 #include <avr/io.h>


Is there any way to fix this error? I really need this to work.

ballscrewbob

You might want to post your code for starters. (make sure you put it between code tags the < / > on the toolbar above)

Also whats your OS and which IDE.

Maybe just a bad or missing library from the partial message you posted but impossible to tell without much more info.
It may not be the answer you were looking for but its the one I am giving based on either experience, educated guess, google or the fact that you gave nothing to go with in the first place so I used my wonky crystal ball.

sGerli

Ok, this is my code from the TFTDispayText Example

Code: [Select]
/*
  Arduino TFT text example

  This example demonstrates how to draw text on the
  TFT with an Arduino. The Arduino reads the value
  of an analog sensor attached to pin A0, and writes
  the value to the LCD screen, updating every
  quarter second.

  This example code is in the public domain

  Created 15 April 2013 by Scott Fitzgerald

  http://www.arduino.cc/en/Tutorial/TFTDisplayText

 */

#include <TFT.h>  // Arduino LCD library
#include <SPI.h>

// pin definition for the Uno
#define CS   7
#define DC   5
#define RESET  6
#define MOSI 8
#define SCLK 9
// create an instance of the library
TFT TFTscreen = TFT(CS, DC, RESET);

// char array to print to the screen
char sensorPrintout[4];

void setup() {

  // Put this line at the beginning of every sketch that uses the GLCD:
  TFTscreen.begin();

  // clear the screen with a black background
  TFTscreen.background(0, 0, 0);

  // write the static text to the screen
  // set the font color to white
  TFTscreen.stroke(255, 255, 255);
  // set the font size
  TFTscreen.setTextSize(2);
  // write the text to the top left corner of the screen
  TFTscreen.text("Sensor Value :\n ", 0, 0);
  // ste the font size very large for the loop
  TFTscreen.setTextSize(5);
}

void loop() {

  // Read the value of the sensor on A0
  String sensorVal = String(analogRead(A0));

  // convert the reading to a char array
  sensorVal.toCharArray(sensorPrintout, 4);

  // set the font color
  TFTscreen.stroke(255, 255, 255);
  // print the sensor value
  TFTscreen.text(sensorPrintout, 0, 20);
  // wait for a moment
  delay(250);
  // erase the text you just wrote
  TFTscreen.stroke(0, 0, 0);
  TFTscreen.text(sensorPrintout, 0, 20);
}

ballscrewbob

That sketch is meant for a UNO and it compiles just fine here with the correct libs installed.

However you may want to check the pin definitions as I don't think they are all the same ?
It may not be the answer you were looking for but its the one I am giving based on either experience, educated guess, google or the fact that you gave nothing to go with in the first place so I used my wonky crystal ball.

sGerli

Yes, I updated my pin definitions, I just forgot to update the comment.
Which libraries should I have installed (I already have installed the TFT librart) for this to work.

Go Up