Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
Matrix of Life
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jan Grewe
Matrix of Life
Commits
27e014c3
Commit
27e014c3
authored
2 years ago
by
Jan Grewe
Browse files
Options
Downloads
Patches
Plain Diff
add color aging decay
parent
af318014
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/display.cpp
+9
-8
9 additions, 8 deletions
src/display.cpp
src/display.h
+1
-1
1 addition, 1 deletion
src/display.h
with
10 additions
and
9 deletions
src/display.cpp
+
9
−
8
View file @
27e014c3
...
@@ -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
<=
2
0
)
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
<=
3
0
)
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
<=
4
0
)
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
...
...
This diff is collapsed.
Click to expand it.
src/display.h
+
1
−
1
View file @
27e014c3
...
@@ -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
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment