@@ -52,84 +52,37 @@ class LightSwitchMgr
52
52
.stepSize = 1 , .transitionTime = 0 , .optionsMask = 0 , .optionsOverride = 0
53
53
};
54
54
55
- struct Timer
56
- {
57
- typedef void (*Callback)(Timer & timer);
58
-
59
- Timer (uint32_t timeoutInMs, Callback callback, void * context);
60
- ~Timer ();
61
-
62
- void Start ();
63
- void Stop ();
64
- void Timeout ();
65
-
66
- Callback mCallback = nullptr ;
67
- void * mContext = nullptr ;
68
- bool mIsActive = false ;
69
-
70
- osTimerId_t mHandler = nullptr ;
71
-
72
- private:
73
- static void TimerCallback (void * timerCbArg);
74
- };
75
-
76
55
CHIP_ERROR Init (chip::EndpointId lightSwitchEndpoint, chip::EndpointId genericSwitchEndpoint);
77
56
78
57
void GenericSwitchOnInitialPress ();
79
58
void GenericSwitchOnShortRelease ();
80
59
60
+ /* *
61
+ * @brief Button event processing function
62
+ * Function triggers a switch action sent to the CHIP task
63
+ *
64
+ * @param aEvent button event being processed
65
+ */
66
+ static void SwitchActionEventHandler (AppEvent * aEvent);
67
+
81
68
void TriggerLightSwitchAction (LightSwitchAction action, bool isGroupCommand = false );
82
69
void TriggerLevelControlAction (StepModeEnum stepMode, bool isGroupCommand = false );
83
70
84
71
StepModeEnum getStepMode ();
85
-
86
- AppEvent CreateNewEvent (AppEvent::AppEventTypes type);
72
+ void changeStepMode ();
87
73
88
74
static LightSwitchMgr & GetInstance () { return sSwitch ; }
89
75
90
- /* *
91
- * @brief Event handler when a button is pressed
92
- * Function posts an event for button processing
93
- *
94
- * @param button BUTTON0 or BUTTON1
95
- * @param btnAction button action - SL_SIMPLE_BUTTON_PRESSED,
96
- * SL_SIMPLE_BUTTON_RELEASED
97
- */
98
- static void ButtonEventHandler (uint8_t button, uint8_t btnAction);
99
-
100
- static void AppEventHandler (AppEvent * aEvent);
101
-
102
76
private:
103
77
static LightSwitchMgr sSwitch ;
104
78
105
- Timer * mLongPressTimer = nullptr ;
106
- bool mFunctionButtonPressed = false ; // True when button0 is pressed, used to trigger factory reset
107
- bool mActionButtonPressed = false ; // True when button1 is pressed, used to initiate toggle or level-up/down
108
- bool mActionButtonSuppressed = false ; // True when both button0 and button1 are pressed, used to switch step direction
109
- bool mResetWarning = false ;
110
-
111
79
// Default Step direction for Level control
112
80
StepModeEnum stepDirection = StepModeEnum::kUp ;
113
-
114
- static void OnLongPressTimeout (Timer & timer);
115
81
LightSwitchMgr () = default ;
116
82
117
- /* *
118
- * @brief This function will be called when PB0 is
119
- * long-pressed to trigger the factory-reset
120
- */
121
- void HandleLongPress ();
122
-
123
83
static void GenericSwitchWorkerFunction (intptr_t context);
124
84
125
85
chip::EndpointId mLightSwitchEndpoint = chip::kInvalidEndpointId ;
126
86
chip::EndpointId mGenericSwitchEndpoint = chip::kInvalidEndpointId ;
127
87
128
- /* *
129
- * @brief Button event processing function
130
- * Function triggers a switch action sent to the CHIP task
131
- *
132
- * @param aEvent button event being processed
133
- */
134
- static void SwitchActionEventHandler (AppEvent * aEvent);
135
88
};
0 commit comments