Hey Guys,
I’m a novice to c++ and was wondering if someone can help me figure out whats going wrong here.
// tested with GHI Gadgeteering 2013 R1 Beta
// Arduino Environment version 1.5.5 Beta
// All Gadgeteering Sketches require these includes:
#include <Wire.h>
#include <SPI.h>
#include <Gadgeteering.h>
#include <Mainboards/FEZMedusaS12.h>
#include <Modules/TempHumidity.h>
#include <Modules/CharacterDisplay.h>
using namespace gadgeteering;
using namespace gadgeteering::mainboards;
using namespace gadgeteering::modules;
fez_medusa_s12 board;
// add variables for each module you are using
temp_humidity *room_weather;
character_display *char_board;
unsigned int temperature;
unsigned int humidity;
void setup() {
Serial.begin(9600);
room_weather = new temp_humidity(3);
room_weather->take_measurements(double& temperature, double& humidity);
char_board = new character_display(12);
char_board->print("Temperature: " + temperature + " Relative Humidity: " + humidity);
}
void loop() {
}
this is the error report: room_temp.ino: In function ‘void setup()’:
room_temp:30: error: expected primary-expression before 'double’
room_temp:30: error: expected primary-expression before 'double’
room_temp:32: error: invalid operands of types ‘const char*’ and ‘const char [21]’ to binary ‘operator+’
room_temp.ino: In function ‘void setup()’:
room_temp:30: error: no matching function for call to 'gadgeteering::modules::temp_humidity::take_measurements(unsigned int&, unsigned int&)'
C:\Users----\Documents\Arduino\libraries\Gadgeteering\src/Modules/TempHumidity.h:42: note: candidates are: void gadgeteering::modules::temp_humidity::take_measurements(double&, double&)
I don’t have the char display interface for medusa in mind, but what is the parameter type of the char_board->print() method?
may be you need to convert temperature into a string before calling print.
You can use sprint to do so.
I did exactly that with the N18 display.
“%d” will be replaced with your temperature.
If you want to have decimal places you need to do that on your own because %f is not supported.
Google for “arduino convert float to string” and you will find several solutions.
If you have the 2x16 char display (or similar) a new line wont work.
The should be method that allows to set cursor position or a print method that accepts the start position (row and column).