<commit_before>#include "SigmaDelta.h"
#include "DeviceRegistry.h"

using namespace ZPUino;

void SigmaDelta_class::begin()
{
    deviceBegin(VENDOR_ZPUINO, PRODUCT_ZPUINO_SIGMADELTA);
}
void SigmaDelta_class::begin(int pin_left, int pin_right)
{
    begin();
    if (!isError()) {
        setChannelPin(CHANNEL_LEFT, pin_left);
        setChannelPin(CHANNEL_RIGHT, pin_right);
    }
}

void SigmaDelta_class::setEndianness(endian_t endianess)
{
    if (!isError()) {
        if (LITTLE_ENDIAN==endianess)
            REG(0).setBit(SDLE);
        else
            REG(0).clearBit(SDLE);
    }
}

int SigmaDelta_class::setPins(int left_pin, int right_pin)
{
    setChannelPin(CHANNEL_LEFT, left_pin);
    setChannelPin(CHANNEL_RIGHT, right_pin);
}

int SigmaDelta_class::setChannelPin(channel_t channel, int pin)
{
    int *i_pin = (channel == CHANNEL_LEFT ? &m_leftPin: &m_rightPin);

    if (!isError()) {
        if (*i_pin>=0)
            pinModePPS(*i_pin, LOW);

        int ppspin = DeviceRegistry::getPPSOutputPin( getSlot(), channel==CHANNEL_LEFT ? 0: 1);
        if (ppspin<0)
            return -1;
        pinModePPS( pin, HIGH );
        outputPinForFunction( pin, ppspin );

        *i_pin = pin;
    }
    return 0;
}

void SigmaDelta_class::setChannelValue(channel_t channel, uint16_t value)
{
    uint32_t rv = REG(1);
    if (channel==CHANNEL_LEFT) {
        rv&=0xffff;
        rv|=((uint32_t)value)<<16;
    } else {
        rv&=0xffff0000;
        rv|=value&0xffff;
    }
    setValues(rv);
}<commit_msg>SigmaDelta: set pin as output, fix instance id<commit_after>#include "SigmaDelta.h"
#include "DeviceRegistry.h"

using namespace ZPUino;

void SigmaDelta_class::begin()
{
    deviceBegin(VENDOR_ZPUINO, PRODUCT_ZPUINO_SIGMADELTA);
}
void SigmaDelta_class::begin(int pin_left, int pin_right)
{
    begin();
    if (!isError()) {
        setChannelPin(CHANNEL_LEFT, pin_left);
        setChannelPin(CHANNEL_RIGHT, pin_right);
    }
}

void SigmaDelta_class::setEndianness(endian_t endianess)
{
    if (!isError()) {
        if (LITTLE_ENDIAN==endianess)
            REG(0).setBit(SDLE);
        else
            REG(0).clearBit(SDLE);
    }
}

int SigmaDelta_class::setPins(int left_pin, int right_pin)
{
    setChannelPin(CHANNEL_LEFT, left_pin);
    setChannelPin(CHANNEL_RIGHT, right_pin);
}

int SigmaDelta_class::setChannelPin(channel_t channel, int pin)
{
    int *i_pin = (channel == CHANNEL_LEFT ? &m_leftPin: &m_rightPin);

    if (!isError()) {
        if (*i_pin>=0)
            pinModePPS(*i_pin, LOW);

        int ppspin = DeviceRegistry::getPPSOutputPin( getSlot(), channel==CHANNEL_LEFT ? 0: 1);
        if (ppspin<0)
            return -1;
        pinModePPS( pin, HIGH );
        pinMode( pin, OUTPUT) ;
        outputPinForFunction( pin, ppspin );

        *i_pin = pin;
    }
    return 0;
}

void SigmaDelta_class::setChannelValue(channel_t channel, uint16_t value)
{
    uint32_t rv = REG(1);
    if (channel==CHANNEL_LEFT) {
        rv&=0xffff;
        rv|=((uint32_t)value)<<16;
    } else {
        rv&=0xffff0000;
        rv|=value&0xffff;
    }
    setValues(rv);
}
{'fraction_non_alphanumeric': 0.12849341471249598, 'fraction_numerical': 0.015419209765499518, 'mean_word_length': 3.119047619047619, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 5, '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': '3747134', 'n_tokens_mistral': 1160, 'n_tokens_neox': 1110, 'n_words': 202}