int UnixSocketAdapter::get_param(string& p, char* lb, unsigned int lbs)
{
  assert(msg_c);
  return msg_get_param(msg_c,p,lb,lbs);
}
Esempio n. 2
0
int main(void)
{
    message_t message;
    uint8_t next_grid[32];
    uint16_t interval = 150;
    uint8_t current_pattern = 0;

    initialise();
    set_up_timers();
    init_timers();
    HTbrightness(1);

    goto init;
    while (1) {
        if (mq_get(&message)) {
            switch (msg_get_event(message)) {
            case M_TIMER:
                memset(next_grid, 0, 32);
                for (uint8_t x = 0; x < 32; x++) {
                    for (uint8_t y = 0; y < 8; y++) {
                        uint8_t c = count(x, y);
                        if (c == 3)
                            next_grid[x] |= 1 << y;
                        else if (c == 4)
                            next_grid[x] |= leds[x] & (1 << y);
                    }
                }
                memcpy(leds, next_grid, 32);
                HTsendscreen();
                break;

            case M_KEY_DOWN:
            case M_KEY_REPEAT:
                switch (msg_get_param(message)) {
                case KEY_LEFT:
                    if (interval > MIN_INTERVAL) {
                        interval -= INTERVAL_INCREMENT;
                        set_timer(interval, 0, true);
                    }
                    break;

                case KEY_RIGHT:
                    if (interval < MAX_INTERVAL) {
                        interval += INTERVAL_INCREMENT;
                        set_timer(interval, 0, true);
                    }
                    break;

                case KEY_MIDDLE:
                    current_pattern = (current_pattern + 1) % (sizeof(patterns) / sizeof(character));
                init:
                    memset(leds, 0, 32);
                    write_offset(patterns[current_pattern], 10, 2);
                    HTsendscreen();
                    set_timer(interval, 0, true);
                    break;
                }
                break;
            }
        }
    }
}