<commit_before>// -*- mode:C++; tab-width:4; c-basic-offset:4; indent-tabs-mode:nil -*-

#include "PwmBot.hpp"

// ------------------- DeviceDriver Related ------------------------------------

bool PwmBot::open(Searchable& config) {

    Bottle gpiosBottle = config.findGroup("gpios").tail();  //-- e.g. 17 27

    printf(BOLDBLUE);
    printf("PwmBot options:\n");
    printf("\t--gpios %s\n",gpiosBottle.toString().c_str());
    printf(RESET);

    if ( config.check("pcm") )
        setup(PULSE_WIDTH_INCREMENT_GRANULARITY_US_DEFAULT, DELAY_VIA_PCM);
    else
        setup(PULSE_WIDTH_INCREMENT_GRANULARITY_US_DEFAULT, DELAY_VIA_PWM);

    for(int j=0; j < gpiosBottle.size(); j++)
    {
        int gpio = gpiosBottle.get(j).asInt();
        init_channel(j, SUBCYCLE_TIME_US_DEFAULT);  //10ms;
        print_channel(j);
        add_channel_pulse(j, gpio, 0);
        gpios.push_back( gpiosBottle.get(j).asInt() );
        RD_SUCCESS("Configured gpio %d on channel %d.\n",gpio,j);
    }
    
    return true;
}

// -----------------------------------------------------------------------------

bool PwmBot::close() {

    return true;
}

// -----------------------------------------------------------------------------
<commit_msg>set up pwm before clear, edit<commit_after>// -*- mode:C++; tab-width:4; c-basic-offset:4; indent-tabs-mode:nil -*-

#include "PwmBot.hpp"

// ------------------- DeviceDriver Related ------------------------------------

bool PwmBot::open(Searchable& config) {

    Bottle gpiosBottle = config.findGroup("gpios").tail();  //-- e.g. 17 27

    printf(BOLDBLUE);
    printf("PwmBot options:\n");
    printf("\t--gpios %s\n",gpiosBottle.toString().c_str());
    printf(RESET);

    if ( config.check("pcm") )
        setup(PULSE_WIDTH_INCREMENT_GRANULARITY_US_DEFAULT, DELAY_VIA_PCM);
    else
        setup(PULSE_WIDTH_INCREMENT_GRANULARITY_US_DEFAULT, DELAY_VIA_PWM);

    for(int j=0; j < gpiosBottle.size(); j++)
    {
        int gpio = gpiosBottle.get(j).asInt();
        init_channel(j, SUBCYCLE_TIME_US_DEFAULT);  //10ms;
        print_channel(j);
        add_channel_pulse(j, gpio, 0, 0);
        gpios.push_back( gpiosBottle.get(j).asInt() );
        RD_SUCCESS("Configured gpio %d on channel %d.\n",gpio,j);
    }
    
    return true;
}

// -----------------------------------------------------------------------------

bool PwmBot::close() {

    return true;
}

// -----------------------------------------------------------------------------

{'fraction_non_alphanumeric': 0.3034925732637495, 'fraction_numerical': 0.008430349257326376, 'mean_word_length': 1.6595517609391675, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1671058', 'n_tokens_mistral': 863, 'n_tokens_neox': 829, 'n_words': 126}