Go Down

Topic: Display heart rate figure on TFT LCD (Read 181 times) previous topic - next topic

hoxymade

i am using a 2.8 TFT LCD touch Shield on an Arduino UNO.

http://www.robotshop.com/en/28-touch-lcd-display-shield-arduino.html

I am using it with a Grove Finger Clip Heart Rate sensor.
Everything is connected and working. I am just having trouble displaying the heart rate figure on the LCD because i do not know the command to put in.

The following sketch is what i have so far;

Code: [Select]
#include <Wire.h>
#include <stdint.h>
#include <LCD.h>
#include <SPI.h>

void setup()
{
    Serial.begin(9600);
    Serial.println("heart rate sensor:");
    Wire.begin();
   
    SPI.setDataMode(SPI_MODE3);
    SPI.setBitOrder(MSBFIRST);
    SPI.setClockDivider(SPI_CLOCK_DIV4);
    SPI.begin();
   
    Tft.lcd_init();                                      // init TFT library
   
//    Tft.lcd_draw_rect(30, 40, 150, 100, RED);
//    Tft.lcd_draw_circle(120, 160, 50, BLUE);
//    Tft.lcd_draw_line(30, 40, 180, 140, RED);
//   
//    Tft.lcd_draw_line(30, 220, 210, 240, RED);
//    Tft.lcd_draw_line(30, 220, 120, 280, RED);
//    Tft.lcd_draw_line(120, 280, 210, 240, RED);
}

void loop()
{
Wire.requestFrom(0xA0 >> 1, 1);   // request 1 bytes from slave device
    while(Wire.available()) {         // slave may send less than requested
        unsigned char c = Wire.read(); // receive heart rate value (a byte)
        Serial.println(c, DEC);       // print heart rate value 
        Tft.lcd_draw_numb(c, 50, 150, 200, RED);


}

delay(500);
}


The error line within the sketch is; Tft.lcd_draw_numb(c, 50, 150, 200, RED)

What is the correct command to display number.... Tft.lcd_...?????

robtillaart

Think you need to instantiate the tft object, poassibly with the right pins.

Do you have a link to the library used?
Examples provided with it might show you the needed syntax.
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

hoxymade

Think you need to instantiate the tft object, poassibly with the right pins.

Do you have a link to the library used?
Examples provided with it might show you the needed syntax.
This thing is there isnt a library exctly or what i want. I want to display just the heart rate figure that gets displayed in the serial monitor in Arduino IDE.
It is literally the line;
Tft.lcd_draw_numb(c, 50, 150, 200, RED);

I need to know how to write it for my TFT to draw the number.


robtillaart

But where is the object named    Tft   instantiated?

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

hoxymade

But where is the object named    Tft   instantiated?


Im not too sure what you mean but i managed to work it out. The code i have is now

Code: [Select]
#include <Wire.h>
#include <stdint.h>
#include <LCD.h>
#include <SPI.h>

void setup()
{
    Serial.begin(9600);
    Serial.println("heart rate sensor:");
    Wire.begin();
   
    SPI.setDataMode(SPI_MODE3);
    SPI.setBitOrder(MSBFIRST);
    SPI.setClockDivider(SPI_CLOCK_DIV4);
    SPI.begin();
   
    Tft.lcd_init();                                      // init TFT library
   
    Tft.lcd_display_string(80, 120, (const uint8_t *)"HEART RATE", FONT_1608, RED);   //Title
   
   
}

void loop()
{
Wire.requestFrom(0xA0 >> 1, 1);   // request 1 bytes from slave device
    while(Wire.available()) {         // slave may send less than requested
        unsigned char c = Wire.read(); // receive heart rate value (a byte)
        Serial.println(c, DEC);       // print heart rate value 
       // Tft.lcd_draw_centered_text(c, 100, 150, 200, RED);
        Tft.lcd_display_string(115, 152, (const uint8_t *) c, FONT_1608, RED);
}

delay(500);
 
}


What i need now is to clear the heart rate number displayed after every loop because it changes. At the moment is printing the numbers ontop of eachother as the heart rate is read.
Do you know the command to clear which will be at the bottom of the void loop section??

robtillaart

You could display the same string in the background color
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

hoxymade

You could display the same string in the background color
I think i just need the command to clear the screen. Do you know the command?

hoxymade

I think i just need the command to clear the screen. Do you know the command?

odometer

I think i just need the command to clear the screen. Do you know the command?
I think maybe this is relevant:
https://www.arduino.cc/en/Reference/TFTBackground

Go Up