I have some thing so simple, and I cannot figure it out. I've always struggled with setting LCD's up properly. I have been able to get text and data to show on my screen, but not what I want, I simply want it to show the external temp reading, the PWM% and the Fan RPMs.
If someone can point me in the direction of a good tutorial for text on LCD's I would be extremely grateful. I like to try myself first, before I ask for literal help.
It sounds like you need help with string formatting maybe and not necessarily specific to an LCD. If you can get text to the screen then that's all you need there. Now you just need to build the text you want to see.
Or maybe I misunderstood you. An example of what you mean might help.
Here is a video, if you scrub to 11:30 you’ll see the display in action. I want close to the same thing, except to include PWM% as well.
As a starting point I tried this:
void loop() {
// when characters arrive over the serial port...
if (Serial.available()) {
// wait a bit for the entire message to arrive
delay(100);
// clear the screen
lcd.clear();
// read all the available characters
while (Serial.available() > 0) {
// display each character to the LCD
lcd.write(Serial.read());
}
}
}
The issue is the Adafruit library doesn’t support lcd.clear(); so that’s one issue. I took that out and the code compiles fine but nothing shows up.
Here is my existing code, in the loop section, if I take any of the Serial.print lines and change them to tft.print those lines will show up on the screen.
// Basic demo for readings from Adafruit EMC2101
#include <Adafruit_EMC2101.h>
#include <Wire.h>
#include <Adafruit_GFX.h> // Core graphics library
#include <Adafruit_ST7789.h> // Hardware-specific library for ST7789
#include <SPI.h>
// Use dedicated hardware SPI pins
Adafruit_ST7789 tft = Adafruit_ST7789(TFT_CS, TFT_DC, TFT_RST);
Adafruit_EMC2101 emc2101;
void setup(void) {
Serial.begin(115200);
while (!Serial) delay(10); // will pause Zero, Leonardo, etc until serial console opens
Serial.print(F("Adafruit EMC2101 test!"));
pinMode(TFT_BACKLITE, OUTPUT);
digitalWrite(TFT_BACKLITE, HIGH);
pinMode(TFT_I2C_POWER, OUTPUT);
digitalWrite(TFT_I2C_POWER, HIGH);
delay(10);
// initialize TFT
tft.init(135, 240); // Init ST7789 240x135
tft.setRotation(3);
tft.setTextColor(ST77XX_WHITE);
tft.setTextSize(2);
Serial.println(F("Initialized"));
uint16_t time = millis();
tft.fillScreen(ST77XX_BLACK);
time = millis() - time;
uint16_t getFanMinRPM();
Serial.println(time, DEC);
delay(500);
// Try to initialize!
if (!emc2101.begin()) {
Serial.println("Failed to find EMC2101 chip");
while (1) { delay(10); }
}
Serial.println("EMC2101 Found!");
emc2101.setDutyCycle(5);
emc2101.setLUT(0, 20, 1);
emc2101.setLUT(1, 30, 10);
emc2101.setLUT(2, 40, 40);
emc2101.setLUT(3, 60, 60);
emc2101.setLUT(4, 80, 80);
emc2101.setLUT(5, 100, 100);
emc2101.LUTEnabled(true);
emc2101.setLUTHysteresis(5); // 5 degree C fudge factor
Serial.print("LUT Hysteresis: "); Serial.println(emc2101.getLUTHysteresis());
Serial.print("LUT enabled: "); Serial.println(emc2101.LUTEnabled());
Serial.print("enable force success: "); Serial.println(emc2101.enableForcedTemperature(false));
// emc2101.setDataRate(EMC2101_RATE_1_16_HZ);
Serial.print("Data rate set to: ");
switch (emc2101.getDataRate()) {
case EMC2101_RATE_1_16_HZ: Serial.println("1/16_HZ"); break;
case EMC2101_RATE_1_8_HZ: Serial.println("1/8_HZ"); break;
case EMC2101_RATE_1_4_HZ: Serial.println("1/4_HZ"); break;
case EMC2101_RATE_1_2_HZ: Serial.println("1/2_HZ"); break;
case EMC2101_RATE_1_HZ: Serial.println("1 HZ"); break;
case EMC2101_RATE_2_HZ: Serial.println("2 HZ"); break;
case EMC2101_RATE_4_HZ: Serial.println("4 HZ"); break;
case EMC2101_RATE_8_HZ: Serial.println("8 HZ"); break;
case EMC2101_RATE_16_HZ: Serial.println("16 HZ"); break;
case EMC2101_RATE_32_HZ: Serial.println("32 HZ"); break;
}
emc2101.enableTachInput(true);
emc2101.setPWMDivisor(0);
}
void loop() {
Serial.print("PWM: ");
Serial.print(emc2101.getDutyCycle());
Serial.println("%");
Serial.print("Fan RPM:: ");
Serial.print(emc2101.getFanRPM());
Serial.println(" RPM");
Serial.print("External Temperature: ");
Serial.print(emc2101.getExternalTemperature());
Serial.println(" degrees C");
delay(3000);
}
Which one?
Please post a link to specs/data/place of purchase please.
Can you please post a copy of your circuit, a picture of a hand drawn circuit in jpg, png?
Hand drawn and photographed is perfectly acceptable.
Please include ALL hardware, power supplies, component names and pin labels.
I was not aware the programming was that much different between a TFT and an LCD. I appreciate the help, and I did mention I'm new to this so any help is appreciated.
What I really want is just a sample piece of code that I can try and work with. All the examples I've found deal with graphics, bmp's, etc...I don't need any of that, I just want text!