3. Seq16 Helper Functions

3.1. Press Function

What happens when a press happens.

<<seq16_function_declarations>>=
static void seq16_pressme(page_seq16_d *seq, int x, int y);
<<seq16_functions>>=
static void seq16_pressme(page_seq16_d *seq, int x, int y)
{
    int curval;
    int newval;

    curval = seq->seq[x];
    newval = (7 - y) + 1;

    if (newval == curval && curval != 0) {
        newval = 0;
    }

    seq->seq[x] = newval;
}

3.2. Set value

Sets value in sequence.

<<seq16_function_declarations>>=
static void seq16_valset(page_seq16_d *seq,
                         int pos, int val);
<<seq16_functions>>=
static void seq16_valset(page_seq16_d *seq,
                         int pos, int val)
{
    if (pos < 0 || pos >= 16) return;
    seq->seq[pos] = val;
}

3.3. Draw column

Draws the value of a particular column on the grid.

<<seq16_function_declarations>>=
static void seq16_draw_col(page_seq16_d *seq, int col);
<<seq16_functions>>=
static void seq16_draw_col(page_seq16_d *seq, int col)
{
    int val;
    if (col < 0 || col >= 16) return;

    if (seq->seq[col] == 0) val = 0;
    else val = 1 << (8 - seq->seq[col]);

    monolith_page_mstate_led_col(seq->mstate,
                                 col, 0, val);
}

3.4. Redraw

<<seq16_function_declarations>>=
static void seq16_redraw(page_seq16_d *seq);
<<seq16_functions>>=
static void seq16_redraw(page_seq16_d *seq)
{
    int c;
    for (c = 0; c < 16; c++) {
        seq16_draw_col(seq, c);
    }
}

3.5. Draw Playhead

Draws playhead at position.

<<seq16_function_declarations>>=
static void seq16_draw_playhead(page_seq16_d *seq, int col);
<<seq16_functions>>=
static void seq16_draw_playhead(page_seq16_d *seq, int col)
{
    if (col < 0 || col >= 16) return;

    if (seq->playhead) {
        monolith_page_mstate_led_col(seq->mstate,
                                    col, 0,
                                    255);
    }
}

3.6. Get Column Value

<<seq16_function_declarations>>=
static int seq16_colget(page_seq16_d *pg, int col);
<<seq16_functions>>=
static int seq16_colget(page_seq16_d *pg, int col)
{
    if (col < 0 || col >= 16) return 0;

    return pg->seq[col];
}



prev | home | next