Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
MiniMatrixRPi
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
MiniMatrixTeam
MiniMatrixRPi
Commits
4b442b7e
Commit
4b442b7e
authored
Feb 12, 2019
by
lmaresz
Browse files
Options
Downloads
Patches
Plain Diff
Pixel és Frame osztályok hozzáadva
parent
db9cbe9e
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
spi_test.cpp
+73
-24
73 additions, 24 deletions
spi_test.cpp
with
73 additions
and
24 deletions
spi_test.cpp
+
73
−
24
View file @
4b442b7e
...
...
@@ -2,39 +2,88 @@
#include
<iostream>
#include
<unistd.h>
#include
<cstring>
using
namespace
std
;
const
uint8_t
WIDTH
=
40
;
const
uint8_t
HEIGHT
=
13
;
#include
<vector>
class
Pixel
{
public:
Pixel
(
uint8_t
r
=
0
,
uint8_t
g
=
0
,
uint8_t
b
=
0
)
:
r
(
r
),
g
(
g
),
b
(
b
)
{}
Pixel
(
uint8_t
red
=
0
,
uint8_t
green
=
0
,
uint8_t
blue
=
0
);
uint8_t
operator
[](
unsigned
index
);
private:
uint8_t
r
;
uint8_t
g
;
uint8_t
b
;
uint8_t
m_red
;
uint8_t
m_green
;
uint8_t
m_blue
;
};
class
Frame
{
private:
uint16_t
duration
;
Pixel
data
[
HEIGHT
][
WIDTH
];
public:
Frame
(
Pixel
data
[
HEIGHT
][
WIDTH
],
uint16_t
duration
)
{}
// : data(data), duration(duration) {}
uint8_t
*
to_spi_data
();
Frame
(
unsigned
height
=
64
,
unsigned
width
=
13
);
~
Frame
();
std
::
vector
<
uint16_t
>
get_raw_data
();
void
transform
();
private:
unsigned
m_height
;
unsigned
m_width
;
Pixel
**
m_data
;
std
::
vector
<
uint16_t
>
m_raw_data
;
};
uint8_t
*
to_spi_data
()
{
uint8_t
*
spi_data
=
new
uint8_t
[
24
*
WIDTH
*
2
];
for
(
int
x
=
0
;
x
<
WIDTH
;
x
++
)
{
for
(
int
y
=
0
;
y
<
HEIGHT
;
y
++
)
{
0
;
Frame
::
Frame
(
unsigned
height
,
unsigned
width
)
:
m_height
(
height
),
m_width
(
width
)
{
m_data
=
new
Pixel
*
[
height
];
for
(
int
i
=
0
;
i
<
height
;
i
++
)
{
m_data
[
i
]
=
new
Pixel
[
width
];
}
}
Frame
::~
Frame
()
{
for
(
int
i
=
0
;
i
<
m_height
;
i
++
)
{
delete
[]
m_data
[
i
];
}
delete
[]
m_data
;
}
std
::
vector
<
uint16_t
>
Frame
::
get_raw_data
()
{
return
m_raw_data
;
}
void
Frame
::
transform
()
{
for
(
int
x
=
0
;
x
<
m_width
;
x
++
)
{
for
(
int
i
=
0
;
i
<
24
;
i
++
)
{
uint16_t
temp_data
;
for
(
int
y
=
0
;
y
<
m_height
;
y
++
)
{
temp_data
+=
m_data
[
y
][
x
][
i
]
>>
y
;
}
m_raw_data
.
push_back
(
temp_data
);
temp_data
=
0
;
}
}
}
Pixel
::
Pixel
(
uint8_t
red
,
uint8_t
green
,
uint8_t
blue
)
:
m_red
(
red
),
m_green
(
green
),
m_blue
(
blue
)
{
}
uint8_t
Pixel
::
operator
[](
unsigned
index
)
{
if
(
index
<
8
)
{
return
m_red
>>
index
;
}
else
if
(
index
<
16
)
{
return
m_green
>>
(
index
-
8
);
}
else
if
(
index
<
24
)
{
return
m_blue
>>
(
index
-
16
);
}
}
using
namespace
std
;
const
uint8_t
WIDTH
=
40
;
const
uint8_t
HEIGHT
=
13
;
uint16_t
dataRed
[
40
*
24
]
=
{
0
};
...
...
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