AppEventCommon.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /*
  2. *
  3. * Copyright (c) 2022 Project CHIP Authors
  4. * All rights reserved.
  5. *
  6. * Licensed under the Apache License, Version 2.0 (the "License");
  7. * you may not use this file except in compliance with the License.
  8. * You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an "AS IS" BASIS,
  14. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. * See the License for the specific language governing permissions and
  16. * limitations under the License.
  17. */
  18. #pragma once
  19. #include <cstdint>
  20. struct AppEvent;
  21. typedef void (*EventHandler)(AppEvent *);
  22. class LEDWidget;
  23. struct AppEvent
  24. {
  25. enum AppEventTypes
  26. {
  27. kEventType_Button = 0,
  28. kEventType_Timer,
  29. kEventType_UpdateLedState,
  30. kEventType_IdentifyStart,
  31. kEventType_IdentifyStop,
  32. kEventType_Lighting,
  33. kEventType_Thermostat,
  34. kEventType_Install,
  35. kEventType_Contact,
  36. kEventType_Start,
  37. };
  38. uint16_t Type;
  39. union
  40. {
  41. struct
  42. {
  43. uint8_t Action;
  44. } ButtonEvent;
  45. struct
  46. {
  47. void * Context;
  48. } TimerEvent;
  49. struct
  50. {
  51. uint8_t Action;
  52. int32_t Actor;
  53. } LightingEvent;
  54. struct
  55. {
  56. uint8_t Action;
  57. } ContactEvent;
  58. struct
  59. {
  60. uint8_t Action;
  61. int32_t Actor;
  62. } StartEvent;
  63. struct
  64. {
  65. LEDWidget * LedWidget;
  66. } UpdateLedStateEvent;
  67. };
  68. EventHandler Handler;
  69. };