void Pin_Init()
{
for (int i = 0; i < GPIO_NUM_PINS; ++i)
- GPIO_Export(i);
+ GPIO_Export(g_index_to_gpio[i]);
for (int i = 0; i < ADC_NUM_PINS; ++i)
ADC_Export();
void Pin_Close()
{
for (int i = 0; i < GPIO_NUM_PINS; ++i)
- GPIO_Unexport(i);
+ GPIO_Unexport(g_index_to_gpio[i]);
for (int i = 0; i < ADC_NUM_PINS; ++i)
ADC_Unexport(i);
FCGIValue values[] = {
{"type", &type, FCGI_REQUIRED(FCGI_STRING_T)},
{"num", &num, FCGI_REQUIRED(FCGI_INT_T)},
- {"set", &set, FCGI_INT_T},
- {"pol", &pol, FCGI_INT_T},
+ {"set", &set, FCGI_BOOL_T},
+ {"pol", &pol, FCGI_BOOL_T},
{"freq", &freq, FCGI_DOUBLE_T},
{"duty", &duty, FCGI_DOUBLE_T}
};
TYPE,
NUM,
SET,
+ POL,
FREQ,
DUTY
} SensorParams;
if (set)
{
Log(LOGDEBUG, "Setting PWM%d", num);
+ duty = duty < 0 ? 0 : duty > 1 ? 1 : duty;
long period_ns = (long)(1e9 / freq);
long duty_ns = (long)(duty * period_ns);
PWM_Set(num, pol, period_ns, duty_ns);
- FCGI_PrintRaw("PWM%d set to period_ns = %lu (%f Hz), duty_ns = %lu (%d), polarity = %d", num, period_ns, freq, duty_ns, duty*100, pol);
+ FCGI_PrintRaw("PWM%d set to period_ns = %lu (%f Hz), duty_ns = %lu (%f), polarity = %d",
+ num, period_ns, freq, duty_ns, duty*100, (int)pol);
}
else
{