Code help

Folny82
Posts: 7
Joined: Wed Feb 07, 2018 1:56 am

Code help

Postby Folny82 » Wed Feb 07, 2018 2:01 am

Hello friends

Can anyone advise me how to edit this sketch to work with ESP32 in advance thanks for your reply.

https://github.com/dc42/arduino/blob/ma ... tector.ino

Problem is with this frequent code

ISR(TIMER1_OVF_vect)
{
++ticks;
uint8_t ctr = TCNT0;
int16_t val = (int16_t)(uint16_t)ADCH; // only need to read most significant 8 bits
if (ctr != ((lastctr + 1) & 7))
{
++misses;
}
lastctr = ctr;
int16_t *p = &bins[ctr & 3];
if (ctr < 4)
{
*p += (val);
if (*p > 15000) *p = 15000;
}
else
{
*p -= val;
if (*p < -15000) p = -15000;
}
if (ctr == 7)
{
++numSamples;
if (numSamples == numSamplesToAverage)
{
numSamples = 0;
if (!sampleReady) // if previous sample has been consumed
{
memcpy((void)averages, bins, sizeof(averages));
sampleReady = true;
}
memset(bins, 0, sizeof(bins));
}
}
}

tele_player
Posts: 90
Joined: Sun Jul 02, 2017 3:38 am

Re: Code help

Postby tele_player » Fri Feb 09, 2018 12:07 am

You will increase your chance of getting help if you describe what you have tried, and what you have seen.
Does it compile cleanly? If not, what error message do you see?
Does it run, but not correctly?

Folny82
Posts: 7
Joined: Wed Feb 07, 2018 1:56 am

Re: Code help

Postby Folny82 » Fri Feb 09, 2018 1:43 am

Hello

I do not know how to set timers i am not totally sure how to edit this code for ESP32 i do not have any experience with ESP32 development board :(

mickeypop
Posts: 11
Joined: Mon May 08, 2017 8:56 pm

Re: Code help

Postby mickeypop » Sat Feb 17, 2018 5:07 am

look at this thread it offers a simple timer.
It should get you going.

https://esp32.com/viewtopic.php?f=19&t=4673

Who is online

Users browsing this forum: No registered users and 56 guests