I am new to C, I hope I can help, good with regard to this I have taken another major problem that the rotation of the screen, I try to make a clock using DS1307 RTC with TINY, however does not show me the right way numbers, ie 1,2,3 but prints all over the account if done right of 0-59 but not let me see the numbers because they never clean the previous issue, I attached a picture, hoping you can help me I thank you in advance for the attention paid,
#include <stdint.h>
#include <SeeedTouchScreen.h>
#include <TFTv2.h>
#include <SPI.h>
#include <Wire.h> // specify use of Wire.h library.
// De Decimal a BCD
byte decToBcd(byte val){
return ( (val/10*16) + (val%10) );
};
// De BCD a Decimal
byte bcdToDec(byte val){
return ( (val/16*10) + (val%16) );
};
/*************************************/
/********** Variables Reloj **********/
byte seconds = 0;
byte minutes = 0;
byte hours = 0;
byte day = 0;
byte date = 0; //dia
byte month = 0;
byte year = 0;
int fecha=0;
char buufer[12];
unsigned long tiempo_s1, tiempo_s2=0, retardo_s1=50;
TouchScreen ts = TouchScreen(XP, YP, XM, YM); //init TouchScreen port pins
void setup()
{
TFT_BL_ON; //turn on the background light
Tft.TFTinit();
Wire.begin();
Tft.fillCircle(40, 160, 30,BLUE); // (x,y, radio, color) BOTON 1
Tft.drawString("AA", 18, 145, 3, WHITE); // 'S', (X, Y), Tamño: 1, color: RED
Tft.fillCircle(120, 160, 30, BLUE); // (x,y, radio, color) BOTON 2
Tft.drawString("B", 110, 145, 3, WHITE); // 'S', (X, Y), Tamño: 1, color: RED
Tft.fillCircle(200, 160, 30, BLUE); // (x,y, radio, color) BOTON 3
Tft.drawString("CC", 180, 145, 3, WHITE); // 'S', (X, Y), Tamño: 1, color: RED
//Tft.setOrientation(1) // ==> If I modify this parameter 1-2 should rotate the screen to landscape mode?.
// Try to do a small clock, setDisplayDirect command only rotating characters?
}
void loop()
{
Wire.beginTransmission(0x68);
Wire.write(0x00);
Wire.endTransmission();
Wire.requestFrom(0x68, 7);
seconds = bcdToDec( Wire.read());
minutes = bcdToDec( Wire.read());
hours = bcdToDec( Wire.read());
day = bcdToDec( Wire.read());
date = bcdToDec( Wire.read());
month = bcdToDec( Wire.read());
year = bcdToDec( Wire.read());
Tft.drawNumber(seconds, 157, 45, 4, WHITE);
Tft.drawNumber(minutes, 105, 45, 3, WHITE);
Tft.drawString(";" , 141, 42, 3, WHITE);
Tft.drawString("/" , 71, 82, 3, WHITE);
Tft.drawNumber(month , 88, 85, 3, WHITE); //(x,y)
Tft.drawNumber(date , 33, 85, 3, WHITE); //(x,y)
Tft.drawString("/" , 126, 82, 3, WHITE);
fecha=year+2000;
Tft.drawNumber(fecha , 144, 85, 3, WHITE); //(x,y)
}