当前位置: 首页>>代码示例>>C++>>正文


C++ Adafruit_ST7735::width方法代码示例

本文整理汇总了C++中Adafruit_ST7735::width方法的典型用法代码示例。如果您正苦于以下问题:C++ Adafruit_ST7735::width方法的具体用法?C++ Adafruit_ST7735::width怎么用?C++ Adafruit_ST7735::width使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Adafruit_ST7735的用法示例。


在下文中一共展示了Adafruit_ST7735::width方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: testlines

void testlines(uint16_t color) {
    tft.fillScreen(ST7735_BLACK);
    for (int16_t x=0; x < tft.width(); x+=6) {
        tft.drawLine(0, 0, x, tft.height()-1, color);
    }
    for (int16_t y=0; y < tft.height(); y+=6) {
        tft.drawLine(0, 0, tft.width()-1, y, color);
    }

    tft.fillScreen(ST7735_BLACK);
    for (int16_t x=0; x < tft.width(); x+=6) {
        tft.drawLine(tft.width()-1, 0, x, tft.height()-1, color);
    }
    for (int16_t y=0; y < tft.height(); y+=6) {
        tft.drawLine(tft.width()-1, 0, 0, y, color);
    }

    tft.fillScreen(ST7735_BLACK);
    for (int16_t x=0; x < tft.width(); x+=6) {
        tft.drawLine(0, tft.height()-1, x, 0, color);
    }
    for (int16_t y=0; y < tft.height(); y+=6) {
        tft.drawLine(0, tft.height()-1, tft.width()-1, y, color);
    }

    tft.fillScreen(ST7735_BLACK);
    for (int16_t x=0; x < tft.width(); x+=6) {
        tft.drawLine(tft.width()-1, tft.height()-1, x, 0, color);
    }
    for (int16_t y=0; y < tft.height(); y+=6) {
        tft.drawLine(tft.width()-1, tft.height()-1, 0, y, color);
    }
}
开发者ID:ubirch,项目名称:ubirch-thgs,代码行数:33,代码来源:tft.cpp

示例2: testfillrects

void testfillrects(uint16_t color1, uint16_t color2) {
    tft.fillScreen(ST7735_BLACK);
    for (int16_t x=tft.width()-1; x > 6; x-=6) {
        tft.fillRect(tft.width()/2 -x/2, tft.height()/2 -x/2 , x, x, color1);
        tft.drawRect(tft.width()/2 -x/2, tft.height()/2 -x/2 , x, x, color2);
    }
}
开发者ID:ubirch,项目名称:ubirch-thgs,代码行数:7,代码来源:tft.cpp

示例3: testfastlines

void testfastlines(uint16_t color1, uint16_t color2) {
    tft.fillScreen(ST7735_BLACK);
    for (int16_t y=0; y < tft.height(); y+=5) {
        tft.drawFastHLine(0, y, tft.width(), color1);
    }
    for (int16_t x=0; x < tft.width(); x+=5) {
        tft.drawFastVLine(x, 0, tft.height(), color2);
    }
}
开发者ID:ubirch,项目名称:ubirch-thgs,代码行数:9,代码来源:tft.cpp

示例4: loop

void loop() {
    Serial.println("printing though!");
    tft.fillScreen(ST7735_BLACK);
    // tft.setCursor(0, 0);
    tft.setTextColor(ST7735_WHITE);
    tft.setTextWrap(true);
    // tft.setTextSize(3);
    // tft.setCursor(30, 3);
    tft.setFont(HERO_10);
    tft.drawRightString("OTTAWA",  3);

    tft.setFont(HERO_16);
    tft.setTextSize(2);
    // tft.setCursor(25, 20);
    tft.drawRightString("-1  C", 20);

    tft.setTextSize(1);
    // tft.setCursor(35, 60);
    tft.drawRightString("2:35 PM", 60);

    tft.drawFastHLine(0, 90, tft.width(), ST7735_CYAN);

    tft.setTextWrap(true);
    tft.setFont(CENTURY_8);
    tft.setTextSize(1);
    // tft.setCursor(0, tft.height()-65);
    int yPos = tft.drawString("Stay Hungry, Stay Foolish!",  0,tft.height()-65);
    tft.setTextColor(ST7735_CYAN);
    tft.drawRightString(" - Steve Jobs   ", yPos);
    tft.setTextColor(ST7735_MAGENTA);
    delay(5000);
}
开发者ID:Trekky12,项目名称:Adafruit_ST7735,代码行数:32,代码来源:example.cpp

示例5: testtriangles

void testtriangles() {
    tft.fillScreen(ST7735_BLACK);
    int color = 0xF800;
    int t;
    int w = tft.width()/2;
    int x = tft.height()-1;
    int y = 0;
    int z = tft.width();
    for(t = 0 ; t <= 15; t+=1) {
        tft.drawTriangle(w, y, y, x, z, x, color);
        x-=4;
        y+=4;
        z-=4;
        color+=100;
    }
}
开发者ID:ubirch,项目名称:ubirch-thgs,代码行数:16,代码来源:tft.cpp

示例6: testdrawcircles

void testdrawcircles(uint8_t radius, uint16_t color) {
    for (int16_t x=0; x < tft.width()+radius; x+=radius*2) {
        for (int16_t y=0; y < tft.height()+radius; y+=radius*2) {
            tft.drawCircle(x, y, radius, color);
        }
    }
}
开发者ID:ubirch,项目名称:ubirch-thgs,代码行数:7,代码来源:tft.cpp

示例7: testfillcircles

void testfillcircles(uint8_t radius, uint16_t color) {
    for (int16_t x=radius; x < tft.width(); x+=radius*2) {
        for (int16_t y=radius; y < tft.height(); y+=radius*2) {
            tft.fillCircle(x, y, radius, color);
        }
    }
}
开发者ID:ubirch,项目名称:ubirch-thgs,代码行数:7,代码来源:tft.cpp

示例8: screen13

void screen13() {
	startTime = millis();
	debugf("screen13: bmpDraw rotaton %d ms", millis() - startTime);
	tft.fillScreen(ST7735_BLACK); // Clear display
	tft.setRotation(tft.getRotation() + 1); // Inc rotation 90 degrees
	for (uint8_t i = 0; i < 4; i++)    // Draw 4 parrots
		bmpDraw(tft, "sming.bmp", tft.width() / 4 * i, tft.height() / 4 * i);
}
开发者ID:BorntraegerMarc,项目名称:SmingRTOS,代码行数:8,代码来源:application.cpp

示例9: testroundrects

void testroundrects() {
    tft.fillScreen(ST7735_BLACK);
    int color = 100;
    int i;
    int t;
    for(t = 0 ; t <= 4; t+=1) {
        int x = 0;
        int y = 0;
        int w = tft.width()-2;
        int h = tft.height()-2;
        for(i = 0 ; i <= 16; i+=1) {
            tft.drawRoundRect(x, y, w, h, 5, color);
            x+=2;
            y+=3;
            w-=4;
            h-=6;
            color+=1100;
        }
        color+=100;
    }
}
开发者ID:ubirch,项目名称:ubirch-thgs,代码行数:21,代码来源:tft.cpp

示例10: bmpDraw

void bmpDraw(Adafruit_ST7735 tft, String fileName, uint8_t x, uint8_t y) {

	file_t handle;

	int bmpWidth, bmpHeight;   		// W+H in pixels
	uint8_t bmpDepth;              	// Bit depth (currently must be 24)
	uint32_t bmpImageoffset;        // Start of image data in file
	uint32_t rowSize;               // Not always = bmpWidth; may have padding
	uint8_t sdbuffer[3 * BUFFPIXEL]; // pixel buffer (R+G+B per pixel)
	uint8_t buffidx = sizeof(sdbuffer); // Current position in sdbuffer
	boolean goodBmp = false;       	// Set to true on valid header parse
	boolean flip = true;        	// BMP is stored bottom-to-top
	int w, h, row, col;
	uint8_t r, g, b;
	uint32_t pos = 0, startTime = millis();

	if ((x >= tft.width()) || (y >= tft.height()))
		return;

	Serial.println();
	Serial.print("Loading image '");
	Serial.print(fileName);
	Serial.println('\'');

	handle = fileOpen(fileName.c_str(), eFO_ReadOnly);
	if (handle == -1)
	{
		debugf("File wasn't found: %s", fileName.c_str());
		fileClose(handle);
		return;
	}

	// Parse BMP header
	if (read16(handle) == 0x4D42) { 				// BMP signature
		debugf("File size: %d\n", read32(handle));	// get File Size
	    (void)read32(handle); 						// Read & ignore creator bytes
	    bmpImageoffset = read32(handle); 			// Start of image data
	    debugf("Image Offset: %d\n", bmpImageoffset);
	    debugf("Header size: %d\n", read32(handle));	// Read DIB header
	    bmpWidth  = read32(handle);
	    bmpHeight = read32(handle);
	    if(read16(handle) == 1) { 					// # planes -- must be '1'
	    	bmpDepth = read16(handle); 				// bits per pixel
	    	debugf("Bit Depth: %d\n", bmpDepth);
	    	if((bmpDepth == 24) && (read32(handle) == 0)) { // 0 = uncompressed
	    		goodBmp = true; 					// Supported BMP format -- proceed!

	    		debugf("Image size: %d x %d\n", bmpWidth, bmpHeight);

	            // BMP rows are padded (if needed) to 4-byte boundary
	            rowSize = (bmpWidth * 3 + 3) & ~3;

	            // If bmpHeight is negative, image is in top-down order.
	            // This is not canon but has been observed in the wild.
	            if(bmpHeight < 0) {
	              bmpHeight = -bmpHeight;
	              flip      = false;
	            }

	            // Crop area to be loaded
	            w = bmpWidth;
	            h = bmpHeight;
	            if((x+w-1) >= tft.width())  w = tft.width()  - x;
	            if((y+h-1) >= tft.height()) h = tft.height() - y;

	            // Set TFT address window to clipped image bounds
	            tft.setAddrWindow(x, y, x+w-1, y+h-1);

	            for (row=0; row<h; row++) { // For each scanline...

	              // Seek to start of scan line.  It might seem labor-
	              // intensive to be doing this on every line, but this
	              // method covers a lot of gritty details like cropping
	              // and scanline padding.  Also, the seek only takes
	              // place if the file position actually needs to change
	              // (avoids a lot of cluster math in SD library).
	              if(flip) // Bitmap is stored bottom-to-top order (normal BMP)
	                pos = bmpImageoffset + (bmpHeight - 1 - row) * rowSize;
	              else     // Bitmap is stored top-to-bottom
	                pos = bmpImageoffset + row * rowSize;
	              if (fileTell(handle) != pos) {
	            	  fileSeek(handle, pos, eSO_FileStart);
		              buffidx = sizeof(sdbuffer); // Force buffer reload
	              }
	              for (col=0; col<w; col++) { // For each pixel...
	                // Time to read more pixel data?
	                if (buffidx >= sizeof(sdbuffer)) { // Indeed
	                  fileRead(handle, sdbuffer, sizeof(sdbuffer));
	                  buffidx = 0; // Set index to beginning
	                }

	                // Convert pixel from BMP to TFT format, push to display
	                b = sdbuffer[buffidx++];
	                g = sdbuffer[buffidx++];
	                r = sdbuffer[buffidx++];
	                tft.pushColor(tft.Color565(r,g,b));
	              } // end pixel
	            } // end scanline
	            Serial.printf("Loaded in %d ms\n", millis() - startTime);
	          } // end goodBmp
//.........这里部分代码省略.........
开发者ID:andew42,项目名称:IOT,代码行数:101,代码来源:BMPDraw.cpp

示例11: setup

void setup(void) {
    Serial.begin(BAUD);
    Serial.print("Hello! professorbunsen, I presume? ");

    // Use this initializer if you're using a 1.8" TFT
    //tft.initR(INITR_BLACKTAB);   // initialize a ST7735S chip, black tab

    // Use this initializer (uncomment) if you're using a 1.44" TFT
    tft.initR(INITR_144GREENTAB);   // initialize a ST7735S chip, black tab

    Serial.println("Initialized");

    uint16_t time = millis();
    tft.fillScreen(ST7735_BLACK);
    time = millis() - time;

    Serial.println(time, DEC);
    delay(500);

    // large block of text
    tft.fillScreen(ST7735_BLACK);
    testdrawtext("Als Gregor Samsa eines Morgens aus unruhigen Träumen erwachte, fand er sich in seinem Bett zu einem ungeheueren Ungeziefer verwandelt. Er lag auf seinem panzerartig harten Rücken und sah, wenn er den Kopf ein wenig hob, seinen gewölbten, braunen, von bogenförmigen Versteifungen geteilten Bauch, auf dessen Höhe sich die Bettdecke, zum gänzlichen Niedergleiten bereit, kaum noch erhalten konnte. Seine vielen, im Vergleich zu seinem sonstigen Umfang kläglich dünnen Beine flimmerten ihm hilflos vor den Augen. Was ist mit mir geschehen? dachte er. Es war kein Traum.", ST7735_WHITE);
    delay(1000);

    // tft print function!
    tftPrintTest();
    delay(4000);

    // a single pixel
    tft.drawPixel(tft.width()/2, tft.height()/2, ST7735_GREEN);
    delay(500);

    // line draw test
    testlines(ST7735_YELLOW);
    delay(500);

    // optimized lines
    testfastlines(ST7735_RED, ST7735_BLUE);
    delay(500);

    testdrawrects(ST7735_GREEN);
    delay(500);

    testfillrects(ST7735_YELLOW, ST7735_MAGENTA);
    delay(500);

    tft.fillScreen(ST7735_BLACK);
    testfillcircles(10, ST7735_BLUE);
    testdrawcircles(10, ST7735_WHITE);
    delay(500);

    testroundrects();
    delay(500);

    testtriangles();
    delay(500);

    mediabuttons();
    delay(500);

    Serial.println("done");
    delay(1000);
}
开发者ID:ubirch,项目名称:ubirch-thgs,代码行数:63,代码来源:tft.cpp

示例12: testdrawrects

void testdrawrects(uint16_t color) {
    tft.fillScreen(ST7735_BLACK);
    for (int16_t x=0; x < tft.width(); x+=6) {
        tft.drawRect(tft.width()/2 -x/2, tft.height()/2 -x/2 , x, x, color);
    }
}
开发者ID:ubirch,项目名称:ubirch-thgs,代码行数:6,代码来源:tft.cpp

示例13: setup

void setup(void) {
	Serial.begin(9600);
  
	// set buttonPin to INPUT and 
	// turn on internal pull up resistor 
	pinMode(BUTTJOY, INPUT);
	digitalWrite(BUTTJOY, HIGH);
  
	// establish interrupts on joystick button falling (when the button is initially pushed)
	// NOTE: BUTTJOY has been set up with a debounced circut
	attachInterrupt(BUTTJOY, buttonPress, FALLING);
  
	// Define the cursor radius to be 2 pixles
	cursor.r = CURSOR_RADIUS;
  
	// Read initial joystick position
	iniJoy.x = analogRead(HORZJOY);
	iniJoy.y = analogRead(VERTJOY);
  
	// If your TFT's plastic wrap has a Red Tab, use the following:
	tft.initR(INITR_REDTAB);   // initialize a ST7735R chip, red tab
	// If your TFT's plastic wrap has a Green Tab, use the following:
	//tft.initR(INITR_GREENTAB); // initialize a ST7735R chip, green tab

	#if DEBUG
	Serial.print("Initializing SD card...");
	#endif
	if (!SD.begin(SD_CS))
	{
		Serial.println("failed!");
		return;
	}
	#if DEBUG
	Serial.println("OK!");
	#endif
  
	// test out reading blocks from the SD card
	if (!card.init(SPI_HALF_SPEED, SD_CS)) {
		#if DEBUG
		Serial.println("Raw SD Initialization has failed");
		#endif
		while (1) {};  // Just wait, stuff exploded.
	}
	
	// Centers map on pre-selected coord
	m_map.x = m_map.x - tft.width()/2;
	m_map.y = m_map.y - tft.height()/2;
	
	// Places cursor in the center of the screen
	cursor.position.x = (int) tft.width()/2.;
	cursor.position.y = (int) tft.height()/2.;

	// clear to blue
	tft.fillScreen(tft.Color565(137, 207, 240));
	
	// Added for debug purposes
	#if DEBUG
	Serial.print("TFT Height: ");
	Serial.print( tft.height() );
	Serial.print(", TFT Width: ");
	Serial.println( tft.width() );
	#endif

	// Draw initial screen
	lcd_image_draw(&map_image, &tft, &m_map, &c_zero,  tft.width(), tft.height());
	// Draw Cursor on map
	drawCursor(&tft, &cursor);
}
开发者ID:wyattjoh,项目名称:RestaurantFinder,代码行数:68,代码来源:RestrauntFinder.cpp

示例14: loop

void loop() {
	// Calculate the position of the map that we are redrawing behind the old cursor
	map_redraw.x = cursor.position.x - cursor.r;
	map_redraw.y = cursor.position.y - cursor.r;
	
	// Calculate the source tile of the map that we are palcing
	map_tile.x = map_redraw.x + m_map.x;
	map_tile.y = map_redraw.y + m_map.y;
	
	// Ini redraw parameter, will be used to indicate that a redraw is required
	bool redraw = 0;
	
	// Analog read into joystick parameters
	JoyStick.x = analogRead(HORZJOY);
	JoyStick.y = analogRead(VERTJOY);
	
	// If there is a deviation from the initial readings, this indicates that there might be some redrawing required
	if(iniJoy.x != JoyStick.x || iniJoy.y != JoyStick.y)
	{
		moveJoystick(&JoyStick, &cursor, &tft, &redraw);
		moveCursorOff(&map_image, &tft, &cursor, &m_map, &redraw);
	}
	
	if(state)
	{
		// Determine the location of the cursor on the image file
		cursor_map.x = m_map.x + cursor.position.x;
		cursor_map.y = m_map.y + cursor.position.y;
		
		#if DEBUG
		Serial.print("Mapped (X,Y) Coord> (");
		Serial.print(cursor_map.x);
		Serial.print(",");
		Serial.print(cursor_map.y);
		Serial.println(")");
		
		Serial.print("Mapped (LON,LAT) Coord> (");
		Serial.print(x_to_lon(cursor_map.x));
		Serial.print(",");
		Serial.print(y_to_lat(cursor_map.y));
		Serial.println(")");
		#endif
		
		// Sets our page number to be zero
		uint16_t page = 1;
		
		// Prints loading screen to tft while loading and sorting get processed
		loadingScreen(&card, &tft);
		
		// Define RestDist structure for holding the distances from the different rest's
		// NOTE: As rest is an array, it does not need to be dereferenced
		RestDist rest[TOTAL_REST];
		
		// Load the restraunts from the SD card into the restdist array
		loadRest(&card, rest, &cursor_map, TOTAL_REST);
		
		// Use the comb sort algorithm to sort the list of restraunts
		comb_sort(rest, TOTAL_REST);
		
		// Print page 1 of the sorted list
		printRest(&card, &tft, rest, page);
		
		while(state)
		{
			// Reads the current position of the joystick
			JoyStick.y = analogRead(VERTJOY);
			
			/*
			* Checks whether the joystick has moved (selecting other restraunts from list) and prints the restraunt according the page passed, with added support for checking that you do not go over the amount of restraunts that were loaded.
			*/
			if(JoyStick.y > 800 && page != 1)
			{
				printRest(&card, &tft, rest, --page);
			}
			else if(JoyStick.y < 250 && (page - 1)*PAGESIZE + PAGESIZE < TOTAL_REST)
			{
				printRest(&card, &tft, rest, ++page);
			}
		}
		
		// Redraw the map
		lcd_image_draw(&map_image, &tft, &m_map, &c_zero, tft.width(), tft.height());
		
		// Redraw the cursor in its old position
		drawCursor(&tft, &cursor);
		
		// Set the redraw parameter to be zero
		redraw = 0;
	}
	
	/*
	*	This will redraw the map over the old cursor, and redraw the cursor in the new position if the cursor has been indicated as moved.
	*/
	
	if(redraw == 1)
	{
		// Included for DEBUG purposes
		#if DEBUG
		// Determine the location of the cursor on the image file
		cursor_map.x = m_map.x + cursor.position.x;
//.........这里部分代码省略.........
开发者ID:wyattjoh,项目名称:RestaurantFinder,代码行数:101,代码来源:RestrauntFinder.cpp


注:本文中的Adafruit_ST7735::width方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。