in-progress adding start and end times to events for sleep calculations

This commit is contained in:
2022-07-20 14:43:39 -07:00
parent c0c37a203b
commit 48fe00b0b8
2 changed files with 53 additions and 7 deletions

12
.github/FUNDING.yml vendored Normal file
View File

@@ -0,0 +1,12 @@
# These are supported funding model platforms
github: taigrr # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
patreon: # Replace with a single Patreon username
open_collective: # Replace with a single Open Collective username
ko_fi: # Replace with a single Ko-fi username
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
liberapay: # Replace with a single Liberapay username
issuehunt: # Replace with a single IssueHunt username
otechie: # Replace with a single Otechie username
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']

View File

@@ -30,9 +30,18 @@ func (s SequenceSleep) Length() time.Duration {
return s.Duration return s.Duration
} }
func (s SequenceSleep) StartTime() time.Time{
return time.Time{}
}
func (s SequenceSwipe) StartTime() time.Time{
return s.Start
}
type SequenceTap struct { type SequenceTap struct {
X int X int
Y int Y int
Start time.Time
End time.Time
} }
func (s SequenceTap) Play(d Device, ctx context.Context) error { func (s SequenceTap) Play(d Device, ctx context.Context) error {
@@ -43,18 +52,27 @@ func (s SequenceTap) Length() time.Duration {
return 0 return 0
} }
func (s SequenceSwipe) StartTime() time.Time{
return s.Start
}
type SequenceSwipe struct { type SequenceSwipe struct {
X1 int X1 int
Y1 int Y1 int
X2 int X2 int
Y2 int Y2 int
Duration time.Duration Duration time.Duration
Start time.Time
End time.Time
} }
func (s SequenceSwipe) Play(d Device, ctx context.Context) error { func (s SequenceSwipe) Play(d Device, ctx context.Context) error {
return d.Swipe(ctx, s.X1, s.Y1, s.X2, s.Y2, s.Duration) return d.Swipe(ctx, s.X1, s.Y1, s.X2, s.Y2, s.Duration)
} }
func (s SequenceSwipe) StartTime() time.Time{
return s.Start
}
func (s SequenceSwipe) Length() time.Duration { func (s SequenceSwipe) Length() time.Duration {
return s.Duration return s.Duration
} }
@@ -62,6 +80,8 @@ func (s SequenceSwipe) Length() time.Duration {
type Input interface { type Input interface {
Play(d Device, ctx context.Context) error Play(d Device, ctx context.Context) error
Length() time.Duration Length() time.Duration
StartTime() time.Time
EndTime() time.Time
} }
type TapSequence struct { type TapSequence struct {
@@ -173,12 +193,27 @@ func parseGetEvent(input string) (events []Input) {
return return
} }
func touchesToInputs([][]event) []Input { func touchesToInputs(events []eventSet) []Input {
return []Input{} inputs := []Input{}
for _, eventSet := range events {
i, err := eventSet.ToInput()
if err != nil {
inputs = append(inputs, i)
}
}
return inputs
} }
func getEventSlices(events []event) [][]event { type eventSet []event
eventSets := [][]event{{}}
func (e eventSet) ToInput() (Input, error) {
var i Input
// i =
return i, nil
}
func getEventSlices(events []event) []eventSet {
eventSets := []eventSet{{}}
current := 0 current := 0
foundDown := false foundDown := false
for _, e := range events { for _, e := range events {
@@ -197,7 +232,6 @@ func getEventSlices(events []event) [][]event {
} }
} }
eventSets = eventSets[:len(eventSets)-1] eventSets = eventSets[:len(eventSets)-1]
// fmt.Println(eventSets[len(eventSets)-1])
return eventSets return eventSets
} }