Bitmap refresh / Audio streaming.

Status
Not open for further replies.
I've managed to get audio and a bitmap running with no issues (now).

I was just wondering how I would now go about changing an image every 'N' seconds, whilst the audio is running?

It's probably something really basic I'm missing (I'm self taught), and I have tried things like running a while loop etc, but the image will only change on every loop rather than every 'N' seconds..

Is this something that in need to do with timers, as here:

https://learn.adafruit.com/multi-tasking-the-arduino-part-1/a-clean-sweep

Or, is there another way?
(I'm sort of out of my depth at this point.. I'm looking to run multiple tasks generally, not just for this combination).

Also, could I just add multiple audio ICs in the same manner, or would that require alternative coding?


Thanks in advance!
 
This is where I start to venture in to 'unsolved understanding' on my part..

I saw that I can assign different timers with the libraries provided on the main Teensy site. https://www.pjrc.com/teensy/td_timing_IntervalTimer.html

This is the first time I've done anything like this.
I've been running standalone multiplexing etc, but I always fall in to issues.

I can digest/follow the tutorial in the link in my initial post, but are there any pitfalls I should be aware of?

Is there any information on where is best to start?

In 'realtime' I'm guessing that 'segments' of bits/bytes are sent to effectively a DAC.
This and basically a much more complex version of a multiplexing system?

Am I right in saying that it follows 'go do this for a fraction of a split second', then 'go and do this now for this split second' (unnoticeable to human interpretation).

I apologise if this all seems very 'noob' of me, but, as my username suggests, in many respects, I am that.


In:

"Up to 4 IntervalTimer objects may be active simultaneuously. The tone function and several libraries use an IntervalTimer.".

Is this a hardware limitation, or a software limitation?
How does this relate to audio and, eg. generating a bitmap?

It's taking around 1 second to generate a bitmap full screen.
That seems like a long time, when I have seen the same setup much faster.

What am I doing wrong?

(PS. I am running on Teensy 3.2).
 
Last edited:
There is a samples in Example / TimerOne / Interrupt

You could set a flag there - but you wouldn't want to sit in the interrupt and wait for the image to draw

If you set the flag you would watch for that in loop() then update the image. On the boundary of seconds checking at top/bottom of every loop shouldn't miss by much unless you have delays or other stalling code in your loop.

Alternatively the elapsedMillis could be an ideal way to watch for N seconds to have passed.

Every time you finish putting up a new image set the elapsedMillis variable to zero. Whenever you want within loop() check the value of that variable and if ">= N" seconds is passed then draw image and zero the variable.
 
"Up to 4 IntervalTimer objects may be active simultaneuously. The tone function and several libraries use an IntervalTimer.".

Is this a hardware limitation, or a software limitation?

It's a hardware limit. Each IntervalTimer uses one of 4 special hardware timers on Teensy 3.2. Or if using Teensy LC, there's only 2 of them.

IntervalTimer uses interrupts. Interrupts are a powerful feature which is tricky to use correctly. Generally I recommend using elapsedMillis or the other non-interrupt ways if they can meet your needs. Even if you're experienced, avoid interrupts unless you really need them.


How does this relate to audio and, eg. generating a bitmap?

It's probably not related at all.


It's taking around 1 second to generate a bitmap full screen.
That seems like a long time, when I have seen the same setup much faster.

What am I doing wrong?

Well, lack of details about what you're doing and the code you're using is really holding everyone back from giving you more specific and useful help. Perhaps you started another thread earlier with that info, but I don't see any links to other conversation.
 
Sorry for the late reply.

I've been getting distracted by other things, but will get some code together and try out endmillis etc and get back to you. Thanks for the input so far!
 
Status
Not open for further replies.
Back
Top