Ejemplo n.º 1
0
uint8_t matrix_scan(void) {
    static matrix_row_t debouncing_matrix[MATRIX_ROWS];
    for (int8_t r = MATRIX_ROWS - 1; r >= 0; --r) {
        toggle_row(r);
        matrix_row_t state = read_cols();
        if (debouncing_matrix[r] != state) {
            debouncing_matrix[r] = state;
            debouncing_delay = DEBOUNCING_DELAY;
        }
        toggle_row(r);
    }
    if (debouncing_delay >= 0) {
        dprintf("Debouncing delay remaining: %X\n", debouncing_delay);
        --debouncing_delay;
        if (debouncing_delay >= 0) {
            wait_ms(1);
        }
        else {
            for (int8_t r = MATRIX_ROWS - 1; r >= 0; --r) {
                matrix[r] = debouncing_matrix[r];
            }
        }
    }
    matrix_scan_quantum();
    return 1;
}
Ejemplo n.º 2
0
void matrix_init(void) {
    /* frees PORTF by setting the JTD bit twice within four cycles */
    #ifdef __AVR_ATmega32U4__
        MCUCR |= _BV(JTD);
        MCUCR |= _BV(JTD);
    #endif
    /* initializes the I/O pins */
#if DIODE_DIRECTION == COL2ROW
    for (int8_t r = MATRIX_ROWS - 1; r >= 0; --r) {
        /* DDRxn */
        _SFR_IO8((row_pins[r] >> 4) + 1) |= _BV(row_pins[r] & 0xF);
        toggle_row(r);
    }
    for (int8_t c = MATRIX_COLS - 1; c >= 0; --c) {
        /* PORTxn */
        _SFR_IO8((col_pins[c] >> 4) + 2) |= _BV(col_pins[c] & 0xF);
    }
#else
    for (int8_t c = MATRIX_COLS - 1; c >= 0; --c) {
        /* DDRxn */
        _SFR_IO8((col_pins[c] >> 4) + 1) |= _BV(col_pins[c] & 0xF);
        toggle_col(c);
    }
    for (int8_t r = MATRIX_ROWS - 1; r >= 0; --r) {
        /* PORTxn */
        _SFR_IO8((row_pins[r] >> 4) + 2) |= _BV(row_pins[r] & 0xF);
    }
#endif
    matrix_init_quantum();
}
Ejemplo n.º 3
0
static void
update_filter_model (GtkCellRendererToggle *cell_renderer_toggle,
		     const gchar           *path,
		     EventLog              *log)
{
	GtkTreeIter iter;
	GtkTreeModel *model = GTK_TREE_MODEL (log->filters);

	if (!gtk_tree_model_get_iter_from_string (model, &iter, path))
		return;

	if (gtk_tree_model_iter_has_child (model, &iter))
		clobber_with_children (model, &iter, !get_row_state (model, &iter));
	else
		toggle_row (model, &iter);
}
Ejemplo n.º 4
0
static void
clobber_with_children (GtkTreeModel *model, GtkTreeIter *iter,
		       gboolean new_state)
{
	GtkTreeIter child;

	if (iter)
		if (get_row_state (model, iter) != new_state)
			toggle_row (model, iter);

	if (gtk_tree_model_iter_children (model, &child, iter)) {
		do {
			clobber_with_children (model, &child, new_state);
		} while (gtk_tree_model_iter_next (model, &child));
	}
}