Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Tweaks for Adafruit_GFX

  • Loading branch information...
commit 0a75570597d3d0aa0852b8f75da847310904c0ad 1 parent 3f7ad19
@PaintYourDragon PaintYourDragon authored
Showing with 21 additions and 23 deletions.
  1. +2 −2 Adafruit_SSD1331.cpp
  2. +4 −6 Adafruit_SSD1331.h
  3. +15 −15 examples/test/test.pde
View
4 Adafruit_SSD1331.cpp
@@ -233,9 +233,9 @@ void Adafruit_SSD1331::drawLine(int16_t x0, int16_t y0, int16_t x1, int16_t y1,
delay(SSD1331_DELAYS_HWLINE);
}
-void Adafruit_SSD1331::drawPixel(uint16_t x, uint16_t y, uint16_t color)
+void Adafruit_SSD1331::drawPixel(int16_t x, int16_t y, uint16_t color)
{
- if ((x >= width()) || (y >= height())) return;
+ if ((x < 0) || (x >= width()) || (y < 0) || (y >= height())) return;
// check rotation, move pixel around if necessary
switch (getRotation()) {
View
10 Adafruit_SSD1331.h
@@ -14,8 +14,6 @@
BSD license, all text above must be included in any redistribution
****************************************************/
-#define swap(a, b) { uint16_t t = a; a = b; b = t; }
-
#if defined(ARDUINO) && ARDUINO >= 100
#include "Arduino.h"
#else
@@ -72,9 +70,9 @@ class Adafruit_SSD1331 : public virtual Adafruit_GFX {
uint16_t Color565(uint8_t r, uint8_t g, uint8_t b);
// drawing primitives!
- void drawPixel(uint16_t x, uint16_t y, uint16_t color);
+ void drawPixel(int16_t x, int16_t y, uint16_t color);
void drawLine(int16_t x0, int16_t y0, int16_t x1, int16_t y1, uint16_t color);
- //void fillRect(uint16_t x, uint16_t y, uint16_t w, uint16_t h, uint16_t fillcolor);
+ //void fillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t fillcolor);
void pushColor(uint16_t c);
// commands
@@ -89,8 +87,8 @@ class Adafruit_SSD1331 : public virtual Adafruit_GFX {
void writeData(uint8_t d);
void writeCommand(uint8_t c);
- static const uint16_t TFTWIDTH = 96;
- static const uint16_t TFTHEIGHT = 64;
+ static const int16_t TFTWIDTH = 96;
+ static const int16_t TFTHEIGHT = 64;
void writeData_unsafe(uint16_t d);
View
30 examples/test/test.pde
@@ -113,34 +113,34 @@ void loop() {
void testlines(uint16_t color) {
display.fillScreen(BLACK);
- for (uint16_t x=0; x < display.width()-1; x+=6) {
+ for (int16_t x=0; x < display.width()-1; x+=6) {
display.drawLine(0, 0, x, display.height()-1, color);
}
- for (uint16_t y=0; y < display.height()-1; y+=6) {
+ for (int16_t y=0; y < display.height()-1; y+=6) {
display.drawLine(0, 0, display.width()-1, y, color);
}
display.fillScreen(BLACK);
- for (uint16_t x=0; x < display.width()-1; x+=6) {
+ for (int16_t x=0; x < display.width()-1; x+=6) {
display.drawLine(display.width()-1, 0, x, display.height()-1, color);
}
- for (uint16_t y=0; y < display.height()-1; y+=6) {
+ for (int16_t y=0; y < display.height()-1; y+=6) {
display.drawLine(display.width()-1, 0, 0, y, color);
}
display.fillScreen(BLACK);
- for (uint16_t x=0; x < display.width()-1; x+=6) {
+ for (int16_t x=0; x < display.width()-1; x+=6) {
display.drawLine(0, display.height()-1, x, 0, color);
}
- for (uint16_t y=0; y < display.height()-1; y+=6) {
+ for (int16_t y=0; y < display.height()-1; y+=6) {
display.drawLine(0, display.height()-1, display.width()-1, y, color);
}
display.fillScreen(BLACK);
- for (uint16_t x=0; x < display.width()-1; x+=6) {
+ for (int16_t x=0; x < display.width()-1; x+=6) {
display.drawLine(display.width()-1, display.height()-1, x, 0, color);
}
- for (uint16_t y=0; y < display.height()-1; y+=6) {
+ for (int16_t y=0; y < display.height()-1; y+=6) {
display.drawLine(display.width()-1, display.height()-1, 0, y, color);
}
@@ -161,24 +161,24 @@ void testdrawtext(char *text, uint16_t color) {
void testfastlines(uint16_t color1, uint16_t color2) {
display.fillScreen(BLACK);
- for (uint16_t y=0; y < display.height()-1; y+=5) {
+ for (int16_t y=0; y < display.height()-1; y+=5) {
display.drawFastHLine(0, y, display.width()-1, color1);
}
- for (uint16_t x=0; x < display.width()-1; x+=5) {
+ for (int16_t x=0; x < display.width()-1; x+=5) {
display.drawFastVLine(x, 0, display.height()-1, color2);
}
}
void testdrawrects(uint16_t color) {
display.fillScreen(BLACK);
- for (uint16_t x=0; x < display.height()-1; x+=6) {
+ for (int16_t x=0; x < display.height()-1; x+=6) {
display.drawRect((display.width()-1)/2 -x/2, (display.height()-1)/2 -x/2 , x, x, color);
}
}
void testfillrects(uint16_t color1, uint16_t color2) {
display.fillScreen(BLACK);
- for (uint16_t x=display.height()-1; x > 6; x-=6) {
+ for (int16_t x=display.height()-1; x > 6; x-=6) {
display.fillRect((display.width()-1)/2 -x/2, (display.height()-1)/2 -x/2 , x, x, color1);
display.drawRect((display.width()-1)/2 -x/2, (display.height()-1)/2 -x/2 , x, x, color2);
}
@@ -193,8 +193,8 @@ void testfillcircles(uint8_t radius, uint16_t color) {
}
void testdrawcircles(uint8_t radius, uint16_t color) {
- for (uint8_t x=0; x < display.width()-1+radius; x+=radius*2) {
- for (uint8_t y=0; y < display.height()-1+radius; y+=radius*2) {
+ for (int16_t x=0; x < display.width()-1+radius; x+=radius*2) {
+ for (int16_t y=0; y < display.height()-1+radius; y+=radius*2) {
display.drawCircle(x, y, radius, color);
}
}
@@ -317,4 +317,4 @@ void lcdTestPattern(void)
else {display.writeData(BLACK>>8);display.writeData(BLACK);}
}
}
-}
+}
Please sign in to comment.
Something went wrong with that request. Please try again.