Hi,
i hope it's okay to resurrect the thread.
i copied roberts code into the custom cpp and it seems to work fine and the console prints out the proper encoder value
but if i add the messages to PureData like this:
libpd_float("encoder",-1); // send to Pd
it stops working as soon as i touch the encoder
(i'm sending -1 and 1 to puredata because i'm only looking for the change, not the absolute value in PD)
//ENCODER STUFF
for(unsigned int n=0; n<context->digitalFrames; n++){
status = digitalRead(context, n, encoder0PinA);
if ((encoder0PinALast == LOW) && (status == HIGH)) {
if (digitalRead(context, n, encoder0PinB) == LOW) {
encoder0Pos--;
libpd_float("encoder",-1); // send to Pd
} else {
encoder0Pos++;
libpd_float("encoder",1); // send to Pd
}
}
encoder0PinALast = status;
// Increment a counter on every frame
gCount++;
// Print a message every quarter second indicating the current encoder count
if(gCount % (int)(context->audioSampleRate*gInterval) == 0) {
gSecondsElapsed += gInterval;
rt_printf("Encoder reading: %d\n",encoder0Pos);
}
}
//ENCODER STUFF
the console gives me the following messages:
Encoder reading: 0
Encoder reading: 0
Encoder reading: 0
Encoder reading: 0
Encoder reading: 0
Segmentation fault
Makefile:606: recipe for target 'runide' failed
make: *** [runide] Error 139
Bela stopped