/*
 * callbacks_JSON.c
 */

#include <callbacks.h>
#include "SCA_Config.h"

//static bool getBoolFromString(char * string);

void GUICallback_VREF(char * string)
{
    globalParams.voltageReference = strtol(string, NULL, 10);
}

void GUICallback_FREQ(char * string)
{
    globalParams.wakeFrequency = strtol(string, NULL, 10);
}

void GUICallback_PGA0_MODE(char * string)
{
    pgaParams[0].mode = strtol(string, NULL, 10);
}

void GUICallback_PGA0_INPUTP(char * string)
{
    pgaParams[0].inputP = strtol(string, NULL, 10);
}

void GUICallback_PGA0_GAIN(char * string)
{
    pgaParams[0].gain = strtol(string, NULL, 10);
}

void GUICallback_PGA0_DAC(char * string)
{
    pgaParams[0].dac = strtol(string, NULL, 10);
}

void GUICallback_PGA1_MODE(char * string)
{
    pgaParams[1].mode = strtol(string, NULL, 10);
}

void GUICallback_PGA1_INPUTP(char * string)
{
    pgaParams[1].inputP = strtol(string, NULL, 10);
}

void GUICallback_PGA1_GAIN(char * string)
{
    pgaParams[1].gain = strtol(string, NULL, 10);
}

void GUICallback_PGA1_DAC(char * string)
{
    pgaParams[1].dac = strtol(string, NULL, 10);
}

void GUICallback_PGA2_MODE(char * string)
{
    pgaParams[2].mode = strtol(string, NULL, 10);
}

void GUICallback_PGA2_INPUTP(char * string)
{
    pgaParams[2].inputP = strtol(string, NULL, 10);
}

void GUICallback_PGA2_GAIN(char * string)
{
    pgaParams[2].gain = strtol(string, NULL, 10);
}

void GUICallback_PGA2_DAC(char * string)
{
    pgaParams[2].dac = strtol(string, NULL, 10);
}

void GUICallback_PGA3_MODE(char * string)
{
    pgaParams[3].mode = strtol(string, NULL, 10);
}

void GUICallback_PGA3_INPUTP(char * string)
{
    pgaParams[3].inputP = strtol(string, NULL, 10);
}

void GUICallback_PGA3_GAIN(char * string)
{
    pgaParams[3].gain = strtol(string, NULL, 10);
}

void GUICallback_PGA3_DAC(char * string)
{
    pgaParams[3].dac = strtol(string, NULL, 10);
}

void GUICallback_COMP0_MODE(char * string)
{
    compParams[0].mode = strtol(string, NULL, 10);
}

void GUICallback_COMP0_INPUTN(char * string)
{
    compParams[0].inputN = strtol(string, NULL, 10);
}

void GUICallback_COMP0_INPUTP(char * string)
{
    compParams[0].inputP = strtol(string, NULL, 10);
}

void GUICallback_COMP0_DAC(char * string)
{
    compParams[0].dac = strtol(string, NULL, 10);
}


void GUICallback_COMP1_MODE(char * string)
{
    compParams[1].mode = strtol(string, NULL, 10);
}

void GUICallback_COMP1_INPUTN(char * string)
{
    compParams[1].inputN = strtol(string, NULL, 10);
}

void GUICallback_COMP1_INPUTP(char * string)
{
    compParams[1].inputP = strtol(string, NULL, 10);
}

void GUICallback_COMP1_DAC(char * string)
{
    compParams[1].dac = strtol(string, NULL, 10);
}

void GUICallback_PWM0(char * string)
{
    pwmParams[0].dutyValue = strtol(string, NULL, 10);
}

void GUICallback_PWM1(char * string)
{
    pwmParams[1].dutyValue = strtol(string, NULL, 10);
}

void GUICallback_PWM2(char * string)
{
    pwmParams[2].dutyValue = strtol(string, NULL, 10);
}

void GUICallback_PWM3(char * string)
{
    pwmParams[3].dutyValue = strtol(string, NULL, 10);
}

void GUICallback_ADC0_MODE(char * string)
{
    adcParams[0].mode = strtol(string, NULL, 10);
}

void GUICallback_ADC1_MODE(char * string)
{
    adcParams[1].mode = strtol(string, NULL, 10);
}

void GUICallback_ADC2_MODE(char * string)
{
    adcParams[2].mode = strtol(string, NULL, 10);
}

void GUICallback_ADC3_MODE(char * string)
{
    adcParams[3].mode = strtol(string, NULL, 10);
}

void GUICallback_INT0(char * string)
{
    intParams[0].mode = strtol(string, NULL, 10);
}

void GUICallback_INT1(char * string)
{
    intParams[1].mode = strtol(string, NULL, 10);
}

void GUICallback_INT2(char * string)
{
    intParams[2].mode = strtol(string, NULL, 10);
}

void GUICallback_INT3(char * string)
{
    intParams[3].mode = strtol(string, NULL, 10);
}

void GUICallback_UPDATE(char * string)
{
    SCA_configGlobal(&globalParams);
    SCA_configPGA(&pgaParams[0],0);
    SCA_configPGA(&pgaParams[1],1);
    SCA_configPGA(&pgaParams[2],2);
    SCA_configPGA(&pgaParams[3],3);
    SCA_configCOMP(&compParams[0],0);
    SCA_configCOMP(&compParams[1],1);
    SCA_configPWM(&pwmParams[0],0);
    SCA_configPWM(&pwmParams[1],1);
    SCA_configPWM(&pwmParams[2],2);
    SCA_configPWM(&pwmParams[3],3);
    SCA_configINT(&intParams[0],0);
    SCA_configINT(&intParams[1],1);
    SCA_configINT(&intParams[2],2);
    SCA_configINT(&intParams[3],3);
}
