Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
M
MarlinKimbra
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
machinery
MarlinKimbra
Commits
599c8a93
Commit
599c8a93
authored
May 13, 2016
by
Franco (nextime) Lanza
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Few minor fixes in LASER_PULSE_METHOD
parent
8a1918ec
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
11 deletions
+11
-11
laser.cpp
MK/module/laser/laser.cpp
+11
-11
No files found.
MK/module/laser/laser.cpp
View file @
599c8a93
...
@@ -26,22 +26,22 @@
...
@@ -26,22 +26,22 @@
laser_t
laser
;
laser_t
laser
;
#if ENABLED(LASER_PULSE_METHOD)
#if ENABLED(LASER_PULSE_METHOD)
#define bit(x) (1 << x)
#define
pulse
bit(x) (1 << x)
#endif
#endif
void
timer3_init
(
int
pin
)
{
void
timer3_init
(
int
pin
)
{
#if ENABLED(LASER_PULSE_METHOD)
#if ENABLED(LASER_PULSE_METHOD)
TCCR3A
=
0
;
// clear control register A
TCCR3A
=
0
;
// clear control register A
TCCR3B
=
bit
(
WGM33
);
// set mode as phase and frequency correct pwm, stop the timer
TCCR3B
=
pulse
bit
(
WGM33
);
// set mode as phase and frequency correct pwm, stop the timer
ICR3
=
F_CPU
/
LASER_PWM
/
2
;
// the counter runs backwards after TOP
ICR3
=
F_CPU
/
LASER_PWM
/
2
;
// the counter runs backwards after TOP
TCCR3B
&=
~
(
bit
(
CS30
)
|
bit
(
CS31
)
|
bit
(
CS32
));
// Stop timer
TCCR3B
&=
~
(
bit
(
CS30
)
|
bit
(
CS31
)
|
bit
(
CS32
));
// Stop timer
TCCR3A
|=
bit
(
COM3A1
);
// Connect pin5 to timer register
TCCR3A
|=
pulse
bit
(
COM3A1
);
// Connect pin5 to timer register
DDRE
|=
bit
(
PORTE3
);
// Actually output on pin 5
DDRE
|=
pulse
bit
(
PORTE3
);
// Actually output on pin 5
OCR3A
=
0
;
// Zero duty cycle = OFF
OCR3A
=
0
;
// Zero duty cycle = OFF
TCCR3B
|=
bit
(
CS30
);
// No prescaler, start timer
TCCR3B
|=
pulse
bit
(
CS30
);
// No prescaler, start timer
// Use timer4 to end laser pulse
// Use timer4 to end laser pulse
/*
/*
...
@@ -90,8 +90,8 @@ void timer3_init(int pin) {
...
@@ -90,8 +90,8 @@ void timer3_init(int pin) {
*/
*/
// Prepare laser pulse shutdown timer
// Prepare laser pulse shutdown timer
TCCR4A
=
0
;
TCCR4A
=
0
;
TCCR4B
=
bit
(
WGM42
);
// CTC
TCCR4B
=
pulse
bit
(
WGM42
);
// CTC
TIMSK4
|=
bit
(
OCIE4A
);
// Enable interrupt on OCR4A
TIMSK4
|=
pulse
bit
(
OCIE4A
);
// Enable interrupt on OCR4A
#else
#else
pinMode
(
pin
,
OUTPUT
);
pinMode
(
pin
,
OUTPUT
);
analogWrite
(
pin
,
1
);
// let Arduino setup do it's thing to the PWM pin
analogWrite
(
pin
,
1
);
// let Arduino setup do it's thing to the PWM pin
...
@@ -117,7 +117,7 @@ void timer3_init(int pin) {
...
@@ -117,7 +117,7 @@ void timer3_init(int pin) {
OCR3A
=
0
;
// 0 Duty cycle
OCR3A
=
0
;
// 0 Duty cycle
// Stop pulse shutdown timer
// Stop pulse shutdown timer
TCCR4B
&=
~
(
bit
(
CS40
)
|
bit
(
CS41
)
|
bit
(
CS42
));
// Stop timer.
TCCR4B
&=
~
(
pulsebit
(
CS40
)
|
pulsebit
(
CS41
)
|
pulse
bit
(
CS42
));
// Stop timer.
}
}
void
laser_pulse
(
uint32_t
ulValue
,
unsigned
long
usec
)
void
laser_pulse
(
uint32_t
ulValue
,
unsigned
long
usec
)
...
@@ -127,8 +127,8 @@ void timer3_init(int pin) {
...
@@ -127,8 +127,8 @@ void timer3_init(int pin) {
// Start timer4 to end pulse
// Start timer4 to end pulse
OCR4A
=
2
*
usec
;
// Ticks until IRQ, "2" comes from prescaler
OCR4A
=
2
*
usec
;
// Ticks until IRQ, "2" comes from prescaler
TCNT4
=
0
;
// Count from 0
TCNT4
=
0
;
// Count from 0
TCCR4B
|=
bit
(
CS41
);
// Start timer
TCCR4B
|=
pulse
bit
(
CS41
);
// Start timer
TIFR4
=
bit
(
OCF4A
);
// Clear any pending interrupt
TIFR4
=
pulse
bit
(
OCF4A
);
// Clear any pending interrupt
}
}
#else // LASER_PULSE_METHOD
#else // LASER_PULSE_METHOD
void
timer4_init
(
int
pin
)
{
void
timer4_init
(
int
pin
)
{
...
@@ -218,7 +218,7 @@ void laser_fire(float intensity = 100.0){
...
@@ -218,7 +218,7 @@ void laser_fire(float intensity = 100.0){
#if(ENABLED(LASER_REMAP_INTENSITY))
#if(ENABLED(LASER_REMAP_INTENSITY))
#if LASER_REMAP_INTENSITY != 0
#if LASER_REMAP_INTENSITY != 0
#define OldRange (255.0 - 0.0);
#define OldRange (255.0 - 0.0);
#define NewRange
=
(255.0 - LASER_REMAP_INTENSITY);
#define NewRange (255.0 - LASER_REMAP_INTENSITY);
intensity
=
intensity
*
NewRange
/
OldRange
+
LASER_REMAP_INTENSITY
;
intensity
=
intensity
*
NewRange
/
OldRange
+
LASER_REMAP_INTENSITY
;
#endif
#endif
#endif
#endif
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment