some basic stuffs.

This commit is contained in:
2022-12-21 18:17:40 +01:00
parent e00fe2a4d2
commit 6f8def066f
9 changed files with 181 additions and 21 deletions
+20 -13
View File
@@ -93,6 +93,8 @@ func (b *bridge) Refresh(ctx context.Context) ([]string, error) {
b.mu.Lock()
PanelLoop:
for _, panelInfo := range overview.PanelLayout.Data.PositionData {
log.Printf("%#+v", panelInfo)
if shapeTypeMap[panelInfo.ShapeType] == "Shapes Controller" {
continue
}
@@ -290,7 +292,7 @@ func (b *bridge) Run(ctx context.Context, bus *lucifer3.EventBus) error {
}
panelUpdate.Add(panel.message())
if panelUpdate.Len() > 150 {
if panelUpdate.Len() > 1256 {
break
}
}
@@ -349,8 +351,7 @@ func (b *bridge) updateEffect(ctx context.Context) error {
}
func (b *bridge) runTouchListener(ctx context.Context, bus *lucifer3.EventBus) {
cooldownID := ""
cooldownUntil := time.Now()
cooldownMap := make(map[uint16]time.Time)
message := make(PanelEventMessage, 65536)
reqCloser := io.Closer(nil)
@@ -408,23 +409,29 @@ func (b *bridge) runTouchListener(ctx context.Context, bus *lucifer3.EventBus) {
}
for i := 0; i < message.Count(); i += 1 {
panelID := message.PanelID(i)
b.mu.Lock()
id, hasID := b.panelIDMap[message.PanelID(i)]
id, hasID := b.panelIDMap[panelID]
swipedFromID := b.panelIDMap[message.SwipedFromPanelID(i)]
b.mu.Unlock()
if !hasID || (id == cooldownID && time.Now().Before(cooldownUntil)) {
if time.Now().Before(cooldownMap[panelID]) {
continue
} else if !hasID {
bus.RunEvent(events.ButtonPressed{
ID: fmt.Sprintf("nanoleaf:%s:meta:%x", b.host, panelID),
SwipedID: swipedFromID,
Name: "Touch",
})
} else {
bus.RunEvent(events.ButtonPressed{
ID: id,
SwipedID: swipedFromID,
Name: "Touch",
})
}
bus.RunEvent(events.ButtonPressed{
ID: id,
SwipedID: swipedFromID,
Name: "Touch",
})
cooldownID = id
cooldownUntil = time.Now().Add(time.Second)
cooldownMap[panelID] = time.Now().Add(time.Second)
}
}
}