示例#1
0
    void textTest() {

      const char *str="The quick brown fox";
      Size size;
      Point p;
      uint32_t i,start;

      prompt("Stream operators test");

      *_gl << Point::Origin << "Let's see PI:";

      for(i=0;i<=7;i++)
        *_gl << Point(0,(1+i)*_font.getHeight()) << DoublePrecision(3.1415926535,i);

      MillisecondTimer::delay(5000);

      prompt("Opaque text test");

      size=_gl->measureString(_font,str);

      for(i=0,start=MillisecondTimer::millis();MillisecondTimer::millis()-start<5000;i++) {

        p.X=rand() % (_gl->getXmax()-size.Width);
        p.Y=rand() % (_gl->getYmax()-size.Height);

        _gl->setForeground(rand());
        _gl->writeString(p,_font,str);
      }
    }
示例#2
0
文件: st7783.cpp 项目: ADTL/stm32plus
    void textTest() {

      int i;
      const char *str="The quick brown fox";
      Size size;
      Point p;
      uint32_t start,before,elapsed,chars;

      prompt("Stream operators test");

      *_gl << Point::Origin << "Let's see PI:";

      for(i=0;i<=7;i++)
        *_gl << Point(0,(1+i)*_font->getHeight()) << DoublePrecision(3.1415926535,i);

      MillisecondTimer::delay(5000);

      prompt("Opaque text test");

      size=_gl->measureString(*_font,str);

      before=MillisecondTimer::millis();
      chars=0;

      for(start=MillisecondTimer::millis();MillisecondTimer::millis()-start<5000;) {

        p.X=rand() % (_gl->getXmax()-size.Width);
        p.Y=rand() % (_gl->getYmax()-size.Height);

        _gl->setForeground(rand());
        _gl->writeString(p,*_font,str);

        chars+=19;
      }

      elapsed=MillisecondTimer::millis()-before;

      _gl->clearScreen();
      _gl->setForeground(ColourNames::WHITE);
      *_gl << Point::Origin << (chars*1000/elapsed)  << " characters/sec";

      MillisecondTimer::delay(3000);
    }
	void drawBox(const char *label, int16_t X_location,int16_t Y_location , Rectangle* touchArea) {
		// create a touch button at location specified by location
		// and display the button on the screen with the specified label
		// touch button are constant size for now
		touchArea->X=X_location;
		touchArea->Y=Y_location;
		touchArea->Height=40;
		touchArea->Width=80;

		lcd->drawRectangle(*touchArea);
		// find the suitable location for the label and display it
		Size stringSize = lcd->measureString(*_font,label);
		Point labelLocation;
		labelLocation.X = touchArea->Width/2-stringSize.Width/2+X_location;
		labelLocation.Y = touchArea->Height/2-stringSize.Height/2+Y_location;
		// debug purpose: we want to make sure the location is still visible
		// even if it's too big for the box
		if (labelLocation.X > 0 && labelLocation.Y>0)
			*lcd << labelLocation << label;

	}