Pages: [1]   Go Down
Author Topic: Multiplexing while preforming other operations  (Read 401 times)
0 Members and 1 Guest are viewing this topic.
California
Offline Offline
Sr. Member
****
Karma: 3
Posts: 433
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

What is the best method of multiplexing a display, while still being able to do other things? For example, reading my RTC and listening for button presses while running though a 4 digit display. The only thing I can think of is to put the display in a for loop, or while loop and give it about 50 rolls or so before going through the rest of my required code for updates. And the button listening could go with the multiplexing loop.

Is there a more practical, or common way?
Logged

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 533
Posts: 26943
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

More practical is blink without delay.
I have code that reads button pushes, makes decisions on stuff every 100uS
These are all unsigned long
currentMicros, previousMicros, hundred_uS_interval
Code:
 // *******************************************************************
  // start timing interval

  currentMicros = micros();  // sample the time
  if (currentMicros - previousMicros >= hundred_uS_interval) // more than our interval?
  {
    // save the last time we okayed time updates
    previousMicros = currentMicros; // save the current time for next comparison
 

    // do stuff on 100uS intervals

}

Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

California
Offline Offline
Sr. Member
****
Karma: 3
Posts: 433
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

okay, so we are updating the display so quickly that we can do it a bunch of times before checking for button presses, and clock updates? then every so often we take a moment to do those other things?
Logged

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 533
Posts: 26943
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Yes.
You could update a counter every time the if condition is met.
Every time the counter hits 50, read your buttons.
Everytime  hits 100, update your clock.
Something along those lines.
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Pages: [1]   Go Up
Jump to: