Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions build.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -168,22 +168,22 @@ package() {
ls -tr $LIB/* 2>/dev/null | tail -1 | grep '\.a' > /dev/null
A=$?

echo Buliding source for dynamic library for sake of size and compatibility
echo Building source for dynamic library for sake of size and compatibility
DYNAMIC="-fPIC"
[ $A = 0 ] && clean objects
build

echo Packagiang lib$LIBNAME.so
echo Packaging lib$LIBNAME.so
OBJECTS=$(find $OBJ -type f)
${CC} -shared -Wl,-soname,lib$LIBNAME.so -o $LIB/lib$LIBNAME.so.$VERSION ${OBJECTS} || die
clean objects
fi

echo Buliding source for static library for sake of runtime speed
echo Building source for static library for sake of runtime speed
DYNAMIC=""
build

echo Packagiang lib$LIBNAME.a
echo Packaging lib$LIBNAME.a
OBJECTS=$(find $OBJ -type f)
ar rcs $LIB/lib$LIBNAME.a $OBJECTS || die
ranlib $LIB/lib$LIBNAME.a || die
Expand Down
42 changes: 29 additions & 13 deletions example/demo1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Wade Ryan

using namespace udd;

DisplayConfigruation d1Config;
DisplayConfiguration d1Config;

DisplayST7789R d1 = DisplayST7789R();

Expand All @@ -41,7 +41,7 @@ unsigned long long currentTimeMillis() {
}


void drawSine(Image image, float offset, float speed, int maxX, int maxY, float waveHeight, Color color, int width) {
void drawSine(Image &image, float offset, float speed, int maxX, int maxY, float waveHeight, Color color, int width) {
bool first = true;;
int lx = -1, ly = -1;
double vx = 0;
Expand All @@ -62,7 +62,7 @@ void drawSine(Image image, float offset, float speed, int maxX, int maxY, float
}


bool demoSineWave(int frameCount, long long start, Image image) {
bool demoSineWave(int frameCount, long long start, Image &image) {
long long now = currentTimeMillis();
float refVoltage = 5;

Expand Down Expand Up @@ -148,6 +148,29 @@ void rotationDemo() {

}

void imageRotationDemo(Image &img) {
Image srcImg = img.scale(0.75f, 0.75f, BILINEAR);
for (int deg = 0; deg < 360; deg += 5) {
printf("Rotate: %d degrees CW\n", deg); fflush(stdout);
d1.showImage(srcImg.rotate(deg, DEGREES), DEGREE_270);
}
for (int deg = 0; deg > -360; deg -= 5) {
printf("Rotate: %d degrees CCW\n", deg); fflush(stdout);
d1.showImage(srcImg.rotate(deg, DEGREES), DEGREE_270);
}
}

void imageScalingDemo(Image &img) {
for (int i = 100; i > 0; i -= 10) {
float scale = i / 100.0f;
d1.showImage(img.scale(scale, scale, BILINEAR), DEGREE_270);
}
for (int i = 20; i <= 200; i += 10) {
float scale = i / 100.0f;
d1.showImage(img.scale(scale, scale, BILINEAR), DEGREE_270);
}
}

void display1Demo() {
printf("demo1\n"); fflush(stdout);

Expand All @@ -170,8 +193,8 @@ void display1Demo() {
delay(solidsDelay);
d1.clearScreen(BLACK);

d1.showImage(bmp, DEGREE_270);
delay(2000);
imageRotationDemo(bmp);
imageScalingDemo(bmp);

rotationDemo();
delay(4000);
Expand All @@ -189,6 +212,7 @@ void configureDisplay1() {
d1Config.width = 240;
d1Config.height = 320;
d1Config.spiSpeed = spiSpeed;
d1Config.spiMode = 0;

d1Config.CS = 21;
d1Config.DC = 22;
Expand All @@ -215,14 +239,6 @@ int main(int argc, char **argv)
digitalWrite(10, HIGH);
digitalWrite(11, HIGH);

int demos = 3;
pthread_t threads[demos];
char message[demos][256];

for (int i = 0; i < demos; ++i) {
sprintf(message[i], "demo thread %d", i);
}

configureDisplay1();

printf("press control-c to quit\n");
Expand Down
8 changes: 4 additions & 4 deletions example/demo2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ Wade Ryan

using namespace udd;

DisplayConfigruation d1Config;
DisplayConfigruation d2Config;
DisplayConfiguration d1Config;
DisplayConfiguration d2Config;

DisplayST7789R d1 = DisplayST7789R();
DisplayST7735R d2 = DisplayST7735R();
Expand All @@ -42,7 +42,7 @@ unsigned long long currentTimeMillis() {
}


void drawSine(Image image, float offset, float speed, int maxX, int maxY, float waveHeight, Color color, int width) {
void drawSine(Image &image, float offset, float speed, int maxX, int maxY, float waveHeight, Color color, int width) {
bool first = true;;
int lx = -1, ly = -1;
double vx = 0;
Expand All @@ -63,7 +63,7 @@ void drawSine(Image image, float offset, float speed, int maxX, int maxY, float
}


bool demoSineWave(int frameCount, long long start, Image image) {
bool demoSineWave(int frameCount, long long start, Image &image) {
long long now = currentTimeMillis();
float refVoltage = 5;

Expand Down
2 changes: 1 addition & 1 deletion example/neopixel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ I'm using an 8x8 matrix

using namespace udd;

DisplayConfigruation d1Config;
DisplayConfiguration d1Config;

DisplayNeoPixel d1 = DisplayNeoPixel();

Expand Down
8 changes: 4 additions & 4 deletions example/neopixel2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ Here is the layout:

using namespace udd;

DisplayConfigruation d1Config;
DisplayConfiguration d1Config;

DisplayNeoPixel d1 = DisplayNeoPixel();

Expand Down Expand Up @@ -73,7 +73,7 @@ unsigned long long currentTimeMillis() {
}


void drawSine(Image image, float offset, float speed, int maxX, int maxY, float waveHeight, Color color, int width) {
void drawSine(Image &image, float offset, float speed, int maxX, int maxY, float waveHeight, Color color, int width) {
bool first = true;
int lx = -1, ly = -1;
double vx = 0;
Expand All @@ -94,7 +94,7 @@ void drawSine(Image image, float offset, float speed, int maxX, int maxY, float
}


bool demoSineWave(int frameCount, long long start, Image image) {
bool demoSineWave(int frameCount, long long start, Image &image) {
long long now = currentTimeMillis();
float refVoltage = 5;

Expand Down Expand Up @@ -394,7 +394,7 @@ void* setBrightness(void *) {

int startTime=currentTimeMillis();
for (int i=0;i<4;++i) {
float v=readVoltage(handle, i, 0);
float v=readVoltage(handle);
if (v>6) {
v=0;
}
Expand Down
6 changes: 3 additions & 3 deletions example/wsePaperV2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Wade Ryan

using namespace udd;

DisplayConfigruation d1Config;
DisplayConfiguration d1Config;

DisplayWS_ePaper_v2 d1 = DisplayWS_ePaper_v2();

Expand All @@ -39,7 +39,7 @@ unsigned long long currentTimeMillis() {
}


void drawSine(Image image, float offset, float speed, int maxX, int maxY, float waveHeight, Color color, int width) {
void drawSine(Image &image, float offset, float speed, int maxX, int maxY, float waveHeight, Color color, int width) {
bool first = true;;
int lx = -1, ly = -1;
double vx = 0;
Expand All @@ -60,7 +60,7 @@ void drawSine(Image image, float offset, float speed, int maxX, int maxY, float
}


bool demoSineWave(int frameCount, long long start, Image image) {
bool demoSineWave(int frameCount, long long start, Image &image) {
long long now = currentTimeMillis();
float refVoltage = 5;

Expand Down
114 changes: 44 additions & 70 deletions src/controller/Color.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,22 @@ Color::Color() {
color.opacity = 255;
}


Color::Color(ColorType color) {
this->color.red = color.red;
this->color.green = color.green;
this->color.blue = color.blue;
this->color.opacity = color.opacity;
memcpy(&this->color, &color, sizeof(ColorType));
}


Color::Color(_byte red, _byte green, _byte blue) {
color.red = red;
color.green = green;
color.blue = blue;
color.opacity = 255;
setColor(red, green, blue, 255);
}

Color::Color(_byte red, _byte green, _byte blue, _byte opacity) {
setColor(red, green, blue, opacity);
}

Color::Color(uint32_t colorRGB24) {
setRGB24(colorRGB24);
}

Color::Color(const char* hexbytes) {
char buf[3];
int intensity;
Expand Down Expand Up @@ -68,63 +68,37 @@ Color::Color(const char* hexbytes) {
}
}

bool Color::equals(Color otherColor) {
if (this->color.blue != otherColor.color.blue) {
return false;
}
if (this->color.red!= otherColor.color.red) {
return false;
}
if (this->color.green != otherColor.color.green) {
return false;
}
return true;
bool Color::equals(const Color &otherColor) const {
return equals(otherColor.color);
}

bool Color::equals(ColorType otherColor) {
if (this->color.blue != otherColor.blue) {
bool Color::equals(const ColorType &otherColor) const {
if (color.blue != otherColor.blue) {
return false;
}
if (this->color.red != otherColor.red) {
if (color.red != otherColor.red) {
return false;
}
if (this->color.green != otherColor.green) {
if (color.green != otherColor.green) {
return false;
}
return true;
}

bool Color::equals(ColorType *otherColor) {
if (this->color.blue != otherColor->blue) {
return false;
}
if (this->color.red != otherColor->red) {
return false;
}
if (this->color.green != otherColor->green) {
return false;
}
return true;
}


Color::Color(_byte red, _byte green, _byte blue, _byte opacity) {
color.red = red;
color.green = green;
color.blue = blue;
color.opacity = opacity;
}

ColorType Color::toType() {
return color;
inline void Color::setColor(_byte red, _byte green, _byte blue, _byte opacity) {
color.red = red;
color.green = green;
color.blue = blue;
color.opacity = opacity;
}


int32_t Color::rgb24() {
return (color.green<<16)+(color.red<<8)+(color.blue);
inline void Color::setRGB24(uint32_t colorRGB24) {
color.red = (_byte)(colorRGB24 & 0xFF);
color.green = (_byte)((colorRGB24 & 0xFF00) >> 8);
color.blue = (_byte)((colorRGB24 & 0xFF0000) >> 16);
color.opacity = (_byte)((colorRGB24 & 0xFF000000) >> 24);
}


Color::Color(int clr) {
color.opacity = 255;

Expand All @@ -150,7 +124,7 @@ Color::Color(int clr) {
}


void Color::print() {
void Color::print() const {

printf("color::print: 0x%02x%02x%02x\n", this->color.red, this->color.blue,this->color.green);
printf("color::print: 0x%02x%02x%02x\n", color.red, color.blue, color.green);
Expand All @@ -164,26 +138,26 @@ void Color::print() {


// Original 8
Color BLACK = Color(0, 0, 0);
Color RED = Color(255, 0, 0);
Color GREEN = Color(0, 255, 0);
Color BLUE = Color(0, 0, 255);
Color YELLOW = Color(255, 255, 0);
Color MAGENTA = Color(255, 0, 255);
Color CYAN = Color(0, 255, 255);
Color WHITE = Color(255, 255, 255);
const Color BLACK = Color(0, 0, 0);
const Color RED = Color(255, 0, 0);
const Color GREEN = Color(0, 255, 0);
const Color BLUE = Color(0, 0, 255);
const Color YELLOW = Color(255, 255, 0);
const Color MAGENTA = Color(255, 0, 255);
const Color CYAN = Color(0, 255, 255);
const Color WHITE = Color(255, 255, 255);

// extended colors
Color GRAY = Color("#808080");
Color BROWN = Color(165, 42, 42);
Color ORANGE = Color(255, 128, 0);
const Color GRAY = Color("#808080");
const Color BROWN = Color(165, 42, 42);
const Color ORANGE = Color(255, 128, 0);

Color DARK_RED = Color(128, 0, 0);
Color DARK_GREEN = Color(0, 128, 0);
Color DARK_BLUE = Color(0, 0, 128);
const Color DARK_RED = Color(128, 0, 0);
const Color DARK_GREEN = Color(0, 128, 0);
const Color DARK_BLUE = Color(0, 0, 128);


Color LIGHT_BLUE = Color(204, 228, 255);
Color LIGHT_GRAY = Color("#E0E0E0");
const Color LIGHT_BLUE = Color(204, 228, 255);
const Color LIGHT_GRAY = Color("#E0E0E0");

Color DARK_GRAY_BLUE = Color("003366");
const Color DARK_GRAY_BLUE = Color("003366");
Loading