Esempio n. 1
0
void
MFD::setLine(int line_id, std::string line, bool center)
{
    // pad with spaces to center text
    if (center) {
        int spaceCount = (16-line.length())/2;

        for (int i=0; i<spaceCount; i++) {
            line = " "+line;
        };
    }

    std::cout<<"setting line "<<line_id<<" to: "<<line<<std::endl;
    char * constLine = const_cast<char*>(line.c_str());
    x52_settext(hdl,line_id,constLine, strlen(constLine));
}
Esempio n. 2
0
int main(int argc, char**argv)
{
	struct x52 *hdl = x52_init();
	if (hdl==NULL)
		return 1;
	x52_debug(hdl, 1);

	char *prog = argv[0];

	if (argc < 2) {
		printf("usage: %s {text|bri|led|time|offset|date|custom}\n", prog);
		return 0;
	}
	char *cmd = argv[1];

	if (!strcmp(cmd, "text")) {
		if (argc < 4) {
			printf("usage: %s text <line> <text>\n", prog);
			return 0;
		}
		x52_settext(hdl, atoi(argv[2]), argv[3], strlen(argv[3]));
	} else if (!strcmp(cmd, "bri")) {
		if (argc < 4) {
			printf("usage: %s bri <mfd> <value>\n", prog);
			return 0;
		}
		x52_setbri(hdl, atoi(argv[2]), atoi(argv[3]));
	} else if (!strcmp(cmd, "led")) {
		if (argc < 4) {
			printf("usage: %s led <id> <on>\n", prog);
			return 0;
		}
		x52_setled(hdl, atoi(argv[2]), atoi(argv[3]));
	} else if (!strcmp(cmd, "time")) {
		if (argc < 5) {
			printf("usage: %s time <h24> <hour> <min>\n", prog);
			return 0;
		}
		x52_settime(hdl, atoi(argv[2]), atoi(argv[3]), atoi(argv[4]));
	} else if (!strcmp(cmd, "offset")) {
		if (argc < 6) {
			printf("usage: %s time <idx> <h24> <inv> <minutes>\n", prog);
			return 0;
		}
		x52_setoffs(hdl, atoi(argv[2]), atoi(argv[3]), atoi(argv[4]),
			atoi(argv[5]));
	} else if (!strcmp(cmd, "date")) {
		if (argc < 5) {
			printf("usage: %s date <year> <month> <day>\n", prog);
			return 0;
		}
		x52_setdate(hdl, atoi(argv[2]), atoi(argv[3]), atoi(argv[4]));
	} else if (!strcmp(cmd, "second")) {
		if (argc < 3) {
			printf("usage: %s date <year> <month> <day>\n", prog);
			return 0;
		}
		x52_setsecond(hdl, atoi(argv[2]));
	} else if (!strcmp(cmd, "model")) {
		enum x52_type type = x52_gettype(hdl);
		switch (type) {
		case DEV_X52:
			printf("Model: X52 Flight Control System\n");
			break;
		case DEV_X52PRO:
			printf("Model: X52 Pro Flight Control System\n");
			break;
		case DEV_YOKE:
			printf("Model: Pro Flight Yoke\n");
			break;
		}
	} else if (!strcmp(cmd, "custom")) {
		if (argc < 4) {
			printf("usage: %s custom <idx> <value>\n", prog);
			return 0;
		}
		int index = strtol(argv[2], NULL, 16);
		int value = strtol(argv[3], NULL, 16);
		x52_custom(hdl, index, value);
	} else {
		printf("unknown command %s\n", cmd);
	}

	x52_close(hdl);
	return 0;
}