Beispiel #1
0
void test_task(void*)   {
	while(1){
		display.begin();
		//display.setContrast(50);
		display.display();

		delay(2000);
		display.clearDisplay();   // clears the screen and buffer

		// draw a single pixel
		display.drawPixel(10, 10, WHITE);
		display.display();
		delay(2000);
		display.clearDisplay();

		// draw many lines
		testdrawline();
		display.display();
		delay(2000);
		display.clearDisplay();

		// draw rectangles
		testdrawrect();
		display.display();
		delay(2000);
		display.clearDisplay();

		// draw multiple rectangles
		testfillrect();
		display.display();
		delay(2000);
		display.clearDisplay();

		// draw mulitple circles
		testdrawcircle();
		display.display();
		delay(2000);
		display.clearDisplay();

		// draw a circle, 10 pixel radius
		display.fillCircle(display.width()/2, display.height()/2, 10, WHITE);
		display.display();
		delay(2000);
		display.clearDisplay();

		testdrawroundrect();
		delay(2000);
		display.clearDisplay();

		testfillroundrect();
		delay(2000);
		display.clearDisplay();

		testdrawtriangle();
		delay(2000);
		display.clearDisplay();

		testfilltriangle();
		delay(2000);
		display.clearDisplay();

		// draw the first ~12 characters in the font
		testdrawchar();
		display.display();
		delay(2000);
		display.clearDisplay();

		// draw scrolling text
		testscrolltext();
		delay(2000);
		display.clearDisplay();

		// text display tests
		display.setTextSize(2);
		display.setTextColor(WHITE);
		display.setCursor(0,0);
		display.println((char*)"Hello, world!");
		display.setTextColor(WHITE, BLACK); // 'inverted' text
		display.println((char*)"3.141592");
		display.setTextSize(1);
		display.setTextColor(WHITE);
		display.print((char*)"0x");
		display.println((char*)"DEADBEEF");
		display.display();
		delay(2000);

		// rotation example
		display.clearDisplay();
		display.setRotation(1);  // rotate 90 degrees counter clockwise, can also use values of 2 and 3 to go further.
		display.setTextSize(1);
		display.setTextColor(WHITE);
		display.setCursor(0,0);
		display.println((char*)"Rotation");
		display.setTextSize(1);
		display.println((char*)"Example!");
		display.display();
		delay(2000);

		// revert back to no rotation
		display.setRotation(0);

		// miniature bitmap display
		display.clearDisplay();
		display.drawBitmap(30, 16,  logo16_glcd_bmp, 16, 16, WHITE);
		display.display();

		// invert the display
		display.invertDisplay(true);
		delay(1000);
		display.invertDisplay(false);
		delay(1000);

		// draw a bitmap icon and 'animate' movement
		testdrawbitmap(logo16_glcd_bmp, LOGO16_GLCD_WIDTH, LOGO16_GLCD_HEIGHT);
	}
}
void setup()   {                
  Serial.begin(9600);

  // by default, we'll generate the high voltage from the 3.3v line internally! (neat!)
  display.begin(SSD1306_SWITCHCAPVCC, 0x3D);  // initialize with the I2C addr 0x3D (for the 128x64)
  // init done
  
  // Show image buffer on the display hardware.
  // Since the buffer is intialized with an Adafruit splashscreen
  // internally, this will display the splashscreen.
  display.display();
  delay(2000);

  // Clear the buffer.
  display.clearDisplay();

  // draw a single pixel
  display.drawPixel(10, 10, WHITE);
  // Show the display buffer on the hardware.
  // NOTE: You _must_ call display after making any drawing commands
  // to make them visible on the display hardware!
  display.display();
  delay(2000);
  display.clearDisplay();

  // draw many lines
  testdrawline();
  display.display();
  delay(2000);
  display.clearDisplay();

  // draw rectangles
  testdrawrect();
  display.display();
  delay(2000);
  display.clearDisplay();

  // draw multiple rectangles
  testfillrect();
  display.display();
  delay(2000);
  display.clearDisplay();

  // draw mulitple circles
  testdrawcircle();
  display.display();
  delay(2000);
  display.clearDisplay();

  // draw a white circle, 10 pixel radius
  display.fillCircle(display.width()/2, display.height()/2, 10, WHITE);
  display.display();
  delay(2000);
  display.clearDisplay();

  testdrawroundrect();
  delay(2000);
  display.clearDisplay();

  testfillroundrect();
  delay(2000);
  display.clearDisplay();

  testdrawtriangle();
  delay(2000);
  display.clearDisplay();
   
  testfilltriangle();
  delay(2000);
  display.clearDisplay();

  // draw the first ~12 characters in the font
  testdrawchar();
  display.display();
  delay(2000);
  display.clearDisplay();

  // draw scrolling text
  testscrolltext();
  delay(2000);
  display.clearDisplay();

  // text display tests
  display.setTextSize(1);
  display.setTextColor(WHITE);
  display.setCursor(0,0);
  display.println("Hello, world!");
  display.setTextColor(BLACK, WHITE); // 'inverted' text
  display.println(3.141592);
  display.setTextSize(2);
  display.setTextColor(WHITE);
  display.print("0x"); display.println(0xDEADBEEF, HEX);
  display.display();
  delay(2000);
  display.clearDisplay();

  // miniature bitmap display
  display.drawBitmap(30, 16,  logo16_glcd_bmp, 16, 16, 1);
  display.display();
  delay(1);

  // invert the display
  display.invertDisplay(true);
  delay(1000); 
  display.invertDisplay(false);
  delay(1000); 
  display.clearDisplay();

  // draw a bitmap icon and 'animate' movement
  testdrawbitmap(logo16_glcd_bmp, LOGO16_GLCD_HEIGHT, LOGO16_GLCD_WIDTH);
}