Alright, seems there is something wrong I am doing that I don't understand. Before I start explaining, my question is different than this white screen
question.
First of all my TFT ST7735
is working very well with the below code, let's name it, code part 1:
#define USE_ARDUINO_INTERRUPTS true // Set-up low-level interrupts for most acurate BPM math.
#include <PulseSensorPlayground.h> // Includes the PulseSensorPlayground Library.
#include <Adafruit_GFX.h> // Core graphics library
#include <Adafruit_ST7735.h> // Hardware-specific library for ST7735
#include <Adafruit_ST7789.h> // Hardware-specific library for ST7789
#include <SPI.h>
#include <SD.h>
#define TFT_CS 10
#define TFT_RST 9 // Or set to -1 and connect to Arduino RESET pin
#define TFT_DC 8
#define TFT_MOSI 11 // Data out
#define TFT_SCLK 13 // Clock out
Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS, TFT_DC, TFT_MOSI, TFT_SCLK, TFT_RST);
float p = 3.1415926;
int Variable1;
int ledState = HIGH;
// Variables
int PulseWire = 0; // PulseSensor PURPLE WIRE connected to ANALOG PIN 0
int myBPM = 0;
const int LED13 = 13; // The on-board Arduino LED, close to PIN 13.
int Threshold = 550; // Determine which Signal to "count as a beat" and which to ignore.
// constants won't change:
const long interval = 1000;
unsigned long previousMillis = 0;
static uint32_t tsLastReport = 0;
void setup(void) {
Serial.begin(9600);
Serial.print(F("Hello! ST77xx TFT Test"));
#ifdef ADAFRUIT_HALLOWING
tft.initR(INITR_HALLOWING); // Initialize HalloWing-oriented screen
pinMode(TFT_BACKLIGHT, OUTPUT);
digitalWrite(TFT_BACKLIGHT, HIGH); // Backlight on
#else
tft.initR(INITR_144GREENTAB); // Init ST7735R chip, green tab
#endif
Serial.println(F("Initialized"));
uint16_t time = millis();
tft.fillScreen(ST77XX_BLACK);
time = millis() - time;
Serial.println(time, DEC);
delay(500);
Serial.println("done");
delay(1000);
}
void loop() {
testdrawtext(" BPM: ", ST77XX_WHITE);
tft.setTextColor(ST77XX_RED);
tft.setTextSize(2);
int sensorValue = analogRead(A0);
tft.print(sensorValue);
delay(300);
tft.fillScreen(ST77XX_BLACK);
}
void testdrawtext(char *text, uint16_t color) {
tft.setCursor(0, 0);
tft.fillScreen(ST77XX_BLACK);
tft.setCursor(0, 0);
// tft.setCursor(10, 40);
tft.setTextSize(2);
// tft.setTextColor(color);
tft.setTextColor(ST7735_YELLOW);
tft.setTextWrap(true);
tft.print(text);
delay(200);
}
Here is the video for Part 1 running very good with a random analog number.
Secondly, I have a simple Heart Beat circuit
and it is working very well when I apply this getting_BPM_to_Monitor
code into it. I don't have a photo for it but trust me it is working good so please, when I do attach the schematic don't focus too much on the hardware side, it might not be very perfectly stable but it is working fine for me.
Now, is the magic when I combine the Heart Beat which is getting_BPM_to_Monitor
& TFT ST7735 circuit
things don't seem alright and I think a code with a video is better explaining the issue than me. The below code, let's name it, code part 2:
#define USE_ARDUINO_INTERRUPTS true // Set-up low-level interrupts for most acurate BPM math.
#include <PulseSensorPlayground.h> // Includes the PulseSensorPlayground Library.
#include <Adafruit_GFX.h> // Core graphics library
#include <Adafruit_ST7735.h> // Hardware-specific library for ST7735
#include <Adafruit_ST7789.h> // Hardware-specific library for ST7789
#include <SPI.h>
#include <SD.h>
#define TFT_CS 10
#define TFT_RST 9 // Or set to -1 and connect to Arduino RESET pin
#define TFT_DC 8
.
#define TFT_MOSI 11 // Data out
#define TFT_SCLK 13 // Clock out
Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS, TFT_DC, TFT_MOSI, TFT_SCLK, TFT_RST);
float p = 3.1415926;
int Variable1;
int ledState = HIGH;
// Variables
int PulseWire = 0; // PulseSensor PURPLE WIRE connected to ANALOG PIN 0
const int LED13 = 13; // The on-board Arduino LED, close to PIN 13.
int Threshold = 550; // Determine which Signal to "count as a beat" and which to ignore.
int myBPM = 0;
PulseSensorPlayground pulseSensor; // Creates an instance of the PulseSensorPlayground object called "pulseSensor"
static uint32_t tsLastReport = 0;
void setup(void) {
Serial.begin(9600);
// . PulseWire = 3;
pulseSensor.analogInput(PulseWire);
pulseSensor.blinkOnPulse(LED13); //auto-magically blink Arduino's LED with heartbeat.
pulseSensor.setThreshold(Threshold);
pulseSensor.begin();
Serial.print(F("Hello! ST77xx TFT Test"));
#ifdef ADAFRUIT_HALLOWING
tft.initR(INITR_HALLOWING); // Initialize HalloWing-oriented screen
pinMode(TFT_BACKLIGHT, OUTPUT);
digitalWrite(TFT_BACKLIGHT, HIGH); // Backlight on
#else
// Use this initializer if using a 1.8" TFT screen:
// tft.initR(INITR_BLACKTAB); // Init ST7735S chip, black tab
// OR use this initializer (uncomment) if using a 1.44" TFT:
tft.initR(INITR_144GREENTAB); // Init ST7735R chip, green tab
// OR use this initializer (uncomment) if using a 0.96" 180x60 TFT:
//tft.initR(INITR_MINI160x80); // Init ST7735S mini display
// OR use this initializer (uncomment) if using a 1.54" 240x240 TFT:
//tft.init(240, 240); // Init ST7789 240x240
#endif
Serial.println(F("Initialized"));
uint16_t time = millis();
tft.fillScreen(ST77XX_BLACK);
time = millis() - time;
Serial.println(time, DEC);
delay(500);
Serial.println("done");
delay(1000);
Variable1 = 90;
}
void loop() {
testdrawtext(" BPM: ", ST77XX_WHITE);
tft.setTextColor(ST77XX_RED);
tft.setTextSize(3);
myBPM = pulseSensor.getBeatsPerMinute();
if (pulseSensor.sawStartOfBeat()) {
}
tft.print(myBPM);
delay(300);
tft.fillScreen(ST77XX_BLACK);
}
void testdrawtext(char *text, uint16_t color) {
tft.setCursor(0, 0);
tft.fillScreen(ST77XX_BLACK);
tft.setCursor(0, 0);
// tft.setCursor(10, 40);
tft.setTextSize(2);
// tft.setTextColor(color);
tft.setTextColor(ST7735_YELLOW);
tft.setTextWrap(true);
tft.print(text);
delay(200);
}
Here is the video or this video for Part 2
Lastly, I provided the schematic for more reasoning opinion and it was provided by Easyeda.com and you have to have an account to view my schematic
Things I have tried...
- I have modified TFT pins since
Gtting_BPM_to_Monitor
uses Timer1 & Timer2 - I have added/remove a lot of delays
- I have inserted
noInterrupts();
andinterrupts();
Edit 1 :
Here is a PNG
of the schematic if and hopefully, it is clear enough.
PNG
file. – Noajm IsMy Name Jun 19 '19 at 7:14