diff --git a/App/Button.cpp b/App/Button.cpp index 3c07e21d..5b708b8a 100644 --- a/App/Button.cpp +++ b/App/Button.cpp @@ -10,8 +10,8 @@ Button::Button() Index = 0; _Value = false; - _Handler = nullptr; - _Param = nullptr; + //_Handler = nullptr; + //_Param = nullptr; } Button::~Button() @@ -54,11 +54,12 @@ void Button::OnPress(Pin pin, bool down) { SetValue(!_Value); - if(_Handler) _Handler(this, _Param); + //if(_Handler) _Handler(this, _Param); + Press(this); } } -void Button::Register(EventHandler handler, void* param) +/*void Button::Register(EventHandler handler, void* param) { if(handler) { @@ -70,7 +71,7 @@ void Button::Register(EventHandler handler, void* param) _Handler = nullptr; _Param = nullptr; } -} +}*/ bool Button::GetValue() { return _Value; } diff --git a/App/Button.h b/App/Button.h index 608fb641..77bdbbeb 100644 --- a/App/Button.h +++ b/App/Button.h @@ -15,8 +15,8 @@ private: static void OnPress(InputPort* port, bool down, void* param); void OnPress(Pin pin, bool down); - EventHandler _Handler; - void* _Param; + //EventHandler _Handler; + //void* _Param; public: cstring Name; // 按钮名称 int Index; // 索引号,方便在众多按钮中标识按钮 @@ -25,6 +25,8 @@ public: OutputPort Led; // 指示灯 OutputPort Relay; // 继电器 + Delegate Press; // 按下事件 + public: // 构造函数。指示灯和继电器一般开漏输出,需要倒置 Button(); @@ -35,7 +37,7 @@ public: bool GetValue(); void SetValue(bool value); - void Register(EventHandler handler, void* param = nullptr); + //void Register(EventHandler handler, void* param = nullptr); virtual int OnWrite(byte data); virtual byte OnRead(); diff --git a/App/Button_GrayLevel.cpp b/App/Button_GrayLevel.cpp index d3354fe1..ba20696d 100644 --- a/App/Button_GrayLevel.cpp +++ b/App/Button_GrayLevel.cpp @@ -27,8 +27,8 @@ Button_GrayLevel::Button_GrayLevel() : ByteDataPort() _Pwm = nullptr; _Channel = 0; - _Handler = nullptr; - _Param = nullptr; + //_Handler = nullptr; + //_Param = nullptr; _tid = 0; Next = 0xFF; @@ -119,13 +119,15 @@ void Button_GrayLevel::OnKeyPress(InputPort* port, bool down) } } SetValue(!_Value); - if (_Handler) _Handler(this, _Param); + //if (_Handler) _Handler(this, _Param); + Press(this); break; case set: Stat = normal; Next = 0xff; SetValue(!_Value); - if (_Handler) _Handler(this, _Param); + //if (_Handler) _Handler(this, _Param); + Press(this); break; } } @@ -157,7 +159,7 @@ void Button_GrayLevel::DelayClose2(int ms) delaytime = ms; } -void Button_GrayLevel::Register(EventHandler handler, void* param) +/*void Button_GrayLevel::Register(EventHandler handler, void* param) { if (handler) { @@ -169,7 +171,7 @@ void Button_GrayLevel::Register(EventHandler handler, void* param) _Handler = nullptr; _Param = nullptr; } -} +}*/ int Button_GrayLevel::OnWrite(byte data) { @@ -229,7 +231,7 @@ bool Button_GrayLevel::SetACZeroPin(Pin aczero) return false; } -void Button_GrayLevel::Init(TIMER tim, byte count, Button_GrayLevel* btns, EventHandler onpress +void Button_GrayLevel::Init(TIMER tim, byte count, Button_GrayLevel* btns, Action onpress , const ButtonPin* pins, byte* level, const byte* state) { debug_printf("\r\n初始化开关按钮 \r\n"); @@ -278,7 +280,8 @@ void Button_GrayLevel::Init(TIMER tim, byte count, Button_GrayLevel* btns, Event #if DEBUG btns[i].Name = names[i]; #endif - btns[i].Register(onpress); + //btns[i].Register(onpress); + btns[i].Press = onpress; // 灰度 LED 绑定到 Button btns[i].Set(&LedPWM, pins[i].PwmIndex); diff --git a/App/Button_GrayLevel.h b/App/Button_GrayLevel.h index e2db3333..1da45b98 100644 --- a/App/Button_GrayLevel.h +++ b/App/Button_GrayLevel.h @@ -45,6 +45,8 @@ public: void * ExterSetParam = nullptr; public: + Delegate Press; + // 构造函数。指示灯和继电器一般开漏输出,需要倒置 Button_GrayLevel(); @@ -54,7 +56,7 @@ public: bool GetValue(); void SetValue(bool value); void RenewGrayLevel(); - void Register(EventHandler handler, void* param = nullptr); + //void Register(EventHandler handler, void* param = nullptr); virtual int Write(byte* pcmd); // 重载 ByteDataPort 的函数 自定义 Delay Flush Open Close //virtual int Read(byte* cmd); @@ -70,8 +72,8 @@ private: bool _Value; // 状态 ushort Reserved; // 补足对齐问题 - EventHandler _Handler; - void* _Param; + //EventHandler _Handler; + //void* _Param; static void OnKeyPress(InputPort* port, bool down, void* param); void OnKeyPress(InputPort* port, bool down); @@ -80,7 +82,7 @@ public: static byte OnGrayLevel; // 开灯时 led 灰度 static byte OffGrayLevel; // 关灯时 led 灰度 - static void Init(TIMER tim, byte count, Button_GrayLevel* btns, EventHandler onpress, const ButtonPin* pins, byte* level, const byte* state); + static void Init(TIMER tim, byte count, Button_GrayLevel* btns, Action onpress, const ButtonPin* pins, byte* level, const byte* state); static void InitZero(Pin zero, int us = 2300); static bool UpdateLevel(byte* level, Button_GrayLevel* btns, byte count); diff --git a/App/Button_magnetic.cpp b/App/Button_magnetic.cpp index 0ea96add..8244fff9 100644 --- a/App/Button_magnetic.cpp +++ b/App/Button_magnetic.cpp @@ -9,8 +9,8 @@ void Button_magnetic::Init() Name = nullptr; _Value = false; - _Handler = nullptr; - _Param = nullptr; + //_Handler = nullptr; + //_Param = nullptr; } Button_magnetic::Button_magnetic(Pin key, Pin led, Pin relay_pin1, Pin relay_pin2) @@ -72,11 +72,12 @@ void Button_magnetic::OnPress(Pin pin, bool down) { SetValue(!_Value); - if(_Handler) _Handler(this, _Param); + //if(_Handler) _Handler(this, _Param); + Press(); } } -void Button_magnetic::Register(EventHandler handler, void* param) +/*void Button_magnetic::Register(EventHandler handler, void* param) { if(handler) { @@ -88,7 +89,7 @@ void Button_magnetic::Register(EventHandler handler, void* param) _Handler = nullptr; _Param = nullptr; } -} +}*/ bool Button_magnetic::GetValue() { return _Value; } diff --git a/App/Button_magnetic.h b/App/Button_magnetic.h index 7fdf1eb1..b8c28336 100644 --- a/App/Button_magnetic.h +++ b/App/Button_magnetic.h @@ -20,10 +20,12 @@ private: static void OnPress(InputPort* port, bool down, void* param); void OnPress(Pin pin, bool down); - EventHandler _Handler; - void* _Param; + //EventHandler _Handler; + //void* _Param; public: cstring Name; + + Delegate Press; InputPort* Key; // 输入按键 OutputPort* Led; // 指示灯 @@ -40,7 +42,7 @@ public: bool GetValue(); void SetValue(bool value); - void Register(EventHandler handler, void* param = nullptr); + //void Register(EventHandler handler, void* param = nullptr); private: bool _Value; // 状态 diff --git a/App/Sensor.cpp b/App/Sensor.cpp index 5bd3e660..2db620dc 100644 --- a/App/Sensor.cpp +++ b/App/Sensor.cpp @@ -6,13 +6,13 @@ void Sensor::Init() Led = nullptr; Buzzer = nullptr; Pir=nullptr; //门磁 - Pir=nullptr; //人体感应 + //Pir=nullptr; //人体感应 Name = nullptr; Index = 0; _Value = false; - _Handler = nullptr; - _Param = nullptr; + //_Handler = nullptr; + //_Param = nullptr; } Sensor::Sensor(Pin key, Pin led, Pin buzzer) @@ -64,11 +64,12 @@ void Sensor::OnPress(Pin pin, bool down) { SetValue(!_Value); - if(_Handler) _Handler(this, _Param); + //if(_Handler) _Handler(this, _Param); + Press(); } } -void Sensor::Register(EventHandler handler, void* param) +/*void Sensor::Register(EventHandler handler, void* param) { if(handler) { @@ -80,7 +81,7 @@ void Sensor::Register(EventHandler handler, void* param) _Handler = nullptr; _Param = nullptr; } -} +}*/ bool Sensor::GetValue() { return _Value; } diff --git a/App/Sensor.h b/App/Sensor.h index 02c9195c..91990ea7 100644 --- a/App/Sensor.h +++ b/App/Sensor.h @@ -21,7 +21,7 @@ public: //I2C* Ifrared //红外转发 - + Delegate Press; // 构造函数。指示灯和继电器一般开漏输出,需要倒置 Sensor() { Init(); } @@ -32,7 +32,7 @@ public: bool GetValue(); void SetValue(bool value); - void Register(EventHandler handler, void* param = nullptr); + //void Register(EventHandler handler, void* param = nullptr); private: @@ -41,8 +41,8 @@ private: static void OnPress(InputPort* port, bool down, void* param); void OnPress(Pin pin, bool down); - EventHandler _Handler; - void* _Param; + //EventHandler _Handler; + //void* _Param; private: bool _Value; // 状态 diff --git a/App/Sound.cpp b/App/Sound.cpp index 4203dcda..e3098bfc 100644 --- a/App/Sound.cpp +++ b/App/Sound.cpp @@ -48,7 +48,8 @@ void Music::Sound() if(_timer!= nullptr && _phonatePin != nullptr && _tuneSet != nullptr && _tuneNum != 0) { _timer->SetFrequency(100000); - _timer->Register(TimerHander, this); + //_timer->Register(TimerHander, this); + _timer->OnTick = Delegate(&Music::TimerHander, this); _timer->Open(); Sounding = true; } @@ -69,7 +70,7 @@ void Music::Unsound() void Music::SetTuneSet(const Tune* tune, int num) { if(Sounding) Unsound(); - + if(tune != nullptr && num != 0) { _tuneSet = tune; @@ -82,11 +83,13 @@ bool Music::getStat() return Sounding; } -void Music::TimerHander(void* sender,void* param) +void Music::TimerHander(Timer* timer) { - if(param == nullptr)return; + /*if(param == nullptr)return; Music * music = (Music * )param; - music->phonate(); + music->phonate();*/ + + phonate(); } void Music::phonate() diff --git a/App/Sound.h b/App/Sound.h index 7eeceaef..c7f616af 100644 --- a/App/Sound.h +++ b/App/Sound.h @@ -37,7 +37,7 @@ private: volatile int sound_cnt; volatile int music_freq; volatile int music_beat; - void static TimerHander(void* sender, void* param); + void TimerHander(Timer* timer); void phonate(); }; diff --git a/Core/Delegate.cpp b/Core/Delegate.cpp new file mode 100644 index 00000000..6d708855 --- /dev/null +++ b/Core/Delegate.cpp @@ -0,0 +1,64 @@ +#include "Type.h" +#include "DateTime.h" +#include "SString.h" + +#include "Delegate.h" + +/************************************************ Delegate ************************************************/ +Delegate::Delegate() +{ + Method = nullptr; + Target = nullptr; +} + +Delegate::Delegate(void* func) +{ + Method = func; + Target = nullptr; +} + +Delegate::Delegate(void* func, void* target) +{ + Method = func; + Target = target; +} + +Delegate::Delegate(Func func) { Method = (void*)func; } +Delegate::Delegate(Action func) { Method = (void*)func; } +Delegate::Delegate(Action2 func){ Method = (void*)func; } +Delegate::Delegate(Action3 func){ Method = (void*)func; } + +/*void Delegate::Add(Func func) +{ + Method = (void*)func; +}*/ + +void Delegate::operator()() +{ + if(!Method) return; + + if(Target) + ((Action)Method)(Target); + else + ((Func)Method)(); +} + +void Delegate::operator()(void* arg) +{ + if(!Method) return; + + if(Target) + ((Action2)Method)(Target, arg); + else + ((Action)Method)(arg); +} + +void Delegate::operator()(void* arg, void* arg2) +{ + if(!Method) return; + + if(Target) + ((Action3)Method)(Target, arg, arg2); + else + ((Action2)Method)(arg, arg2); +} diff --git a/Core/Delegate.h b/Core/Delegate.h index 302371da..af4201c4 100644 --- a/Core/Delegate.h +++ b/Core/Delegate.h @@ -1,6 +1,80 @@ #ifndef _Delegate_H_ #define _Delegate_H_ +// 没有参数和返回值的委托 +typedef void (*Func)(void); +// 一个参数没有返回值的委托,一般param参数用作目标对象,调用者用静态函数包装成员函数 +typedef void (*Action)(void* param); +typedef void(*Action2)(void*, void*); +typedef void(*Action3)(void*, void*, void*); +// 事件处理委托,一般sender表示事件发出者,param用作目标对象,调用者用静态函数包装成员函数 +typedef void (*EventHandler)(void* sender, void* param); +// 传入数据缓冲区地址和长度,如有反馈,仍使用该缓冲区,返回数据长度 +typedef uint (*DataHandler)(void* sender, byte* buf, uint size, void* param); + +// 事件处理器 +class Delegate +{ +public: + void* Method; // 函数指针 + void* Target; // 参数 + + Delegate(); + Delegate(void* func); + Delegate(void* func, void* target); + Delegate(Func func); + Delegate(Action func); + Delegate(Action2 func); + Delegate(Action3 func); + + template + Delegate(void(T::*func)(), T* target) { Method = (void*)&func; Target = target; } + template + Delegate(void(T::*func)(TArg), T* target) { Method = (void*)&func; Target = target; } + template + Delegate(void(T::*func)(TArg, TArg2), T* target) { Method = (void*)&func; Target = target; } + + void operator()(); + void operator()(void* arg); + void operator()(void* arg, void* arg2); + template + void operator()() + { + if(Method) + { + auto obj = (T*)Target; + typedef void(T::*TAction)(); + auto act = *(TAction*)Method; + + (obj->*act)(); + } + } + template + void operator()(TArg arg) + { + if(Method) + { + auto obj = (T*)Target; + typedef void(T::*TAction)(TArg); + auto act = *(TAction*)Method; + + (obj->*act)(arg); + } + } + template + void operator()(TArg arg, TArg arg2) + { + if(Method) + { + auto obj = (T*)Target; + typedef void(T::*TAction)(TArg, TArg2); + auto act = *(TAction*)Method; + + (obj->*act)(arg, arg2); + } + } +}; + /* 成员函数指针的操作 class A{ @@ -21,158 +95,4 @@ A* pa=&a; 要调用一个成员函数,仅仅有成员函数指针是不够的,还需要一个对象指针,所以要用一个类将两者绑到一起。 */ -// 没有参数和返回值的委托 -typedef void (*Func)(void); -// 一个参数没有返回值的委托,一般param参数用作目标对象,调用者用静态函数包装成员函数 -typedef void (*Action)(void* param); -// 事件处理委托,一般sender表示事件发出者,param用作目标对象,调用者用静态函数包装成员函数 -typedef void (*EventHandler)(void* sender, void* param); -// 数据接收委托,一般sender表示事件发出者,param用作目标对象,调用者用静态函数包装成员函数 -// 传入数据缓冲区地址和长度,如有反馈,仍使用该缓冲区,返回数据长度 -typedef uint (*DataHandler)(void* sender, byte* buf, uint size, void* param); - -class Delegate -{ -public: - void* Target; - void* Method; - - // 构造函数后面的冒号起分割作用,是类给成员变量赋值的方法 - // 初始化列表,更适用于成员变量的常量const型 - template - Delegate(T* target, void(T::*func)(TArg)) : Target(target), Method(&func) {} - - template - void Invoke(TArg value) - { - auto obj = (T*)Target; - typedef void(T::*TAction)(TArg); - auto act = *(TAction*)Method; - - (obj->*act)(value); - } -}; - -template -class Delegate2 -{ -public: - Delegate2(T* target, void(T::*func)(TArg, TArg2)) : _Target(target), _Func(func) {} - - void Invoke(TArg value, TArg2 value2) - { - (_Target->*_Func)(value, value2); - } - -private: - T* _Target; - void (T::*_Func)(TArg, TArg2); -}; - -//*************************************************************************** -// 函数模版接口 -template -class ifunction -{ -public: - // 函数参数的类型 - typedef TParameter parameter_type; - - // 将被重载的函数操作 - virtual void operator ()(TParameter) const = 0; -}; - -// 无参函数模版接口 -template <> -class ifunction -{ -public: - typedef void parameter_type; - - virtual void operator ()() const = 0; -}; - -// 对象函数模版 -template -class function : public ifunction -{ -public: - typedef TObject object_type; // 对象类型 - typedef TParameter parameter_type; // 函数参数的类型 - - function(TObject& object, void(TObject::* p_function)(TParameter)) - : p_object(&object), - p_function(p_function) - { - } - - virtual void operator ()(TParameter data) const - { - // 调用对象的成员函数 - (p_object->*p_function)(data); - } - -private: - TObject* p_object; // 对象指针 - void (TObject::* p_function)(TParameter); // 成员函数指针 -}; - -// 对象无参函数模版 -template -class function : public ifunction -{ -public: - function(TObject& object, void(TObject::* p_function)(void)) - : p_object(&object), - p_function(p_function) - { - } - - virtual void operator ()() const - { - (p_object->*p_function)(); - } - -private: - TObject* p_object; - void (TObject::* p_function)(); -}; - -// 全局函数模版 -template -class function : public ifunction -{ -public: - function(void(*p_function)(TParameter)) - : p_function(p_function) - { - } - - virtual void operator ()(TParameter data) const - { - (*p_function)(data); - } - -private: - void (*p_function)(TParameter); -}; - -template <> -class function : public ifunction -{ -public: - function(void(*p_function)(void)) - : p_function(p_function) - { - } - - virtual void operator ()() const - { - (*p_function)(); - } - -private: - void (*p_function)(); -}; - #endif //_Delegate_H_ diff --git a/Core/EventHandler.cpp b/Core/EventHandler.cpp deleted file mode 100644 index 903f143b..00000000 --- a/Core/EventHandler.cpp +++ /dev/null @@ -1,58 +0,0 @@ -#include "Type.h" -#include "DateTime.h" -#include "SString.h" - -#include "EventHandler.h" - -/************************************************ EventHandler ************************************************/ -EventHandler::EventHandler() -{ - Method = nullptr; - Target = nullptr; -} - -EventHandler& EventHandler::operator=(const Func& func) -{ - Method = (void*)func; - - return *this; -} - -void EventHandler::Add(Func func) -{ - Method = (void*)func; -} - -void EventHandler::operator()() -{ - if(!Method) return; - - if(Target) - ((Action)Method)(Target); - else - ((Func)Method)(); -} - -/*void EventHandler::Invoke(void* arg) -{ - if(!Method) return; - - auto func = (Func)Method; - - if(Target) - func(Target, arg); - else - ((Action)Method)(arg); -} - -void EventHandler::Invoke(void* arg1, void* arg2) -{ - if(!Method) return; - - auto func = (Func)Method; - - if(Target) - func(Target, arg1, arg2); - else - func(arg1, arg2); -}*/ diff --git a/Device/Timer.cpp b/Device/Timer.cpp index f416ff26..b3962b51 100644 --- a/Device/Timer.cpp +++ b/Device/Timer.cpp @@ -24,15 +24,16 @@ Timer::Timer(TIMER index) Opened = false; - _Handler = nullptr; - _Param = nullptr; + //_Handler = nullptr; + //_Param = nullptr; } Timer::~Timer() { Close(); - if(_Handler) Register(nullptr); + //if(_Handler) Register(nullptr); + if(OnTick.Method) SetHandler(false); Timers[_index] = nullptr; } @@ -91,17 +92,25 @@ void Timer::Close() Opened = false; } -void Timer::Register(EventHandler handler, void* param) +/*void Timer::Register(EventHandler handler, void* param) { _Handler = handler; _Param = param; SetHandler(handler != nullptr); +}*/ + +void Timer::Register(const Delegate& dlg) +{ + OnTick = dlg; + + SetHandler(dlg.Method); } void Timer::OnInterrupt() { - if(_Handler) _Handler(this, _Param); + //if(_Handler) _Handler(this, _Param); + OnTick(this); } /*================ PWM ================*/ diff --git a/Device/Timer.h b/Device/Timer.h index 40ed4822..1b02221b 100644 --- a/Device/Timer.h +++ b/Device/Timer.h @@ -16,12 +16,14 @@ public: void* _Timer; bool Opened; // 可能在中断里关闭自己 - Timer(TIMER index); - virtual ~Timer(); - ushort Prescaler; // 预分频。实际值,此时无需减一。 uint Period; // 周期。实际值,此时无需减一。 + Delegate OnTick; + + Timer(TIMER index); + virtual ~Timer(); + virtual void Open(); // 开始定时器 virtual void Close(); // 停止定时器 virtual void Config(); @@ -31,14 +33,15 @@ public: uint GetCounter(); void SetCounter(uint cnt); // 设置计数器值 - void Register(EventHandler handler, void* param = nullptr); + //void Register(EventHandler handler, void* param = nullptr); + void Register(const Delegate& dlg); static void ClockCmd(int idx, bool state); private: static void OnHandler(ushort num, void* param); - EventHandler _Handler; - void* _Param; + //EventHandler _Handler; + //void* _Param; protected: virtual void OnInterrupt(); @@ -47,12 +50,12 @@ public: static const byte TimerCount; // 定时器个数 static Timer* Create(byte index = 0xFF); // 创建指定索引的定时器,如果已有则直接返回,默认0xFF表示随机分配 - + private: void OnInit(); void OnOpen(); void OnClose(); - + static const void* GetTimer(byte idx); }; diff --git a/Net/Dhcp.cpp b/Net/Dhcp.cpp index b6b341e8..1e4c66e5 100644 --- a/Net/Dhcp.cpp +++ b/Net/Dhcp.cpp @@ -32,7 +32,7 @@ Dhcp::Dhcp(ISocketHost& host) : Host(host) MaxTimes = 6; ExpiredTime = 500 * 10; - OnStop = nullptr; + //OnStop = nullptr; taskID = 0; auto port = dynamic_cast(Socket); @@ -200,7 +200,8 @@ void Dhcp::Stop() } } - if(OnStop) OnStop(this, nullptr); + //if(OnStop) OnStop(this, nullptr); + OnStop(this); } void Dhcp::Loop(void* param) diff --git a/Net/Dhcp.h b/Net/Dhcp.h index cec5d070..babad644 100644 --- a/Net/Dhcp.h +++ b/Net/Dhcp.h @@ -33,7 +33,7 @@ public: void Start(); // 开始 void Stop(); // 停止 - EventHandler OnStop; + Delegate OnStop; private: static uint OnReceive(ITransport* port, Buffer& bs, void* param, void* param2); diff --git a/Test/TimerTest.cpp b/Test/TimerTest.cpp index bf3e4659..4a907ac7 100644 --- a/Test/TimerTest.cpp +++ b/Test/TimerTest.cpp @@ -2,18 +2,17 @@ #include "Port.h" #include "Timer.h" -Timer* timer; +//Timer* timer; -void TimerTask(void* sender, void* param) +void TimerTask(OutputPort* leds, Timer* timer) { - OutputPort* leds = (OutputPort*)param; *leds = !*leds; } uint frequency = 0; int step = 1; -void TimerTask2(void* sender, void* param) +void TimerTask2(Timer* timer) { frequency += step; @@ -36,14 +35,16 @@ void TestTimer(OutputPort& leds) debug_printf("\r\n"); debug_printf("TestTimer Start......\r\n"); - timer = new Timer(Timer2); + auto timer = new Timer(Timer2); timer->SetFrequency(50); - timer->Register(TimerTask, &leds); + //timer->Register(TimerTask, &leds); + timer->OnTick = Delegate((void*)&TimerTask, &leds); timer->Open(); - Timer* timer2 = Timer::Create(); + auto timer2 = Timer::Create(); timer2->SetFrequency(10); - timer2->Register(TimerTask2, nullptr); + //timer2->Register(TimerTask2, nullptr); + timer2->OnTick = (void*)&TimerTask2; timer2->Open(); debug_printf("\r\n TestTimer Finish!\r\n"); diff --git a/TinyNet/Tiny.cpp b/TinyNet/Tiny.cpp index 370ec65f..0ebf085a 100644 --- a/TinyNet/Tiny.cpp +++ b/TinyNet/Tiny.cpp @@ -234,22 +234,18 @@ bool CheckUserPress(InputPort* port, bool down, void* param) return false; } -void CheckUserPress2(InputPort* port, bool down, void* param) -{ - CheckUserPress(port, down, param); -} - -void CheckUserPress3(void* sender, void* param) +void CheckUserPress3(void* sender) { auto but = (Button_GrayLevel *)sender; - CheckUserPress(&but->Key, but->Key.Read(), param); + CheckUserPress(&but->Key, but->Key.Read(), nullptr); } void InitButtonPress(Button_GrayLevel* btns, byte count) { for(int i=0; i