Beispiel #1
0
    void textTest() {

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

      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();

      for(i=0;i<15000;i++) {

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

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

      elapsed=MillisecondTimer::millis()-before;

      _gl->clearScreen();
      _gl->setForeground(ColourNames::WHITE);
      *_gl << Point::Origin << "Elapsed: " << (int32_t)elapsed << "ms";

      MillisecondTimer::delay(3000);
    }
Beispiel #2
0
    void run() {

      // reset is on PE1 and RS (D/CX) is on PD11

      GpioE<DefaultDigitalOutputFeature<1> > pe;
      GpioD<DefaultFsmcAlternateFunctionFeature<11> > pd;

      // set up the FSMC timing. these numbers (particularly the data setup time) are dependent on
      // both the FSMC bus speed and the panel timing parameters.

      Fsmc8080LcdTiming fsmcTiming(0,3);

      // set up the FSMC with RS=A16 (PD11)

      _accessMode=new LcdAccessMode(fsmcTiming,16,pe[1]);
      _gl=new LcdPanel(*_accessMode);

      // clear to black while the lights are out

      _gl->setBackground(0);
      _gl->clearScreen();

      // create the backlight on timer4, channel2 (PD13)

      DefaultBacklight backlight;

      // fade up to 100% in 4ms steps

      backlight.fadeTo(100,4);

      // create a font

      _font=new Font_VOLTER__28GOLDFISH_299;
      *_gl << *_font;

      _gl->setForeground(ColourNames::RED);
      _gl->fillRectangle(Rectangle(10,20,5,10));

      for(;;) {
        jpegTest();
        lzgTest();
        basicColoursTest();
        textTest();
        scrollTest();
        ellipseTest();
        gradientTest();
        rectTest();
        lineTest();
        clearTest();
        sleepTest();
      }
    }
Beispiel #3
0
    void error(const std::string& str) {

      _tft->setBackground(ColourNames::WHITE);
      _tft->setForeground(ColourNames::BLACK);
      _tft->clearScreen();

      LinearBufferInputOutputStream compressedData((uint8_t *)&ErrorPixels,(uint32_t)&ErrorPixelsSize);
      _tft->drawJpeg(Rectangle(95,135,50,50),compressedData);

      *_tft << Point(2,2) << str.c_str();

      errorRestart();
    }
Beispiel #4
0
    void lineTest() {

      Point p1,p2;
      uint32_t i,start;

      prompt("Line test");

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

        p1.X=rand() % _gl->getXmax();
        p1.Y=rand() % _gl->getYmax();
        p2.X=rand() % _gl->getXmax();
        p2.Y=rand() % _gl->getYmax();

        _gl->setForeground(rand());
        _gl->drawLine(p1,p2);
      }

      _gl->setForeground(ColourNames::WHITE);
      _gl->clearScreen();
      *_gl << Point::Origin << i << " lines in 5 seconds";
      MillisecondTimer::delay(3000);
    }
Beispiel #5
0
    void lineTest() {

      Point p1,p2;
      uint32_t start;

      prompt("Line test");

      for(start=MillisecondTimer::millis();MillisecondTimer::millis()-start<5000;) {
        p1.X=rand() % _gl->getXmax();
        p1.Y=rand() % _gl->getYmax();
        p2.X=rand() % _gl->getXmax();
        p2.Y=rand() % _gl->getYmax();

        _gl->setForeground(rand());
        _gl->drawLine(p1,p2);
      }
    }
Beispiel #6
0
    void lineTest() {

      Point p1,p2;
      int i;

      prompt("Line test");

      for(i=0;i<5000;i++) {
        p1.X=rand() % _gl->getXmax();
        p1.Y=rand() % _gl->getYmax();
        p2.X=rand() % _gl->getXmax();
        p2.Y=rand() % _gl->getYmax();

        _gl->setForeground(rand());
        _gl->drawLine(p1,p2);
      }
    }
	void initDisplay(){

		// we've got RESET on PE1, backlight on PD13 and RS (D/CX) on PD11
		GpioE<DefaultDigitalOutputFeature<1>> pe;
		GpioD<DefaultDigitalOutputFeature<13>,DefaultFsmcAlternateFunctionFeature<11>> pd;

		// set up the FSMC timing for this panel
		Fsmc8080LcdTiming fsmcTiming(2,5);

		// set up the FSMC on bank 1 with A16 as the RS line (PD11)
		_accessMode=new LcdAccessMode(fsmcTiming,16,pe[1]);

		// create the LCD interface in landscape mode
		// this will power it up and do the reset sequence
		lcd=new LcdPanel(*_accessMode);

		HX8352AGamma gamma(0xA0,0x03,0x00,0x45,0x03,0x47,0x23,0x77,0x01,0x1F,0x0F,0x03);
		// jb settings: check which one gives better colors
		//HX8352AGamma gamma(0xF0,0x07,0x00,0x43,0x16,0x16,0x43,0x77,0x00,0x1E,0x0F,0x00);
		lcd->applyGamma(gamma);

		// create a font and select it for stream operations
		_font=new Font_NINTENDO_DS_BIOS16();
		*lcd << *_font;
		lcd->setFontFilledBackground(true);

		// turn on the backlight at 100%
		backlight=new DefaultBacklight;

		//uint16_t backlightPercentage=100;
		backlight->fadeTo(100,4);

		// setup font/background colors
		bgcolor = ColourNames::BLACK;
		fgcolor = ColourNames::YELLOW;

		lcd->setBackground(bgcolor);
		lcd->setForeground(fgcolor);

	}
Beispiel #8
0
    void initialiseLcd() {

      // reset is on PE1 and RS (D/CX) is on PE3

      GpioE<DefaultDigitalOutputFeature<1>,
            DefaultFsmcAlternateFunctionFeature<3>> pe;

      // set up the FSMC timing. these numbers (particularly the data setup time) are dependent on
      // both the FSMC bus speed and the panel timing parameters.

      Fsmc8080LcdTiming fsmcTiming(2,4);

      // set up the FSMC with RS=A19 (PE3)

      _accessMode=new LcdAccessMode(fsmcTiming,19,pe[1]);
      _tft=new LcdPanel(*_accessMode);

      // apply gamma settings

      ST7783Gamma gamma(0,0x0107,0,0x0203,0x0402,0,0x0207,0,0x0203,0x0403);
      _tft->applyGamma(gamma);

      // clear to black while the lights are out

      _tft->setBackground(ColourNames::BLACK);
      _tft->setForeground(ColourNames::WHITE);
      _tft->clearScreen();

      // fade up to 100% in 4ms steps

      _backlight=new DefaultBacklight;
      _backlight->fadeTo(100,4);

      // create a font

      _font=new Font_VOLTER__28GOLDFISH_299;
      *_tft << *_font;
      _line=0;
    }
	void processEvents() {

		//event 1: click on the touch panel

		// check if there's a click
		if(touch->_clicked){

			// a click happened!
			do {
				touch->panel->getCoordinates(hitPoint);

				// event: calibrate button tap
				if(calibrate_box.containsPoint(hitPoint)){
					MillisecondTimer::delay(500);
					touch->calibrate();
				}
				// event: send AT commands button tap
				else if (ATcommands.containsPoint(hitPoint)){
					// NEXT STEP: start usart, send AT+RST COMMAND AND GET THE ANSWER
					//debug purpose
					*lcd << Point(20,160);
					*lcd << "sending reset commands";
					MillisecondTimer::delay(1000);
					//

				}

			} while(!touch->_penIrqPin.read());

			//reset clicked flag
			touch->_clicked=false;

			// back to main menu
			lcd->clearScreen();
			lcd->setForeground(fgcolor);
			drawMenu();

		}
	}
Beispiel #10
0
    void scrollTest() {

      int32_t i,j,numRows;
      Point p;

      prompt("Hardware scrolling test");

      _gl->setForeground(0xffffff);
      _gl->setBackground(0);
      _gl->clearScreen();

      numRows=((_gl->getYmax()+1)/_font->getHeight())/3;

      p.X=0;

      for(i=0;i<numRows;i++) {

        p.Y=(numRows+i)*_font->getHeight();
        *_gl << p << "Test row " << i;
      }

      for(j=0;j<15;j++) {

        numRows=(_gl->getYmax()+1)/4;

        for(i=0;i<numRows;i++) {
          _gl->setScrollPosition(i);
          MillisecondTimer::delay(5);
        }

        for(i=0;i<numRows;i++) {
          _gl->setScrollPosition(numRows-i);
          MillisecondTimer::delay(5);
        }
      }

      _gl->setScrollPosition(0);
    }
Beispiel #11
0
    void stopTimer(const char *prompt,uint32_t elapsed) {

      _gl->setForeground(ColourNames::WHITE);
      *_gl << Point(0,0) << (int32_t)elapsed << "ms " << prompt;
    }
Beispiel #12
0
    void backlightTest() {

      prompt("Backlight test");

      Rectangle rc;
      uint16_t i;
      static uint32_t colours[8]={
        ColourNames::RED,
        ColourNames::GREEN,
        ColourNames::BLUE,
        ColourNames::CYAN,
        ColourNames::MAGENTA,
        ColourNames::YELLOW,
        ColourNames::WHITE,
        ColourNames::BLACK,
      };

      // draw a row of solid colours

      rc.X=0;
      rc.Y=0;
      rc.Height=_gl->getHeight()/2;
      rc.Width=_gl->getWidth()/(sizeof(colours)/sizeof(colours[0]));

      for(i=0;i<sizeof(colours)/sizeof(colours[0]);i++) {

        _gl->setForeground(colours[i]);
        _gl->fillRectangle(rc);

        rc.X+=rc.Width;
      }

      // draw a greyscale

      rc.X=0;
      rc.Y=rc.Height;
      rc.Height=rc.Height/4;
      rc.Width=_gl->getWidth()/256;

      for(i=0;i<256;i++) {
        _gl->setForeground(i | (i << 8) | (i << 16));
        _gl->fillRectangle(rc);
        rc.X+=rc.Width;
      }

      for(i=100;i>0;i-=5) {

        // set the level

        _backlight->setPercentage(i);

        // show the indicator

        rc.X=_gl->getWidth()/4;
        rc.Y=(_gl->getHeight()*6)/8;
        rc.Height=_gl->getHeight()/8;

        // fill

        rc.Width=(_gl->getWidth()/2*i)/100;
        _gl->gradientFillRectangle(rc,Direction::HORIZONTAL,0x008000,0x00ff00);

        // remainder

        rc.X+=rc.Width;
        rc.Width=_gl->getWidth()/2-rc.Width;
        _gl->setForeground(ColourNames::BLACK);
        _gl->fillRectangle(rc);

        // show the percentage

        _gl->setForeground(ColourNames::WHITE);
        *_gl << Point(0,_gl->getHeight()-_font.getHeight()) << "Backlight level: " << i << "%  ";

        // pause

        MillisecondTimer::delay(750);
      }

      // restore backlight

      _backlight->setPercentage(100);
    }
Beispiel #13
0
    void stopTimer(const char *prompt,uint32_t elapsed) {

      _gl->setForeground(0xffffff);
      *_gl << Point(0,0) << (int32_t)elapsed << "ms " << prompt;
    }