|
| 1 | +/* |
| 2 | + AeroQuad v2.0.1 - September 2010 |
| 3 | + www.AeroQuad.com |
| 4 | + Copyright (c) 2010 Ted Carancho. All rights reserved. |
| 5 | + An Open Source Arduino based multicopter. |
| 6 | + |
| 7 | + This program is free software: you can redistribute it and/or modify |
| 8 | + it under the terms of the GNU General Public License as published by |
| 9 | + the Free Software Foundation, either version 3 of the License, or |
| 10 | + (at your option) any later version. |
| 11 | +
|
| 12 | + This program is distributed in the hope that it will be useful, |
| 13 | + but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | + GNU General Public License for more details. |
| 16 | +
|
| 17 | + You should have received a copy of the GNU General Public License |
| 18 | + along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 19 | +*/ |
| 20 | + |
| 21 | +// User this as a template for new classes or subclasses |
| 22 | + |
| 23 | +// *********************************************************************** |
| 24 | +// ************************** Example Class ****************************** |
| 25 | +// *********************************************************************** |
| 26 | +class exampleClass { |
| 27 | +public: |
| 28 | + int exampleVariable; |
| 29 | + float exampleData[3]; |
| 30 | + exampleClass(void) { |
| 31 | + // this is the constructor of the object and must have the same name |
| 32 | + // can be used to initialize any of the variables declared above |
| 33 | + } |
| 34 | + |
| 35 | + // ********************************************************************** |
| 36 | + // The following function calls must be defined inside any new subclasses |
| 37 | + // ********************************************************************** |
| 38 | + virtual void initialize(void); |
| 39 | + virtual void exampleFunction(int); |
| 40 | + virtual const int getExampleData(byte); |
| 41 | + |
| 42 | + // ********************************************************* |
| 43 | + // The following functions are common between all subclasses |
| 44 | + // ********************************************************* |
| 45 | + void examplePublicFunction(byte axis, int value) { |
| 46 | + // insert common code here |
| 47 | + } |
| 48 | + const int getPublicData(byte axis) { |
| 49 | + return exampleData[axis]; |
| 50 | + } |
| 51 | +}; |
| 52 | + |
| 53 | +// *********************************************************************** |
| 54 | +// ************************ Example Subclass ***************************** |
| 55 | +// *********************************************************************** |
| 56 | +class exampleSubClass : public exampleClass { |
| 57 | +private: |
| 58 | + int exampleArray[3]; // only for use inside this subclass |
| 59 | + int examplePrivateData; // only for use inside this subclass |
| 60 | + void examplePrivateFunction(int functionVariable) { |
| 61 | + // it’s possible to declare functions just for this subclass |
| 62 | + } |
| 63 | + |
| 64 | +public: |
| 65 | + exampleSubClass() : exampleClass(){ |
| 66 | + // this is the constructor of the object and must have the same name |
| 67 | + // can be used to initialize any of the variables declared above |
| 68 | + } |
| 69 | + |
| 70 | + // *********************************************************** |
| 71 | + // Define all the virtual functions declared in the main class |
| 72 | + // *********************************************************** |
| 73 | + void initialize(void) { |
| 74 | + // insert code here |
| 75 | + } |
| 76 | + void exampleFunction(int someVariable) { |
| 77 | + // insert code here |
| 78 | + examplePrivateFunction(someVariable); |
| 79 | + } |
| 80 | + const int getExampleData(byte axis) { |
| 81 | + // insert code here |
| 82 | + return exampleArray[axis]; |
| 83 | + } |
| 84 | +}; |
0 commit comments