Skip to content

Commit

Permalink
Aux display of basic instruments
Browse files Browse the repository at this point in the history
  • Loading branch information
tomcourt authored and tomcourt committed Jul 7, 2017
1 parent 4e61b79 commit 39d75f5
Show file tree
Hide file tree
Showing 4 changed files with 91 additions and 21 deletions.
16 changes: 10 additions & 6 deletions enguino/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const char *red = "red";

// sensor-type, pin, decimal, voffset, vfactor, moffset, mfactor, lowAlarm, lowAlert, highAlert, highAlarm
const Sensor vtS = { st_volts, 0, 1, 0, MX(ADCtoV10), GB(100*V10toADC), GMX(60*V10toADC), 110, 130, 9999, 160 };
const Sensor opS = { st_r240to33, 1, 0, 0, MX(0.1), 0, MX(1.0), 25, 55, 95, 95 };
const Sensor opS = { st_r240to33, 1, 0, 0, MX(0.1), 0, MX(1.0), 25, 55, 9999, 95 };
const Sensor otS = { st_thermistorF, 2, 0, 0, MX(.1), GB(50*10), GMX(200*10), -1, 140, 9999, 250 };
const Sensor fpS = { st_r240to33, 3, 1, 0, MX(0.1), 0, MX(1.0), 5, 20, 60, 80 };
const Sensor flS = { st_r240to33, 4, 1, 0, MX(0.16), 0, MX(1.0), 25, 50, 9999, 999 };
Expand Down Expand Up @@ -93,10 +93,14 @@ const Gauge gauges[] = {
};

// Guage layout for aux display
const AuxDisplay auxdisplay[2] = {
{ .sensor = {&taS, 0} },
{ .sensor = {&taS, 0} }


#define XTEXT(a,b,c,d) { .literal = {LED_TEXT(a,b,c,d)} } // literals must not be blank in last 2 letters
#define XSENSOR(x) { .sensor = {&x, 0} }
const AuxDisplay auxdisplay[] = {
XTEXT( ,b,A,t), XSENSOR(vtS),
XSENSOR(taS), XSENSOR(flS),
XTEXT( , ,O,P), XSENSOR(opS),
XTEXT( , ,O,t), XSENSOR(otS),
XTEXT( , ,F,P), XSENSOR(fpS),
XTEXT( ,A,L,t), XSENSOR(vtS),
};

2 changes: 1 addition & 1 deletion enguino/egTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ typedef struct {
enum GaugeColor { gc_green, gc_yellow, gc_red };

typedef union {
struct { byte a,b,c,d; } literal;
byte literal[4];
struct { Sensor *s; word zero; } sensor;
} AuxDisplay;

Expand Down
87 changes: 73 additions & 14 deletions enguino/enguino.ino
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,14 @@

#include "persist.h"

// configuration of sensors and layout of the gauges
#include "config.h"
// Update the first 3 numbers of this IP address to your local network
// for testing but restore it to (192, 168, 0, 111) when finished.
IPAddress ip(192, 168, 0, 111);

// A made up MAC address. Only real critera is the first bytes 2 lsb must be 1 (for local) and 0 (for unicast).
byte mac[] = { 0xDE, 0x15, 0x24, 0x33, 0x42, 0x51 };

// Update the first 3 numbers of this IP address to your local network
// for testing but restore it to (192, 168, 0, 111) when finished.
IPAddress ip(192, 168, 0, 111);
int readSensor(const Sensor *s, byte n = 0);

// #define RANDOM_SENSORS 1

Expand All @@ -29,7 +28,6 @@ IPAddress ip(192, 168, 0, 111);
EthernetServer server(80);
EthernetClient client;

int readSensor(const Sensor *s, byte n = 0);
bool leanMode;
int peakEGT[4];
byte hobbsCount = 90;
Expand All @@ -42,6 +40,13 @@ volatile byte rpmP;

bool dim;
bool didKeyDown;
byte auxScreen = 2;

// printLED functions for the auxiliary display
#include "printLED.h"

// configuration of sensors and layout of the gauges
#include "config.h"

// Performance 'print' functions to ethernet 'client' (includes flush)
#include "printEthernet.h"
Expand All @@ -51,12 +56,11 @@ bool didKeyDown;
// Implementation for printPrefix and pringGauge
#include "printGauges.h"

// printLED functions for the auxiliary display
#include "printLED.h"

// Measure thermocouple tempertaures in the background
#include "tcTemp.h"



InterpolateTable thermistor = {
64, 32,
(byte []) {
Expand Down Expand Up @@ -195,6 +199,61 @@ void tachIRQ() {
tachDidPulse = true;
}

bool isLow(Sensor *s, int v) {
return v < s->lowAlarm || v < s->lowAlert;
}

bool isHigh(Sensor *s, int v) {
return v > s->highAlarm || v > s->highAlert;
}

bool isAlarm(Sensor *s, int v) {
return v < s->lowAlarm || v > s->highAlarm;
}

void auxDisplay(byte i) {
int v;
Sensor *s = 0;
for (signed char n=1; n>=0; n--) {
AuxDisplay *a = auxdisplay+(i+n);
if (a->sensor.zero == 0) {
commandLED(n, HT16K33_BLINK_OFF);
s = a->sensor.s;
if (s == &flS) {
printLEDFuel(scaleValue(s, readSensor(s,0)), scaleValue(s, readSensor(s,1))); // Show the dual fuel gauge
s = 0; // fuel gauge stands alone, doesn't have label to blink
}
else {
v = scaleValue(s, readSensor(s));
printLED(n,v, s->decimal);
}
}
else {
byte t[4];
memcpy(t,a->literal,4);
if (s) {
if (isLow(s, v) || isHigh(s, v)) {
if (t[1] == 0) {
t[1] = t[2];
t[2] = t[3];
t[3] = LED__;
}
t[0] = t[1];
t[1] = t[2];
t[2] = t[3];
t[3] = isLow(s,v) ? LED_L : LED_H;
}
if (isAlarm(s, v)) {
commandLED(n, HT16K33_BLINK_1HZ);
goto blink;
}
}
commandLED(n, HT16K33_BLINK_OFF);
blink:
printLED(n,t);
}
}
}



Expand All @@ -210,8 +269,7 @@ void setup() {
printLED(0,LED_TEXT(h,o,b,b));
printLED(1,ee_status.hobbs>>2,1);
delay(1000);
printLED(0,LED_TEXT( ,b,A,t));
printLED(1,scaleValue(&vtS, readSensor(&vtS)),1);
auxDisplay(0);
delay(1000);

attachInterrupt(digitalPinToInterrupt(2),tachIRQ,RISING);
Expand All @@ -230,7 +288,9 @@ void loop() {
// listen for incoming clients
if (switchPress) {
if (!didKeyDown) {
// !!!!! show next item
auxScreen += 2;
if (auxScreen >= sizeof(auxdisplay)/sizeof(auxdisplay[0]))
auxScreen = 2;
}
switchPress = 0;
didKeyDown = false;
Expand Down Expand Up @@ -327,7 +387,6 @@ void loop() {
eighthSecondCount -= 8;

halfSecond:
printLED(0,scaleValue(&taS, readSensor(&taS)),0);
printLEDFuel(scaleValue(&flS, readSensor(&flS,0)), scaleValue(&flS, readSensor(&flS,1)));
auxDisplay(auxScreen);
}
}
7 changes: 7 additions & 0 deletions enguino/printLED.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,19 +52,26 @@
#define LED_ 0x0 // blank

#define LED_A 0x77
#define LED_a 0x77
#define LED_b 0x7c
#define LED_C 0x39
#define LED_D 0x5e
#define LED_d 0x5e
#define LED_E 0x79
#define LED_F 0x71
#define LED_f 0x71
#define LED_H 0x76
#define LED_h 0x74
#define LED_i 0x4
#define LED_L 0x38
#define LED_n 0x54
#define LED_O 0x3F
#define LED_o 0x5c
#define LED_P 0x73
#define LED_r 0x50
#define LED_S 0x6D
#define LED_s 0x6D
#define LED_T 0x78
#define LED_t 0x78
#define LED_U 0x3e

Expand Down

0 comments on commit 39d75f5

Please sign in to comment.