Exemple #1
0
static int proto_series_open(monome_t *monome, const char *dev,
							 const char *serial, const monome_devmap_t *m,
							 va_list args) {
	monome->rows   = m->dimensions.rows;
	monome->cols   = m->dimensions.cols;
	monome->serial = serial;

	return monome_platform_open(monome, dev);
}
Exemple #2
0
int main(int argc, char **argv) {
	char c, *device;
	uint8_t buf[1];
	int grids, i;

	monome_t mk;

	struct option arguments[] = {
		{"help",         no_argument,       0, 'h'},
		{"device",       required_argument, 0, 'd'},
		{"active-grids", required_argument, 0, 'g'}
	};

	grids = 0;
	device = NULL;
	i = 0;

	while( (c = getopt_long(argc, argv, "hd:g:", arguments, &i)) > 0 )
		switch( c ) {
		case 'h':
			usage(argv[0]);
			return 1;

		case 'd':
			device = optarg;
			break;

		case 'g':
			grids = atoi(optarg);
			break;
		}

	if( !device || !grids ) {
		usage(argv[0]);
		exit(EXIT_FAILURE);
	}

	memset(&mk, '\0', sizeof(monome_t));

	/* monome_platform_open() needs a devmap to check if it has any quirks.
	   &mapping[3] is the device entry for the mk. */
	if( monome_platform_open(&mk, &mapping[3], device) )
		exit(EXIT_FAILURE);

	buf[0] = (PROTO_MK_GRIDS << 4) | (grids & 0xF);
	monome_platform_write(&mk, buf, 1);

	printf("successfully set active grids on %s\n", device);

	monome_platform_close(&mk);
	return EXIT_SUCCESS;
}