Update of /cvsroot/pure-data/externals/hardware/arduino/Pd_firmware In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2374/Pd_firmware
Modified Files: Pd_firmware.pde Log Message:
- fixed up help file so that everything loads with Pd-extended - fixed up [arduino] so that everything loads with Pd-extended - started to clean up the firmware and wrote lots of TODOs
Index: Pd_firmware.pde =================================================================== RCS file: /cvsroot/pure-data/externals/hardware/arduino/Pd_firmware/Pd_firmware.pde,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** Pd_firmware.pde 31 Oct 2006 00:39:07 -0000 1.21 --- Pd_firmware.pde 6 Dec 2006 03:29:06 -0000 1.22 *************** *** 46,49 **** --- 46,50 ---- * TODO: add "pinMode all 0/1" command * TODO: add cycle markers to mark start of analog, digital, pulseIn, and PWM + * TODO: convert to MIDI protocol using SysEx for longer messages */
*************** *** 54,59 **** * software can test whether it will be compatible with the currently * installed firmware. */ ! #define MAJOR_VERSION 0 ! #define MINOR_VERSION 2
/* firmata protocol --- 55,60 ---- * software can test whether it will be compatible with the currently * installed firmware. */ ! #define MAJOR_VERSION 0 // for non-compatible changes ! #define MINOR_VERSION 3 // for backwards compatible changes
/* firmata protocol *************** *** 113,122 **** /* 230-239 // UNASSIGNED */ #define REPORT_VERSION 240 // return the firmware version ! /* 240-249 // UNASSIGNED */ #define DISABLE_PWM 250 // next byte sets pin # to disable #define ENABLE_PWM 251 // next two bytes set pin # and duty cycle ! #define DISABLE_SOFTWARE_PWM 252 // next byte sets pin # to disable ! #define ENABLE_SOFTWARE_PWM 253 // next two bytes set pin # and duty cycle ! #define SET_SOFTWARE_PWM_FREQ 254 // set master frequency for software PWMs /* 255 // UNASSIGNED */
--- 114,122 ---- /* 230-239 // UNASSIGNED */ #define REPORT_VERSION 240 // return the firmware version ! /* 240-248 // UNASSIGNED */ ! #define SET_PIN_STATE 249 // set a digital pit to INPUT or OUTPUT #define DISABLE_PWM 250 // next byte sets pin # to disable #define ENABLE_PWM 251 // next two bytes set pin # and duty cycle ! #define RESET 254 // reset if receive 8 of these bytes /* 255 // UNASSIGNED */
*************** *** 124,136 **** /* two byte digital output data format * ---------------------- ! * 0 get ready for digital input bytes (229) * 1 digitalOut 7-13 bitmask * 2 digitalOut 0-6 bitmask */
! /* two byte PWM data format * ---------------------- ! * 0 get ready for digital input bytes (ENABLE_SOFTWARE_PWM/ENABLE_PWM) ! * 1 pin # * 2 duty cycle expressed as 1 byte (255 = 100%) */ --- 124,136 ---- /* two byte digital output data format * ---------------------- ! * 0 set digital output bytes (229/OUTPUT_TO_DIGITAL_PINS) * 1 digitalOut 7-13 bitmask * 2 digitalOut 0-6 bitmask */
! /* control PWM * ---------------------- ! * 0 send digital input bytes (ENABLE_PWM) ! * 1 pin # (0-127) * 2 duty cycle expressed as 1 byte (255 = 100%) */ *************** *** 150,153 **** --- 150,194 ---- */
+ /* version report format + * Send a single byte 240, Arduino will reply with: + * ---------------------- + * 0 version report header (240) + * 1 major version (0-127) + * 2 minor version (0-127) + */ + + /* PROPOSED PROTOCOL ADDITIONS */ + + /* set digital pin state (249/SET_PIN_STATE) + * ---------------------- + * 0 set digital pin state + * 1 pin number (0-127) + * 2 state (OUTPUT/INPUT, 0/1) */ + + /* toggle analogIn reporting (249/SET_PIN_STATE) + * ---------------------- + * 0 analogIn reporting mode + * 1 pin number (0-127) + * 2 state (0/1) + */ + + /* control PWM 14-bit + * ---------------------- + * 0 send digital input bytes (ENABLE_PWM) + * 1 pin # (0-127) + * 2 duty cycle, high bits (8-13) + * 3 duty cycle, low bits (0-7) + */ + + + /* pulseIn (uses 32-bit value) + * ---------------------- + * 0 pulseIn + * 1 bits 24-31 (most significant byte) + * 2 bits 16-23 + * 3 bits 8-15 + * 4 bits 0-7 (least significant byte) + */ + #define TOTAL_DIGITAL_PINS 14
*************** *** 182,185 **** --- 223,227 ----
boolean digitalInputsEnabled = true; + // TODO: convert this to a bit array int, 1=report, 0=no report byte analogInputsEnabled = 6;
*************** *** 274,283 **** setPinMode(storedInputData[0],INPUT); break; - case ENABLE_SOFTWARE_PWM: - break; - case DISABLE_SOFTWARE_PWM: - break; - case SET_SOFTWARE_PWM_FREQ: - break; } executeMultiByteCommand = 0; --- 316,319 ---- *************** *** 307,310 **** --- 343,380 ---- else { switch (inputData) { + case REPORT_VERSION: + Serial.print(REPORT_VERSION, BYTE); + Serial.print(MAJOR_VERSION, BYTE); + Serial.print(MINOR_VERSION, BYTE); + break; + case ENABLE_PWM: + waitForData = 2; // 2 bytes needed (pin#, dutyCycle) + executeMultiByteCommand = inputData; + break; + case DISABLE_PWM: + waitForData = 1; // 1 byte needed (pin#) + executeMultiByteCommand = inputData; + break; + case OUTPUT_TO_DIGITAL_PINS: // bytes to send to digital outputs + firstInputByte = true; + break; + case DISABLE_DIGITAL_INPUTS: // all digital inputs off + digitalInputsEnabled = false; + break; + case ENABLE_DIGITAL_INPUTS: // all digital inputs on + digitalInputsEnabled = true; + break; + case ZERO_ANALOG_INS: // analog input off + case ONE_ANALOG_IN: // analog 0 on + case TWO_ANALOG_INS: // analog 0,1 on + case THREE_ANALOG_INS: // analog 0-2 on + case FOUR_ANALOG_INS: // analog 0-3 on + case FIVE_ANALOG_INS: // analog 0-4 on + case SIX_ANALOG_INS: // analog 0-5 on + case SEVEN_ANALOG_INS: // analog 0-6 on + case EIGHT_ANALOG_INS: // analog 0-7 on + case NINE_ANALOG_INS: // analog 0-8 on + analogInputsEnabled = inputData - ZERO_ANALOG_INS; + break; case SET_PIN_ZERO_TO_IN: // set digital pins to INPUT case SET_PIN_ONE_TO_IN: *************** *** 339,388 **** setPinMode(inputData - SET_PIN_ZERO_TO_OUT, OUTPUT); break; - case DISABLE_DIGITAL_INPUTS: // all digital inputs off - digitalInputsEnabled = false; - break; - case ENABLE_DIGITAL_INPUTS: // all digital inputs on - digitalInputsEnabled = true; - break; - case ZERO_ANALOG_INS: // analog input off - case ONE_ANALOG_IN: // analog 0 on - case TWO_ANALOG_INS: // analog 0,1 on - case THREE_ANALOG_INS: // analog 0-2 on - case FOUR_ANALOG_INS: // analog 0-3 on - case FIVE_ANALOG_INS: // analog 0-4 on - case SIX_ANALOG_INS: // analog 0-5 on - case SEVEN_ANALOG_INS: // analog 0-6 on - case EIGHT_ANALOG_INS: // analog 0-7 on - case NINE_ANALOG_INS: // analog 0-8 on - analogInputsEnabled = inputData - ZERO_ANALOG_INS; - break; - case ENABLE_PWM: - waitForData = 2; // 2 bytes needed (pin#, dutyCycle) - executeMultiByteCommand = inputData; - break; - case DISABLE_PWM: - waitForData = 1; // 1 byte needed (pin#) - executeMultiByteCommand = inputData; - break; - case SET_SOFTWARE_PWM_FREQ: - waitForData = 1; // 1 byte needed (pin#) - executeMultiByteCommand = inputData; - break; - case ENABLE_SOFTWARE_PWM: - waitForData = 2; // 2 bytes needed (pin#, dutyCycle) - executeMultiByteCommand = inputData; - break; - case DISABLE_SOFTWARE_PWM: - waitForData = 1; // 1 byte needed (pin#) - executeMultiByteCommand = inputData; - break; - case OUTPUT_TO_DIGITAL_PINS: // bytes to send to digital outputs - firstInputByte = true; - break; - case REPORT_VERSION: - Serial.print(REPORT_VERSION, BYTE); - Serial.print(MAJOR_VERSION, BYTE); - Serial.print(MINOR_VERSION, BYTE); - break; } } --- 409,412 ---- *************** *** 398,401 **** --- 422,427 ---- // TODO: load state from EEPROM here
+ Serial.begin(115200); + /* TODO: send digital inputs here, if enabled, to set the initial state on the * host computer, since once in the loop(), the Arduino will only send data on *************** *** 413,417 **** setPinMode(i,INPUT); } - Serial.begin(115200); }
--- 439,442 ----