I am trying to convert some code to a class and it mostly works except for one thing I want to add. Let me explain what I am trying to do by example. When you #include <Wire.h> it creates a Wire object of class of TwoWire. You don't have to have TwoWire Wire(i2c0_addr, TwoWire::i2c0_hardware); in your code just including the library is enough.
What I have tried that didn't work is:
The error is
Anyone care to point out my error? I'm really new to the ++ part of C++ and I know its simple but I just don't get it.
What I have tried that didn't work is:
Code:
// TestCL.ino
#include "TestCL.h"
//TestCL SVM; <<<<<<<<<<<<<<<< uncomment this and it works
void setup() {
SVM.begin();
}
void loop() {
}
// TestCL.cpp
#include "TestCL.h"
void TestCL::begin() {
Serial.println("Started");
}
TestCL SVM(); // <<<<<<< I thought this would work
//TestCl.h
#include <Arduino.h>
class TestCL {
public:
void begin(void);
private:
};
The error is
Code:
Arduino: 1.8.3 (Mac OS X), TD: 1.37, Board: "Teensy 3.2 / 3.1, Serial, 72 MHz, Faster, US English"
TestCL: In function 'void setup()':
TestCL:7: error: 'SVM' was not declared in this scope
SVM.begin();
^
'SVM' was not declared in this scope
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
Anyone care to point out my error? I'm really new to the ++ part of C++ and I know its simple but I just don't get it.