Forum Replies Created
-
AuthorPosts
-
Jack1Member
Didn’t work. Any other to try?
Jack1MemberOk i will try that thank you.
Jack1MemberStill no answer. :/
Jack1MemberThe date and time is displayed correctly now! New problem is that when there is no video input to the video experimenter the arduino executes too fast and the clock goes fast forward. Here is code:
#include
#include
#include
#include
#define W 136
#define H 96
RTC_DS1307 RTC;
TVout tv;
char s[32];
DateTime dateOnStart;
unsigned int DATE_HOUR;
unsigned int DATE_MIN;
unsigned int DATE_SEC;
unsigned int DATE_DAY;
unsigned int DATE_MONTH;
unsigned int DATE_YEAR;
unsigned long int unixTime2;
void increment() {
unixTime2 = unixTime2 + 1;
DateTime unixTime(unixTime2);
DATE_HOUR = unixTime.hour();
DATE_MIN = unixTime.minute();
DATE_SEC = unixTime.second();
DATE_DAY = unixTime.day();
DATE_MONTH = unixTime.month();
DATE_YEAR = unixTime.year();
}
void setup() {
Wire.begin();
RTC.begin();
dateOnStart = RTC.now();
unixTime2 = dateOnStart.unixtime();
tv.begin(PAL, W, H);
initOverlay();
tv.select_font(font6x8);
tv.fill(0);
}
// Initialize ATMega registers for video overlay capability.
// Must be called after tv.begin().
void initOverlay() {
TCCR1A = 0;
// Enable timer1. ICES0 is set to 0 for falling edge detection on input capture pin.
TCCR1B = _BV(CS10);
// Enable input capture interrupt
TIMSK1 |= _BV(ICIE1);
// Enable external interrupt INT0 on pin 2 with falling edge.
EIMSK = _BV(INT0);
EICRA = _BV(ISC11);
}
// Required to reset the scan line when the vertical sync occurs
ISR(INT0_vect) {
display.scanLine = 0;
}
void loop() {
sprintf(s, "%u:%u:%u %u.%u.%u", DATE_HOUR, DATE_MIN, DATE_SEC, DATE_DAY, DATE_MONTH, DATE_YEAR);
tv.print(0, 0, s);
increment();
delay(2500);
}
Another problem: there is some strange pixels on the screen.
Here is a picture:
Jack1MemberI’m sure that the RTC is working properly. I actually took timer code and RTC code away and then the date and time showed as zeros. I will try messing aorund with the code some more to see if i get it working.
I think that the wire library interferes with the video experimenter.Jack1MemberIt dont show any text on screen. But when i remove all code related to rtc and change sprintf to something that outputs only text then it shows that text.
Jack1MemberSo i made the code now but it still doesnt work for some reason.
Could you see if it has something wrong? Here it is:#include
#include
#include
#include
#include
#define W 136
#define H 96
RTC_DS1307 RTC;
TVout tv;
char s[32];
DateTime dateOnStart;
unsigned int DATE_HOUR;
unsigned int DATE_MIN;
unsigned int DATE_SEC;
unsigned int DATE_DAY;
unsigned int DATE_MONTH;
unsigned int DATE_YEAR;
unsigned long int unixTime2;
void increment() {
unixTime2 = unixTime2 + 1;
DateTime unixTime;
DATE_HOUR = unixTime.hour();
DATE_MIN = unixTime.minute();
DATE_SEC = unixTime.second();
DATE_DAY = unixTime.day();
DATE_MONTH = unixTime.month();
DATE_YEAR = unixTime.year();
}
void setup() {
Wire.begin();
RTC.begin();
dateOnStart = RTC.now();
unixTime2 = dateOnStart.unixtime();
MsTimer2::set(1000, increment);
MsTimer2::start();
tv.begin(PAL, W, H);
initOverlay();
tv.select_font(font6x8);
tv.fill(0);
}
// Initialize ATMega registers for video overlay capability.
// Must be called after tv.begin().
void initOverlay() {
TCCR1A = 0;
// Enable timer1. ICES0 is set to 0 for falling edge detection on input capture pin.
TCCR1B = _BV(CS10);
// Enable input capture interrupt
TIMSK1 |= _BV(ICIE1);
// Enable external interrupt INT0 on pin 2 with falling edge.
EIMSK = _BV(INT0);
EICRA = _BV(ISC11);
}
// Required to reset the scan line when the vertical sync occurs
ISR(INT0_vect) {
display.scanLine = 0;
}
void loop() {
sprintf(s, "%u:%u:%u %u.%u.%u", DATE_HOUR, DATE_MIN, DATE_SEC, DATE_DAY, DATE_MONTH, DATE_YEAR);
tv.print(0, 0, s);
}Jack1MemberThank you! I think i can do it now. Thanks for your help
Jack1MemberCould you provide some example code on ISR and those timers to get me started?
Jack1MemberI think it uses I2C communications. Is there any other way i could get time displayed on the video?
-
AuthorPosts