Пример #1
0
// On this controller the back-light is controlled by the controllers internal PWM
//	which is why it is in this file rather than the board file.
static inline void set_backlight(GDisplay* g, uint8_t percent) {
	uint8_t temp;

	//Work in progress: the RA8875 has a built-in PWM, its output can
	//be used by a Dynamic Background Control or by a host (user)

	// Enable PWM1
	write_index(g, 0x8a);						//MCLR
	setreadmode(g);
	temp = read_data(g);
	setwritemode(g);
	temp |= 1<<7 ;
	write_data(g, temp);

	// PWM1 function select
	write_index(g, 0x8a);						//MCLR
	setreadmode(g);
	temp = read_data(g);
	setwritemode(g);
	temp &= ~(1<<4);
	write_data(g, temp);

	// PWM1 Clock ratio
	write_index(g, 0x8a);						//MCLR
	setreadmode(g);
	temp = read_data(g);
	setwritemode(g);
	temp &= 0xf0;
	temp |= 0x0b & 0x0f;
	write_data(g, temp);

	// PWM1 Write duty cycle
	write_reg8(g, 0x8b, 54+percent);			// PTNO: Also change percent to range from 0x00 to 0xFF
}
Пример #2
0
void EditorGarraFun::desenho_livre(const COORDENADA& x1, const COORDENADA& y1,
                                   const COORDENADA& x2, const COORDENADA& y2,
                                   MouseFun& mouse, const pacova& t,
                                   MOUSE_EVENTO* evento)
{
  BOLEANO pinta = FALSO;
  COORDENADA antx, anty;

  while (mouse.verifica(x1, y1, x2, y2))
  {
    {
      COORDENADA ax, ay;
      ax = mouse.x();
      ay = mouse.y();

      setcolor(7);
      setlinestyle(1, 0, 0);
      setwritemode(XOR_PUT);
      line(ax, 0, ax, t.max_y);
      line(0, ay, t.max_x, ay);

      *evento = mouse.evento_pause();

      line(ax, 0, ax, t.max_y);
      line(0, ay, t.max_x, ay);
      setwritemode(COPY_PUT);
      setlinestyle(SOLID_LINE, 0, 0);
    }

    if (*evento == MOUSE_DOWN)
    {
      mouse.area(x1, y1, x2, y2);
      pinta = VERDADEIRO;
      antx = mouse.x();
      anty = mouse.y();
    }
    else
      if (*evento == MOUSE_UP)
      {
        mouse.area(0, 0, t.max_x, t.max_y);
        pinta = FALSO;
      }

    if (pinta)
    {
      COORDENADA x = mouse.x(), y = mouse.y();
      setcolor(15);
      line(antx, anty, x, y);
      antx = x;
      anty = y;
    }
  }
}
Пример #3
0
/*
 * Redeseneaza zona din dreapta dupa ce utilizatorul a miscat sau a
 * modificat dreptunghiul in zona din stanga.
 */
void redraw_right_area()
{
	int restidx, pi;

	set(3);
	setwritemode(COPY_PUT);
	setcolor(LIGHTBLUE);
	clearviewport();
	for (int i = 0; i <= REF; i++)
	{
		if ((x[i] >= x1) && (x[i] <= x2) && (y[i] >= y1) && (y[i] <= y2))
		{
			moveto(newX(x[i]), newY(y[i]));
			pi = i;
			restidx = i+1;
			i = REF+1;
		}
	}
	for (i = restidx; i <= REF; i++)
	{
		if ((x[i] >= x1) && (x[i] <= x2) && (y[i] >= y1) && (y[i] <= y2))
		{
			if ((pi+1) == i)
			{
				lineto(newX(x[i]), newY(y[i]));
			}
			else
			{
				moveto(newX(x[i]), newY(y[i]));
			}
			pi = i;
		}
	}
}
Пример #4
0
void InitMouse(int& mouse_maxX, int& mouse_maxY)
 // functions to initialize the mouse pointer
 {//reseting the mouse ...
  registers.r_ax = 0x00;
  intr(0x33, &registers);
  // determining the minX maxX coordinates of the mouse ...
  registers.r_ax = 0x07;
  registers.r_cx = 0x00;   // min X coordinate
  registers.r_dx = mouse_maxX;   // max X coordinate
  intr(0x33, &registers);
  // determining the minY maxY coordinates of the mouse ...
  registers.r_ax = 0x08;
  registers.r_cx = 0x00;   // min Y coordinate
  registers.r_dx = mouse_maxY;   // max Y coordinate
  intr(0x33, &registers);
  // set the start coordinates ...
  registers.r_ax = 0x04;
  registers.r_cx = cursorx = mouse_maxX/2;
  registers.r_dx = cursory = mouse_maxY/2;
  intr(0x33, &registers);
  // drawing the first cursor ...
  setwritemode(XOR_PUT);
  BLine(cursorx, cursory - 2, cursorx, cursory - 10, C);
  BLine(cursorx, cursory + 2, cursorx, cursory + 10, C);
  BLine(cursorx - 2, cursory, cursorx - 10, cursory, C);
  BLine(cursorx + 2, cursory, cursorx + 10, cursory, C);

  // installing event handler ...
  registers.r_ax = 0x0c;
  registers.r_cx = 0x01;
  registers.r_es = FP_SEG(mouse_event_handler);
  registers.r_dx = FP_OFF(mouse_event_handler);
  intr(0x33, &registers);
 }
Пример #5
0
/*
 * Seteaza viewport-ul curent in functie de parametrul v la niste valori
 * predefinite.
 */
void set(int v)
{
    setcolor(MAGENTA);
    switch (v)
    {
    case 0:
        setviewport(0, 50, getmaxx(), getmaxy(), 1);
        setwritemode(COPY_PUT);
        rectangle(0, 0, getmaxx(), getmaxy()-50);
        setviewport(1, 51, getmaxx()-1, getmaxy()-1, 1);
        break;
    case 1:
        setviewport(10, 5, 100, 45, 1);
        break;
    case 2:
        setviewport(110, 5, 200, 45, 1);
        break;
    case 3:
        setviewport(210, 5, 300, 45, 1);
        break;
    case 4:
        setviewport(310, 5, 500, 45, 1);
        break;
    case 5:
        setviewport(490, 0, getmaxx(), 48, 1);
        break;
    }
    setcolor(CYAN);
}
int main()
{
 int buttons,x,y;
 char str[100];
 int driver=VGA;
 int mode=VGAHI;
 initgraph(&driver,&mode,"");
 cleardevice();
 rectangle(0,0,639,479);
 setfillstyle(SOLID_FILL,BLUE);
 bar(1,1,638,478);
 outtextxy(3,15,"move mouse using any button.");
 outtextxy(285,15,"quit");
 setwritemode(XOR_PUT);
 if(init(2, 638, 8, 477)==0 )     /*调用init 函数对鼠标器初始化*/
   {printf("Mouse or Mouse Driver Absent,P1ease install!");
    delay(5000);
    closegraph();
    exit(1);
   }
 x=320;y=240;
 cursor(x,y);                       /*置十字光标在屏幕中心*/
 for(;;)
   {
    newxy(&x,&y,&buttons);
    if(x>=280&& x<=330 &&y>=12&&y<=33&& buttons)
      {
       cleardevice();
       closegraph();
       exit(0);
      }
   }
}
Пример #7
0
/*
 * Desenarea graficului in zona din stanga a ecranului.
 */
void initialize_left_area()
{
	set(2);

	// desenarea graficului
	setcolor(LIGHTBLUE);
	moveto(x[0], y[0]);

	for (int i = 1; i <= REF; i++)
		lineto(x[i], y[i]);

	setcolor(LIGHTGRAY);
	// desenarea axelor daca sunt in figura
	if ((minf <= 0) && (maxf >= 0))
	{
		// axa Ox
		line(0, virtualY(f(zerof())), 316, virtualY(f(zerof())));
	}
	if ((a <= 0) && (b >= 0))
	{
		// axa Oy
		line(virtualX(0), 0, virtualX(0), 316);
	}

	setwritemode(XOR_PUT);
	setcolor(GREEN);
	rectangle(x1, y1, x2, y2);
}
Пример #8
0
/*
 * Deseneaza axele de coordonate.
 */
void draw_axes()
{
    set(0);
    setwritemode(XOR_PUT);
    setcolor(WHITE);
    line(x, 0, x, getmaxy());
    line(0, y, getmaxx(), y);
}
Пример #9
0
/*
 * Deseneaza toate segmentele.
 */
void draw_figure()
{
    set(0);
    setwritemode(XOR_PUT);
    setcolor(CYAN);
    for (int i = 0; i < DIM; i++)
    {
        line(round(x1[i]), round(y1[i]), round(x2[i]), round(y2[i]));
    }
}
Пример #10
0
double energy()
{
	int i = 0;
	int flag=1,kk=0;

	setcolor(WHITE);
	setlinestyle(0,0,0);
	setwritemode(COPY_PUT);
	rectangle(maxx/2-LENTH/2-2,50,maxx/2+LENTH/2+2,60);

	settextstyle(4,0,3);
	setcolor(BLUE);
	outtextxy(170,25,"MIN");
	outtextxy(420,25,"MAX");
	do
	{
		while(bioskey(1)!=0) getch();
		if (0<=(i+flag)&&(i+flag)<=LENTH) i+=flag;
		else flag=-flag;

		setcolor(BLUE);
		setwritemode(XOR_PUT);
		line(maxx/2-LENTH/2+i,52,maxx/2-LENTH/2+i,58);

		if (Music_on)
		{
			sound(15*i);
			delay(400);
			nosound();
		}
		else delay(600);
	}while((kk=bioskey(1))!=ESC && kk!=SPACE);

	setfillstyle(SOLID_FILL,BLACK);
	floodfill(maxx/2-LENTH/2,52,WHITE);

	if (bioskey(0)==ESC) return -1;

	return 4.0*i/LENTH;
}
Пример #11
0
/*
 * Deseneaza linia aleatoare
 */
void draw_line()
{
    set(0);
    setwritemode(XOR_PUT);
    setcolor(BLUE);
    if (simA < 0.09)
        line(0, simY, 638, simY);
    else if ((simA > 4.65) && (simA < 4.75))
        line(simX, 0, simX, 428);
    else
        line(0, round(simY+((double) simX*tan(simA))),
             638, round(simY-((double) (638-simX)*tan(simA))));
}
Пример #12
0
void Drawborder(int x,int y)
{
   setwritemode(COPY_PUT);
   setcolor(0);
   line(x+60,y-20,x+180,y-20);//       __
   line(x+60,y+60,x+60,y-20);//      |
   line(x-40,y+60,x+60,y+60);//   __
   line(x-40,y+60,x-40,y+180);// |
   setcolor(15);
   line(x-40,y+180,x+60,y+180);// __
   setcolor(0);
   line(x+60,y+180,x+60,y+280);//   |
   setcolor(15);
   line(x+180,y-20,x+180,y+60);//        |
   setcolor(0);
   line(x+180,y+60,x+290,y+60);//         __
   setcolor(15);
   line(x+290,y+60,x+290,y+180);//          |
   line(x+180,y+180,x+290,y+180);//       __
   line(x+180,y+180,x+180,y+280);//      |
   line(x+180,y+280,x+60,y+280);//    __
   setwritemode(XOR_PUT);
}
Пример #13
0
void HideMouse(void)
 { // hiding the mouse pointer by drawing again with XOR_PUT mode ...
  setwritemode(XOR_PUT);
  BLine(cursorx, cursory - 2, cursorx, cursory - 10, C);
  BLine(cursorx, cursory + 2, cursorx, cursory + 10, C);
  BLine(cursorx - 2, cursory, cursorx - 10, cursory, C);
  BLine(cursorx + 2, cursory, cursorx + 10, cursory, C);
  // disabling the mouse event handler ...
  registers.r_ax = 0x0c;
  registers.r_cx = 0x00;
  registers.r_es = FP_SEG(mouse_event_handler);
  registers.r_dx = FP_OFF(mouse_event_handler);
  intr(0x33, &registers);
 }
Пример #14
0
void draw_mark()								/****绘制球桌上的标记***/
{
	setlinestyle(0,0,0);
	setcolor(WHITE);
	setwritemode(COPY_PUT);


	line(137,121,137,459);
	arc(137,290,90,270,53);
	line(136,289,138,289);

	line(319,290,321,290);
	line(320,289,320,291);
}
Пример #15
0
static void DrawLine(int x0,int y0,int x1,int y1,int color)
{
  int SaveColor;
  struct viewporttype SaveViewPort;

  MouseHidden();
  getviewsettings(&SaveViewPort);
  SaveColor=getcolor();

  setviewport(ScreenX,ScreenY,ScreenX+mXw-1,ScreenY+mYw-1,1);

  if (color<0) { setwritemode(XOR_PUT); color=-color; }
    else setwritemode(COPY_PUT);

  setcolor(color);
  line(x0,y0,x1,y1);

  setwritemode(COPY_PUT);
  setcolor(SaveColor);
  setviewport(SaveViewPort.left,SaveViewPort.top,SaveViewPort.right,
              SaveViewPort.bottom,SaveViewPort.clip);
  MouseShow();

}
Пример #16
0
Файл: FED.C Проект: MegaGod/TW
void draw_frame( int x1, int y1, int x2, int y2 ) {
	struct linesettingstype tmp;
	getlinesettings( &tmp );
	setlinestyle( SOLID_LINE, 0, THICK_WIDTH ); setwritemode( 0 );
	y1 += 4;
#ifdef NOALIGN
	x1 += 40; x2 += 40;
#else
	x1 += align; x2 += align;
#endif
	moveto( x1, y1 );
	lineto( x2, y1 ); lineto( x2, y2 );
	lineto( x1, y2 ); lineto( x1, y1 );
	moveto( x1 + 1, y1 + 1 );
	setlinestyle( tmp.linestyle, tmp.upattern, tmp.thickness );
}
Пример #17
0
main()
{
   int drv= DETECT, mod_g;

   if ((f= fopen("gr.in", "r")) == NULL)
   {
      printf("Eroare la deschiderea fisierului !");
      getch();
      return 0;
   }
   i= 0;
   while (!feof(f))
   {
      i++;
      fscanf(f, "%i %i %i %i\n", &x1[i], &y1[i], &x2[i], &y2[i]);
   }
   fclose(f);
   initgraph(&drv, &mod_g, "c:\\bc31\\bgi");
   setbkcolor(WHITE);
   cleardevice();
   setcolor(YELLOW);
   setwritemode(XOR_PUT);
   for (j= 1; j <= i; j++)
   {
      if (x1[j] != x2[j])
      {
	 a1= (float(y2[j]-y1[j]))/(float(x2[j]-x1[j]));
	 a2= (float(x1[j])*float(y2[j])-float(y1[j])*float(x2[j]))/(x2[j]-x1[j]);
	 i1= -float(a2);
	 i2= (float(a1)*float(getmaxx()))-float(a2);
	 for (x= 0; x <= getmaxx(); x++)
	 {
	    j1= (float(a1)*float(x))-float(a2);
	    line(x, j1, x, 0);
	 }
      }
      else
	 for (x= 0; x <= getmaxy(); x++)
	    line(x1[j], x, getmaxx(), x);
   }


   getch();
   return 0;
}
Пример #18
0
void draw_table()								/********绘制球桌********/
{
	setlinestyle(0,0,3);
	setcolor(WHITE);
	setwritemode(COPY_PUT);
	rectangle(1,100,638,480);

	draw_boundary();
	draw_net();

	setfillstyle(SOLID_FILL,TABLECOLOR);
	floodfill(300,400,WHITE);
	setfillstyle(SOLID_FILL,6);
	floodfill(20,290,WHITE);
	floodfill(620,290,WHITE);

	draw_mark();
}
Пример #19
0
void mouse_event_handler(void) // used only to draw the mouse cursor
 {
  //in these registers are the coordinates of the Mouse pointer
  register int mousex = _CX, mousey = _DX;

  setwritemode(XOR_PUT);
  //first we draw in the old cursor place
  BLine(cursorx, cursory - 2, cursorx, cursory - 10, C);
  BLine(cursorx, cursory + 2, cursorx, cursory + 10, C);
  BLine(cursorx - 2, cursory, cursorx - 10, cursory, C);
  BLine(cursorx + 2, cursory, cursorx + 10, cursory, C);
  cursorx = mousex;
  cursory = mousey;
  //and now to the new cursor place
  BLine(cursorx, cursory - 2, cursorx, cursory - 10, C);
  BLine(cursorx, cursory + 2, cursorx, cursory + 10, C);
  BLine(cursorx - 2, cursory, cursorx - 10, cursory, C);
  BLine(cursorx + 2, cursory, cursorx + 10, cursory, C);
  draw_uvxy();
 }
Пример #20
0
void ShowMouse(void)
 {
  char fikt1, fikt2;
  int mousex, mousey;

  GetMouseButtons(&fikt1, &fikt2, &mousex, &mousey);
  cursorx = mousex;
  cursory = mousey;
  // and now draw to the new cursor place ...
  setwritemode(XOR_PUT);
  BLine(cursorx, cursory - 2, cursorx, cursory - 10, C);
  BLine(cursorx, cursory + 2, cursorx, cursory + 10, C);
  BLine(cursorx - 2, cursory, cursorx - 10, cursory, C);
  BLine(cursorx + 2, cursory, cursorx + 10, cursory, C);
  // istalling again the mouse event handler ...
  registers.r_ax = 0x0c;
  registers.r_cx = 0x01;
  registers.r_es = FP_SEG(mouse_event_handler);
  registers.r_dx = FP_OFF(mouse_event_handler);
  intr(0x33, &registers);
 }
Пример #21
0
void draw_stick(struct BALL ball,double w)					/**********球杆*********/
{
	setcolor(YELLOW);
	setlinestyle(0,0,3);
	setwritemode(XOR_PUT);

	line(ball.posi.x+(BALL_R+5)*cos(w),ball.posi.y+(BALL_R+5)*sin(w),\
	     ball.posi.x+(BALL_R+40)*cos(w),ball.posi.y+(BALL_R+40)*sin(w));

	setcolor(DARKGRAY);
	setlinestyle(0,0,0);
	moveto(ball.posi.x+(BALL_R+41)*cos(w-0.02),ball.posi.y+(BALL_R+41)*sin(w-0.02));

	lineto(ball.posi.x+STICKLENTH*cos(w-0.01),ball.posi.y+STICKLENTH*sin(w-0.01));

	setlinestyle(0,0,3);
	lineto(ball.posi.x+STICKLENTH*cos(w+0.01),ball.posi.y+STICKLENTH*sin(w+0.01));

	setlinestyle(0,0,0);
	lineto(ball.posi.x+(BALL_R+41)*cos(w+0.02),ball.posi.y+(BALL_R+41)*sin(w+0.02));

}
Пример #22
0
void draw_boundary()								/******绘制球桌边界*****/
{
	int x_off,y_off;

	setlinestyle(0,0,0);
	setcolor(WHITE);
	setwritemode(COPY_PUT);

	line(22,149,22,433);
	line(49,120,300,120);
	line(339,121,588,121);
	line(616,148,616,432);
	line(50,459,299,459);
	line(339,459,588,459);


	x_off=20;y_off=13;

	line(50,121,50-x_off,121-y_off);
	line(588,121,588+x_off,121-y_off);
	line(50,459,50-x_off,459+y_off);
	line(588,459,588+x_off,459+y_off);

	x_off=13;y_off=20;

	line(23,148,23-x_off,148-y_off);
	line(23,432,23-x_off,432+y_off);
	line(616,148,616+x_off,148-y_off);
	line(616,432,616+x_off,432+y_off);

	x_off=4;y_off=11;

	line(299,121,299+x_off,121-y_off);
	line(339,121,339-x_off,121-y_off);
	line(299,459,299+x_off,459+y_off);
	line(339,459,339-x_off,459+y_off);
}
	LLDSPEC	void gdisp_lld_read_stop(GDisplay *g) {
		setwritemode(g);
		release_bus(g);
	}
Пример #24
0
/*
 * Deseneaza dreptunghiurile in care se introduc valorile.
 */
void variable_space(int direction)
{
    setcolor(RED);
    setwritemode(COPY_PUT);
    switch (idx)
    {
    case 1:
        setcolor(RED);
        setwritemode(COPY_PUT);
        if (direction == 1)
        {
            set(4);
            setcolor(RED);
            setwritemode(COPY_PUT);
            rectangle(90+textwidth("р = "), 13,
                      135+textwidth("р = "), 15+textheight("1")+2);
        }
        else
        {
            set(1);
            setcolor(RED);
            setwritemode(COPY_PUT);
            rectangle(10+textwidth("y = "), 28,
                      45+textwidth("y = "), 30+textheight("1")+2);
        }
        set(1);
        setcolor(WHITE);
        rectangle(10+textwidth("x = "), 13,
                  45+textwidth("x = "), 15+textheight("1")+2);
        break;
    case 2:
        if (direction == 1)
        {
            set(1);
            setcolor(RED);
            setwritemode(COPY_PUT);
            rectangle(10+textwidth("x = "), 13,
                      45+textwidth("x = "), 15+textheight("1")+2);
        }
        else
        {
            set(2);
            setcolor(RED);
            setwritemode(COPY_PUT);
            rectangle(10+textwidth("x = "), 13,
                      55+textwidth("x = "), 15+textheight("1")+2);
        }
        set(1);
        setcolor(WHITE);
        rectangle(10+textwidth("y = "), 28,
                  45+textwidth("y = "), 30+textheight("1")+2);
        break;
    case 3:
        if (direction == 1)
        {
            set(1);
            setcolor(RED);
            setwritemode(COPY_PUT);
            rectangle(10+textwidth("y = "), 28,
                      45+textwidth("y = "), 30+textheight("1")+2);
        }
        else
        {
            set(2);
            setcolor(RED);
            setwritemode(COPY_PUT);
            rectangle(10+textwidth("y = "), 28,
                      55+textwidth("y = "), 30+textheight("1")+2);
        }
        set(2);
        setcolor(WHITE);
        rectangle(10+textwidth("x = "), 13,
                  55+textwidth("x = "), 15+textheight("1")+2);
        break;
    case 4:
        if (direction == 1)
        {
            set(2);
            setcolor(RED);
            setwritemode(COPY_PUT);
            rectangle(10+textwidth("x = "), 13,
                      55+textwidth("x = "), 15+textheight("1")+2);
        }
        else
        {
            set(3);
            setcolor(RED);
            setwritemode(COPY_PUT);
            rectangle(10+textwidth("р = "), 13,
                      55+textwidth("р = "), 15+textheight("1")+2);
        }
        set(2);
        setcolor(WHITE);
        rectangle(10+textwidth("y = "), 28,
                  55+textwidth("y = "), 30+textheight("1")+2);
        break;
    case 5:
        if (direction == 1)
        {
            set(2);
            setcolor(RED);
            setwritemode(COPY_PUT);
            rectangle(10+textwidth("y = "), 28,
                      55+textwidth("y = "), 30+textheight("1")+2);
        }
        else
        {
            set(4);
            setcolor(RED);
            setwritemode(COPY_PUT);
            rectangle(10+textwidth("x = "), 13,
                      45+textwidth("x = "), 15+textheight("1")+2);
        }
        set(3);
        setcolor(WHITE);
        rectangle(10+textwidth("р = "), 13,
                  55+textwidth("р = "), 15+textheight("1")+2);
        break;
    case 6:
        if (direction == 1)
        {
            set(3);
            setcolor(RED);
            setwritemode(COPY_PUT);
            rectangle(10+textwidth("р = "), 13,
                      55+textwidth("р = "), 15+textheight("1")+2);
        }
        else
        {
            set(4);
            setcolor(RED);
            setwritemode(COPY_PUT);
            rectangle(10+textwidth("y = "), 28,
                      45+textwidth("y = "), 30+textheight("1")+2);
        }
        set(4);
        setcolor(WHITE);
        rectangle(10+textwidth("x = "), 13,
                  45+textwidth("x = "), 15+textheight("1")+2);
        break;
    case 7:
        if (direction == 1)
        {
            set(4);
            setcolor(RED);
            setwritemode(COPY_PUT);
            rectangle(10+textwidth("x = "), 13,
                      45+textwidth("x = "), 15+textheight("1")+2);
        }
        else
        {
            set(4);
            setcolor(RED);
            setwritemode(COPY_PUT);
            rectangle(90+textwidth("р = "), 13,
                      135+textwidth("р = "), 15+textheight("1")+2);
        }
        set(4);
        setcolor(WHITE);
        rectangle(10+textwidth("y = "), 28,
                  45+textwidth("y = "), 30+textheight("1")+2);
        break;
    case 8:
        if (direction == 1)
        {
            set(4);
            setcolor(RED);
            setwritemode(COPY_PUT);
            rectangle(10+textwidth("y = "), 28,
                      45+textwidth("y = "), 30+textheight("1")+2);
        }
        else
        {
            set(1);
            setcolor(RED);
            setwritemode(COPY_PUT);
            rectangle(10+textwidth("x = "), 13,
                      45+textwidth("x = "), 15+textheight("1")+2);
        }
        set(4);
        setcolor(WHITE);
        rectangle(90+textwidth("р = "), 13,
                  135+textwidth("р = "), 15+textheight("1")+2);
        break;
    }
}
Пример #25
0
LLDSPEC bool_t gdisp_lld_init(GDisplay *g) {
	uint16_t cver;

	// No private area for this controller
	g->priv = 0;

	// Initialise the board interface
	init_board(g);

	/* Hardware reset */
	setpin_reset(g, TRUE);
	gfxSleepMicroseconds(1000);
	setpin_reset(g, FALSE);
	gfxSleepMicroseconds(1000);

	acquire_bus(g);
	write_index(g, 0);				// Get controller version
	setreadmode(g);
	dummy_read(g);
	cver = read_data(g);
	setwritemode(g);

	/* initializing funciton */   
		write_reg(g, 0xe5,0x8000);  /* Set the internal vcore voltage */   
		write_reg(g, 0x00,0x0001);  /* start OSC */   
		write_reg(g, 0x2b,0x0010);  /* Set the frame rate as 80 when the internal resistor is used for oscillator circuit */   
		write_reg(g, 0x01,0x0100);  /* s720  to  s1 ; G1 to G320 */   
		write_reg(g, 0x02,0x0700);  /* set the line inversion */   
		write_reg(g, 0x03,0x1018);  /* 65536 colors */    
		write_reg(g, 0x04,0x0000);   
		write_reg(g, 0x08,0x0202);  /* specify the line number of front and back porch periods respectively */   
		write_reg(g, 0x09,0x0000);   
		write_reg(g, 0x0a,0x0000);   
		write_reg(g, 0x0c,0x0000);  /* select  internal system clock */  
		write_reg(g, 0x0d,0x0000);   
		write_reg(g, 0x0f,0x0000);    
		write_reg(g, 0x50,0x0000);  /* set windows adress */   
		write_reg(g, 0x51,0x00ef);   
		write_reg(g, 0x52,0x0000);   
		write_reg(g, 0x53,0x013f);   
		write_reg(g, 0x60,0x2700);   
		write_reg(g, 0x61,0x0001);   
		write_reg(g, 0x6a,0x0000);   
		write_reg(g, 0x80,0x0000);   
		write_reg(g, 0x81,0x0000);   
		write_reg(g, 0x82,0x0000);   
		write_reg(g, 0x83,0x0000);   
		write_reg(g, 0x84,0x0000);   
		write_reg(g, 0x85,0x0000);   
		write_reg(g, 0x90,0x0010);   
		write_reg(g, 0x92,0x0000);   
		write_reg(g, 0x93,0x0003);   
		write_reg(g, 0x95,0x0110);   
		write_reg(g, 0x97,0x0000);   
		write_reg(g, 0x98,0x0000);    
		/* power setting function */   
		write_reg(g, 0x10,0x0000);   
		write_reg(g, 0x11,0x0000);   
		write_reg(g, 0x12,0x0000);   
		write_reg(g, 0x13,0x0000);   
		gfxSleepMicroseconds(100);   
		write_reg(g, 0x10,0x17b0);   
		write_reg(g, 0x11,0x0004);   
		gfxSleepMicroseconds(50);   
		write_reg(g, 0x12,0x013e);   
		gfxSleepMicroseconds(50);   
		write_reg(g, 0x13,0x1f00);   
		write_reg(g, 0x29,0x000f);   
		gfxSleepMicroseconds(50);   
		write_reg(g, 0x20,0x0000);   
		write_reg(g, 0x21,0x0000);   
		
		/* initializing function */  	
		write_reg(g, 0x30,0x0204);   
		write_reg(g, 0x31,0x0001);   
		write_reg(g, 0x32,0x0000);   
		write_reg(g, 0x35,0x0206);   
		write_reg(g, 0x36,0x0600);   
		write_reg(g, 0x37,0x0500);   
		write_reg(g, 0x38,0x0505);   
		write_reg(g, 0x39,0x0407);   
		write_reg(g, 0x3c,0x0500);   
		write_reg(g, 0x3d,0x0503);   
		
		/* display on */  
		write_reg(g, 0x07,0x0173);

		gfxSleepMicroseconds(50);

    // Finish Init
    post_init_board(g);

  	// Release the bus
 	release_bus(g);

	// Turn on the backlight
	set_backlight(g, GDISP_INITIAL_BACKLIGHT);
	
    /* Initialise the GDISP structure */
    g->g.Width = GDISP_SCREEN_WIDTH;
    g->g.Height = GDISP_SCREEN_HEIGHT;
    g->g.Orientation = GDISP_ROTATE_0;
    g->g.Powermode = powerOn;
    g->g.Backlight = GDISP_INITIAL_BACKLIGHT;
    g->g.Contrast = GDISP_INITIAL_CONTRAST;
	return TRUE;
}
Пример #26
0
void PintaFun::desenha_circulo(const COORDENADA& x1, const COORDENADA& y1,
                               const COORDENADA& x2, const COORDENADA& y2,
                               MouseFun& mouse, MOUSE_EVENTO* evento)
{
  BOLEANO pinta = FALSO;
  COORDENADA antx, anty;
  ConversorFun conv;
  int raio;

  while (mouse.verifica(x1, y1, x2, y2) || pinta)
  {
    {
      COORDENADA ax = mouse.x(), ay = mouse.y();

      if (pinta)
      {
        double r, a;
        conv.converte(mouse.x(), mouse.y(), &a, &r, antx, anty);
        raio = (int) r;
      }

      setcolor(7);
      setlinestyle(1, 0, 0);
      setwritemode(XOR_PUT);

      line(ax, 0, ax, getmaxy());
      line(0, ay, getmaxx(), ay);

      if (pinta)
      {
        setcolor(10);
        setlinestyle(0, 0, 0);
        circulo(x1, y1, x2, y2, antx, anty, raio);
      }

      *evento = mouse.evento_pause();

      if (pinta)
        circulo(x1, y1, x2, y2, antx, anty, raio);

      setcolor(7);
      setlinestyle(1, 0, 0);
      line(ax, 0, ax, getmaxy());
      line(0, ay, getmaxx(), ay);

      setwritemode(COPY_PUT);
      setlinestyle(SOLID_LINE, 0, 0);
    }

    if (*evento == MOUSE_DOWN)
    {
      pinta = VERDADEIRO;
      antx = mouse.x();
      anty = mouse.y();
    }
    else
      if (*evento == MOUSE_UP)
      {
        if (pinta)
        {
          /*
          setcolor(15);
          setviewport(x1, y1, x2, y2, 1);*/
          //circle(antx - x1/*12*/, anty - y1/*26*/, raio);
          //setviewport(0, 0, getmaxx(), getmaxy(), 0);

          CirculoGrafico* cir = new CirculoGrafico(antx - this->x1() /* - 5*/,
                                                   anty - this->y1() /*- 20*/,
                                                   raio);
          c_lista.ins(cir);
          cir->exibe(this->x1(), this->y1(), this->x2(), this->y2());

          pinta = FALSO;
        }
      }
      else
        if (*evento == MOUSE_UP_DIREITO)
          return;
  }
}
Пример #27
0
void PintaFun::desenha_linha(const COORDENADA& x1, const COORDENADA& y1,
                             const COORDENADA& x2, const COORDENADA& y2,
                             MouseFun& mouse, MOUSE_EVENTO* evento)
{
  BOLEANO pinta = FALSO;
  COORDENADA antx, anty;

  while (mouse.verifica(x1, y1, x2, y2))
  {
    {
      COORDENADA ax = mouse.x(), ay = mouse.y();

      setcolor(7);
      setlinestyle(1, 0, 0);
      setwritemode(XOR_PUT);

      line(ax, 0, ax, getmaxy());
      line(0, ay, getmaxx(), ay);

      if (pinta)
      {
        setcolor(12);
        setlinestyle(1, 0, 0);
        line(antx, anty, ax, ay);
      }

      *evento = mouse.evento_pause();

      if (pinta)
        line(antx, anty, ax, ay);

      setcolor(7);
      setlinestyle(1, 0, 0);
      line(ax, 0, ax, getmaxy());
      line(0, ay, getmaxx(), ay);

      setwritemode(COPY_PUT);
      setlinestyle(SOLID_LINE, 0, 0);
    }

    if (*evento == MOUSE_DOWN)
    {
      mouse.area(x1, y1, x2, y2);
      pinta = VERDADEIRO;
      antx = mouse.x();
      anty = mouse.y();
    }
    else
      if (*evento == MOUSE_UP)
      {
        if (pinta)
        {
          /*
          setcolor(15);
          line(antx, anty, mouse.x(), mouse.y());
          */
          LinhaGrafico* linha = new LinhaGrafico(antx - this->x1(), anty - this->y1(),
                                                 mouse.x() - this->x1(), mouse.y() - this->y1());
          c_lista.ins(linha);
          linha->exibe(this->x1(), this->y1(),
                       this->x2(), this->y2());

          mouse.area(0, 0, getmaxx(), getmaxy());

          pinta = FALSO;
        }
      }
      else
        if (*evento == MOUSE_UP_DIREITO)
          return;
  }
}
Пример #28
0
void PintaFun::desenha_ponto(const COORDENADA& x1, const COORDENADA& y1,
                             const COORDENADA& x2, const COORDENADA& y2,
                             MouseFun& mouse, MOUSE_EVENTO* evento)
{
  BOLEANO pinta = FALSO;
  COORDENADA antx, anty;

  if (*evento == MOUSE_DOWN)
    pinta = VERDADEIRO;
  else
    if (*evento == MOUSE_UP)
    {
      if (pinta)
      {
        PontoGrafico* ponto = new PontoGrafico(mouse.x() - this->x1(), mouse.y() - this->y1());
        c_lista.ins(ponto);
        ponto->exibe(this->x1(), this->y1(),
                     this->x2(), this->y2());
        //putpixel(mouse.x(), mouse.y(), 15);
        pinta = FALSO;
      }
    }
    else
      if (*evento == MOUSE_UP_DIREITO)
        return;

  while (mouse.verifica(x1, y1, x2, y2))
  {
    {
      COORDENADA ax, ay;
      ax = mouse.x();
      ay = mouse.y();

      setcolor(7);
      setlinestyle(1, 0, 0);
      setwritemode(XOR_PUT);
      line(ax, this->y1(), ax, this->y2());
      line(this->x1(), ay, this->x2(), ay);

      *evento = mouse.evento_pause();

      line(ax, this->y1(), ax, this->y2());
      line(this->x1(), ay, this->x2(), ay);
      setwritemode(COPY_PUT);
      setlinestyle(SOLID_LINE, 0, 0);
    }

    if (*evento == MOUSE_DOWN)
      pinta = VERDADEIRO;
    else
      if (*evento == MOUSE_UP)
      {
        if (pinta)
        {
          PontoGrafico* ponto = new PontoGrafico(mouse.x() - this->x1(), mouse.y() - this->y1());
          c_lista.ins(ponto);
          ponto->exibe(this->x1(), this->y1(),
                       this->x2(), this->y2());
          //putpixel(mouse.x(), mouse.y(), 15);
          pinta = FALSO;
        }
      }
      else
        if (*evento == MOUSE_UP_DIREITO)
          return;
  }
}
Пример #29
0
/*
 * Functia care deplaseaza, mareste sau micsoreaza dreptunghiul de
 * selectie in functie de parametrul flag folosind macrourile
 * MOVE_STEP si ZOOM_STEP. Parametrul flag are urmatoarea
 * semnificatie:
 *  0: misca sus;
 *  1: misca jos;
 *  2: misca stanga;
 *  3: misca dreapta;
 *  4: zoom in;
 *  5: zoom out;
 *  alta valoare: nu se face nimic.
 */
void move_selector(int flag)
{
	int oldx1 = x1;
	int oldy1 = y1;
	int oldx2 = x2;
	int oldy2 = y2;

	switch(flag)
	{
		// misca in sus
		case 0:
			if ((y1-MOVE_STEP) >= 0)
			{
				y1 = y1-MOVE_STEP;
				y2 = y2-MOVE_STEP;
			}
			else
			{
				y2 = y2-y1;
				y1 = 0;
			}
			break;
		// misca in jos
		case 1:
			if ((y2+MOVE_STEP) <= 316)
			{
				y1 = y1+MOVE_STEP;
				y2 = y2+MOVE_STEP;
			}
			else
			{
				y1 = y1+(316-y2);
				y2 = 316;
			}
			break;
		// misca in stanga
		case 2:
			if ((x1-MOVE_STEP) >= 0)
			{
				x1 = x1-MOVE_STEP;
				x2 = x2-MOVE_STEP;
			}
			else
			{
				x2 = x2-x1;
				x1 = 0;
			}
			break;
		// misca in dreapta
		case 3:
			if ((x2+MOVE_STEP) <= 316)
			{
				x1 = x1+MOVE_STEP;
				x2 = x2+MOVE_STEP;
			}
			else
			{
				x1 = x1+(316-x2);
				x2 = 316;
			}
			break;
		// zoom in
		case 4:
			if (((x2-x1-2*ZOOM_STEP) >= 50) && ((y2-y1-2*ZOOM_STEP) >= 50))
			{
				x1 = x1+ZOOM_STEP;
				x2 = x2-ZOOM_STEP;
				y1 = y1+ZOOM_STEP;
				y2 = y2-ZOOM_STEP;
			}
			else
			{
				int maxzoom;
				if ((x2-x1) > (y2-y1))
				{
					maxzoom = (int) (((y2-y1)-50)/2);
				}
				else
				{
					maxzoom = (int) (((x2-x1)-50)/2);
				}
				x1 = x1+maxzoom;
				x2 = x2-maxzoom;
				y1 = y1+maxzoom;
				y2 = y2-maxzoom;
			}
			break;
		// zoom out
		case 5:
			if ((x1-ZOOM_STEP) < 0)
			{
				x1 = 0;
			}
			else
			{
				x1 = x1-ZOOM_STEP;
			}
			if ((x2+ZOOM_STEP) > 316)
			{
				x2 = 316;
			}
			else
			{
				x2 = x2+ZOOM_STEP;
			}
			if ((y1-ZOOM_STEP) < 0)
			{
				y1 = 0;
			}
			else
			{
				y1 = y1-ZOOM_STEP;
			}
			if ((y2+ZOOM_STEP) > 316)
			{
				y2 = 316;
			}
			else
			{
				y2 = y2+ZOOM_STEP;
			}
			break;
	}
	set(2);
	setwritemode(XOR_PUT);
	setcolor(GREEN);
	rectangle(oldx1, oldy1, oldx2, oldy2);
	rectangle(x1, y1, x2, y2);
}
Пример #30
0
LLDSPEC bool_t gdisp_lld_init(GDisplay *g) {

   unsigned short DeviceCode;

   // No private area for this controller
   g->priv = 0;

   // Initialise the board interface
   init_board(g);

   /* Hardware reset */
   setpin_reset(g, TRUE);
   gfxSleepMilliseconds(1);
   setpin_reset(g, FALSE);
   gfxSleepMilliseconds(10);
   setpin_reset(g, TRUE);
   gfxSleepMilliseconds(50);

   acquire_bus(g);
   setreadmode(g);
   DeviceCode = read_reg(g, 0x00);
   setwritemode(g);

   if( DeviceCode == 0x9320 || DeviceCode == 0x9300 )
   {
      write_reg(g, 0x00, 0x0000);
      write_reg(g, 0x01, 0x0100); /* Driver Output Contral */
      write_reg(g, 0x02, 0x0700); /* LCD Driver Waveform Contral */
      write_reg(g, 0x03, 0x1038); /* Set the scan mode */
      write_reg(g, 0x04, 0x0000); /* Scalling Contral */
      write_reg(g, 0x08, 0x0202); /* Display Contral 2 */
      write_reg(g, 0x09, 0x0000); /* Display Contral 3 */
      write_reg(g, 0x0a, 0x0000); /* Frame Cycle Contal */
      write_reg(g, 0x0c, (1<<0)); /* Extern Display Interface Contral 1 */
      write_reg(g, 0x0d, 0x0000); /* Frame Maker Position */
      write_reg(g, 0x0f, 0x0000); /* Extern Display Interface Contral 2 */
      gfxSleepMilliseconds(50);
      write_reg(g, 0x07, 0x0101); /* Display Contral */
      gfxSleepMilliseconds(50);
      write_reg(g, 0x10, (1<<12)|(0<<8)|(1<<7)|(1<<6)|(0<<4)); /* Power Control 1 */
      write_reg(g, 0x11, 0x0007);                              /* Power Control 2 */
      write_reg(g, 0x12, (1<<8)|(1<<4)|(0<<0));                /* Power Control 3 */
      write_reg(g, 0x13, 0x0b00);                              /* Power Control 4 */
      write_reg(g, 0x29, 0x0000);                              /* Power Control 7 */
      write_reg(g, 0x2b, (1<<14)|(1<<4));
      write_reg(g, 0x50, 0);       /* Set X Start */
      write_reg(g, 0x51, 239);     /* Set X End */
      write_reg(g, 0x52, 0);       /* Set Y Start */
      write_reg(g, 0x53, 319);     /* Set Y End */
      gfxSleepMilliseconds(50);

      write_reg(g, 0x60, 0x2700); /* Driver Output Control */
      write_reg(g, 0x61, 0x0001); /* Driver Output Control */
      write_reg(g, 0x6a, 0x0000); /* Vertical Srcoll Control */

      write_reg(g, 0x80, 0x0000); /* Display Position? Partial Display 1 */
      write_reg(g, 0x81, 0x0000); /* RAM Address Start? Partial Display 1 */
      write_reg(g, 0x82, 0x0000); /* RAM Address End-Partial Display 1 */
      write_reg(g, 0x83, 0x0000); /* Displsy Position? Partial Display 2 */
      write_reg(g, 0x84, 0x0000); /* RAM Address Start? Partial Display 2 */
      write_reg(g, 0x85, 0x0000); /* RAM Address End? Partial Display 2 */

      write_reg(g, 0x90, (0<<7)|(16<<0)); /* Frame Cycle Contral */
      write_reg(g, 0x92, 0x0000);         /* Panel Interface Contral 2 */
      write_reg(g, 0x93, 0x0001);         /* Panel Interface Contral 3 */
      write_reg(g, 0x95, 0x0110);         /* Frame Cycle Contral */
      write_reg(g, 0x97, (0<<8));
      write_reg(g, 0x98, 0x0000);         /* Frame Cycle Contral */
      write_reg(g, 0x07, 0x0133);
   } 
   else if( DeviceCode == 0x9325 || DeviceCode == 0x9328)
   {

      write_reg(g, 0x00e7, 0x0010);
      write_reg(g, 0x0000, 0x0001);    /* start internal osc */
      write_reg(g, 0x0001, 0x0100);
      write_reg(g, 0x0002, 0x0700);    /* power on sequence */
      write_reg(g, 0x0003, (1<<12)|(1<<5)|(1<<4)|(0<<3) );     /* importance */
      write_reg(g, 0x0004, 0x0000);
      write_reg(g, 0x0008, 0x0207);
      write_reg(g, 0x0009, 0x0000);
      write_reg(g, 0x000a, 0x0000);    /* display setting */
      write_reg(g, 0x000c, 0x0001);    /* display setting */
      write_reg(g, 0x000d, 0x0000);
      write_reg(g, 0x000f, 0x0000);
      /* Power On sequence */
      write_reg(g, 0x0010, 0x0000);
      write_reg(g, 0x0011, 0x0007);
      write_reg(g, 0x0012, 0x0000);
      write_reg(g, 0x0013, 0x0000);
      gfxSleepMilliseconds(50);  /* delay 50 ms */
      write_reg(g, 0x0010, 0x1590);
      write_reg(g, 0x0011, 0x0227);
      gfxSleepMilliseconds(50);  /* delay 50 ms */
      write_reg(g, 0x0012, 0x009c);
      gfxSleepMilliseconds(50);  /* delay 50 ms */
      write_reg(g, 0x0013, 0x1900);
      write_reg(g, 0x0029, 0x0023);
      write_reg(g, 0x002b, 0x000e);
      gfxSleepMilliseconds(50);  /* delay 50 ms */
      write_reg(g, 0x0020, 0x0000);
      write_reg(g, 0x0021, 0x0000);
      gfxSleepMilliseconds(50);  /* delay 50 ms */
      write_reg(g, 0x0030, 0x0007);
      write_reg(g, 0x0031, 0x0707);
      write_reg(g, 0x0032, 0x0006);
      write_reg(g, 0x0035, 0x0704);
      write_reg(g, 0x0036, 0x1f04);
      write_reg(g, 0x0037, 0x0004);
      write_reg(g, 0x0038, 0x0000);
      write_reg(g, 0x0039, 0x0706);
      write_reg(g, 0x003c, 0x0701);
      write_reg(g, 0x003d, 0x000f);
      gfxSleepMilliseconds(50);  /* delay 50 ms */
      write_reg(g, 0x0050, 0x0000);
      write_reg(g, 0x0051, 0x00ef);
      write_reg(g, 0x0052, 0x0000);
      write_reg(g, 0x0053, 0x013f);
      write_reg(g, 0x0060, 0xa700);
      write_reg(g, 0x0061, 0x0001);
      write_reg(g, 0x006a, 0x0000);
      write_reg(g, 0x0080, 0x0000);
      write_reg(g, 0x0081, 0x0000);
      write_reg(g, 0x0082, 0x0000);
      write_reg(g, 0x0083, 0x0000);
      write_reg(g, 0x0084, 0x0000);
      write_reg(g, 0x0085, 0x0000);

      write_reg(g, 0x0090, 0x0010);
      write_reg(g, 0x0092, 0x0000);
      write_reg(g, 0x0093, 0x0003);
      write_reg(g, 0x0095, 0x0110);
      write_reg(g, 0x0097, 0x0000);
      write_reg(g, 0x0098, 0x0000);
      /* display on sequence */
      write_reg(g, 0x0007, 0x0133);

      write_reg(g, 0x0020, 0x0000);
      write_reg(g, 0x0021, 0x0000);
   }

   gfxSleepMilliseconds(100);   /* delay 50 ms */


   // Finish Init
   post_init_board(g);

   // Release the bus
   release_bus(g);

   // Turn on the backlight
   set_backlight(g, GDISP_INITIAL_BACKLIGHT);

   /* Initialise the GDISP structure */
   g->g.Width = GDISP_SCREEN_WIDTH;
   g->g.Height = GDISP_SCREEN_HEIGHT;
   g->g.Orientation = GDISP_ROTATE_0;
   g->g.Powermode = powerOn;
   g->g.Backlight = GDISP_INITIAL_BACKLIGHT;
   g->g.Contrast = GDISP_INITIAL_CONTRAST;

   return TRUE;
}