Search found 31 matches

by hdsjulian
Wed Mar 06, 2019 5:03 pm
Forum: General Discussion and Questions
Topic: fastest way to fill large bytearrays? (Neopixel, APA102 et al)
Replies: 15
Views: 33077

Re: fastest way to fill large bytearrays? (Neopixel, APA102 et al)

Update: This takes 42ms to run. is there any option to speed it up?

Code: Select all

import utime
ba = bytearray(120*4)
 
start = utime.ticks_us()
for i in range(120):
    ba[i*4+0] = 255
    ba[i*4+1] = 255
    ba[i*4+2] = 255
    ba[i*4+3] = 255
end = utime.ticks_us()
print("Total time: "+str(end-start))
by hdsjulian
Wed Mar 06, 2019 4:22 pm
Forum: General Discussion and Questions
Topic: fastest way to fill large bytearrays? (Neopixel, APA102 et al)
Replies: 15
Views: 33077

fastest way to fill large bytearrays? (Neopixel, APA102 et al)

So i'm working on a project with 120 APA102 LEDs and it's insanely slow. Same goes for Neopixels. The problem isn't the writing itself (this takes about 2ms) but rather the filling / overwriting of the bytearray (which takes about 100ms for the 120*4 Values).
Any pointers on how i can speed this up?
by hdsjulian
Wed Mar 06, 2019 1:56 pm
Forum: General Discussion and Questions
Topic: Running two concurrent threads
Replies: 16
Views: 9058

Re: Running two concurrent threads

using the ADC interface. it's a max4466 electret microphone
by hdsjulian
Wed Mar 06, 2019 1:55 pm
Forum: General Discussion and Questions
Topic: Running two concurrent threads
Replies: 16
Views: 9058

Re: Running two concurrent threads

sorry my second comment was useless. don't know how i double posted this
by hdsjulian
Tue Mar 05, 2019 1:06 pm
Forum: General Discussion and Questions
Topic: Running two concurrent threads
Replies: 16
Views: 9058

Re: Running two concurrent threads

true. but this won't keep me from only sampling 1000 inputs per second?
by hdsjulian
Sun Mar 03, 2019 12:27 pm
Forum: General Discussion and Questions
Topic: Running two concurrent threads
Replies: 16
Views: 9058

Re: Running two concurrent threads

right. but even if i do it that way i can only sample 1000 times per second, right?
by hdsjulian
Sat Mar 02, 2019 9:36 pm
Forum: General Discussion and Questions
Topic: Running two concurrent threads
Replies: 16
Views: 9058

Re: Running two concurrent threads

def handleInterrupt(timer): global beat val = mic.read() [do some calculations and stuff create the envelope value that determines the bass, cutting out here because it's not really ready and a little offtopic] timer.init(period=1, mode=machine.Timer.PERIODIC, callback=handleInterrupt) def run(thre...
by hdsjulian
Fri Mar 01, 2019 4:22 pm
Forum: General Discussion and Questions
Topic: Running two concurrent threads
Replies: 16
Views: 9058

Re: Running two concurrent threads

yeah this is the way i handled it. unfortunately the interrupt-timer can only go down to 1ms? or is there an option i'm missing?
by hdsjulian
Thu Feb 28, 2019 11:52 am
Forum: General Discussion and Questions
Topic: Running two concurrent threads
Replies: 16
Views: 9058

Re: Running two concurrent threads

i could probably do with less. The main problem is that the "writing the LEDs" is blocking the reading (for about 0.5ms per LED) and if i have to write LEDs four times a second (beat on, beat off, assuming the track has 120bpm) , i'm gonna loose a a quarter of all samples no matter how often i sampl...
by hdsjulian
Thu Feb 28, 2019 8:58 am
Forum: General Discussion and Questions
Topic: Running two concurrent threads
Replies: 16
Views: 9058

Re: Running two concurrent threads

If this is normal audio, how is 10,000 samples per minute enough? That’s 167 samples per second aka 167Hz. Sent from my iPhone using Tapatalk Pro asking the important questions, eh ;) first of all i made a mistake, it's not per minute it's per second, but actually only 1000 per second, which is fin...