00001 /* 00002 Copyright (c) 2010 Les Newell. All rights reserved 00003 00004 This program is free software: you can redistribute it and/or modify 00005 it under the terms of the GNU General Public License as published by 00006 the Free Software Foundation, either version 3 of the License, or 00007 (at your option) any later version. 00008 00009 This program is distributed in the hope that it will be useful, 00010 but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 GNU General Public License for more details. 00013 00014 You should have received a copy of the GNU General Public License 00015 along with this program. If not, see <http://www.gnu.org/licenses/>. 00016 */ 00017 00018 00020 00023 //define the module. 00024 class MyModule : public Module 00025 { 00026 DECLARE_MODULE(MyModule,Module) 00027 00028 00029 //Only use this to expose sockets and parameters. Do most of your 00030 //initialisastion in Init() 00031 MyModule() 00032 { 00033 /*Expose sockets to the outside world 00034 NOTE: the socket name must be a static string. 00035 Bad Things will happen if you use a string allocated on the stack 00036 You can use a pointer to a static string.*/ 00037 AddSocket("SocketName", &m_socket); 00038 00039 } 00040 00041 //A parameter has changed. This happens at bootup if the EEPROM 00042 //contains valid data and at run-time if the user changes a 00043 //parameter over the serial link 00044 virtual void ParamChanged(Socket * param) 00045 { 00046 } 00047 00048 //Initialise the module 00049 //set up hardware etc 00050 virtual void Init() 00051 { 00052 //Set how often Loop() should be executed (in milliseconds) 00053 SetInterval(100); 00054 //Set this module's priority. -1 is never execute, 100 is maximum. 00055 SetPriority (10); 00056 } 00057 00058 //Here is where you do your work. It is called at the rate defined by SetInterval 00059 virtual void Loop(const unsigned long& interval) 00060 { 00061 } 00062 00063 private: 00064 Socket8 m_socket; 00065 00066 }; 00067 00068 MyModule g_MyModule; 00069
1.7.0