ВходНаше всё Теги codebook 无线电组件 Поиск Опросы Закон Четверг
2 мая
519588 Топик полностью
fk0, легенда (02.06.2014 12:10, просмотров: 390) ответил Derun на Обновил версию, но графического режима пока не добился, не помешал бы пример.
...  #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <math.h> #define TEKWIDTH 1023 #define TEKHEIGHT 767 FILE *tekfile; #define BEL 007 #define ETX 003 #define FF 014 #define FS 034 #define ESC 033 #define GS 035 #define RS 036 #define US 037 void tek_coord(int x, int y) { putc(0x20 | (y>>5), tekfile); #if 0 putchar(0x60); /* 10 bit coord */ #endif putc(0x60 | (y&0x1f), tekfile); putc(0x20 | (x>>5), tekfile); putc(0x40 | (x&0x1f), tekfile); } #define TEKVECT() fputc(GS, tekfile) #define TEKPLOT() fputc(FS, tekfile) #define TEKTEXT() fputc(US, tekfile) #define TEK_SOLID "\033`" #define TEK_DOTTED "\033a" #define TEK_DOT_DASH "\033b" #define TEK_SHORT_DASH "\033c" #define TEK_LONG_DASH "\033d" #define TEK_LARGE_FONT "\0338" #define TEK_SMALL_FONT "\033;" #define TEK_PAGE "\033\014" #define TEK_MODE "\033[?38h" #define VT_MODE "\033\003" void tek_cleanup(void) { /* return to VT100 mode for xterm */ fputs(VT_MODE, tekfile); fflush(tekfile); } void tek_rect(int x0, int y0, int x1, int y1) { TEKVECT(); tek_coord(x0, y0), tek_coord(x1, y0), tek_coord(x1, y1), tek_coord(x0, y1), tek_coord(x0, y0); } unsigned N_CHAN = 12; #define L_WIDTH 48 #define R_HEIGHT 16 #define R_LENGTH 100 #define C_HEIGHT ((TEKHEIGHT-R_HEIGHT)/N_CHAN) #define C_BOTTOM(chan) (chan*C_HEIGHT+R_HEIGHT) static float maxscale(float x) { const static int steps[] = {1, 2, 5}; int i; float v; float min = INFINITY; if (x == 0) abort(); if (x > 0) { for (i=0; i<sizeof(steps)/sizeof(steps[0]); i++) { v=steps[i]*pow(10, ceil(log10(x/steps[i]))); if (min > v) min=v; } return min; } else { return 0 - maxscale(0-x); } } void plot2xy(unsigned chan, int Xp, int Yp, float *x, float *y) { } void xy2plot(unsigned chan, float x, float y, int *Xp, int *Yp) { } void draw_decor(void) { int i; float x; fputs(TEK_SMALL_FONT, tekfile); for (x=L_WIDTH; x<TEKWIDTH-50; x+=50) { TEKVECT(), tek_coord(x, R_HEIGHT), tek_coord(x, R_HEIGHT-4); TEKPLOT(), tek_coord(x, 0); TEKTEXT(), fprintf(tekfile, "%g", x); } fputs(TEK_LARGE_FONT, tekfile); for (i=0; i<N_CHAN; i++) { TEKPLOT(), tek_coord(L_WIDTH/4, C_BOTTOM(i)+L_WIDTH/4); TEKTEXT(), fprintf(tekfile, "%i", i); TEKVECT(); tek_coord(0, C_BOTTOM(i)); tek_coord(TEKWIDTH-1, C_BOTTOM(i)); } TEKVECT(); tek_coord(0, N_CHAN*C_HEIGHT+R_HEIGHT); tek_coord(TEKWIDTH-1, N_CHAN*C_HEIGHT+R_HEIGHT); TEKVECT(); tek_coord(L_WIDTH, 0), tek_coord(L_WIDTH, N_CHAN*C_HEIGHT+R_HEIGHT); } int main() { tekfile=stdout; atexit(tek_cleanup); /* switch VT320 to tek mode and clear screen, * set large font */ fputs(TEK_MODE TEK_PAGE TEK_LARGE_FONT TEK_SOLID, tekfile); draw_decor(); TEKPLOT(), tek_coord(50, 50); TEKPLOT(), tek_coord(100, 100); fflush(tekfile); tek_cleanup(); printf("%f\n", maxscale(-3)); return 0; }
[ZX]