Hello
Has anyone built this unique flip clock using a 2.2 inch color graphics display found at this website:
http://olganet.com/electro/2014/03/17/horloge-avec-afficheur-tft-2-2-240x320/
The host has done a nice job of posting the schematic and main code but does not say where we can get the specific include libraries he used.
The problem is; Im having trouble getting his code to compile.
I think the problem is with 2 of the libraries that I obtained from the Arduino github repository.
Im afraid that I don't know enough about Arduino C to get the RTClib and Button libraries working.
/**
- Flip-Clock
- Desinged for Arduino ATMEGA328P / TFT 2.2" 240x320 display
**/
#include <SPI.h> //working
#include "Adafruit_GFX.h" //working
#include "Adafruit_ILI9340.h" //working
#include <Wire.h> //working
#include <RTClib.h> // This library is giving me grief..not sure if I downloaded the right library. so far I have tried 4 downloads RCTClib.h and RTC.cpp.
#include <Button.h> // This library is giving me grief.. not sure if I downloaded the right library. so far I have tried 14 downloads button.h and button.cpp.
I purchased all the parts for the project from Ebay. total cost so far $26.00
I have spent 18hrs trying different things.
I hope someone can shed some light on this project or tell me if I should just give up.
I don't know enough about arduino C to be able to to alter the libraries or, calls to the libraries to get it working.
I have left postings on the fellows web page but the host doesn't reply.
This is a example of one of the many errors I receive after compiling with Aduino IDEv 105r2 . I also tried using versions 00018 thru 0022 with no luck.
flipclknewlibrys:75: error: variable or field 'handleButtonReleaseEvents' declared void
flipclknewlibrys:75: error: expected primary-expression before ')' token
flipclknewlibrys:76: error: variable or field 'handleButtonHoldEvents' declared void
flipclknewlibrys:76: error: expected primary-expression before ')' token
flipclknewlibrys:69: error: expected unqualified-id before '=' token
flipclknewlibrys.ino: In function 'void setup()':
flipclknewlibrys:93: error: expected primary-expression before '.' token
flipclknewlibrys:93: error: 'handleButtonReleaseEvents' was not declared in this scope
flipclknewlibrys:94: error: expected primary-expression before '.' token
flipclknewlibrys:94: error: 'handleButtonHoldEvents' was not declared in this scope
Thanks
shortened version of Original code from the hosts web page:
/**
- Flip-Clock
- Desinged for Arduino ATMEGA328P / TFT 2.2" 240x320 display
**/
#include <SPI.h>
#include "Adafruit_GFX.h"
#include "Adafruit_ILI9340.h"
#include <Wire.h>
#include <RTClib.h>
#include <Button.h>
// These are the pins used for the UNO
#define TFT_SCLK 13
#define TFT_MISO 12
#define TFT_MOSI 11
#define TFT_CS 5
#define TFT_DC 6
#define TFT_RST 4
#define TFT_BL_ON {DDRD |= 0x80;PORTD |= 0x80;}
#define WHITE tft.Color565(255,255,255)
#define BLACK tft.Color565(0,0,0)
#define RED tft.Color565(255,58,47)
#define GREEN tft.Color565(58,255,47)
#define BLUE tft.Color565(13,143,209)
#define YELLOW tft.Color565(209,193,13)
#define DARK_GRAY tft.Color565(40,40,40)
#define GRAY tft.Color565(60,60,60)
#define LIGHT_GRAY tft.Color565(150,150,150)
#define BUTTON1_PIN 9
#define BACKLIGHT_PIN 3
#define HOLD_DURATION 1000
#define SMALL_FONT 1
#define MEDIUM_FONT 2
#define BIG_FONT 3
extern uint8_t BigFont[];
extern uint8_t MediumFont[];
extern uint8_t SmallFont[];
extern uint8_t Symbol[];
RTC_DS1307 RTC;
Adafruit_ILI9340 tft = Adafruit_ILI9340(TFT_CS, TFT_DC, TFT_RST);
Button button1 = Button(BUTTON1_PIN,BUTTON_PULLDOWN);
boolean longPush = false;
byte value, etat, lastEtat = 0;
boolean forceRefresh = false;
byte dimCycle[4] = {30,60,120};
byte dimValue = 1;
int digitPos[4] = {10,82,172,244};
String dayNames[7] = {
"DIM","LUN", "MAR","MER","JEU","VEN","SAM"};
String monthNames[13] = {
"","JAN","FEV","MAR","AVR","MAI","JUN","JUI","AOU","SEP","OCT","NOV","DEC"};
String settingsStates[7] = {
"","Set clock hours (+)","Set clock minutes (+)","Set clock date (+)", "Set clock date (-)", "Set clock year (+)","Set clock year (-)"};
DateTime now;
byte lastHour, lastMinute, lastSecond, lastDay, lastTemp, temp = 0xFF;
int lastYear = 0;
boolean showDots = true;
int top = 23;
void setup() {
Wire.begin();
RTC.begin();
button1.releaseHandler(handleButtonReleaseEvents);
button1.holdHandler(handleButtonHoldEvents,HOLD_DURATION);
pinMode(BACKLIGHT_PIN, OUTPUT);
analogWrite(BACKLIGHT_PIN, dimCycle[dimValue]);
tft.begin();
tft.fillScreen(DARK_GRAY);
tft.setRotation(1);
//RTC.adjust(DateTime(DATE, TIME));
}
void loop(void) {
button1.isPressed();
now = RTC.now();
// Display hours
if (lastHour != now.hour() || forceRefresh) {
showDigit(digitPos[0], top, now.hour()/10, (etat == 1)?true:false);
showDigit(digitPos[1], top, now.hour()%10, (etat == 1)?true:false);
lastHour = now.hour();
}
// Display minutes
if (lastMinute != now.minute() || forceRefresh) {
showDigit(digitPos[2], top, now.minute()/10, (etat == 2)?true:false);
showDigit(digitPos[3], top, now.minute()%10, (etat == 2)?true:false);
lastMinute = now.minute();
}
// Display flashing dots
if (lastSecond != now.second()){
lastSecond = now.second();
drawDots(top); // 2 points
}
// Display temperature
temp = round(getTemperature());
if ((temp != lastTemp && temp >= 0 && etat == 0 ) || (etat == 0 && forceRefresh)) {
showTemp(digitPos[0]+160, top+121, temp);
lastTemp = temp;
}
// Display date
if (lastDay != now.day() || lastYear != now.year() || forceRefresh) {
showDate(digitPos[0], top+121, now.dayOfWeek(), now.day(), now.month(), now.year(), (etat > 2 && etat < 7)?true:false);
lastDay = now.day();
lastYear = now.year();
}
// Set time or date
if (value > 0) {
switch (etat) {
case 1: // Set hours
RTC.adjust(DateTime (now.year(), now.month(), now.day(), (now.hour() <23) ? now.hour()+1 : 0, now.minute(), 0));
break;
case 2: // Set minutes
RTC.adjust(DateTime (now.year(), now.month(), now.day(), now.hour(), (now.minute() <59) ? now.minute()+1 : 0, 0));
break;
case 3: // Set date + 1day
RTC.adjust(now.unixtime() + 86400);
break;
case 4: // Set date - 1day
RTC.adjust(now.unixtime() - 86400);
break;
case 5: // Set date + year
RTC.adjust(DateTime ((now.year() <2100) ? now.year()+1 : 2000, now.month(), now.day(), now.hour(), now.minute(), 0));
break;
case 6: // Set date - year
RTC.adjust(DateTime ((now.year() >2000) ? now.year()-1 : 2000, now.month(), now.day(), now.hour(), now.minute(), 0));
break;
}
value = 0;
}
forceRefresh = false; // cancel forceRefresh
if (lastEtat != etat ) {
tft.fillScreen(DARK_GRAY);
showDebug(settingsStates[etat]);
forceRefresh = true; // force refresh
lastEtat = etat;
}
// delay(10);
}
// ---------------------------------- Fonctions ---------------------------------- //
void drawDots(int y) {
tft.fillRect(155, y+23, 10, 10, (showDots) ? DARK_GRAY : WHITE);
tft.fillRect(155, y+73, 10, 10, (showDots) ? DARK_GRAY : WHITE);
showDots = !showDots;
}
void showDigit(int x, int y, int number, boolean isSet) {
drawFlap(x, y, 66, 102, 20, 2);
showCar(x+9, y+12 , number, BIG_FONT, (isSet)?GREEN:WHITE, GRAY);
}
}
