Hello! I need a really desperate help for my programming problem.
I have Arduino Mega2560 original board, DS3231 module and FTDI Chip Board which is VM800C35A attach with 3.5" LCD.
This is the image of FTDI Chip Board I have
I have play around with all the hardware and I can display time from DS3231 module on the screen. There no problem to program the LCD for a simple display.
Can someone guide me how to create a touchscreen button on a menu display? I have calibrate the touchscreen but it seen like the touchscreen are not accurate.
Here my code
#include <SPI.h>
#include <Wire.h>
#include <FT_VM800B35.h>
#include <DS3231.h>
DS3231 rtc(SDA, SCL);
Time t;
#define RAM_BACK 147580
static PROGMEM prog_uchar Back[] = {
#include "Back.h"
};
#define RAM_NEXT 225380
static PROGMEM prog_uchar Next[] = {
#include "Next.h"
};
FT800IMPL_SPI FTImpl(FT_CS_PIN, FT_PDN_PIN, FT_INT_PIN);
void Calibrate()
{
FTImpl.DLStart();
FTImpl.ClearColorRGB(255, 255, 255); // ClearColorRGB(Red, Green, BLue) to set the background color
FTImpl.Clear(1, 1, 1); // Clear(ColorBuffer, StencilBuffer, TagBuffer)
FTImpl.ColorRGB(0, 0, 0); // to set the text color
FTImpl.Cmd_Text(160, 100, 26, FT_OPT_CENTER, "SILA TEKAN PADA"); // Cmd_Text(x-coordinate, y-coordinate, font, options, text in string)
FTImpl.Cmd_Text(160, 115, 26, FT_OPT_CENTER, "BUTANG DI PAPARAN");
FTImpl.Cmd_Calibrate(0); // to calibrate the touchscreen value
FTImpl.DLEnd();
FTImpl.Finish();
}
int tag = 0;
int tagValue = 0;
int pressed = 0;
void FirstDisplay()
{
t = rtc.getTime();
FTImpl.DLStart();
FTImpl.ClearColorRGB(255, 255, 255);
FTImpl.Clear(1, 1, 1);
FTImpl.Tag(2);
FTImpl.Begin(FT_BITMAPS); // Next
FTImpl.Vertex2ii(270, 190, 12, 0);
FTImpl.End();
FTImpl.ColorRGB(0, 0, 0);
FTImpl.Cmd_Clock(70, 50, 36, FT_OPT_FLAT|FT_OPT_NOBACK, t.hour, t.min, t.sec, millis); // Cmd_Clock(x-coordinate, y-coordinate, radius, options, hours, minutes, seconds, milliseconds)
FTImpl.Cmd_Text(70, 110, 31, FT_OPT_CENTER, rtc.getTimeStr(1));
FTImpl.Cmd_Text(70, 160, 28, FT_OPT_CENTER, rtc.getDateStr());
FTImpl.Cmd_Text(70, 200, 28, FT_OPT_CENTER, rtc.getDOWStr());
FTImpl.DLEnd();
FTImpl.Finish();
}
void ThirdDisplay()
{
FTImpl.DLStart();
FTImpl.ClearColorRGB(255, 255, 255);
FTImpl.Clear(1, 1, 1);
FTImpl.ColorRGB(0, 0, 0);
FTImpl.Cmd_FGColor(16744255);
FTImpl.Cmd_Button(120, 110, 145, 35, 27, 0, "TUTORIAL");
FTImpl.Cmd_Button(120, 155, 145, 35, 27, 0, "EXERCISE");
FTImpl.Cmd_Button(120, 200, 145, 35, 27, 0, "RECORD");
FTImpl.DLEnd();
FTImpl.Finish();
}
void setup()
{
rtc.begin();
FTImpl.Init(FT_DISPLAY_RESOLUTION);
FTImpl.SetDisplayEnablePin(FT_DISPENABLE_PIN);
FTImpl.SetAudioEnablePin(FT_AUDIOENABLE_PIN);
FTImpl.DisplayOn();
FTImpl.AudioOn();
FTImpl.DLStart();
FTImpl.BitmapHandle(12);
FTImpl.BitmapSource(225380); // Next
FTImpl.BitmapLayout(FT_RGB565, 100, 50);
FTImpl.BitmapSize(FT_NEAREST, FT_BORDER, FT_BORDER, 50, 50);
FTImpl.DLEnd();
FTImpl.Finish();
}
void loop()
{
sTagXY sTagxy;
FTImpl.GetTagXY(sTagxy);
tagValue = sTagxy.tag;
if(tagValue == 2 && tag == 2)pressed = 2;
switch(pressed)
{
case 0:
FirstDisplay();
break;
case 2:
ThirdDisplay();
break;
}
tag = tagValue;
}