Hallo,
ich habe für mein Netzteil eine kleine Anzeige mit INA 219 und 3,2" TFT gebastelt.
Gibt es noch einen Trick, wie man das Anzeigeflimmern unterbinden kann ?
Anbei ein Video dazu.
#include <INA219.h>
#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h> // include Adafruit graphics library
#include <Adafruit_ILI9341.h> // include Adafruit ILI9341 TFT library
#include <Fonts/FreeSerif24pt7b.h>
#include <Fonts/Seven_Segment30pt7b.h>
#define TFT_CS 14 // TFT CS pin is connected to arduino pin 14
#define TFT_RST 13 // TFT RST pin is connected to arduino pin 13
#define TFT_DC 12 // TFT DC pin is connected to arduino pin 12
// initialize ILI9341 TFT library
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_RST);
#define TFT_GREY 0x5AEB // New colour
#define TFT_Yellow 0xFFE0
#define TFT_AQUA 0x0000
#define TFT_GOLD 0xA508
#define TFT_SILVER 0xA510
float value1;
float old_value1 ;
float value2;
float old_value2 ;
float value3;
float old_value3 ;
float shuntvoltage = 0.0;
float busvoltage = 0.0;
float current = 0.0;
float power = 0.0;
INA219 ina;
void setup(void)
{
// Default INA219 address is 0x40
ina.begin();
tft.begin();
tft.setRotation(1);
tft.fillScreen(ILI9341_BLACK);
tft.drawRect(0, 0, 320, 80, ILI9341_WHITE );
tft.drawRect(2, 2, 316, 76,ILI9341_WHITE );
tft.drawRect(0, 80, 320, 80,ILI9341_WHITE );
tft.drawRect(2, 82, 316, 76, ILI9341_WHITE );
tft.drawRect(0, 160, 320, 80, ILI9341_WHITE );
tft.drawRect(2, 162, 316, 76,ILI9341_WHITE );
tft.setTextColor( ILI9341_YELLOW);
tft.setFont(&FreeSerif24pt7b);
tft.setTextSize(1);
tft.setCursor(10, 50 );
tft.print("Volt:");
tft.setCursor(10, 130 );
tft.print("Amp.:");
tft.setCursor(10, 210 );
tft.print("Pow.:");
// Configure INA219
ina.configure(INA219_RANGE_16V, INA219_GAIN_320MV, INA219_BUS_RES_12BIT, INA219_SHUNT_RES_12BIT_1S);
// Calibrate INA219. Rshunt = 0.1 ohm
ina.calibrate(0.10, 2);
}
void loop(void)
{
busvoltage = ina.readBusVoltage();
current = ina.readShuntCurrent();
power = ina.readBusPower();
value1 = (busvoltage *1.025);
value2 = (current * 1.11);
value3 = (power * 1.105);
old_value1 = busvoltage;
old_value2 = current;
old_value3 = power;
if(value1 != old_value1)
{
tft.fillRect(160,15,115,50,ILI9341_BLACK);
tft.setTextColor(ILI9341_GREEN);
tft.setFont(&Seven_Segment30pt7b);
tft.setTextSize(1);
tft.setCursor(170, 60 );
tft.print(value1,2);
}
if(value2 != old_value2)
tft.fillRect(160,95,115,50,ILI9341_BLACK);
tft.setTextColor( ILI9341_RED);
tft.setFont(&Seven_Segment30pt7b);
tft.setTextSize(1);
tft.setCursor(170, 140 );
tft.print(value2,2);
}
if(value3 != old_value3)
{
tft.fillRect(160,175,115,50,ILI9341_BLACK);
tft.setTextColor(ILI9341_BLUE,ILI9341_BLACK);
tft.setFont(&Seven_Segment30pt7b);
tft.setTextSize(1);
tft.setCursor(170,220);
tft.print(value3,2);
}
}
Ich danke für jegliche Hilfe - viele Grüße Maik.
Anzeige TFT.mpg (1.32 MB)