Skip to content

Commit

Permalink
Update logic for queue
Browse files Browse the repository at this point in the history
  • Loading branch information
alexwohlbruck committed May 3, 2022
1 parent f7c9a83 commit 1d9b408
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
5 changes: 3 additions & 2 deletions client/src/views/Lamps.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ v-container
v-img.mt-5.mb-10(src='@/assets/undraw_signal_searching.svg' width='300')


.d-flex.flex-column.align-center(v-else style='gap: 1em;')
.d-flex.flex-column.align-center(v-else)
v-card.lamp-card.mb-4.pa-6.small-container(
v-for='(group, groupId) in groups'
:key='groupId'
Expand All @@ -18,7 +18,8 @@ v-container
| {{ group.lamps.length }} {{ group.lamps.length === 1 ? 'lamp' : 'lamps' }}
| - {{ group.group.accessCode }}

lamp(v-for='lamp in group.lamps' :key='lamp._id' :lamp='lamp')
.d-flex.flex-column(style='gap: 1.5em;')
lamp(v-for='lamp in group.lamps' :key='lamp._id' :lamp='lamp')

.d-flex.justify-center
v-btn.ml-4(
Expand Down
15 changes: 8 additions & 7 deletions micro/app/commander.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,11 +136,8 @@ def dequeue():
global last_room_is_lit
global last_motion_detected
print(last_room_is_lit, last_motion_detected)

# Check if user has interacted with device in the last 30 seconds
user_has_interacted = ticks_ms() - time_since_interactive < 30000

if user_has_interacted or (last_room_is_lit and last_motion_detected):
if last_room_is_lit and last_motion_detected:
# Wait 1 second between dequeuing
while len(message_queue) > 0:
message = message_queue.pop(0)
Expand Down Expand Up @@ -172,12 +169,16 @@ def pulse_received(data):

global last_room_is_lit
global last_motion_detected
global time_since_interactive

# Queue if the room is not lit or no motion detected
if not last_room_is_lit or not last_motion_detected:
# Check if user has interacted with device in the last 10 seconds
user_has_interacted = ticks_ms() - time_since_interactive < 10000

# Don't light if user has not interacted recently, the room is dark, or motion is not detected
if not user_has_interacted and (not last_room_is_lit or not last_motion_detected):
if active:
message_queue.append(data)
return
return

global last_active
global last_colors
Expand Down

0 comments on commit 1d9b408

Please sign in to comment.