Prechádzať zdrojové kódy

Fix merge conflict.

Tony DiCola 11 rokov pred
rodič
commit
bf5ab389b5
3 zmenil súbory, kde vykonal 33 pridanie a 0 odobranie
  1. 18 0
      Adafruit_GFX.cpp
  2. 2 0
      Adafruit_GFX.h
  3. 13 0
      README.txt

+ 18 - 0
Adafruit_GFX.cpp

@@ -385,6 +385,24 @@ void Adafruit_GFX::drawBitmap(int16_t x, int16_t y,
   }
 }
 
+//Draw XBitMap Files (*.xbm), exported from GIMP,
+//Usage: Export from GIMP to *.xbm, rename *.xbm to *.c and open in editor.
+//C Array can be directly used with this function
+void Adafruit_GFX::drawXBitmap(int16_t x, int16_t y,
+                              const uint8_t *bitmap, int16_t w, int16_t h,
+                              uint16_t color) {
+  
+  int16_t i, j, byteWidth = (w + 7) / 8;
+  
+  for(j=0; j<h; j++) {
+    for(i=0; i<w; i++ ) {
+      if(pgm_read_byte(bitmap + j * byteWidth + i / 8) & (1 << (i % 8))) {
+        drawPixel(x+i, y+j, color);
+      }
+    }
+  }
+}
+
 #if ARDUINO >= 100
 size_t Adafruit_GFX::write(uint8_t c) {
 #else

+ 2 - 0
Adafruit_GFX.h

@@ -50,6 +50,8 @@ class Adafruit_GFX : public Print {
       int16_t w, int16_t h, uint16_t color),
     drawBitmap(int16_t x, int16_t y, const uint8_t *bitmap,
       int16_t w, int16_t h, uint16_t color, uint16_t bg),
+    drawXBitmap(int16_t x, int16_t y, const uint8_t *bitmap, 
+      int16_t w, int16_t h, uint16_t color),
     drawChar(int16_t x, int16_t y, unsigned char c, uint16_t color,
       uint16_t bg, uint8_t size),
     setCursor(int16_t x, int16_t y),

+ 13 - 0
README.txt

@@ -1,3 +1,16 @@
+Current additions:
+
+- XBitMap support (*.xbm)
+  Use exported xbm files from GIMP with bitmap data directly in your sources.
+  (fits perfectly with SSD1306 library from Adafruit)
+  New function: Adafruit_GFX::drawXBitmap()
+  Usage: Export bitmap with GIMP as *.xbm file,
+         Rename the *.xbm to *.c,
+         Open file in editor,
+         Use C array directly in your sources.
+
+----------------------------------
+
 This is the core graphics library for all our displays, providing a common set of graphics primitives (points, lines, circles, etc.).  It needs to be paired with a hardware-specific library for each display device we carry (to handle the lower-level functions).
 
 Adafruit invests time and resources providing this open source code, please support Adafruit and open-source hardware by purchasing products from Adafruit!