Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
ActivityTracker
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
willm3
ActivityTracker
Merge requests
!2
Activity Recording
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Activity Recording
wmalisch/Basic-activity-recording
into
main
Overview
2
Commits
1
Pipelines
0
Changes
4
Merged
willm3
requested to merge
wmalisch/Basic-activity-recording
into
main
1 year ago
Overview
2
Commits
1
Pipelines
0
Changes
4
Expand
Created by: wmalisch
0
0
Merge request reports
Compare
main
main (base)
and
latest version
latest version
a18f9679
1 commit,
1 year ago
4 files
+
40
−
8
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
4
Search (e.g. *.vue) (Ctrl+P)
src/Activity.py
0 → 100644
+
29
−
0
Options
from
sense_hat
import
SenseHat
import
time
class
Activity
:
def
__init__
(
self
,
sense
):
self
.
sense
=
sense
self
.
running
=
False
def
record
(
self
):
try
:
self
.
running
=
True
print
(
"
Activity started.
"
)
i
=
0
while
self
.
running
:
# Read data from the IMU
imu_data
=
self
.
sense
.
get_accelerometer_raw
()
acceleration
=
imu_data
[
'
x
'
],
imu_data
[
'
y
'
],
imu_data
[
'
z
'
]
print
(
"
Acceleration (g): x={:.2f}, y={:.2f}, z={:.2f}
"
.
format
(
*
acceleration
))
time
.
sleep
(
0.1
)
# Adjust sleep time as needed
joy_stick
=
self
.
sense
.
stick
.
get_events
()
for
event
in
joy_stick
:
if
(
event
.
action
==
"
pressed
"
and
event
.
direction
==
"
middle
"
):
self
.
running
=
not
self
.
running
return
"
Success
"
except
Exception
as
e
:
return
"
Failed
"
Loading