Join Today
Page 13 of 13 FirstFirst ... 3111213
Results 241 to 247 of 247
  1. #241
    New Identity
    Back in an AWD....Oh the grip!
    Dangerous Dave's Avatar
    Join Date
    Dec 2006
    Location
    West Midlands
    Posts
    8,310
    Thanks
    2,355
    Thanked 2,362 Times in 1,869 Posts
    You wouldn't even know there used to be switches in there

    How are you getting on with the arduino stuff?
    1996 Olive Green 850 AWD - Forged rods, VXR injectors, 19T, Ostrich 2.0, cold air con. Follow the project here
    1996 Nautic Blue 850 AWD - The daily, resisting the urge to modify

  2. The Following User Says Thank You to Dangerous Dave For This Useful Post:

    claymore (Monday 8th May 2017)

  3. #242
    Whiny Old Git
    Aching bones :(
    claymore's Avatar
    Join Date
    Aug 2009
    Location
    Shrewsbury
    Posts
    9,045
    Thanks
    4,340
    Thanked 4,980 Times in 3,002 Posts
    Quote Originally Posted by Dangerous Dave View Post

    How are you getting on with the arduino stuff?

    Lol, all the gear, no idea, I've got an Arduino uno, mega and duo, and am going to get an ESP32, I've got a couple of screens but I'm still waiting for my Nextion screen to arrive, but I wouldn't mind having a copy of your sketch to play with.
    PIC][/SIGPIC]
    aaaaaaaaaaaaaaaaaaaaaaaaa
    aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaa

    Facebook^^^^^^^^^^^^^^^^ Old T-5 Kompressor Thread^^^^^^^^^^^^^^^ New TT-10 Kompressor Thread

  4. #243
    New Identity
    Back in an AWD....Oh the grip!
    Dangerous Dave's Avatar
    Join Date
    Dec 2006
    Location
    West Midlands
    Posts
    8,310
    Thanks
    2,355
    Thanked 2,362 Times in 1,869 Posts
    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.
    1996 Olive Green 850 AWD - Forged rods, VXR injectors, 19T, Ostrich 2.0, cold air con. Follow the project here
    1996 Nautic Blue 850 AWD - The daily, resisting the urge to modify

  5. #244
    New Identity
    Back in an AWD....Oh the grip!
    Dangerous Dave's Avatar
    Join Date
    Dec 2006
    Location
    West Midlands
    Posts
    8,310
    Thanks
    2,355
    Thanked 2,362 Times in 1,869 Posts
    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;
    }
    1996 Olive Green 850 AWD - Forged rods, VXR injectors, 19T, Ostrich 2.0, cold air con. Follow the project here
    1996 Nautic Blue 850 AWD - The daily, resisting the urge to modify

  6. The Following User Says Thank You to Dangerous Dave For This Useful Post:

    claymore (Tuesday 9th May 2017)

  7. #245
    Whiny Old Git
    Aching bones :(
    claymore's Avatar
    Join Date
    Aug 2009
    Location
    Shrewsbury
    Posts
    9,045
    Thanks
    4,340
    Thanked 4,980 Times in 3,002 Posts
    Quote Originally Posted by Dangerous Dave View Post
    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;
    }

    Cheers mate, I'll have a play in a couple of days when I've finished with the steering wheel.
    PIC][/SIGPIC]
    aaaaaaaaaaaaaaaaaaaaaaaaa
    aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaa

    Facebook^^^^^^^^^^^^^^^^ Old T-5 Kompressor Thread^^^^^^^^^^^^^^^ New TT-10 Kompressor Thread

  8. #246
    Whiny Old Git
    Aching bones :(
    claymore's Avatar
    Join Date
    Aug 2009
    Location
    Shrewsbury
    Posts
    9,045
    Thanks
    4,340
    Thanked 4,980 Times in 3,002 Posts
    PIC][/SIGPIC]
    aaaaaaaaaaaaaaaaaaaaaaaaa
    aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaa

    Facebook^^^^^^^^^^^^^^^^ Old T-5 Kompressor Thread^^^^^^^^^^^^^^^ New TT-10 Kompressor Thread

  9. The Following 3 Users Say Thank You to claymore For This Useful Post:

    Dangerous Dave (Monday 16th October 2017),kmb (Monday 16th October 2017),MoleT-5R (Sunday 15th October 2017)

  10. #247
    Senior Member
    Appreciative
    kmb's Avatar
    Join Date
    Oct 2014
    Location
    Suffolk & Rhone Alpes
    Posts
    1,093
    Thanks
    648
    Thanked 385 Times in 312 Posts
    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

    Glad to see the update Colin.


 

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
ipv6 ready