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 00019 00027 //define the module. 00028 class Tweaker : public Module 00029 { 00030 DECLARE_MODULE(Tweaker,Module) 00031 00032 00033 //Only use this to expose sockets and parameters. Do most of your 00034 //initialisastion in Init() 00035 Tweaker() 00036 { 00037 } 00038 00039 //A parameter has changed. This happens at bootup if the EEPROM 00040 //contains valid data and at run-time if the user changes a 00041 //parameter over the serial link 00042 virtual void ParamChanged(Socket * param) 00043 { 00044 } 00045 00046 //Initialise the module 00047 //set up hardware etc 00048 virtual void Init() 00049 { 00050 //Set how often Loop() should be executed (in milliseconds) 00051 SetInterval(100); 00052 SetPriority(5); 00053 for (int ct=0; ct<MAX_TWEAKERS; ct++) 00054 { 00055 m_inputs[ct].Connect(tweakInputNames[ct]); 00056 m_outputs[ct].Connect(tweakOutputNames[ct]); 00057 } 00058 } 00059 00060 //Here is where you do your work. It is called at the rate defined by SetInterval 00061 virtual void Loop(const unsigned long& interval) 00062 { 00063 for (int ct=0; ct<MAX_TWEAKERS; ct++) 00064 { 00065 m_outputs[ct] = (m_inputs[ct] + tweakOffsets[ct]) * tweakGains[ct]; 00066 } 00067 } 00068 00069 private: 00070 PlugF m_inputs[MAX_TWEAKERS]; 00071 PlugF m_outputs[MAX_TWEAKERS]; 00072 00073 }; 00074 00075 Tweaker g_Tweaker; 00076 00077
1.7.0