Browse Source

Move coolant temp to floating point.

master
Solomon Peachy 4 years ago
parent
commit
5e3d794f8b
  1. 20
      a179.c
  2. 8
      aldl.c
  3. 3
      aldl.h
  4. 7
      aldl_pi.c
  5. 2
      sdldash.c

20
a179.c

@ -35,20 +35,25 @@
#define STREAM A179
#define STREAM_WORDS 23
#define VERSION 0
static const int8_t A179_coolant_temp_table[] = {
static const float A179_coolant_temp_table[] = {
[0] = 200,
[12] = 150,
[13] = 145,
[14] = 140,
[15] = 137.5, //
[16] = 135,
[17] = 132.5, //
[18] = 130,
[21] = 125,
[23] = 120,
[26] = 115,
[30] = 110,
[34] = 105,
[35] = 104, //
[36] = 103, //
[37] = 102, //
[38] = 101, //
[39] = 100,
[44] = 95,
[50] = 90,
@ -70,19 +75,25 @@ static const int8_t A179_coolant_temp_table[] = {
[218] = 10,
[225] = 5,
[231] = 0,
// 232, 233, 234, 235, 236
[237] = -5,
// 238, 239, 240
[241] = -10,
// 242, 242, 243, 244,
[245] = -15,
[246] = -17.5, //
[247] = -20,
// 248, 249
[250] = -25,
[251] = -30,
[252] = -35, //
[253] = -40,
[254] = -50, //
[255] = -60, //
};
void aldl_a179_callback(uint8_t *data, int datalen)
{
printf("! %d\n", datalen); // XXX indicate!
/* Decode */
decoded.heartbeat = !decoded.heartbeat;
@ -126,5 +137,4 @@ void aldl_a179_callback(uint8_t *data, int datalen)
decoded.fuelp_v = (float)data[20] / 10;
decoded.idle_tgt = (float)data[21] * 12.5;
decoded.tp = (float)data[22] / 2.55;
}

8
aldl.c

@ -89,23 +89,29 @@ void isrfn(void)
ALDLSR |= (val & 1);
if ((ALDLSR & SYNC_WORD) == SYNC_WORD) {
/* Received a 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 */
printf(" - %d\n", datalen);
/* Process ALDL payload */
if (aldl_callback)
aldl_callback(data, datalen);
/* Log data */
if (datalog_handle)
aldl_datalog(data, datalen);
/* Reset state */
bits = 0;
datalen = 0;
} else if (++bits == 9) {
printf(" %02x", ALDLSR & 0xFF);
/* Just latch in the word */
data[datalen++] = ALDLSR & 0xff;
/* Reset state */
bits = 0;
ALDLSR = 0;
}

3
aldl.h

@ -50,7 +50,6 @@ struct stream_common {
/* Raw data */
uint16_t mph; /* Miles per hour */
uint16_t rpm; /* Revolutions per minute */
int16_t coolant_temp_c; /* Coolant temperature */
uint16_t tp; /* Throttle Position, percent */
uint16_t iac_steps;
uint16_t idle_tgt; /* Idle target RPM */
@ -66,7 +65,7 @@ struct stream_common {
float o2_v; /* O2 sensor, Voltage */
/* Derived data */
float coolant_temp_c; /* Coolant temperature */
uint16_t running; /* non-zero if engine running */
uint16_t driving; /* non-zero if moving */
uint16_t idling; /* 1 = first idle, 2 = regular */

7
aldl_pi.c

@ -60,21 +60,24 @@ int main (int argc, char **argv)
wiringPiSetup();
/* Set highest possible priority */
piHiPri(99);
// piHiPri(99);
/* Set up RPi GPIO */
pinMode(ALDL_PIN_IN, INPUT);
pullUpDnControl(ALDL_PIN_IN, PUD_DOWN);
wiringPiISR (ALDL_PIN_IN, INT_EDGE_FALLING, &isrfn);
/* Initialize datalogging */
datalog_init(datalog_fname);
/* Initialize dashboard */
if (init_dash())
return -1;
/* No point in updating the display more than once a second */
while(run) {
run = render_dash();
sleep(1);
run = render_dash();
}
datalog_close();

2
sdldash.c

@ -178,7 +178,7 @@ int render_dash(void) {
/* Draw variable text */
RENDER_TEXT_1ARG(i, 10, 50, textcolor, "%03u MPH", decoded.mph);
RENDER_TEXT_1ARG(i, 10, 70, textcolor, "%04d RPM", decoded.rpm);
RENDER_TEXT_1ARG(i, 10, 90, textcolor, "%03d C", decoded.coolant_temp_c);
RENDER_TEXT_1ARG(i, 10, 90, textcolor, "%03.1f C", decoded.coolant_temp_c);
RENDER_TEXT_1ARG(i, 10, 110, textcolor, "%03u%% TP", decoded.tp);
if (decoded.idling) {

Loading…
Cancel
Save