示例#1
0
int main()
{
	int i, j;
	int black = 1;
	display.init(PIN_DC, PIN_RESET, PIN_CS, OLED_ADAFRUIT_SPI_128x32);
	display.begin();

	/* 左上 */
	display.drawPixel(0, 0, WHITE);
	display.display();
	sleep(2);

	/* 左下 */
	display.drawPixel(0, 31, WHITE);
	display.display();
	sleep(2);

	/* 右上 */	
	display.drawPixel(127, 0, WHITE);
	display.display();
	sleep(2);

	/* 右下 */
        display.drawPixel(127, 31, WHITE);
        display.display();
        sleep(2);

	for (i = 0; i < 32; i++) {
		for (j = 0; j < 128; j++) {
			//display.drawPixel(j, i, (black % 2) ? BLACK : WHITE);
			display.drawPixel(j, i, WHITE);
			display.display();
			black++;
		}
		//black = i;
		//display.display();
	}

	display.clearDisplay();
	display.close();
	return 0;
}
示例#2
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);
	}
}