some basic stuffs.
This commit is contained in:
+20
-13
@@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user