コード例 #1
0
ファイル: series.c プロジェクト: dext3r/wifi_monome
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));
}
コード例 #2
0
ファイル: chronome.c プロジェクト: owenvallis/libmonome
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));
}
コード例 #3
0
ファイル: series.c プロジェクト: dext3r/wifi_monome
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));
}
コード例 #4
0
ファイル: series.c プロジェクト: kellydunn/libmonome
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));
}
コード例 #5
0
ファイル: libmonome.c プロジェクト: herringson/libmonome
int monome_get_cols(monome_t *monome) {
	if( ROTSPEC(monome).flags & ROW_COL_SWAP )
		return monome->rows;
	else
		return monome->cols;
}