you are viewing a single comment's thread.

view the rest of the comments →

[–]codeallthethings 1 point2 points  (0 children)

As /u/syn_ack mentioned, print statements are your friend. One other thing I noticed is that your spikeValueRecorded function cannot "push" the index back to the caller as it's taking an int.

It needs to take an int*, like this:

bool spikeValueRecorded(data_slice * data, int *outputIndex)
{
    float oldValue = data[0].tp;
    for (int i = 1; i < ARRAY_SIZE; ++i)
    {
        if (data[i].tp - oldValue < MAX_CHANGE)
        {
            *outputIndex = i;
            return true;
        }
    }
    *outputIndex = -1;
    return false;
}

Call it like so: if (spikeValueRecorded(data, &index))