mirror of
git://projects.qi-hardware.com/antorcha.git
synced 2024-11-01 11:28:26 +02:00
fw/: rearrange parameters and move defaults from antorcha.c to proto.h
This commit is contained in:
parent
cb846be507
commit
308c094af2
@ -14,6 +14,7 @@
|
|||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#include "proto.h"
|
||||||
#include "rf.h"
|
#include "rf.h"
|
||||||
#include "dispatch.h"
|
#include "dispatch.h"
|
||||||
#include "sweep.h"
|
#include "sweep.h"
|
||||||
@ -25,17 +26,17 @@
|
|||||||
|
|
||||||
|
|
||||||
static struct sweep fwd_sweep = {
|
static struct sweep fwd_sweep = {
|
||||||
.pixel_ticks = 1100, /* 1.1 ms */
|
.pixel_ticks = TP_FWD_PIX_DEFAULT,
|
||||||
.left = 0,
|
.left = PX_FWD_LEFT_DEFAULT,
|
||||||
.right = MAX_LINES-1,
|
.right = PX_FWD_RIGHT_DEFAULT,
|
||||||
.forward = 1,
|
.forward = 1,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
static struct sweep bwd_sweep = {
|
static struct sweep bwd_sweep = {
|
||||||
.pixel_ticks = 1100, /* 1.1 ms */
|
.pixel_ticks = TP_BWD_PIX_DEFAULT,
|
||||||
.left = 0,
|
.left = PX_BWD_LEFT_DEFAULT,
|
||||||
.right = MAX_LINES-1,
|
.right = PX_BWD_RIGHT_DEFAULT,
|
||||||
.forward = 0,
|
.forward = 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -52,11 +53,10 @@ static volatile uint32_t tR0, tR1, tL0, tL1;
|
|||||||
static volatile uint32_t tL, tR;
|
static volatile uint32_t tL, tR;
|
||||||
static volatile bool wake = 0;
|
static volatile bool wake = 0;
|
||||||
|
|
||||||
|
static uint16_t xa_high = XA_HIGH_DEFAULT;
|
||||||
//#define THRESH_HIGH 900
|
static uint16_t xa_low = XA_LOW_DEFAULT;
|
||||||
//#define THRESH_LOW 120
|
static uint32_t fwd_start = TP_FWD_START_DEFAULT;
|
||||||
#define THRESH_HIGH 850
|
static uint32_t bwd_start = TP_BWD_START_DEFAULT;
|
||||||
#define THRESH_LOW 170
|
|
||||||
|
|
||||||
|
|
||||||
static void sync_sweep(bool x, uint16_t v)
|
static void sync_sweep(bool x, uint16_t v)
|
||||||
@ -68,37 +68,37 @@ static void sync_sweep(bool x, uint16_t v)
|
|||||||
t = uptime_irq();
|
t = uptime_irq();
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case IDLE:
|
case IDLE:
|
||||||
if (v < THRESH_LOW) {
|
if (v < xa_low) {
|
||||||
tR0 = t;
|
tR0 = t;
|
||||||
state = RIGHT;
|
state = RIGHT;
|
||||||
} else if (v > THRESH_HIGH) {
|
} else if (v > xa_high) {
|
||||||
tL0 = t;
|
tL0 = t;
|
||||||
state = LEFT;
|
state = LEFT;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case RIGHT:
|
case RIGHT:
|
||||||
if (v < THRESH_LOW)
|
if (v < xa_low)
|
||||||
break;
|
break;
|
||||||
tR1 = t;
|
tR1 = t;
|
||||||
tR = t-tR0;
|
tR = t-tR0;
|
||||||
state = BWD;
|
state = BWD;
|
||||||
/* fall through */
|
/* fall through */
|
||||||
case BWD:
|
case BWD:
|
||||||
if (v < THRESH_HIGH)
|
if (v < xa_high)
|
||||||
break;
|
break;
|
||||||
tL0 = t;
|
tL0 = t;
|
||||||
state = LEFT;
|
state = LEFT;
|
||||||
wake = 1;
|
wake = 1;
|
||||||
break;
|
break;
|
||||||
case LEFT:
|
case LEFT:
|
||||||
if (v > THRESH_HIGH)
|
if (v > xa_high)
|
||||||
break;
|
break;
|
||||||
tL1 = t;
|
tL1 = t;
|
||||||
tL = t-tL0;
|
tL = t-tL0;
|
||||||
state = FWD;
|
state = FWD;
|
||||||
/* fall through */
|
/* fall through */
|
||||||
case FWD:
|
case FWD:
|
||||||
if (v > THRESH_LOW)
|
if (v > xa_low)
|
||||||
break;
|
break;
|
||||||
tR0 = t;
|
tR0 = t;
|
||||||
state = RIGHT;
|
state = RIGHT;
|
||||||
@ -116,14 +116,14 @@ static void submit_fwd_sweep(void)
|
|||||||
tIMG = (fwd_sweep.right-fwd_sweep.left+1)*(fwd_sweep.pixel_ticks)/2;
|
tIMG = (fwd_sweep.right-fwd_sweep.left+1)*(fwd_sweep.pixel_ticks)/2;
|
||||||
fwd_sweep.start_ticks = tL0+110000-tIMG/2;
|
fwd_sweep.start_ticks = tL0+110000-tIMG/2;
|
||||||
#endif
|
#endif
|
||||||
fwd_sweep.start_ticks = tL0+70000;
|
fwd_sweep.start_ticks = tL0+fwd_start;
|
||||||
sweep_image(&fwd_sweep);
|
sweep_image(&fwd_sweep);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void submit_bwd_sweep(void)
|
static void submit_bwd_sweep(void)
|
||||||
{
|
{
|
||||||
bwd_sweep.start_ticks = tR0+50000;
|
bwd_sweep.start_ticks = tR0+bwd_start;
|
||||||
sweep_image(&bwd_sweep);
|
sweep_image(&bwd_sweep);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
26
fw/proto.h
26
fw/proto.h
@ -34,6 +34,19 @@ enum pck_type {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#define XA_HIGH_DEFAULT 850
|
||||||
|
#define XA_LOW_DEFAULT 170
|
||||||
|
|
||||||
|
#define PX_FWD_LEFT_DEFAULT 0
|
||||||
|
#define PX_FWD_RIGHT_DEFAULT (MAX_LINES-1)
|
||||||
|
#define PX_BWD_LEFT_DEFAULT 0
|
||||||
|
#define PX_BWD_RIGHT_DEFAULT (MAX_LINES-1)
|
||||||
|
|
||||||
|
#define TP_FWD_START_DEFAULT 70000 /* 70 ms */
|
||||||
|
#define TP_BWD_START_DEFAULT 50000 /* 50 ms */
|
||||||
|
#define TP_FWD_PIX_DEFAULT 1100 /* 1.1 ms */
|
||||||
|
#define TP_BWD_PIX_DEFAULT 1100 /* 1.1 ms */
|
||||||
|
|
||||||
struct params {
|
struct params {
|
||||||
/* Timer ticks */
|
/* Timer ticks */
|
||||||
|
|
||||||
@ -46,10 +59,10 @@ struct params {
|
|||||||
|
|
||||||
/* Pixel offsets (in image) */
|
/* Pixel offsets (in image) */
|
||||||
|
|
||||||
uint8_t px_fwd_img_first; /* first column in forward move */
|
uint8_t px_fwd_left; /* first column in forward move */
|
||||||
uint8_t px_fwd_img_end; /* last column in forward move */
|
uint8_t px_fwd_right; /* last column in forward move */
|
||||||
uint8_t px_bwd_img_first; /* first (high) col. in backward move */
|
uint8_t px_bwd_left; /* last (low) column in backward move */
|
||||||
uint8_t px_bwd_img_end; /* last (low) column in backward move */
|
uint8_t px_bwd_right; /* first (high) col. in backward move */
|
||||||
|
|
||||||
/* Timer periods, for imaging */
|
/* Timer periods, for imaging */
|
||||||
|
|
||||||
@ -57,11 +70,6 @@ struct params {
|
|||||||
uint16_t tp_bwd_start; /* backward image start */
|
uint16_t tp_bwd_start; /* backward image start */
|
||||||
uint8_t tp_fwd_pix; /* pixel size in forward move */
|
uint8_t tp_fwd_pix; /* pixel size in forward move */
|
||||||
uint8_t tp_bwd_pix; /* pixel size in backward move */
|
uint8_t tp_bwd_pix; /* pixel size in backward move */
|
||||||
|
|
||||||
/* Timer periods, for estimation */
|
|
||||||
|
|
||||||
uint16_t tp_fwd; /* forward half-period */
|
|
||||||
uint16_t tp_bwd; /* backward half-period */
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* !PROTO_H */
|
#endif /* !PROTO_H */
|
||||||
|
Loading…
Reference in New Issue
Block a user