Skip to content
Snippets Groups Projects
Commit 27e014c3 authored by Jan Grewe's avatar Jan Grewe
Browse files

add color aging decay

parent af318014
Branches
No related tags found
No related merge requests found
...@@ -18,7 +18,8 @@ rgb24 gameColor = {colorR, colorG, colorB}; ...@@ -18,7 +18,8 @@ rgb24 gameColor = {colorR, colorG, colorB};
rgb24 textColor = {255, 255, 255}; rgb24 textColor = {255, 255, 255};
rgb24 pixelColor = {255, 255, 255}; rgb24 pixelColor = {255, 255, 255};
int colorMode = 2; // 0 = static, 1 = RGB, 2 = dynamic int colorMode = 2; // 0 = static, 1 = simple RGB, 2 = dynamic aging (decay)
int colorDecay = 5;
SMARTMATRIX_ALLOCATE_BUFFERS(matrix, kMatrixWidth, kMatrixHeight, kRefreshDepth, kDmaBufferRows, kPanelType, kMatrixOptions); SMARTMATRIX_ALLOCATE_BUFFERS(matrix, kMatrixWidth, kMatrixHeight, kRefreshDepth, kDmaBufferRows, kPanelType, kMatrixOptions);
SMARTMATRIX_ALLOCATE_BACKGROUND_LAYER(backgroundLayer, kMatrixWidth, kMatrixHeight, COLOR_DEPTH, kBackgroundLayerOptions); SMARTMATRIX_ALLOCATE_BACKGROUND_LAYER(backgroundLayer, kMatrixWidth, kMatrixHeight, COLOR_DEPTH, kBackgroundLayerOptions);
...@@ -58,7 +59,7 @@ void displayLoop() ...@@ -58,7 +59,7 @@ void displayLoop()
} }
else if (colorMode == 2) else if (colorMode == 2)
{ {
ageColor(age); ageColor(age, colorDecay);
} }
backgroundLayer.drawPixel(row, col, pixelColor); backgroundLayer.drawPixel(row, col, pixelColor);
} }
...@@ -73,27 +74,27 @@ void displayLoop() ...@@ -73,27 +74,27 @@ void displayLoop()
} }
} }
void ageColor(int age) void ageColor(int age, int decay)
{ {
if (age <= 10) if (age <= 2 * decay)
{ {
pixelColor.red = 255; pixelColor.red = 255;
pixelColor.green = (uint8_t)map(age, 1, 10, 0, 255); // 1 -> 10 = 0 -> 255 pixelColor.green = (uint8_t)map(age, 1, 2 * decay, 0, 255); // 1 -> 10 = 0 -> 255
pixelColor.blue = 0; pixelColor.blue = 0;
} }
else if (age <= 20) else if (age <= (2 * decay) * 2)
{ {
pixelColor.red = (uint8_t)map(age, 11, 20, 255, 0); // 11 -> 20 = 255 -> 0 pixelColor.red = (uint8_t)map(age, 11, 20, 255, 0); // 11 -> 20 = 255 -> 0
pixelColor.green = 255; pixelColor.green = 255;
pixelColor.blue = 0; pixelColor.blue = 0;
} }
else if (age <= 30) else if (age <= (2 * decay) * 3)
{ {
pixelColor.red = 0; pixelColor.red = 0;
pixelColor.green = 255; pixelColor.green = 255;
pixelColor.blue = (uint8_t)map(age, 21, 30, 0, 255); // 21 -> 31 = 0 -> 255 pixelColor.blue = (uint8_t)map(age, 21, 30, 0, 255); // 21 -> 31 = 0 -> 255
} }
else if (age <= 40) else if (age <= (2 * decay) * 4)
{ {
pixelColor.red = 0; pixelColor.red = 0;
pixelColor.green = (uint8_t)map(age, 31, 40, 0, 255); // 31 -> 41 = 255 -> 0 pixelColor.green = (uint8_t)map(age, 31, 40, 0, 255); // 31 -> 41 = 255 -> 0
......
...@@ -14,7 +14,7 @@ extern uint8_t colorB; ...@@ -14,7 +14,7 @@ extern uint8_t colorB;
void setupDisplay(); void setupDisplay();
void displayLoop(); void displayLoop();
void ageColor(int age); void ageColor(int age, int decay);
void showEndScreen(int ticks); void showEndScreen(int ticks);
void showMessage(char* msg); void showMessage(char* msg);
void displayBrightness(int brightness); void displayBrightness(int brightness);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment