When I ditch d to string and char
code be like this
#include <SPI.h>
#include <Adafruit_GFX.h> // Core graphics library
#include <Adafruit_ST7735.h> // Hardware-specific library
#include "bitmaps.h"
#include "bitmapsLarge.h"
#include "BluetoothSerial.h"
#include "ELMduino.h"
#define TFT_CS 5
#define TFT_RST 4 // Or set to -1 and connect to Arduino RESET pin
#define TFT_DC 2
BluetoothSerial SerialBT;
#define ELM_PORT SerialBT
#define DEBUG_PORT Serial
ELM327 myELM327;
uint32_t rpm = 0;
Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS, TFT_DC, TFT_RST);
float p = 3.1415926;
float temp=myELM327.engineCoolantTemp();
float usis=myELM327.intakeAirTemp();
float ugrana=myELM327.manifoldPressure();
float pritisak=myELM327.absBaroPressure();
float granausis= (uint8_t)ugrana;
float kpa= (uint8_t)pritisak;
float boost=(granausis-kpa)/100;
void setup(void) {
Serial.begin(9600);
Serial.print(F("Hello! ST77xx TFT Test"));
tft.initR(INITR_BLACKTAB);
tft.setRotation(0);
tft.fillScreen(ST7735_BLACK);
{
#if LED_BUILTIN
pinMode(LED_BUILTIN, OUTPUT);
digitalWrite(LED_BUILTIN, LOW);
#endif
DEBUG_PORT.begin(115200);
//SerialBT.setPin("1234");
ELM_PORT.begin("ArduHUD", true);
if (!ELM_PORT.connect("OBDII"))
{
DEBUG_PORT.println("Couldn't connect to OBD scanner - Phase 1");
while(1);
}
if (!myELM327.begin(ELM_PORT, true, 2000))
{
Serial.println("Couldn't connect to OBD scanner - Phase 2");
while (1);
}
Serial.println("Connected to ELM327");
}
//Case 2: Multi Colored Images/Icons
int h = 160,w = 128, row, col, buffidx=0;
for (row=0; row<h; row++) { // For each scanline...
for (col=0; col<w; col++) { // For each pixel...
//To read from Flash Memory, pgm_read_XXX is required.
//Since image is stored as uint16_t, pgm_read_word is used as it uses 16bit address
tft.drawPixel(col, row, pgm_read_word(evive_in_hand + buffidx));
buffidx++;
} // end pixel
}
delay(5000);
// Use this initializer if using a 1.8" TFT screen:
// tft.initR(INITR_BLACKTAB); // Init ST7735S chip, black tab
tft.setRotation(1); // set display orientation
}
void loop() {
tft.fillScreen(ST77XX_BLACK);
print_text(20,5,boost,5,ST77XX_GREEN);
print_text(70,50,"BAR",2,ST77XX_GREEN); ////Boost
print_text(5, 90, "Temp engine:", 1, ST77XX_WHITE);
print_text(70, 90, temp, 1, ST77XX_WHITE); ///Engine_temp
print_text(5, 100, "Temp usisa:", 1, ST77XX_BLUE); ///Intake_temp
print_text(70, 100, usis, 1, ST77XX_BLUE);
print_text(146,116,"AM",1,ST77XX_WHITE);
{
float tempRPM = myELM327.rpm();
if (myELM327.nb_rx_state == ELM_SUCCESS)
{
rpm = (uint32_t)tempRPM;
Serial.print("RPM: "); Serial.println(rpm);
}
else if (myELM327.nb_rx_state != ELM_GETTING_MSG)
myELM327.printError();
}
delay(5000);
}
void print_text(byte x_pos, byte y_pos, char *text, byte text_size, uint16_t color) {
tft.setCursor(x_pos, y_pos);
tft.setTextSize(text_size);
tft.setTextColor(color);
tft.setTextWrap(true);
tft.print(text);
}
I get this error
Arduino: 1.8.19 (Windows 10), Board: "ESP32 Dev Module, Disabled, Default 4MB with spiffs (1.2MB APP/1.5MB SPIFFS), 240MHz (WiFi/BT), QIO, 40MHz, 4MB (32Mb), 921600, Core 1, Core 1, None"
C:\Users\X260\Documents\Arduino\Displej-Test-Print_greske_skoro\Displej-Test-Print_greske_skoro.ino: In function 'void loop()':
Displej-Test-Print_greske_skoro:97:19: error: cannot convert 'float' to 'char*'
print_text(20,5,boost,5,ST77XX_GREEN);
^~~~~
C:\Users\X260\Documents\Arduino\Displej-Test-Print_greske_skoro\Displej-Test-Print_greske_skoro.ino:122:47: note: initializing argument 3 of 'void print_text(byte, byte, char*, byte, uint16_t)'
void print_text(byte x_pos, byte y_pos, char *text, byte text_size, uint16_t color) {
~~~~~~^~~~
C:\Users\X260\Documents\Arduino\Displej-Test-Print_greske_skoro\Displej-Test-Print_greske_skoro.ino:98:40: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
print_text(70,50,"BAR",2,ST77XX_GREEN); ////Boost
^
C:\Users\X260\Documents\Arduino\Displej-Test-Print_greske_skoro\Displej-Test-Print_greske_skoro.ino:100:53: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
print_text(5, 90, "Temp engine:", 1, ST77XX_WHITE);
^
Displej-Test-Print_greske_skoro:101:22: error: cannot convert 'float' to 'char*'
print_text(70, 90, temp, 1, ST77XX_WHITE); ///Engine_temp
^~~~
C:\Users\X260\Documents\Arduino\Displej-Test-Print_greske_skoro\Displej-Test-Print_greske_skoro.ino:122:47: note: initializing argument 3 of 'void print_text(byte, byte, char*, byte, uint16_t)'
void print_text(byte x_pos, byte y_pos, char *text, byte text_size, uint16_t color) {
~~~~~~^~~~
C:\Users\X260\Documents\Arduino\Displej-Test-Print_greske_skoro\Displej-Test-Print_greske_skoro.ino:103:51: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
print_text(5, 100, "Temp usisa:", 1, ST77XX_BLUE); ///Intake_temp
^
Displej-Test-Print_greske_skoro:104:23: error: cannot convert 'float' to 'char*'
print_text(70, 100, usis, 1, ST77XX_BLUE);
^~~~
C:\Users\X260\Documents\Arduino\Displej-Test-Print_greske_skoro\Displej-Test-Print_greske_skoro.ino:122:47: note: initializing argument 3 of 'void print_text(byte, byte, char*, byte, uint16_t)'
void print_text(byte x_pos, byte y_pos, char *text, byte text_size, uint16_t color) {
~~~~~~^~~~
C:\Users\X260\Documents\Arduino\Displej-Test-Print_greske_skoro\Displej-Test-Print_greske_skoro.ino:106:41: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
print_text(146,116,"AM",1,ST77XX_WHITE);
^
exit status 1
cannot convert 'float' to 'char*'
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.