How to make that only the values change when using the TFT screen, not the entire screen #3222
Unanswered
ucay99
asked this question in
Q&A - General
Replies: 1 comment
-
I think what you need are Sprites. There are examples using them for quickly changing values. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I have the following code
`#include <FastIMU.h>
#include <Wire.h>
#include <math.h>
#include <TFT_eSPI.h> // Hardware-specific library
#include <SPI.h>
#include "NotoSansBold15.h"
#include "NotoSansBold36.h"
// The font names are arrays references, thus must NOT be in quotes ""
#define AA_FONT_SMALL NotoSansBold15
#define AA_FONT_LARGE NotoSansBold36
#define IMU_ADDRESS 0x68 //Change to the address of the IMU
#define PERFORM_CALIBRATION //Comment to disable startup calibration
MPU6500 IMU; //Change to the name of any supported IMU!
calData calib = { 0 }; //Calibration data
AccelData accelData; //Sensor data
GyroData gyroData;
MagData magData;
TFT_eSPI tft = TFT_eSPI(); // Invoke custom library
TFT_eSprite spr = TFT_eSprite(&tft); // Sprite class needs to be invoked
void setup() {
tft.begin();
tft.setRotation(3);
tft.loadFont(AA_FONT_LARGE); // Load another different font
Wire.begin();
Serial.begin(115200);
while (!Serial) {
;
}
int err = IMU.init(calib, IMU_ADDRESS);
if (err != 0) {
Serial.print("Error initializing IMU: ");
Serial.println(err);
while (true) {
;
}
}
#ifdef PERFORM_CALIBRATION
Serial.println("FastIMU calibration & data example");
if (IMU.hasMagnetometer()) {
delay(1000);
Serial.println("Move IMU in figure 8 pattern until done.");
delay(3000);
IMU.calibrateMag(&calib);
Serial.println("Magnetic calibration done!");
}
else {
delay(100);
}
delay(2000);
Serial.println("Tolong jangan gerak-gerak.. IMU sedang dikalibrasi");
delay(2000);
IMU.calibrateAccelGyro(&calib);
IMU.init(calib, IMU_ADDRESS);
Serial.println("Kalibrasi Selesai!");
delay(3000);
#endif
if (err != 0) {
Serial.print("Error Setting range: ");
Serial.println(err);
while (true) {
;
}
}
}
void loop() {
IMU.update();
// Dapatkan data akselerometer dan giroskop
IMU.getAccel(&accelData);
IMU.getGyro(&gyroData);
delay(50);
// Hitung sudut kemiringan menggunakan arctan
float pitch = fabs(atan2(accelData.accelY, accelData.accelZ)- PI)* 180.0 / PI;
float roll = fabs(atan2(accelData.accelX, accelData.accelZ)- PI)* 180.0 / PI;
tft.fillScreen(TFT_BLACK);
tft.setTextColor(TFT_WHITE, TFT_BLACK); // Set the font colour AND the background colour
// Tampilkan data sudut kemiringan
Serial.print("Sudut X: ");
Serial.print(pitch);
Serial.print("\t Sudut Y: ");
Serial.println(roll);
tft.setTextColor(TFT_WHITE, TFT_BLACK, false);
tft.setCursor(50, 100);
tft.print(pitch, 1);
tft.setCursor(200, 100);
tft.print(roll, 1);
delay(500);
}`
How do I prevent the TFT screen from flashing when the value of the sensor changes
Beta Was this translation helpful? Give feedback.
All reactions