コード例 #1
0
ファイル: tt.c プロジェクト: Dewb/mod
int main() {
	char *in;
	time_t t;
	error_t status;
	int i;

	srand((unsigned) time(&t));

	update_metro = &tele_metro;
	update_tr = &tele_tr;
	update_cv = &tele_cv;
	update_cv_slew = &tele_cv_slew;
	update_delay = &tele_delay;
	update_s = &tele_s;
	update_cv_off = &tele_cv_off;
	update_ii = &tele_ii;
	update_scene = &tele_scene;
	update_pi = &tele_pi;
	run_script = &tele_script;
	update_kill = &tele_kill;
	update_mute = &tele_mute;
	update_input = &tele_input_state;

	// tele_command_t stored;
	// stored.data[0].t = OP;
	// stored.data[0].v = 2;
	// stored.data[1].t = NUMBER;
	// stored.data[1].v = 8;
	// stored.data[2].t = NUMBER;
	// stored.data[2].v = 10;
	// stored.separator = -1;
	// stored.l = 3;
	// printf("\nstored process: ");
	// process(&stored);

	in = malloc(256);

	printf("teletype. (blank line quits)\n\n");

	do {
		printf("> ");
		fgets(in, 256, stdin);

		i = 0;
		while(in[i]) {
			in[i] = toupper(in[i]);
			i++;
		}

		status = parse(in);
		if(status == E_OK) {
			status = validate(&temp);
			printf("validate: %s", tele_error(status));
			if(error_detail[0])
				printf(": %s",error_detail);
			error_detail[0] = 0;
			printf("\n");
			if(status == E_OK)
				process(&temp);
		}
		else {
			printf("ERROR: %s", tele_error(status));
			if(error_detail[0])
				printf(": %s",error_detail);
			error_detail[0] = 0;
			printf("\n");
		}

		// tele_tick(100);
		printf("\n");
	}
	while(in[0] != 10);

	free(in);

	printf("(teletype exit.)\n");
}
コード例 #2
0
ファイル: live_mode.c プロジェクト: bpcmusic/teletype
bool screen_refresh_live() {
    bool screen_dirty = false;
    if (dirty & D_INPUT) {
        line_editor_draw(&le, '>', &line[7]);
        screen_dirty = true;
        dirty &= ~D_INPUT;
    }

    if (dirty & D_MESSAGE) {
        char s[32];
        if (status != E_OK) {
            strcpy(s, tele_error(status));
            if (error_msg[0]) {
                size_t len = strlen(s);
                strcat(s, ": ");
                strncat(s, error_msg, 32 - len - 3);
                error_msg[0] = 0;
            }
            status = E_OK;
        }
        else if (output.has_value) {
            itoa(output.value, s, 10);
            output.has_value = false;
        }
        else if (show_welcome_message) {
            strcpy(s, TELETYPE_VERSION ": ");
            strcat(s, git_version);
            show_welcome_message = false;
        }
        else {
            s[0] = 0;
        }

        region_fill(&line[6], 0);
        font_string_region_clip(&line[6], s, 0, 0, 0x4, 0);

        screen_dirty = true;
        dirty &= ~D_MESSAGE;
    }

    if (dirty & D_LIST) {
        for (int i = 0; i < 6; i++) region_fill(&line[i], 0);

        screen_dirty = true;
        dirty &= ~D_LIST;
    }

    if ((activity != activity_prev)) {
        region_fill(&line[0], 0);

        // slew icon
        uint8_t slew_fg = activity & A_SLEW ? 15 : 1;
        line[0].data[98 + 0 + 512] = slew_fg;
        line[0].data[98 + 1 + 384] = slew_fg;
        line[0].data[98 + 2 + 256] = slew_fg;
        line[0].data[98 + 3 + 128] = slew_fg;
        line[0].data[98 + 4 + 0] = slew_fg;

        // delay icon
        uint8_t delay_fg = activity & A_DELAY ? 15 : 1;
        line[0].data[106 + 0 + 0] = delay_fg;
        line[0].data[106 + 1 + 0] = delay_fg;
        line[0].data[106 + 2 + 0] = delay_fg;
        line[0].data[106 + 3 + 0] = delay_fg;
        line[0].data[106 + 4 + 0] = delay_fg;
        line[0].data[106 + 0 + 128] = delay_fg;
        line[0].data[106 + 0 + 256] = delay_fg;
        line[0].data[106 + 0 + 384] = delay_fg;
        line[0].data[106 + 0 + 512] = delay_fg;
        line[0].data[106 + 4 + 128] = delay_fg;
        line[0].data[106 + 4 + 256] = delay_fg;
        line[0].data[106 + 4 + 384] = delay_fg;
        line[0].data[106 + 4 + 512] = delay_fg;

        // queue icon
        uint8_t stack_fg = activity & A_STACK ? 15 : 1;
        line[0].data[114 + 0 + 0] = stack_fg;
        line[0].data[114 + 1 + 0] = stack_fg;
        line[0].data[114 + 2 + 0] = stack_fg;
        line[0].data[114 + 3 + 0] = stack_fg;
        line[0].data[114 + 4 + 0] = stack_fg;
        line[0].data[114 + 0 + 256] = stack_fg;
        line[0].data[114 + 1 + 256] = stack_fg;
        line[0].data[114 + 2 + 256] = stack_fg;
        line[0].data[114 + 3 + 256] = stack_fg;
        line[0].data[114 + 4 + 256] = stack_fg;
        line[0].data[114 + 0 + 512] = stack_fg;
        line[0].data[114 + 1 + 512] = stack_fg;
        line[0].data[114 + 2 + 512] = stack_fg;
        line[0].data[114 + 3 + 512] = stack_fg;
        line[0].data[114 + 4 + 512] = stack_fg;

        // metro icon
        uint8_t metro_fg = activity & A_METRO ? 15 : 1;
        line[0].data[122 + 0 + 0] = metro_fg;
        line[0].data[122 + 0 + 128] = metro_fg;
        line[0].data[122 + 0 + 256] = metro_fg;
        line[0].data[122 + 0 + 384] = metro_fg;
        line[0].data[122 + 0 + 512] = metro_fg;
        line[0].data[122 + 1 + 128] = metro_fg;
        line[0].data[122 + 2 + 256] = metro_fg;
        line[0].data[122 + 3 + 128] = metro_fg;
        line[0].data[122 + 4 + 0] = metro_fg;
        line[0].data[122 + 4 + 128] = metro_fg;
        line[0].data[122 + 4 + 256] = metro_fg;
        line[0].data[122 + 4 + 384] = metro_fg;
        line[0].data[122 + 4 + 512] = metro_fg;

        // mutes
        for (size_t i = 0; i < 8; i++) {
            // make it staggered to match how the device looks
            size_t stagger = i % 2 ? 384 : 128;
            uint8_t mute_fg = ss_get_mute(&scene_state, i) ? 15 : 1;
            line[0].data[87 + i + stagger] = mute_fg;
        }

        activity_prev = activity;
        screen_dirty = true;
        activity &= ~A_MUTES;
    }

    return screen_dirty;
}
コード例 #3
0
ファイル: tt.c プロジェクト: monome/teletype
int main() {
    char *in;
    time_t t;
    error_t status;
    int i;

    srand((unsigned)time(&t));

    // tele_command_t stored;
    // stored.data[0].t = OP;
    // stored.data[0].v = 2;
    // stored.data[1].t = NUMBER;
    // stored.data[1].v = 8;
    // stored.data[2].t = NUMBER;
    // stored.data[2].v = 10;
    // stored.separator = -1;
    // stored.l = 3;
    // printf("\nstored process: ");
    // process(&stored);

    in = malloc(256);

    printf("teletype. (blank line quits)\n\n");

    scene_state_t ss;
    ss_init(&ss);

    do {
        printf("> ");
        fgets(in, 256, stdin);

        i = 0;
        while (in[i]) {
            in[i] = toupper(in[i]);
            i++;
        }

        tele_command_t temp;
        exec_state_t es;
        es_init(&es);
        char error_msg[TELE_ERROR_MSG_LENGTH];
        status = parse(in, &temp, error_msg);
        if (status == E_OK) {
            status = validate(&temp, error_msg);
            printf("validate: %s", tele_error(status));
            if (error_msg[0]) printf(": %s", error_msg);
            printf("\n");
            if (status == E_OK) {
                process_result_t output = process_command(&ss, &es, &temp);
                if (output.has_value) { printf(">>> %i\n", output.value); }
            }
        }
        else {
            printf("ERROR: %s", tele_error(status));
            if (error_msg[0]) printf(": %s", error_msg);
            printf("\n");
        }

        // tele_tick(100);
        printf("\n");
    } while (in[0] != 10);

    free(in);

    printf("(teletype exit.)\n");
}