449a3a801a
- Introduced KnxDaliModule class for handling DALI message queuing, commissioning, and KNX group-object dispatch. - Implemented Message and MessageQueue classes for managing message operations. - Removed obsolete OpenKNX IDF component files and CMake configurations. - Updated submodule reference for KNX. Signed-off-by: Tony <tonylu@tony-cloud.com>
92 lines
2.3 KiB
C++
92 lines
2.3 KiB
C++
#pragma once
|
|
|
|
// =============================================================================
|
|
// KnxDaliChannel — Per-address / per-group DALI channel (ported from DaliChannel)
|
|
// =============================================================================
|
|
|
|
#include "dali_gateway_bridge.h"
|
|
|
|
#include "knx/group_object.h"
|
|
|
|
#include <cstdint>
|
|
|
|
namespace gateway {
|
|
namespace knx_dali_gw {
|
|
|
|
class KnxDaliChannel {
|
|
public:
|
|
KnxDaliChannel();
|
|
~KnxDaliChannel();
|
|
|
|
void init(uint8_t channel_index, bool is_group, DaliGatewayBridge& bridge);
|
|
void setup();
|
|
void loop();
|
|
|
|
void processInputKo(GroupObject& ko);
|
|
|
|
// --- Configuration ---
|
|
void setOnValue(uint8_t value);
|
|
void setGroups(uint16_t groups);
|
|
void setGroupState(uint8_t group, bool state);
|
|
void setGroupState(uint8_t group, uint8_t value);
|
|
void setMinMax(uint8_t min, uint8_t max);
|
|
void setMinArc(uint8_t min);
|
|
void setHcl(uint8_t curve, uint16_t temp, uint8_t bri);
|
|
uint8_t getMin() const { return min_; }
|
|
uint8_t getMax() const { return max_; }
|
|
uint16_t getGroups() const { return groups_; }
|
|
|
|
bool isNight{false};
|
|
|
|
private:
|
|
enum class DimmDirection { kDown, kUp, kNone };
|
|
|
|
void loopDimming();
|
|
void loopStaircase();
|
|
void loopQueryLevel();
|
|
void sendColor();
|
|
void setSwitchState(bool value, bool is_switch_command = true);
|
|
void setDimmState(uint8_t value, bool is_dimm_command = true, bool is_last = false);
|
|
void koHandleSwitch(GroupObject& ko);
|
|
void koHandleDimmRel(GroupObject& ko);
|
|
void koHandleDimmAbs(GroupObject& ko);
|
|
void koHandleLock(GroupObject& ko);
|
|
void koHandleColor(GroupObject& ko);
|
|
|
|
DaliGatewayBridge* dali_{nullptr};
|
|
uint8_t index_{0};
|
|
bool is_group_{false};
|
|
|
|
// Dimming
|
|
DimmDirection dimm_direction_{DimmDirection::kNone};
|
|
uint8_t dimm_step_{0};
|
|
uint64_t dimm_last_{0};
|
|
uint8_t dimm_interval_{100};
|
|
|
|
// Staircase
|
|
uint64_t start_time_{0};
|
|
uint32_t interval_{0};
|
|
|
|
// Limits
|
|
uint8_t min_{0};
|
|
uint8_t max_{254};
|
|
uint8_t on_day_{100};
|
|
uint8_t on_night_{10};
|
|
|
|
// State
|
|
bool current_state_{false};
|
|
uint8_t current_step_{0};
|
|
bool current_is_locked_{false};
|
|
uint8_t current_color_[4]{};
|
|
|
|
// HCL
|
|
uint8_t hcl_curve_{255};
|
|
uint16_t hcl_current_temp_{0};
|
|
|
|
// Groups
|
|
uint16_t groups_{0};
|
|
};
|
|
|
|
} // namespace knx_dali_gw
|
|
} // namespace gateway
|