You wouldn't even know there used to be switches in there :D
How are you getting on with the arduino stuff?
Printable View
You wouldn't even know there used to be switches in there :D
How are you getting on with the arduino stuff?
I too was looking at the ESP32 as it has more inputs than the ESP8266
No worries, it is set up to use an ILI9341 library which has the faster draw functions than the standard adafruit libaries.
Here you go, give me a shout if you have any questions
Code:/********************************************************************************************************
Claymore's temperature gauge display for monitoring temps
*******************************************************************************************************/
#include <SPI.h>
#include <TFT_ILI9341_ESP.h>
#define TFT_GREY 0x5AEB // Dark grey 16 bit colour
// define case for meter colours
#define RED2RED 0
#define GREEN2GREEN 1
#define BLUE2BLUE 2
#define BLUE2RED 3
#define GREEN2RED 4
#define RED2GREEN 5
#define RED2BLUE 6
#define CYAN2RED 7
#define CYAN2CYAN 8
TFT_ILI9341_ESP tft = TFT_ILI9341_ESP(); //initiate ILI9341 ESP8266 library
//setup values (float datatype for decimal values)
float ccIn;
float ccOut;
float bayTemp;
float airboxTemp;
void setup() {
tft.init(); //init display
tft.setRotation(3); //set display orientation
tft.fillScreen(TFT_BLACK); //set background colour
}
void loop() {
// read analog inputs from sensors and apply conversion factors
ccIn = (analogRead(0)*xxxx);
ccOut = (analogRead(0)*xxxx);
bayTemp = (analogRead(0)*xxxx);
airboxTemp = (analogRead(0)*xxxx);
// Draw meters
ringMeter(ccIn.1, 0, 50, 10, 5, 68, "CC-in", GREEN2RED);
ringMeter(ccOut.3, 0, 50, 170, 5, 68, "CC-out", GREEN2RED);
ringMeter(bayTemp.3, 0, 50, 10, 125, 68, "Bay", GREEN2RED);
ringMeter(airboxTemp, 0, 50, 170, 125, 68, "Airbox", GREEN2RED);
}
// #####################################################################################################
// Ring Meter section/setup (Modified by Dangerous Dave to work with ESP8266)
// int ringMeter(value, vmin, vmax, x, y, r, "Units", scheme)
// The ringMeter function returns the x coordinate of the right hand side of the meter to aid placement
// of the next meter.
// 'value' is the value to be displayed and plotted, integer values up to 4 digits are accommodated
// 'vmin' is the minimum value to be plotted
// 'vmax' is the maximum value to be plotted, thus vmin and vmax set the full meter range
// 'x' and 'y' are the coordinates of the top left corner of an imaginary box that contains the meter
// 'r' in the outer radius of the ring in pixels, the minimum is about 52 before the text intrudes on
// the ring.
// "Units" is the text string such as "Volts", "C" etc.
// 'scheme' sets the colour scheme, there are some # define statements in the example that enumerate the
// settings available, others could be added:
//
// #define RED2RED 0
// #define GREEN2GREEN 1
// #define BLUE2BLUE 2
// #define BLUE2RED 3
// #define GREEN2RED 4
// #define RED2GREEN 5
//
// These different schemes set the colour change as the value grows from vmin to vmax, so for example in
// the following the colour scheme is change from Blue to Red as the value increases:
// ringMeter(reading,-10,50, xpos,ypos,radius,"degC",BLUE2RED);
// In this case a temperature reading is being plotted in the range -10 to +50 degrees C, as the value
// increases the segments turn from blue (cold!) to red (hot!)
// #####################################################################################################
// Function to Draw the meter on the screen
int ringMeter(float value, int vmin, int vmax, int x, int y, int r, char *units, byte scheme)
{
x += r; y += r; // Calculate coords of centre of ring
uint8_t w = r / 4; // Width of outer ring is 1/4 of radius
uint16_t colour;
int i;
int text_colour = 0; // To hold the text colour
int angle = 130; // Half the sweep angle of meter (300 degrees)
int v = map(value, vmin, vmax, -angle, angle); // Map the value to an angle 'v'
// Settings/////////////////////////////////////////////////////////////////////////
const uint8_t seg = 5; // Segments are 5 degrees wide = 60 segments for 300 degrees
uint8_t inc = 5; // Draw segments every 5 degrees, increase to 10 for segmented ring 2 before value text intrudes on ring
// Draw colour blocks every inc degrees
for (i = -angle; i < angle; i += inc) {
// Choose colour from scheme
colour = 0;
switch (scheme) {
case 0: colour = TFT_RED; break; // Fixed colour
case 1: colour = TFT_GREEN; break; // Fixed colour
case 2: colour = TFT_BLUE; break; // Fixed colour
case 3: colour = rainbow(map(i, -angle, angle, 0, 127)); break; // Full spectrum blue to red
case 4: colour = rainbow(map(i, -angle, angle, 63, 127)); break; // Green to red (high temperature etc)
case 5: colour = rainbow(map(i, -angle, angle, 127, 63)); break; // Red to green (low battery etc)
case 6: colour = rainbow(map(i, -angle, angle, 127, 0)); break; // Red to blue (air cond reverse)
case 7: colour = rainbow(map(i, -angle, angle, 35, 127)); break; // cyan to red
case 8: colour = TFT_CYAN; break; // Fixed colour
default: colour = TFT_BLUE; break; // Fixed colour
}
// Calculate pair of coordinates for segment start
float sx = cos((i - 90) * 0.0174532925);
float sy = sin((i - 90) * 0.0174532925);
uint16_t x0 = sx * (r - w) + x;
uint16_t y0 = sy * (r - w) + y;
uint16_t x1 = sx * r + x;
uint16_t y1 = sy * r + y;
// Calculate pair of coordinates for segment end
float sx2 = cos((i + seg - 90) * 0.0174532925);
float sy2 = sin((i + seg - 90) * 0.0174532925);
int x2 = sx2 * (r - w) + x;
int y2 = sy2 * (r - w) + y;
int x3 = sx2 * r + x;
int y3 = sy2 * r + y;
if (i < v) { // Fill in coloured segments with 2 triangles
tft.fillTriangle(x0, y0, x1, y1, x2, y2, colour);
tft.fillTriangle(x1, y1, x2, y2, x3, y3, colour);
text_colour = colour; // Save the last colour drawn
}
else // Fill in blank segments
{
tft.fillTriangle(x0, y0, x1, y1, x2, y2, TFT_GREY);
tft.fillTriangle(x1, y1, x2, y2, x3, y3, TFT_GREY);
}
}
// Convert value to a string
char buf[10];
byte len = 4; if (value > 999) len = 5;
dtostrf(value, len, 0, buf);
// Set the text colour to default
tft.setTextColor(ILI9341_WHITE, ILI9341_BLACK);
// Uncomment next line to set the text colour to the last segment value!
// tft.setTextColor(text_colour, ILI9341_BLACK);
// Print value, if the meter is large then use big font 6, othewise use 4
if (r > 84) tft.drawFloat(value,1, x - 5, y - 20, 6); // Value in middle
else tft.drawFloat(value,1, x - 25, y - 20, 4); // Value in middle
// Print units, if the meter is large then use big font 4, othewise use 2
tft.setTextColor(ILI9341_WHITE, ILI9341_BLACK);
if (r > 84) tft.drawCentreString(units, x, y + 30, 4); // Units display
else tft.drawCentreString(units, x, y + 5, 4); // Units display
// Calculate and return right hand side x coordinate
return x + r;
}
// Return a 16 bit rainbow colour for the gauge
unsigned int rainbow(uint8_t val)
{
// Value is expected to be in range 0-127
// The value is converted to a spectrum colour from 0 = blue through to 127 = red
uint8_t r = 0;
uint8_t g = 0;
uint8_t b = 0;
uint8_t q = val / 32;
switch (q) {
case 0: r = 0; g = 2 * (val % 32); b = 31; break;
case 1: r = 0; g = 63; b = 31 - (val % 32); break;
case 2: r = val % 32; g = 63; b = 0; break;
case 3: r = 31; g = 63 - 2 * (val % 32); b = 0; break;
}
return (r << 11) + (g << 5) + b;
}
I was going to make a Shania Twain 'That don't impress me much' comment... then I started doubting if it actually was her on your in car TV :lol:
Glad to see the update Colin.
Overdue Update, the T-5R is now a T-5RS
Attachment 32847
Wahey, thats what we like to see :D
So Colin, what is the S for?
Oh and is the photo upload working ok for you?
Looks like a juicy supercharger found it's way in there :o
Hopefully we'll still get updates though!
That's me going in a different direction, compound charging should be fun and expand my knowledge a fair bit more, I'm already machining up a part that may grace the engine bay, which will depend on what is already fitted, whilst I was making bits for Gul's next round of upgrades, seemed sensible to make a spare, which now can possibly go onto the RS.
Can't wait to have a meet :D