Пример #1
0
Item *servo(List *expression)
{
    uint8_t x = eval_as_uint8(second(expression));
    servo_value = (x>250) ? 250 : x;

    return 0;
}
Пример #2
0
Item *led(List *expression)
{
    uint8_t led = eval_as_string(second(expression))[0] == 'R' ? 0 : 1;
    Item *value = third(expression);
    led_mode(led, value ? LEDMANUAL : LEDSTATE_OFF);
    set_out(leds[led], eval_as_uint8(value));
    return 0;
}
Пример #3
0
// 8bit value (poke address value)
Item *poke(List *expression)
{
    uint16_t addr = eval_as_uint16(second(expression));
    if (third(expression)) {
        *((uint8_t *)(addr)) = eval_as_uint8(third(expression));
    }
    return peek(expression);
}
Пример #4
0
// (set_pin <pinid> <value>)
Item *lio_setpin(List *expression)
{
    const uint8_t pinid = eval_as_uint8(second(expression));
    for (List *values = rest(rest(expression)); values; values = rest(values)) {
        set_pin_value(pinid, eval_as_uint16(first(values)));
    }
    return 0;
}
Пример #5
0
// (pin_mode <pinid> IN|HIGH|OUT|PWM|ADC [value])
Item *lio_pinmode(List *expression)
{
    const uint8_t pinid = eval_as_uint8(second(expression));
    pin_mode(pinid, eval_as_string(third(expression)));
    Item *value = fourth(expression);
    if (value) {
        set_pin_value(pinid, eval_as_uint16(value));
    }
    return 0;
}
Пример #6
0
Item *port(List *expression)
{
    uint16_t value = eval_as_uint16(second(expression));
    uint8_t i=0;
    for (List *remaining = rest(rest(expression)); remaining; remaining = rest(remaining)) {
        set_pin_value(eval_as_uint8(first(remaining)), value & (1<<i));
        i++;
    }
    return 0;
}
Пример #7
0
// value (get_pin <pinid>)
Item *lio_getpin(List *expression)
{
    const uint8_t pinid = eval_as_uint8(second(expression));
    return uint16_retval(get_pin_value(pinid));
}
Пример #8
0
// (set_pin <pinid> <value>)
Item *lio_setpin(List *expression)
{
    const uint8_t pinid = eval_as_uint8(second(expression));
    set_pin_value(pinid, eval_as_uint16(third(expression)));
    return 0;
}