Hi all. Working with the Arduino Due mainly for the DMA support on the SPI ILI9341 screens for a project where quick updates is useful. Thus, I am using the said optimized Due library for the code but I'm hitting a brick wall with the code and I'm not sure why.
Sauce:
#define menuDivide 45
#define dateDivide 70
#define odoDivide 238
#define gearDivide 275
#define gearWidth 48
#include "fonts\Arial_bold_14.h"
#include "fonts\ABlack20B.h"
ILI9341_due tft = ILI9341_due(TFT_CS, TFT_DC, TFT_RST);
extern SdFat SD;
typedef enum {nuetral, drive, reverse} gears;
gears currentGear;
long odometer = 999999; // Set highest for test
tftMenu::tftMenu(){
pinMode(TFT_LED, OUTPUT);
pinMode(SD_CS, OUTPUT);
digitalWrite(TFT_LED, 0);
ledPWM = 0;
}
void tftMenu::drawMenu(){
tft.fillScreen(ILI9341_BLACK);
tft.drawLine(0, menuDivide, 240, menuDivide, ILI9341_WHITE);
tft.drawLine(0, dateDivide, 240, dateDivide, ILI9341_WHITE);
tft.drawLine(0, odoDivide, 240, odoDivide, ILI9341_WHITE);
tft.drawLine(0, gearDivide, 240, gearDivide, ILI9341_WHITE);
drawGear(0, gearWidth, gearDivide+1);
drawGear(1, gearWidth*2, gearDivide+1);
drawGear(0, gearWidth*3, gearDivide+1);
drawBMP("bike.bmp",4,3);
drawBMP("batt.bmp",4+gearWidth,3);
drawBMP("map.bmp",4+(gearWidth*3),3);
drawBMP("cog.bmp",4+(gearWidth*4),3);
drawBMP("stop.bmp", 4, gearDivide+4);
drawBMP("warn.bmp",4+(gearWidth*4),gearDivide+4);
tft.setFont(Arial_bold_14);
tft.setTextColor(128,128,128);
tft.setTextScale(1);
tft.printAt("23/07",6,52);
tft.printAt("17:42", 100,52);
tft.printAt("16°c", 200, 52);
tft.setTextColor(128,128,128);
tft.printAt("trip", 6,257);
tft.setTextColor(ILI9341_WHITE);
tft.printAt("odo",6,241);
tft.setFont(ABlack20B);
tft.setTextScale(1);
tft.setTextColor(ILI9341_WHITE);
tft.cursorTo(45,248);
if(odometer > 999){
int odo = odometer/100;
tft.print(odo);
tft.print(',');
int odo = odometer%100;
tft.print(odo);
} else tft.println(odometer);
tft.cursorTo(160,248);
tft.print("miles");
}
void tftMenu::drawGear(bool active, int x, int y){
if(active == 1) tft.fillRect(x, y, gearDivide+48, gearWidth+45, ILI9341_WHITE);
else tft.fillRect(x, y, gearDivide+48, gearWidth+45, ILI9341_BLACK);
}
This is all the code relevant to the "menu" I have being displayed right now. I get trouble using the print command, it just doesn't show any text at all. I was using the printAt command which does work but more of a hassle to use and I rather prefer the Adafruit GFX library style of commands as having to specify each text location gets repetitive and tedious.
The menu in questions is supposed to look like this (1:1 scale):
But in actuality i get this:
Please excuse the glare and blobs, my camera decided to be funny. Also I'm aware the gear letters are missing, haven't gotten to coding them yet.
I'm just wondering if there's any obvious reason that tft.print() isnt working. I tried converting to int but didn't get any better results. I checked the original library and it calls on the Print class and goes beyond what I know. Any help is appreciated, thanks