DWIN’s UART (Universal Asynchronous Receiver-Transmitter) TFT displays are a type of colour TFT LCD that communicate with a microcontroller or microprocessor through a UART interface. UART is one of the most common communication protocols, and it is widely supported by almost all microprocessors and microcontrollers The UART protocol allows these displays to be easily integrated into systems without requiring complex parallel interfaces, which are common with traditional TFT displays.
Link to ORIC Electronics
UART Communication (TX, RX)
UART communication is asynchronous, meaning that no clock signal is needed. Data is sent as a series of bytes over the TX pin of the microcontroller to the RX pin of the display, and vice versa for receiving.
In conclusion, DWIN UART TFT displays offer a highly efficient and flexible solution for integrating advanced graphical interfaces into microcontroller-based systems. With simplified wiring, reduced CPU load, and robust GUI development tools like DGUS, they streamline both hardware and software design. Whether for home automation, industrial control, or wearable devices, DWIN’s versatile display range provides reliable and scalable options to meet a wide array of application needs.
Hi, I am attempting (and failing miserably!) to convert the original sketch used to output the results from an LTC to a TFT display. I can get the serial output version of the sketch to work fine.
The TFT version of the sketch uses a library
As the guru on TFT devices and the range of drivers etc used, and my belief that you were probably heavily involved in the creation of the original TFT LTC script can you point me in the right direction on modifying the sketch to use the new TFT libraries.
Thank you in anticipation,
Don
David,
Thank you for your prompt response. I purchased this on EBAY:http://www.ebay.co.uk/itm/2-4-inch-TFT-LCD-Display-Shield-Touch-Panel-ILI-240X320-for-Arduino-UN-D1E3-/?_trksid=p.m.l.c10#. Whilst the seller says it uses a 1L controller it doesnt, having read your posts about the stuff sold on EBAY and using the test in MCUFRIEND_kbv it identifies it as a HED. Setting this as controller in the Library code (.cpp file) it runs through all the graphicstest_kbv tests perfectly.
The sketch I am using is as follows:
[code//LTC 24bit ADC Module
//
//Application Demo: 7 digit voltmeter interfacing with CTE UART TFT LCD
//24bit ADC IC: LTC
//4.096 precision reference: TI REF
//
//By coldtears electronics
//
//LTC code is adapted from Martin Nawrath
//Kunsthochschule fuer Medien Koeln
//Academy of Media Arts Cologne
//
//UART TFT Library from coldtears electronics is used
//as to display results
#include
#include
#include
UARTLCD uartlcd(true,false); //(single wire mode,checksum enable)
#ifndef cbi
#define cbi(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit))
#endif
#ifndef sbi
#define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit))
#endif
#define LTC_CS 2 // LTC Chip Select Pin on Portb 2
#define LTC_MISO 4 // LTC SDO Select Pin on Portb 4
#define LTC_SCK 5 // LTC SCK Select Pin on Portb 5
void setup() {
cbi(PORTB,LTC_SCK); // LTC SCK low
sbi (DDRB,LTC_CS); // LTC CS HIGH
cbi (DDRB,LTC_MISO);
sbi (DDRB,LTC_SCK);
Serial.begin();
uartlcd.Clr_screen(BLACK); delay(400); //Clear screen Black color
uartlcd.Clr_screen(BLACK); delay(400); //Clear screen Black color
uartlcd.Draw_image(412,15,6); delay(100);
uartlcd.Draw_text(BLACK, PURPLE,"LTC 24bit", 100, 4, 319,230, 6); delay(70);
uartlcd.Draw_text(BLACK, CYAN,"ADC Module ", 110, 35, 319,230, 6); delay(70);
// init SPI Hardware
sbi(SPCR,MSTR) ; // SPI master mode
sbi(SPCR,SPR0) ; // SPI speed
sbi(SPCR,SPR1); // SPI speed
sbi(SPCR,SPE); //SPI enable
//Serial.println("LTC ADC Test");
}
float volt;
float v_ref=4.094; // Reference Voltage, 5.0 Volt for LT or 3.0 for LP-3
long int ltw = 0; // ADC Data ling int
int cnt; // counter
byte b0; //
byte sig; // sign bit flag
char st1[20]; // float voltage text
/********************************************************************/
void loop() {
cbi(PORTB,LTC_CS); // LTC CS Low
delayMicroseconds(1);
if (!(PINB & (1 << 4))) { // ADC Converter ready ?
// cli();
ltw=0;
sig=0;
b0 = SPI_read(); // read 4 bytes adc raw data with SPI
if ((b0 & 0x20) ==0) sig=1; // is input negative ?
b0 &=0x1F; // discard bit 25..31
ltw |= b0;
ltw <<= 8;
b0 = SPI_read();
ltw |= b0;
ltw <<= 8;
b0 = SPI_read();
ltw |= b0;
ltw <<= 8;
b0 = SPI_read();
ltw |= b0;
delayMicroseconds(1);
sbi(PORTB,LTC_CS); // LTC CS Low
if (sig) ltw |= 0xf; // if input negative insert sign bit
ltw=ltw/16; // scale result down , last 4 bits have no information
volt = ltw * v_ref / ; // max scale
char tmp[10];
dtostrf(volt,6,6,tmp);
tmp[8]='V';
tmp[9]='\n';
// Serial.print(cnt++);
// Serial.print("; ");
// printFloat(volt,6); // print voltage as floating number
// Serial.println(" ");
uartlcd.Draw_text(BLACK, YELLOW,tmp, 10, 100, 319, 220, 9); delay(50);
}
sbi(PORTB,LTC_CS); // LTC CS hi
delay(20);
}
/********************************************************************/
byte SPI_read()
{
SPDR = 0;
while (!(SPSR & (1 << SPIF))) ; /* Wait for SPI shift out done */
return SPDR;
}
/********************************************************************/
// printFloat from tim / Arduino: Playground
// printFloat prints out the float 'value' rounded to 'places' places
//after the decimal point
void printFloat(float value, int places) {
// this is used to cast digits
int digit;
float tens = 0.1;
int tenscount = 0;
int i;
float tempfloat = value;
// if value is negative, set tempfloat to the abs value
// make sure we round properly. this could use pow from
//, but doesn't seem worth the import
// if this rounding step isn't here, the value 54.321 prints as
// calculate rounding term d: 0.5/pow(10,places)
float d = 0.5;
if (value < 0)
d *= -1.0;
// divide by ten for each decimal place
for (i = 0; i < places; i++)
d/= 10.0;
// this small addition, combined with truncation will round our
tempfloat += d;
if (value < 0)
tempfloat *= -1.0;
while ((tens * 10.0) <= tempfloat) {
tens *= 10.0;
tenscount += 1;
}
// write out the negative if needed
if (value < 0)
Serial.print('-');
if (tenscount == 0)
Serial.print(0, DEC);
for (i=0; i< tenscount; i++) {
digit = (int) (tempfloat/tens);
Serial.print(digit, DEC);
tempfloat = tempfloat - ((float)digit * tens);
tens /= 10.0;
}
// if no places after decimal, stop now and return
if (places <= 0)
return;
// otherwise, write the point and continue on
Serial.print(',');
for (i = 0; i < places; i++) {
tempfloat *= 10.0;
digit = (int) tempfloat;
Serial.print(digit,DEC);
// once written, subtract off that digit
tempfloat = tempfloat - (float) digit;
}
}
]
I also have a serial out sketch which works fine. If i had carried on failing so dramatically i was going to try and convert this to output to a TFT display :o
For more information, please visit uart tft display.
Hardware: Arduino R3, LTC on breakout, TFT panel. I have had the DVM working fine and the TFT panel working fine , just not with this sketch.
I don't need anything clever on the display:
| |
| PSU N | N = Constant 1 or 2
| |
| XX.XXXX Volts |
| |
| X.XXXX Amps |
If you can help me with the basics I am sure I can tart this up. As I said if I could get a copy of the original Library (UARtLCD so I could compile the sketch I have, I am sure I could have solved this myself, however I am most grateful for whatever help you can give.
I have to add some logic to the DVM so I can switch the input between the two measurements being made (Voltage and Current). This will require me to hang an output onto the arduino/sketch so the input matches what is being displayed (or vice versa).
Once again many thanks for the help
Don
For more pm oled displayinformation, please contact us. We will provide professional answers.