Skip to content

Commit

Permalink
Add support for fatek color channel.
Browse files Browse the repository at this point in the history
Signed-off-by: Łukasz Dywicki <[email protected]>
  • Loading branch information
splatch committed Mar 5, 2024
1 parent faaf773 commit 139172b
Show file tree
Hide file tree
Showing 22 changed files with 864 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,18 @@

<<co7io-fatek:rollershutter32>>

| co7io-fatek:color16
| Color (16-bit)
| Data register for position will use 16 bit registers.

<<co7io-fatek:color16>>

| co7io-fatek:color32
| Color (32-bit)
| Data register for position will use 32 bit registers.

<<co7io-fatek:color32>>

|===


Expand Down Expand Up @@ -248,4 +260,72 @@ Below table contain configuration parameters which can be assigned to channels o
|===


[[co7io-fatek:color16]]
== Configuration of `co7io-fatek:color16`

Below table contain configuration parameters which can be assigned to channels of type `co7io-fatek:color16`.

[width="100%",caption="Channel type color16 configuration",cols="1,1,1,2"]
|===
|Name | Type | Label ^|Description

| color1register
| TEXT
| Color 1 register
| Data register used to retrieve or write Red or Hue part of color information.

| color1index
| INTEGER
| Register index
| Index of register used to retrieve data.

| color2register
| TEXT
| Color 2 register
| Data register used to retrieve or write Green or Saturation part of color information.

| color2index
| INTEGER
| Register index
| Index of register used to retrieve data.

| color3register
| TEXT
| Color 2 register
| Data register used to retrieve or write Blue or Brightness part of color information.

| color3index
| INTEGER
| Register index
| Index of register used to retrieve data.

| rgb
| BOOLEAN
| RGB mode
| Write and interpret read data as RGB code instead of HSB.

| switcherRegister
| TEXT
| Register
| Type of discrete register to write ON or OFF command.

| switcherIndex
| INTEGER
| Register index
| Index of register used to write data.

| switcherInvert
| BOOLEAN
| Invert
| Invert logical representation of related register (0->1, 1->0).

|===


[[co7io-fatek:color32]]
== Configuration of `co7io-fatek:color32`

Below table contain configuration parameters which can be assigned to channels of type `co7io-fatek:color32`.



Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,61 @@
| BOOLEAN
| Invert
| Invert logical representation of related register (0->1, 1->0).

|===

[[channel-type:co7io-fatek:color16]]
== Config `channel-type:co7io-fatek:color16`
[width="100%",caption="channel-type:co7io-fatek:color16 configuration",cols="1,1,1,2"]
|===
|Name | Type | Label ^|Description

| color1register
| TEXT
| Color 1 register
| Data register used to retrieve or write Red or Hue part of color information.

| color1index
| INTEGER
| Register index
| Index of register used to retrieve data.

| color2register
| TEXT
| Color 2 register
| Data register used to retrieve or write Green or Saturation part of color information.

| color2index
| INTEGER
| Register index
| Index of register used to retrieve data.

| color3register
| TEXT
| Color 2 register
| Data register used to retrieve or write Blue or Brightness part of color information.

| color3index
| INTEGER
| Register index
| Index of register used to retrieve data.

| rgb
| BOOLEAN
| RGB mode
| Write and interpret read data as RGB code instead of HSB.

| switcherRegister
| TEXT
| Register
| Type of discrete register to write ON or OFF command.

| switcherIndex
| INTEGER
| Register index
| Index of register used to write data.

| switcherInvert
| BOOLEAN
| Invert
| Invert logical representation of related register (0->1, 1->0).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ public interface FatekBindingConstants extends BaseBindingConstants {
ChannelTypeUID CHANNEL_TYPE_DATA32 = new ChannelTypeUID(BINDING_ID, "data32");
ChannelTypeUID CHANNEL_TYPE_ROLLERSHUTTER16 = new ChannelTypeUID(BINDING_ID, "rollershutter16");
ChannelTypeUID CHANNEL_TYPE_ROLLERSHUTTER32 = new ChannelTypeUID(BINDING_ID, "rollershutter32");
ChannelTypeUID CHANNEL_TYPE_COLOR16 = new ChannelTypeUID(BINDING_ID, "color16");
ChannelTypeUID CHANNEL_TYPE_COLOR32 = new ChannelTypeUID(BINDING_ID, "color32");


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* Copyright (C) 2024-2024 ConnectorIO Sp. z o.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* SPDX-License-Identifier: Apache-2.0
*/
package org.connectorio.addons.binding.fatek.config.channel.color;

import org.connectorio.addons.binding.fatek.config.channel.data.DataChannelConfig;
import org.simplify4u.jfatek.registers.RegName;

public class ColorChannelConfig extends DataChannelConfig {

// RGB color control mode
public boolean rgb = false;

public RegName color1register;
public int color1index;

public RegName color2register;
public int color2index;

public RegName color3register;
public int color3index;

// optional
public RegName switcherRegister;
public int switcherIndex;
public boolean switcherInvert;

// increase decrease step - optional
public int step;

}
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,17 @@
package org.connectorio.addons.binding.fatek.config.channel.data;

import org.connectorio.addons.binding.fatek.config.channel.BaseChannelConfig;
import org.simplify4u.jfatek.registers.RegName;

public class DataChannelConfig extends BaseChannelConfig {

public boolean unsigned;

public DataChannelConfig() {}

public DataChannelConfig(RegName register, int index) {
this.register = register;
this.index = index;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@

public class RollerShutter32ChannelConfig extends Data32ChannelConfig {

public int startIndex;
public RegName startRegister;
public int startIndex;
public boolean startInvert;

public int stopIndex;
public RegName stopRegister;
public int stopIndex;
public boolean stopInvert;

}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
*/
package org.connectorio.addons.binding.fatek.internal.channel;

import java.util.Collections;
import java.util.List;
import org.connectorio.addons.binding.fatek.internal.channel.converter.Converter;
import org.openhab.core.thing.Channel;
import org.openhab.core.thing.ChannelUID;
Expand All @@ -41,8 +43,8 @@ public BinaryChannelHandler(Channel channel, DisReg register, Converter converte
}

@Override
public Reg register() {
return register;
public List<Reg> registers() {
return Collections.singletonList(register);
}

@Override
Expand All @@ -60,8 +62,8 @@ public FatekCommand<?> prepareWrite(Command command) {
}

@Override
public State state(RegValue value) {
return converter.toState(value);
public State state(List<RegValue> value) {
return converter.toState(value.get(0));
}

}
Loading

0 comments on commit 139172b

Please sign in to comment.