Open ghost opened 7 years ago
The problem is your order. The code is stuck inside here: "do { draw(); // constantly drawing and never updates the timer } "
Sent from my iPhone
On Feb 8, 2017, at 9:19 AM, Antonireykern notifications@github.com wrote:
do { draw(); }
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
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.