chiark / gitweb /
wiringPi Version 2 - First commit (of v2)
[wiringPi.git] / wiringPi / softPwm.c
index 56bf4d88ffa661b498ff755fbca4340466e0e7a5..a4f0fc43f6b0fc3e0dc434c1cef9087e0833a982 100644 (file)
@@ -28,7 +28,7 @@
 #include "wiringPi.h"
 #include "softPwm.h"
 
-#define        MAX_PINS        64
+#define        MAX_PINS        1024
 
 // The PWM Frequency is derived from the "pulse time" below. Essentially,
 //     the frequency is a function of the range and this pulse time.
@@ -84,8 +84,22 @@ static PI_THREAD (softPwmThread)
   return NULL ;
 }
 
+
+/*
+ * softPwmWrite:
+ *     Write a PWM value to the given pin
+ *********************************************************************************
+ */
+
 void softPwmWrite (int pin, int value)
 {
+  pin &= (MAX_PINS - 1) ;
+
+  /**/ if (value < 0)
+    value = 0 ;
+  else if (value > range [pin])
+    value = range [pin] ;
+
   marks [pin] = value ;
 }