Commits

Nirav Patel committed f3b02bc

adding brightness control

Comments (0)

Files changed (2)

     
     if (v4l2_get_control(self->fd, V4L2_CID_VFLIP, &value))
         self->vflip = value;
+
+    if (v4l2_get_control(self->fd, V4L2_CID_BRIGHTNESS, &value))
+        self->brightness = value;
 #endif    
-    return Py_BuildValue ("(OO)", PyBool_FromLong(self->hflip), PyBool_FromLong(self->vflip));
+    return Py_BuildValue ("(OOO)", PyBool_FromLong(self->hflip), PyBool_FromLong(self->vflip), PyInt_FromLong(self->brightness));
 }
 
 /* set_controls() - changes camera settings if supported by the camera */
 PyObject* camera_set_controls (PyCameraObject* self, PyObject* arg, PyObject *kwds)
 {
+    camera_get_controls(self);
     int hflip = self->hflip;
     int vflip = self->vflip;
+    int brightness = self->brightness;
     
-    char *kwids[] = {"hflip", "vflip", NULL};
-    if (!PyArg_ParseTupleAndKeywords(arg, kwds, "|ii", kwids, &hflip, &vflip))
+    char *kwids[] = {"hflip", "vflip", "brightness", NULL};
+    if (!PyArg_ParseTupleAndKeywords(arg, kwds, "|iii", kwids, &hflip, &vflip, &brightness))
         return NULL;
 #if defined(__unix__)        
     if (v4l2_set_control(self->fd, V4L2_CID_HFLIP, hflip))
         
     if (v4l2_set_control(self->fd, V4L2_CID_VFLIP, vflip))
         self->vflip = vflip;
+        
+    if (v4l2_set_control(self->fd, V4L2_CID_BRIGHTNESS, brightness))
+        self->brightness = brightness;
 #endif    
-    return Py_BuildValue ("(OO)", PyBool_FromLong(self->hflip), PyBool_FromLong(self->vflip));
+    return Py_BuildValue ("(OOO)", PyBool_FromLong(self->hflip), PyBool_FromLong(self->vflip), PyInt_FromLong(self->brightness));
 }
 
 /* get_size() - returns the dimensions of the images being recorded */
         cameraobj->size = 0;
         cameraobj->hflip = 0;
         cameraobj->vflip = 0;
+        cameraobj->brightness = 0;
         cameraobj->fd = -1;
     }
     
     int size;
     int hflip;
     int vflip;
+    int brightness;
     int fd;
 } PyCameraObject;