Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
M
marlin-anet-a8
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
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD 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
Jonas Leder
marlin-anet-a8
Commits
c99773ba
Commit
c99773ba
authored
Mar 7, 2020
by
Scott Lahteine
Browse files
Options
Downloads
Patches
Plain Diff
Max7219 suspend/resume
parent
8ff25a95
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
Marlin/src/feature/Max7219_Debug_LEDs.cpp
+16
-5
16 additions, 5 deletions
Marlin/src/feature/Max7219_Debug_LEDs.cpp
Marlin/src/feature/Max7219_Debug_LEDs.h
+7
-0
7 additions, 0 deletions
Marlin/src/feature/Max7219_Debug_LEDs.h
with
23 additions
and
5 deletions
Marlin/src/feature/Max7219_Debug_LEDs.cpp
+
16
−
5
View file @
c99773ba
...
...
@@ -73,6 +73,7 @@
Max7219
max7219
;
uint8_t
Max7219
::
led_line
[
MAX7219_LINES
];
// = { 0 };
uint8_t
Max7219
::
suspended
;
// = 0;
#define LINE_REG(Q) (max7219_reg_digit0 + ((Q) & 0x7))
...
...
@@ -212,6 +213,7 @@ void Max7219::send(const uint8_t reg, const uint8_t data) {
// Send out a single native row of bits to just one unit
void
Max7219
::
refresh_unit_line
(
const
uint8_t
line
)
{
if
(
suspended
)
return
;
#if MAX7219_NUMBER_UNITS == 1
send
(
LINE_REG
(
line
),
led_line
[
line
]);
#else
...
...
@@ -223,6 +225,7 @@ void Max7219::refresh_unit_line(const uint8_t line) {
// Send out a single native row of bits to all units
void
Max7219
::
refresh_line
(
const
uint8_t
line
)
{
if
(
suspended
)
return
;
#if MAX7219_NUMBER_UNITS == 1
refresh_unit_line
(
line
);
#else
...
...
@@ -241,9 +244,9 @@ void Max7219::set(const uint8_t line, const uint8_t bits) {
// Draw an integer with optional leading zeros and optional decimal point
void
Max7219
::
print
(
const
uint8_t
start
,
int16_t
value
,
uint8_t
size
,
const
bool
leadzero
=
false
,
bool
dec
=
false
)
{
if
(
suspended
)
return
;
constexpr
uint8_t
led_numeral
[
10
]
=
{
0x7E
,
0x60
,
0x6D
,
0x79
,
0x63
,
0x5B
,
0x5F
,
0x70
,
0x7F
,
0x7A
},
led_decimal
=
0x80
,
led_minus
=
0x01
;
bool
blank
=
false
,
neg
=
value
<
0
;
if
(
neg
)
value
*=
-
1
;
while
(
size
--
)
{
...
...
@@ -295,6 +298,7 @@ void Max7219::led_toggle(const uint8_t x, const uint8_t y) {
}
void
Max7219
::
send_row
(
const
uint8_t
row
)
{
if
(
suspended
)
return
;
#if _ROT == 0 || _ROT == 180 // Native Lines are horizontal too
#if MAX7219_X_LEDS <= 8
refresh_unit_line
(
LED_IND
(
0
,
row
));
// A single unit line
...
...
@@ -308,6 +312,7 @@ void Max7219::send_row(const uint8_t row) {
}
void
Max7219
::
send_column
(
const
uint8_t
col
)
{
if
(
suspended
)
return
;
#if _ROT == 90 || _ROT == 270 // Native Lines are vertical too
#if MAX7219_Y_LEDS <= 8
refresh_unit_line
(
LED_IND
(
col
,
0
));
// A single unit line
...
...
@@ -344,8 +349,8 @@ void Max7219::clear_column(const uint8_t col) {
/**
* Plot the low order bits of val to the specified row of the matrix.
* With 4 Max7219 units in the chain, it's possible to set 32 bits at
once with
* one call to the function (if rotated 90° or
18
0°).
* With 4 Max7219 units in the chain, it's possible to set 32 bits at
* on
ce with a singl
e call to the function (if rotated 90° or
27
0°).
*/
void
Max7219
::
set_row
(
const
uint8_t
row
,
const
uint32_t
val
)
{
if
(
row
>=
MAX7219_Y_LEDS
)
return
error
(
PSTR
(
"set_row"
),
row
);
...
...
@@ -359,8 +364,8 @@ void Max7219::set_row(const uint8_t row, const uint32_t val) {
/**
* Plot the low order bits of val to the specified column of the matrix.
* With 4 Max7219 units in the chain, it's possible to set 32 bits at
once with
* one call to the function (if rotated
9
0° or 180°).
* With 4 Max7219 units in the chain, it's possible to set 32 bits at
* on
ce with a singl
e call to the function (if rotated 0° or 180°).
*/
void
Max7219
::
set_column
(
const
uint8_t
col
,
const
uint32_t
val
)
{
if
(
col
>=
MAX7219_X_LEDS
)
return
error
(
PSTR
(
"set_column"
),
col
);
...
...
@@ -692,6 +697,12 @@ void Max7219::idle_tasks() {
last_depth
=
current_depth
;
}
#endif
// After resume() automatically do a refresh()
if
(
suspended
==
0x80
)
{
suspended
=
0
;
refresh
();
}
}
#endif // MAX7219_DEBUG
This diff is collapsed.
Click to expand it.
Marlin/src/feature/Max7219_Debug_LEDs.h
+
7
−
0
View file @
c99773ba
...
...
@@ -88,6 +88,12 @@ public:
// Refresh all units
static
inline
void
refresh
()
{
for
(
uint8_t
i
=
0
;
i
<
8
;
i
++
)
refresh_line
(
i
);
}
// Suspend / resume updates to the LED unit
// Use these methods to speed up multiple changes
// or to apply updates from interrupt context.
static
inline
void
suspend
()
{
suspended
++
;
}
static
inline
void
resume
()
{
suspended
--
;
suspended
|=
0x80
;
}
// Update a single native line on all units
static
void
refresh_line
(
const
uint8_t
line
);
...
...
@@ -126,6 +132,7 @@ public:
static
void
idle_tasks
();
private
:
static
uint8_t
suspended
;
static
void
error
(
const
char
*
const
func
,
const
int32_t
v1
,
const
int32_t
v2
=-
1
);
static
void
noop
();
static
void
set
(
const
uint8_t
line
,
const
uint8_t
bits
);
...
...
...
...
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