mirror of
git://projects.qi-hardware.com/antorcha.git
synced 2024-11-01 09:24:05 +02:00
fw/: simple image test mode (still untested)
This commit is contained in:
parent
87cc67d5f7
commit
9bc9c57fb2
@ -17,6 +17,16 @@
|
||||
#include "rf.h"
|
||||
#include "dispatch.h"
|
||||
#include "sweep.h"
|
||||
#include "image.h"
|
||||
|
||||
|
||||
static struct sweep sweep = {
|
||||
.wait_ticks = 100000, /* 100 ms */
|
||||
.pixel_ticks = 5000, /* 5 ms */
|
||||
.left = 0,
|
||||
.right = MAX_LINES,
|
||||
.forward = 1,
|
||||
};
|
||||
|
||||
|
||||
static const struct handler *protos[] = {
|
||||
@ -42,5 +52,7 @@ int main(void)
|
||||
got = rf_recv(buf, sizeof(buf));
|
||||
if (got > 2)
|
||||
dispatch(buf, got-2, protos);
|
||||
if (!sweeping)
|
||||
sweep_image(&sweep);
|
||||
}
|
||||
}
|
||||
|
17
fw/sweep.c
17
fw/sweep.c
@ -21,7 +21,10 @@
|
||||
#include "sweep.h"
|
||||
|
||||
|
||||
static uint32_t t_sw; /* cumulative number of timer ticks in sweep */
|
||||
volatile bool sweeping = 0;
|
||||
|
||||
|
||||
static volatile uint32_t t_sw; /* cumulative number of timer ticks in sweep */
|
||||
|
||||
static uint16_t wait_periods; /* number of periods to wait before image */
|
||||
static uint16_t wait_period; /* ticks in wait period */
|
||||
@ -67,14 +70,16 @@ ISR(TIMER1_OVF_vect)
|
||||
|
||||
/* wait until the next pixel (or slow down if we're done) */
|
||||
|
||||
if (curr_line == end_line)
|
||||
if (curr_line == end_line) {
|
||||
OCR1A = 0xffff;
|
||||
else
|
||||
sweeping = 0;
|
||||
} else {
|
||||
OCR1A = pixel_ticks;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void image_sweep(const struct sweep *sweep)
|
||||
void sweep_image(const struct sweep *sweep)
|
||||
{
|
||||
TCCR1B = 0; /* stop the timer */
|
||||
|
||||
@ -129,6 +134,10 @@ void image_sweep(const struct sweep *sweep)
|
||||
1 << WGM13 | /* WG Mode 15, continued */
|
||||
1 << WGM12 |
|
||||
1 << CS11; /* clkIO/8 */
|
||||
|
||||
sweeping = 1;
|
||||
|
||||
sei();
|
||||
}
|
||||
|
||||
|
||||
|
@ -27,7 +27,10 @@ struct sweep {
|
||||
};
|
||||
|
||||
|
||||
void image_sweep(const struct sweep *sweep);
|
||||
extern volatile bool sweeping;
|
||||
|
||||
|
||||
void sweep_image(const struct sweep *sweep);
|
||||
void sweep_init(void);
|
||||
|
||||
#endif /* !SWEEP_H */
|
||||
|
Loading…
Reference in New Issue
Block a user