Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Timer not Changing #19

Open
ghost opened this issue Feb 8, 2017 · 1 comment
Open

Timer not Changing #19

ghost opened this issue Feb 8, 2017 · 1 comment

Comments

@ghost
Copy link

ghost commented Feb 8, 2017

Hello There,

I have a problem with the library. I have set up a 128x64 display with u8glib. I want it to work as a timer.
In my code I have set the Timer to 999:59:59, but the display just keeps showing 999:59:58. I can confirm, that the Display updates without the Countdown library but just a rand() int.

I have an Arduino Mega 2560

Here's my code:
`#include<CountUpDownTimer.h>
#include "U8glib.h"

U8GLIB_ST7920_128X64 u8g(18, 16, 17, U8G_PIN_NONE);
CountUpDownTimer T(DOWN);

char buf[8];
char buf1[8];
char buf2[8];

void draw(void) {

u8g.setColorIndex(1);
u8g.drawBox(0,0,128,64);
u8g.setColorIndex(0);
// graphic commands to redraw the complete screen should be placed here
u8g.setFont(u8g_font_courB18r);
//u8g.setFont(u8g_font_osb21);

itoa(T.ShowHours(), buf, 10);
u8g.drawStr(3, 40, buf);

u8g.drawStr(45, 40, ":");
itoa(T.ShowMinutes(), buf1, 10);
u8g.drawStr(56, 40, buf1);

u8g.drawStr(85, 40, ":");
itoa(T.ShowSeconds(), buf2, 10);
u8g.drawStr(96, 40, buf2);
}

void setup(void) {
pinMode(13,OUTPUT);
digitalWrite(13,HIGH);
// assign default color value
T.SetTimer(999,59,59);
T.StartTimer();
}

void loop(void) {
T.Timer();
if (T.TimeHasChanged() ){
// picture loop
u8g.firstPage();
do {
draw();
} while( u8g.nextPage() );

// rebuild the picture after some delay
u8g.firstPage();
do {
draw();
} while( u8g.nextPage() );

}
}`

I hope someone can help.

@AndrewMascolo
Copy link
Owner

AndrewMascolo commented Feb 8, 2017 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant