Bug fixes. Data coming in but timing isn't right.
...WiringPi may not be up for the accuracy / latency we need.
This commit is contained in:
parent
3d07cdeb23
commit
34dadfb0dd
19
aldl.c
19
aldl.c
|
@ -50,7 +50,6 @@ struct stream_common decoded = { 0 };
|
|||
|
||||
void (*aldl_callback)(uint8_t *data, int datalen) = NULL;
|
||||
|
||||
|
||||
/* Datalogging */
|
||||
void datalog_init(char *fname)
|
||||
{
|
||||
|
@ -84,20 +83,18 @@ static void aldl_datalog(uint8_t *data, int datalen)
|
|||
void isrfn(void)
|
||||
{
|
||||
int val;
|
||||
delayfn(1); // To handle both variations, minimum of 0.5, max of 1.8
|
||||
delayfn(2000); // To handle both variations, minimum of 0.5, max of 1.8ms
|
||||
val = readbit();
|
||||
ALDLSR <<= 1;
|
||||
ALDLSR |= (val & 1);
|
||||
|
||||
/* Wait for initial sync. */
|
||||
if (!gotsync) {
|
||||
if ((ALDLSR & SYNC_WORD) == SYNC_WORD) {
|
||||
gotsync = 1;
|
||||
}
|
||||
return; /* No sync, drop everything */
|
||||
}
|
||||
|
||||
if ((ALDLSR & SYNC_WORD) == SYNC_WORD) {
|
||||
ALDLSR = 0;
|
||||
if (!gotsync) {
|
||||
gotsync = 1;
|
||||
return; /* First one, we don't do anything */
|
||||
}
|
||||
printf(" - %d\n", datalen);
|
||||
/* New sync word, we've finished a sequence */
|
||||
if (aldl_callback)
|
||||
aldl_callback(data, datalen);
|
||||
|
@ -106,8 +103,10 @@ void isrfn(void)
|
|||
bits = 0;
|
||||
datalen = 0;
|
||||
} else if (++bits == 9) {
|
||||
printf(" %02x", ALDLSR & 0xFF);
|
||||
/* Just latch in the word */
|
||||
data[datalen++] = ALDLSR & 0xff;
|
||||
bits = 0;
|
||||
ALDLSR = 0;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,9 +44,9 @@ int readbit(void)
|
|||
{
|
||||
return !digitalRead(ALDL_PIN_IN); /* Logic low is ALDL '1' */
|
||||
}
|
||||
void delayfn(int ms)
|
||||
void delayfn(int us)
|
||||
{
|
||||
delay(1);
|
||||
delayMicroseconds(us);
|
||||
}
|
||||
|
||||
/* Main */
|
||||
|
@ -54,6 +54,9 @@ int main (int argc, char **argv)
|
|||
{
|
||||
int run = 1;
|
||||
|
||||
/* Set up callback for our type */
|
||||
aldl_callback = aldl_a179_callback;
|
||||
|
||||
wiringPiSetup();
|
||||
|
||||
/* Set highest possible priority */
|
||||
|
@ -62,7 +65,6 @@ int main (int argc, char **argv)
|
|||
/* Set up RPi GPIO */
|
||||
pinMode(ALDL_PIN_IN, INPUT);
|
||||
pullUpDnControl(ALDL_PIN_IN, PUD_DOWN);
|
||||
|
||||
wiringPiISR (ALDL_PIN_IN, INT_EDGE_FALLING, &isrfn);
|
||||
|
||||
datalog_init(datalog_fname);
|
||||
|
|
20
sdldash.c
20
sdldash.c
|
@ -182,28 +182,28 @@ int render_dash(void) {
|
|||
RENDER_TEXT_1ARG(i, 10, 110, textcolor, "%03u%% TP", decoded.tp);
|
||||
|
||||
if (decoded.idling) {
|
||||
RENDER_TEXT_1ARG(i, 200, 10, textcolor, "IDLE @ %04d", decoded.idle_tgt);
|
||||
RENDER_TEXT_1ARG(i, 200, 30, textcolor, "IDLE @ %04d", decoded.idle_tgt);
|
||||
if (decoded.closed_loop_idle)
|
||||
RENDER_TEXT_NOARG(i, 200, 30, textcolor, "CLOSED LOOP");
|
||||
RENDER_TEXT_NOARG(i, 200, 50, textcolor, "CLOSED LOOP");
|
||||
else
|
||||
RENDER_TEXT_NOARG(i, 200, 30, textcolor, "OPEN LOOP");
|
||||
RENDER_TEXT_NOARG(i, 200, 50, textcolor, "OPEN LOOP");
|
||||
} else {
|
||||
if (decoded.closed_loop)
|
||||
RENDER_TEXT_NOARG(i, 200, 30, textcolor, "CLOSED LOOP");
|
||||
RENDER_TEXT_NOARG(i, 200, 50, textcolor, "CLOSED LOOP");
|
||||
else
|
||||
RENDER_TEXT_NOARG(i, 200, 30, textcolor, "OPEN LOOP");
|
||||
RENDER_TEXT_NOARG(i, 200, 50, textcolor, "OPEN LOOP");
|
||||
}
|
||||
if (decoded.ac_request)
|
||||
RENDER_TEXT_NOARG(i, 200, 50, textcolor, "AC REQ");
|
||||
RENDER_TEXT_NOARG(i, 200, 70, textcolor, "AC REQ");
|
||||
|
||||
if (decoded.shift_req)
|
||||
RENDER_TEXT_NOARG(i, 200, 70, textcolor, "SHIFT REQ");
|
||||
RENDER_TEXT_NOARG(i, 200, 90, textcolor, "SHIFT REQ");
|
||||
else if (decoded.top_gear)
|
||||
RENDER_TEXT_NOARG(i, 200, 70, textcolor, "TOP GEAR");
|
||||
RENDER_TEXT_NOARG(i, 200, 90, textcolor, "TOP GEAR");
|
||||
else if (decoded.neutral)
|
||||
RENDER_TEXT_NOARG(i, 200, 70, textcolor, "NEUTRAL");
|
||||
RENDER_TEXT_NOARG(i, 200, 90, textcolor, "NEUTRAL");
|
||||
|
||||
RENDER_TEXT_1ARG(i, 200, 90, textcolor, "BAT %02.01f v", decoded.battery_v);
|
||||
RENDER_TEXT_1ARG(i, 200, 110, textcolor, "BAT %02.01f v", decoded.battery_v);
|
||||
|
||||
RENDER_TEXT_1ARG(i, 310, 225, textcolor, "%c", decoded.heartbeat ? '^' : '*');
|
||||
|
||||
|
|
Loading…
Reference in New Issue