Example #1
0
int cleanupPwm(char *channel)
{
    char key[8];

    clear_error_msg();

    // The !channel fixes issues #50
    if (channel == NULL || strcmp(channel, "\0") == 0) {
        pwm_cleanup();
    } else {
        if (!get_pwm_key(channel, key)) {
            pwm_cleanup();
        }
        pwm_disable(key);
    }
}
// python function cleanup()
static PyObject *py_cleanup(PyObject *self, PyObject *args)
{
    // unexport the PWM
    pwm_cleanup();

    Py_RETURN_NONE;
}
Example #3
0
int main (void) {
    int i;
    //initialize_pwm();
    unload_device_tree("P8_13");
    unload_device_tree("P9_14");
    if (pwm_start("P8_13",50,10,0) == -1) {
        printf("Error starting PWM\n");
    } else {
        printf("PWM Started!\n");
    }
    if (pwm_start("P9_14",50,5,0) == -1) {
        printf("Error starting PWM\n");
    } else {
        printf("PWM Started!\n");
    }
    /*
    for (i = 100; i > 0; i--)
    {
        pwm_set_frequency("P8_13",i);
        sleep(10);
    }
    for (i = 0; i < 100; i++)
    {
        pwm_set_frequency("P8_13",i);
        sleep(10);
    }*/
    sleep(5);
    pwm_cleanup();
}