Hi, first of all, thank you for the driver.
I found that the evaluation of the swipe data is incorrect. It is a 2-byte, 10-bit value, where each channel is represented by 1 bit:
1 = channel crossed
0 = channel not crossed
Below is the logic to evaluate the data. Please feel free to adopt it:
var event = ""
# Do not change defaults, see evaluation below
var channels = 0
var from = 0
var to = 0
...
# Swipe left and right
elif message[4] == 0x03
# Swipe panel
if message[5] == 0x0C
event = "Swipe right"
# 10 bits: each traversed zone is represented by 1 bit (channels 1–10)
var crossedZonesBitWise = (message[6] << 8) | message[7]
# Determine number of crossed channels, start, and end
while crossedZonesBitWise > 0
if 0 != (crossedZonesBitWise & 1) # Check if bit is set
channels += 1
if 0 == from
# First detected channel (1–10) is the start, because swipe is right
from = channels
end
end
crossedZonesBitWise = crossedZonesBitWise >> 1 # shift right
if crossedZonesBitWise == 0
# Last detected channel (1–10) is the end, because swipe is right
to = channels
end
end
elif message[5] == 0x0D
event = "Swipe left"
# 10 bits: each traversed zone is represented by 1 bit (channels 1–10)
var crossedZonesBitWise = (message[6] << 8) | message[7]
# Determine number of crossed channels, start, and end
while crossedZonesBitWise > 0
if 0 != (crossedZonesBitWise & 1) # Check if bit is set
channels += 1
if 0 == to
# First detected channel (1–10) is the end, because swipe is left
to = channels
end
end
crossedZonesBitWise = crossedZonesBitWise >> 1 # shift right
if crossedZonesBitWise == 0
# Last detected channel (1–10) is the start, because swipe is left
from = channels
end
end
end
end
...
Hi, first of all, thank you for the driver.
I found that the evaluation of the swipe data is incorrect. It is a 2-byte, 10-bit value, where each channel is represented by 1 bit:
1 = channel crossed
0 = channel not crossed
Below is the logic to evaluate the data. Please feel free to adopt it: