From 722d40641e24d433684dce93c03333ee2b57c7d7 Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Sun, 21 May 2006 17:37:46 +0000 Subject: its now possible to turn on and off digital and analog input, so you can stop arduino from sending data alltoger, while still responding; digitalInputs are still not tested svn path=/trunk/externals/hardware/arduino/; revision=5104 --- Pd_firmware/Pd_firmware.pde | 79 ++++++++++++++++++++++++++++++++------------- 1 file changed, 57 insertions(+), 22 deletions(-) (limited to 'Pd_firmware/Pd_firmware.pde') diff --git a/Pd_firmware/Pd_firmware.pde b/Pd_firmware/Pd_firmware.pde index ba93885..367a6e8 100644 --- a/Pd_firmware/Pd_firmware.pde +++ b/Pd_firmware/Pd_firmware.pde @@ -24,6 +24,15 @@ * 230 - next byte sets PWM0 value * 231 - next byte sets PWM1 value * 232 - next byte sets PWM2 value + * 238 - disable all digital inputs + * 239 - enable all digital inputs + * 240 - disable all analog inputs + * 241 - enable 1 analog input (0) + * 242 - enable 2 analog inputs (0,1) + * 243 - enable 3 analog inputs (0-2) + * 244 - enable 4 analog inputs (0-3) + * 245 - enable 5 analog inputs (0-4) + * 246 - enable 6 analog inputs (0-5) * * Pd->Arduino byte cycle * ---------------------- @@ -83,6 +92,9 @@ int digitalPinStatus; */ int pwmStatus; +boolean digitalInputsEnabled = true; +byte analogInputsEnabled = 6; + byte analogPin; int analogData; @@ -105,6 +117,7 @@ void transmitDigitalInput(byte startPin) { digitalData = 0; // pin set to PWM, don't read } else { + // TODO: get digital in working // digitalData = digitalRead(digitalPin); digitalData = pwmStatus; } @@ -151,15 +164,15 @@ void processInput(byte inputData) { // the PWM commands (230-232) have a byte of data following the command if (waitForPWMData > 0) { - printByte(150); - printByte(inputData); + // printByte(150); + // printByte(inputData); analogWrite(waitForPWMData,inputData); waitForPWMData = 0; } else if(inputData < 128) { - printByte(151); + // printByte(151); if(firstInputByte) { - printByte(160); + // printByte(160); for(i=0; i<7; ++i) { mask = 1 << i; //printByte(254); @@ -173,7 +186,7 @@ void processInput(byte inputData) { firstInputByte = false; } else { - printByte(161); + // printByte(161); // output data for pins 7-13 for(i=7; i> 7); // bitshift the big stuff into the output byte printByte(analogData % 128); // mod by 32 for the small byte + checkForInput(); } - // read all digital pins - transmitDigitalInput(0); - transmitDigitalInput(7); - - checkForInput(); - - /* end with the cycle marker */ - printByte(255); - - // setPinMode(13,OUTPUT); - // digitalWrite(13,HIGH); + /* end with the cycle marker, if any of the inputs are enabled */ + if( digitalInputsEnabled || analogInputsEnabled) { + printByte(255); + } } -- cgit v1.2.1