mirror of
git://projects.qi-hardware.com/antorcha.git
synced 2024-11-01 09:24:05 +02:00
fw/: base sweep start time on absolute time
This way, we can define the next sweep while the previous one is still in progress.
This commit is contained in:
parent
646f54d25c
commit
023c2aa1e9
@ -25,7 +25,6 @@
|
||||
|
||||
|
||||
static struct sweep sweep = {
|
||||
.wait_ticks = 60000, /* 60 ms */
|
||||
.pixel_ticks = 1000, /* 1 ms */
|
||||
.left = 0,
|
||||
.right = MAX_LINES-1,
|
||||
@ -128,6 +127,7 @@ sei();
|
||||
#if 1
|
||||
if (state == FWD_START_SWEEP && !sweeping) {
|
||||
state = FWD_SWEEP;
|
||||
sweep.start_ticks = uptime()+60000; /* 60 ms */
|
||||
sweep_image(&sweep);
|
||||
}
|
||||
#endif
|
||||
|
15
fw/sweep.c
15
fw/sweep.c
@ -118,6 +118,15 @@ uint32_t uptime(void)
|
||||
|
||||
void sweep_image(const struct sweep *sweep)
|
||||
{
|
||||
uint32_t t;
|
||||
|
||||
/* calculate start time */
|
||||
|
||||
t = uptime();
|
||||
if (sweep->start_ticks <= t)
|
||||
return;
|
||||
t = sweep->start_ticks-t;
|
||||
|
||||
TCCR1B = 0; /* stop the timer */
|
||||
|
||||
cli();
|
||||
@ -142,9 +151,9 @@ void sweep_image(const struct sweep *sweep)
|
||||
/* timing parameters */
|
||||
|
||||
pixel_ticks = sweep->pixel_ticks;
|
||||
wait_periods = sweep->wait_ticks >> 16;
|
||||
wait_periods = t >> 16;
|
||||
if (wait_periods) {
|
||||
wait_short = sweep->wait_ticks;
|
||||
wait_short = t;
|
||||
wait_period = 0xffff;
|
||||
|
||||
/*
|
||||
@ -157,7 +166,7 @@ void sweep_image(const struct sweep *sweep)
|
||||
}
|
||||
ICR1 = wait_period;
|
||||
} else {
|
||||
ICR1 = sweep->wait_ticks;
|
||||
ICR1 = t;
|
||||
}
|
||||
|
||||
/* prepare the hardware timer */
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
|
||||
struct sweep {
|
||||
uint32_t wait_ticks; /* number of ticks to wait before image */
|
||||
uint32_t start_ticks; /* absolute start time */
|
||||
uint16_t pixel_ticks; /* number of ticks per pixel */
|
||||
uint8_t left; /* leftmost line of image */
|
||||
uint8_t right; /* rightmost line of image */
|
||||
|
Loading…
Reference in New Issue
Block a user