[PD-cvs] externals/hardware/arduino/Pd_firmware Pd_firmware.pde, 1.16, 1.17

Georg Holzmann grholzi at users.sourceforge.net
Mon Sep 4 17:43:15 CEST 2006


Update of /cvsroot/pure-data/externals/hardware/arduino/Pd_firmware
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21041

Modified Files:
	Pd_firmware.pde 
Log Message:
some fixes in the firmware for PWM


Index: Pd_firmware.pde
===================================================================
RCS file: /cvsroot/pure-data/externals/hardware/arduino/Pd_firmware/Pd_firmware.pde,v
retrieving revision 1.16
retrieving revision 1.17
diff -C2 -d -r1.16 -r1.17
*** Pd_firmware.pde	4 Sep 2006 07:44:29 -0000	1.16
--- Pd_firmware.pde	4 Sep 2006 15:43:13 -0000	1.17
***************
*** 37,42 ****
  /* 
   * TODO: get digitalInput working
!  * TODO: add pulseIn/pulseOut functionality
!  * TODO: save settings to EEPROM
   * TODO: add software PWM for servos, etc (servo.h or pulse.h)
   * TODO: redesign protocol to accomodate boards with more I/Os
--- 37,41 ----
  /* 
   * TODO: get digitalInput working
!  * TODO: add pulseIn functionality
   * TODO: add software PWM for servos, etc (servo.h or pulse.h)
   * TODO: redesign protocol to accomodate boards with more I/Os
***************
*** 114,118 ****
  /* two byte PWM data format
   * ----------------------
!  * 0  get ready for digital input bytes (ENABLE_PWM)
   * 1  pin #
   * 2  duty cycle expressed as 1 byte (255 = 100%)
--- 113,117 ----
  /* 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%)
***************
*** 219,228 ****
      pinMode(pin,OUTPUT);
    }
-   // this will apply to all digital pins once softPWM is implemented
    else if( (mode == PWM) && (pin >= 9) && (pin <= 11) ) {
      digitalPinStatus = digitalPinStatus | (1 << pin);
      pwmStatus = pwmStatus | (1 << pin);
      pinMode(pin,OUTPUT);
    }
  }
  
--- 218,233 ----
      pinMode(pin,OUTPUT);
    }
    else if( (mode == PWM) && (pin >= 9) && (pin <= 11) ) {
      digitalPinStatus = digitalPinStatus | (1 << pin);
      pwmStatus = pwmStatus | (1 << pin);
+     softPwmStatus = softPwmStatus &~ (1 << pin);
      pinMode(pin,OUTPUT);
    }
+   else if(mode == SOFTPWM) {
+     digitalPinStatus = digitalPinStatus | (1 << pin);
+     pwmStatus = pwmStatus &~ (1 << pin);
+     softPwmStatus = softPwmStatus | (1 << pin);
+     pinMode(pin,OUTPUT);
+   } 
  }
  
***************
*** 278,307 ****
      waitForData--;
      storedInputData[waitForData] = inputData;
!   }
!   else if(executeMultiByteCommand) {
!     //we got everything
!     switch(executeMultiByteCommand) {
!     case ENABLE_PWM:
!       setPinMode(storedInputData[1],PWM);
!       analogWrite(storedInputData[1], storedInputData[0]);
!       break;
!     case DISABLE_PWM:
!       setPinMode(storedInputData[0],INPUT);
!       break;
! /*    case ENABLE_SOFTWARE_PWM:
!       setPinMode(storedInputData[1],SOFTPWM);
!       setSoftPwm(storedInputData[1], storedInputData[0]);     
!       break; 
!     case DISABLE_SOFTWARE_PWM:
!       disSoftPwm(storedInputData[0]);
!       break;
!     case SET_SOFTWARE_PWM_FREQ:
!       setSoftPwmFreq(storedInputData[0]);
!       break;
!       */
      }
-     executeMultiByteCommand = 0;
    }
-   
    else if(inputData < 128) {
      if(firstInputByte) {  //
--- 283,311 ----
      waitForData--;
      storedInputData[waitForData] = inputData;
! 
!     if(executeMultiByteCommand && (waitForData==0)) {
!       //we got everything
!       switch(executeMultiByteCommand) {
!       case ENABLE_PWM:
!         setPinMode(storedInputData[1],PWM);
!         analogWrite(storedInputData[1], storedInputData[0]);
!         break;
!       case DISABLE_PWM:
!         setPinMode(storedInputData[0],INPUT);
!         break;
!       case ENABLE_SOFTWARE_PWM:
!         setPinMode(storedInputData[1],SOFTPWM);
!         setSoftPwm(storedInputData[1], storedInputData[0]);     
!         break; 
!       case DISABLE_SOFTWARE_PWM:
!         disSoftPwm(storedInputData[0]);
!         break;
!       case SET_SOFTWARE_PWM_FREQ:
!         setSoftPwmFreq(storedInputData[0]);
!         break;
!       }
!       executeMultiByteCommand = 0;
      }
    }
    else if(inputData < 128) {
      if(firstInputByte) {  //
***************
*** 410,414 ****
    beginSerial(19200);
    for(i=0; i<TOTAL_DIGITAL_PINS; ++i) {
!     setPinMode(i,OUTPUT);
    }
  }
--- 414,418 ----
    beginSerial(19200);
    for(i=0; i<TOTAL_DIGITAL_PINS; ++i) {
!     setPinMode(i,INPUT);
    }
  }





More information about the Pd-cvs mailing list