Hi all
I am trying to get some code to output data using the VGA module from Strich Labs. My issue is around converting a float (analogue volt read from a temp sensor) to char that the VGA module can handle.
Code (obviously not my own work) below:
#include <Wire.h>
#include <MultiSerial.h>
#include <VGA.h>
#include <stdlib.h>
#define RES_X 640
#define RES_Y 480
VGA vgaInstance = VGA(0x4D);
char temperatureVGA;
int sensorPin = 5;
void setup()
{
Serial.begin(115200);
// vgaInstance.begin();
//vgaInstance.setResolution(RES_640x480);
//vgaInstance.textBackgroundOpaque(1);
//vgaInstance.fillShapes(0);
//vgaInstance.setFont(FONT_12x16);
//vgaInstance.clearScreen();
}
void loop()
{
int reading = analogRead(sensorPin);
float voltage = reading * 5.0;
voltage /= 1024.0;
// print out the readings
Serial.print(voltage); Serial.println(" volts");
float temperatureC = (voltage - 0.5) * 100 ;
Serial.print(temperatureC); Serial.println(" degrees C");
float temperatureF = (temperatureC * 9.0 / 5.0) + 32.0;
Serial.print(temperatureF); Serial.println(" degrees F");
dtostrf(temperatureC,0,2,temperatureVGA);
vgaInstance.drawGraphicsText("The coolant temperature is ",10,10,2,2,vgaInstance.generateColour(0,255,0));
vgaInstance.drawGraphicsText(temperatureVGA,10,10,2,2,vgaInstance.generateColour(0,255,0));
delay(1000);
}
Error on compile is
Test_VGA_Temp_1_2.cpp: In function 'void loop()':
Test_VGA_Temp_1_2:38: error: invalid conversion from 'char' to 'char*'
Test_VGA_Temp_1_2:38: error: initializing argument 4 of 'char* dtostrf(double, signed char, unsigned char, char*)'
Test_VGA_Temp_1_2.cpp:43: warning: deprecated conversion from string constant to 'char*'
Test_VGA_Temp_1_2:40: error: invalid conversion from 'char' to 'char*'
Test_VGA_Temp_1_2:40: error: initializing argument 1 of 'void VGA::drawGraphicsText(char*, short int, short int, byte, byte, PackedColour)'
Any advice much appreciated.
FYI this is for a monitor on a CNC machine, reading temp, flow rates etc.
Thanks