Hello everyone!
I’m experiencing some problems with interfacing ILI9341 screen in SPI mode with BluePill (STM32F103C8T6 devboard) with mbed framework.
Libraries:
- for ILI9341 : SPI_TFT_ILI9341 - Lib for the new LCD Display with ILI9341 controll… | Mbed
- fonts : TFT_fonts - Font to use with the SPI_TFT lib | Mbed
Code:
#include "stdio.h"
#include "mbed.h"
#include "SPI_TFT_ILI9341.h" // https://os.mbed.com/users/dreschpe/code/SPI_TFT_ILI9341/
#include "string"
#include "Arial12x12.h" // All fonts were installe with library:
#include "Arial24x23.h" // https://os.mbed.com/users/dreschpe/code/TFT_fonts/
#include "Arial28x28.h"
#include "font_big.h"
// Pins for SPI1 on BluePill devboard
SPI_TFT_ILI9341 TFT(PA_7, PA_6, PA_5, PB_14, PB_13, PB_12,"TFT"); // mosi, miso, sclk, cs, reset, dc
int main()
{
int i;
TFT.claim(stdout); // send stdout to the TFT display
TFT.background(Black); // set background to black
TFT.foreground(White); // set chars to white
TFT.cls(); // clear the screen
TFT.background(Black);
TFT.cls();
TFT.set_orientation(1);
TFT.set_font((unsigned char*)Arial24x23);
TFT.locate(50,100);
TFT.printf("TFT orientation");
TFT.set_font((unsigned char*)Arial12x12);
for (int orientation = 1; orientation < 4 ; orientation++){
TFT.set_orientation(orientation);
TFT.locate(0,0);
TFT.printf(" Hello Mbed %d", orientation);
};
// draw some graphics
TFT.cls();
TFT.set_font((unsigned char*)Arial24x23);
TFT.locate(100,100);
TFT.printf("Graphic");
TFT.line(0,0,100,0,Green);
TFT.line(0,0,0,200,Green);
TFT.line(0,0,100,200,Green);
TFT.rect(100,50,150,100,Red);
TFT.fillrect(180,25,220,70,Blue);
TFT.circle(80,150,33,White);
TFT.fillcircle(160,190,20,Yellow);
double s;
for (i=0; i<320; i++) {
s =20 * sin((long double) i / 10 );
TFT.pixel(i,100 + (int)s ,Red);
}
wait(5); // wait two seconds
// bigger text
TFT.foreground(White);
TFT.background(Blue);
TFT.cls();
TFT.set_font((unsigned char*)Arial24x23);
TFT.locate(0,0);
TFT.printf("Different Fonts :");
TFT.set_font((unsigned char*)Neu42x35);
TFT.locate(0,30);
TFT.printf("Hello Mbed 1");
TFT.set_font((unsigned char*)Arial24x23);
TFT.locate(20,80);
TFT.printf("Hello Mbed 2");
TFT.set_font((unsigned char*)Arial12x12);
TFT.locate(35,120);
TFT.printf("Hello Mbed 3");
wait(5);
// mbed logo
TFT.background(Black);
TFT.cls();
TFT.locate(10,10);
TFT.printf("Graphic from Flash");
wait(5);
TFT.cls();
TFT.locate(10,10);
TFT.printf("Graphic from File System");
TFT.locate(10,20);
TFT.printf("open test.bmp");
int err = TFT.BMP_16(20,50,"test.bmp");
if (err != 1) TFT.printf(" - Err: %d",err);
}
Errors:
In file included from src\main.cpp:8:0:
C:\Users\Yehor\.platformio\lib\TFT_fonts_ID284/Arial12x12.h:8:8: error: expected constructor, destructor, or type conversion before '(' token
__align(2)
^
In file included from src\main.cpp:9:0:
C:\Users\Yehor\.platformio\lib\TFT_fonts_ID284/Arial24x23.h:10:8: error: expected constructor, destructor, or type conversion before '(' token
__align(2)
^
In file included from src\main.cpp:10:0:
C:\Users\Yehor\.platformio\lib\TFT_fonts_ID284/Arial28x28.h:10:8: error: expected constructor, destructor, or type conversion before '(' token
__align(2)
^
In file included from src\main.cpp:11:0:
C:\Users\Yehor\.platformio\lib\TFT_fonts_ID284/font_big.h:10:8: error: expected constructor, destructor, or type conversion before '(' token
__align(2)
^
src\main.cpp: In function 'int main()':
src\main.cpp:30:34: error: 'Arial24x23' was not declared in this scope
TFT.set_font((unsigned char*)Arial24x23);
^~~~~~~~~~
src\main.cpp:34:34: error: 'Arial12x12' was not declared in this scope
TFT.set_font((unsigned char*)Arial12x12);
^~~~~~~~~~
src\main.cpp:76:34: error: 'Neu42x35' was not declared in this scope
TFT.set_font((unsigned char*)Neu42x35);
^~~~~~~~
*** [.pioenvs\bluepill_f103c8\src\main.o] Error 1
Please, help me to fix those errors.
The actual screen:
P.S. Fonts were installed with “TFT_fonts” library and they are declared in following files:
- Arial12x12 : Arial12x12.h
- Neu42x35 : big_font.h
- Arial24x23 : Arial24x23.h
which are included, based on first 3 errors.