Esempio n. 1
0
static int proto_chronome_led_all(monome_t *monome, uint_t status) {

	uint8_t buf[1];

	buf[0] = 0x80 | (PROTO_CHRONOME_LED_ALL_ON | (status << 4));

	return monome_write(monome, buf, sizeof(buf));

}
Esempio n. 2
0
static int proto_series_led_set(monome_t *monome, uint_t x, uint_t y, uint_t on) {
	uint8_t buf[2];

	ROTATE_COORDS(monome, x, y);

	buf[0] = PROTO_SERIES_LED_ON + (!on << 4);
	buf[1] = (x << 4) | y;

	return monome_write(monome, buf, sizeof(buf));
}
Esempio n. 3
0
static int proto_chronome_led_set(monome_t *monome, uint_t x, uint_t y, uint_t on) {
    uint8_t buf[2];

	ROTATE_COORDS(monome, x, y);

    x &= 0x7;
	y &= 0x7;

	buf[0] = 0x80 | (PROTO_CHRONOME_LED_ON + !on);
	buf[1] = 0x7F & ((x << 4) | y);

	return monome_write(monome, buf, sizeof(buf));
}
Esempio n. 4
0
static int proto_series_led_col_row_8(monome_t *monome,
                                      proto_series_message_t mode,
                                      uint_t address, const uint8_t *data) {
	uint8_t buf[2] = {0, 0};
	uint_t xaddress = address;

	/* I guess this is a bit of a hack...but damn does it work well!

	   treating the address as a coordinate pair with itself lets us calculate
	   the row/col translation in one call using the existing rotation code
	   then we just pick whether we want the x coord (row) or y coord (col)
	   depending on what sort of message it is. */

	ROTATE_COORDS(monome, xaddress, address);

	switch( mode ) {
	case PROTO_SERIES_LED_ROW_8:
		if( ROTSPEC(monome).flags & ROW_COL_SWAP )
			address = xaddress;

		if( ROTSPEC(monome).flags & ROW_REVBITS )
			buf[1] = REVERSE_BYTE(*data);
		else
			buf[1] = *data;

		break;

	case PROTO_SERIES_LED_COL_8:
		if( !(ROTSPEC(monome).flags & ROW_COL_SWAP) )
			address = xaddress;

		if( ROTSPEC(monome).flags & COL_REVBITS )
			buf[1] = REVERSE_BYTE(*data);
		else
			buf[1] = *data;

		break;

	default:
		return -1;
	}

	if( ROTSPEC(monome).flags & ROW_COL_SWAP )
		mode = (!(mode - PROTO_SERIES_LED_ROW_8) << 4) + PROTO_SERIES_LED_ROW_8;

	buf[0] = mode | (address & 0x0F );

	return monome_write(monome, buf, sizeof(buf));
}
Esempio n. 5
0
/* soundcyst 4+2 */
static int proto_tinycyst_led_color(monome_t *monome, uint_t x, uint_t y,
								    uint_t r, uint_t g, uint_t b)
{

	uint8_t buf[5];

	buf[0] = PROTO_TINYCYST_LED_COLOR;
	buf[1] = (x << 4) | y;

	buf[2] = r;
	buf[3] = g;
	buf[4] = b;
	
	return monome_write(monome, buf, sizeof(buf));
}
Esempio n. 6
0
/* tinycyst only listens to small row messages, since it's only one row.

iiii.... ....aaaa

i: message id (4)
.: don't care
a: row data (4 bits)
*/
static int proto_tinycyst_led_row(monome_t *monome, uint_t x_off, uint_t y,
                                size_t count, const uint8_t *data) {
	uint8_t buf[2];

	if (y != 0)
	{
		return -1;
	}

	buf[0] = PROTO_TINYCYST_LED_ROW;

	buf[1] = (*data) & 0x0F;

	return monome_write(monome, buf, sizeof(buf));

}
Esempio n. 7
0
static int proto_series_led_frame(monome_t *monome, uint_t quadrant, const uint8_t *frame_data) {
	uint8_t buf[9];

	/* by treating frame_data as a bigger integer, we can copy it in
	   one or two operations (instead of 8) */
#ifdef __LP64__
	*((uint64_t *) &buf[1]) = *((uint64_t *) frame_data);
#else
	*((uint32_t *) &buf[1]) = *((uint32_t *) frame_data);
	*((uint32_t *) &buf[5]) = *(((uint32_t *) frame_data) + 1);
#endif

	ROTSPEC(monome).frame_cb(monome, &quadrant, &buf[1]);
	buf[0] = PROTO_SERIES_LED_FRAME | (quadrant & 0x03);

	return monome_write(monome, buf, sizeof(buf));
}
Esempio n. 8
0
static int proto_chronome_led_color_set(monome_t *monome, uint_t x, uint_t y,
		uint_t r, uint_t g, uint_t b)
{

    ROTATE_COORDS(monome, x, y);

	uint8_t buf[5];

	buf[0] = 0x80 | PROTO_CHRONOME_LED_COLOR;
	buf[1] = 0x7F & ((x << 4) | y);

	buf[2] = 0x7F & (uint8_t)r;
	buf[3] = 0x7F & (uint8_t)g;
	buf[4] = 0x7F & (uint8_t)b;

	return monome_write(monome, buf, sizeof(buf));
}
Esempio n. 9
0
static int proto_series_led_col_row_16(monome_t *monome, proto_series_message_t mode, uint_t address, const uint8_t *data) {
	uint8_t buf[3] = {0, 0, 0};
	uint_t xaddress = address;

	ROTATE_COORDS(monome, xaddress, address);

	switch( mode ) {
	case PROTO_SERIES_LED_ROW_16:
		address = xaddress;

		if( ROTSPEC(monome).flags & ROW_REVBITS ) {
			buf[1] = REVERSE_BYTE(data[1]);
			buf[2] = REVERSE_BYTE(data[0]);
		} else {
			buf[1] = data[0];
			buf[2] = data[1];
		}

		break;

	case PROTO_SERIES_LED_COL_16:
		if( ROTSPEC(monome).flags & COL_REVBITS ) {
			buf[1] = REVERSE_BYTE(data[1]);
			buf[2] = REVERSE_BYTE(data[0]);
		} else {
			buf[1] = data[0];
			buf[2] = data[1];
		}

		break;

	default:
		return -1;
	}

	if( ROTSPEC(monome).flags & ROW_COL_SWAP )
		mode = (!(mode - PROTO_SERIES_LED_ROW_16) << 4) + PROTO_SERIES_LED_ROW_16;

	buf[0] = mode | (address & 0x0F );

	return monome_write(monome, buf, sizeof(buf));
}
Esempio n. 10
0
static int proto_series_led_map(monome_t *monome, uint_t x_off, uint_t y_off,
                                const uint8_t *data) {
	uint8_t buf[9];
	uint_t quadrant;

	/* by treating data as a bigger integer, we can copy it in
	   one or two operations (instead of 8) */
#ifdef __LP64__
	*((uint64_t *) &buf[1]) = *((uint64_t *) data);
#else
	*((uint32_t *) &buf[1]) = *((uint32_t *) data);
	*((uint32_t *) &buf[5]) = *(((uint32_t *) data) + 1);
#endif

	ROTSPEC(monome).map_cb(monome, &buf[1]);

	ROTATE_COORDS(monome, x_off, y_off);
	quadrant = (x_off / 8) + ((y_off / 8) * 2);

	buf[0] = PROTO_SERIES_LED_FRAME | (quadrant & 0x03);

	return monome_write(monome, buf, sizeof(buf));
}
Esempio n. 11
0
static int proto_chronome_led_col_row(monome_t *monome, proto_chronome_message_t mode, uint_t address, const uint8_t *data) {
	uint8_t buf[2];
	uint_t xaddress = address;

    ROTATE_COORDS(monome, xaddress, address);

    switch( mode ) {
        case PROTO_CHRONOME_LED_ROW:
            address = xaddress;

            if( ROTSPEC(monome).flags & ROW_REVBITS )
                buf[1] = REVERSE_BYTE(*data);
            else
                buf[1] = *data;

            break;

        case PROTO_CHRONOME_LED_COL:

            if( ROTSPEC(monome).flags & COL_REVBITS )
                buf[1] = REVERSE_BYTE(*data);
            else
                buf[1] = *data;

            break;

        default:
            return -1;
	}

    if( ROTSPEC(monome).flags & ROW_COL_SWAP )
        mode = !(mode - PROTO_CHRONOME_LED_ROW) + PROTO_CHRONOME_LED_ROW;

	buf[0] = 0x80 | ((address & 0x7 ) << 4) | mode;

    return monome_write(monome, buf, sizeof(buf));
}
Esempio n. 12
0
static int proto_series_tilt_disable(monome_t *monome, uint_t sensor) {
	uint8_t buf[1] = {192};
	return monome_write(monome, buf, sizeof(buf));
}
Esempio n. 13
0
static int proto_tinycyst_mode(monome_t *monome, monome_mode_t mode) {
	uint8_t buf = PROTO_TINYCYST_MODE | ((mode & PROTO_TINYCYST_MODE_TEST) | (mode & PROTO_TINYCYST_MODE_SHUTDOWN));
	return monome_write(monome, &buf, sizeof(buf));
}
Esempio n. 14
0
static int proto_series_mode(monome_t *monome, monome_mode_t mode) {
	uint8_t buf = PROTO_SERIES_MODE | ((mode & PROTO_SERIES_MODE_TEST) | (mode & PROTO_SERIES_MODE_SHUTDOWN));
	return monome_write(monome, &buf, sizeof(buf));
}
Esempio n. 15
0
static int proto_series_led_intensity(monome_t *monome, uint_t brightness) {
	uint8_t buf = PROTO_SERIES_INTENSITY | (brightness & 0x0F);
	return monome_write(monome, &buf, sizeof(buf));
}
Esempio n. 16
0
static int proto_series_led_all(monome_t *monome, uint_t status) {
	uint8_t buf = PROTO_SERIES_CLEAR | (status & 0x01);
	return monome_write(monome, &buf, sizeof(buf));
}
Esempio n. 17
0
static int proto_tinycyst_led_all(monome_t *monome, uint_t status) {
	uint8_t buf = PROTO_TINYCYST_CLEAR | (status & 0x01);
	return monome_write(monome, &buf, sizeof(buf));
}
Esempio n. 18
0
static int proto_series_clear(monome_t *monome, monome_clear_status_t status) {
	uint8_t buf = PROTO_SERIES_CLEAR | (status & PROTO_SERIES_CLEAR_ON);
	return monome_write(monome, &buf, sizeof(buf));
}