Pages: 1 ... 12 13 [14]   Go Down
Author Topic: U8glib: Graphics Lib for LCDs and OLEDs  (Read 35149 times)
0 Members and 1 Guest are viewing this topic.
Germany
Online Online
Edison Member
*
Karma: 100
Posts: 1243
If you believe something is right, you won't see what's wrong (David Straker).
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You should break down your task into three independent steps:

Code:
loop() {
  do measure and derive other values (FFT)
  display data
  calculate which page should be visible
}

"display data" will look like this:
Code:
if ( page_to_display == 1 )
  display_page_1();
else if ( page_to_display == 2 )
  display_page_2();

The "calculate which page should be visible" steps solves the task to calculate a suitable value for  "page_to_display". This calculation will be done based on the current system time, which is returned by millis(). So every 5 seconds you could switch the value for "page_to_display" from 1 to 2 and 2 to 1.

Oliver
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You should break down your task into three independent steps:

Code:
loop() {
  do measure and derive other values (FFT)
  display data
  calculate which page should be visible
}

"display data" will look like this:
Code:
if ( page_to_display == 1 )
  display_page_1();
else if ( page_to_display == 2 )
  display_page_2();

The "calculate which page should be visible" steps solves the task to calculate a suitable value for  "page_to_display". This calculation will be done based on the current system time, which is returned by millis(). So every 5 seconds you could switch the value for "page_to_display" from 1 to 2 and 2 to 1.

Oliver

Thanks for the reply!

I just wonder if I should do the "display data" inside the draw function picture loop or..? as if I do it in the main loop I would need delay(5000) after obtaining the millis() value so as to switch between the display page for every 5 seconds.

could you please explain a bit more detail about how to perform the function as I am confused?

The below is the program structure I am trying to perform and it needs to be finished in one cycle since the system picks new measurement during every cycle.

Code:
loop(){
     do measure and derive FFT value
     picture loop {
        draw();
     }
}

draw(){
    for (i=0; i<3; i++){
        display value
        wait 5s
        display FFT result
    }
}
« Last Edit: February 13, 2014, 10:42:14 am by oscar0226 » Logged

Germany
Online Online
Edison Member
*
Karma: 100
Posts: 1243
If you believe something is right, you won't see what's wrong (David Straker).
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You should not do the delay inside the picture loop.

You could do it like this:
Code:
loop(){
     do measure and derive FFT value
     picture loop {
        display value
     }
     wait 5s
     picture loop {
        display FFT result
     }
     wait 5s
}

Oliver
Logged

Pages: 1 ... 12 13 [14]   Go Up
Jump to: