Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
TP_labyrinth
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
remi.greub
TP_labyrinth
Commits
8b8e4596
Commit
8b8e4596
authored
4 weeks ago
by
remi.greub
Browse files
Options
Downloads
Patches
Plain Diff
masterball fonctionnelle avec quelques corrections a faire encore
parent
ef6b0a76
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
G3_TP1_labyrinth_etu/src/labyrinth.c
+66
-2
66 additions, 2 deletions
G3_TP1_labyrinth_etu/src/labyrinth.c
with
66 additions
and
2 deletions
G3_TP1_labyrinth_etu/src/labyrinth.c
+
66
−
2
View file @
8b8e4596
...
@@ -85,6 +85,8 @@ void slave_info_rx(void *data, int len)
...
@@ -85,6 +85,8 @@ void slave_info_rx(void *data, int len)
// code executed when the slave sends an ethernet frame
// code executed when the slave sends an ethernet frame
}
}
void
Algo_main_ball
(
void
*
params
);
int
main
(
void
)
int
main
(
void
)
{
{
accel_t
ball_accel
;
accel_t
ball_accel
;
...
@@ -111,9 +113,71 @@ int main(void)
...
@@ -111,9 +113,71 @@ int main(void)
accel_read
(
&
ball_accel
);
// example: reading of the accelerometer
accel_read
(
&
ball_accel
);
// example: reading of the accelerometer
// creating tasks...
// creating tasks...
// xTaskCreate(...);
xTaskCreate
(
Algo_main_ball
,
(
signed
portCHAR
*
)
"Masterball"
,
// vTaskStartScheduler(); // launch scheduler
configMINIMAL_STACK_SIZE
,
&
ball_param_th
[
0
],
tskIDLE_PRIORITY
+
1
,
NULL
);
vTaskStartScheduler
();
// launch scheduler
LPC_TIM0
->
TCR
=
1
;
while
(
1
);
while
(
1
);
return
1
;
return
1
;
}
}
void
Algo_main_ball
(
void
*
params
){
ball_param_th_t
*
ball
=
(
ball_param_th_t
*
)
params
;
accel_t
ball_acc
;
int
un_ou_moins_un_x
=
1
,
un_ou_moins_un_y
=
1
;
while
(
1
){
lcd_filled_circle
(
ball
->
ball
.
pos
.
x
,
ball
->
ball
.
pos
.
y
,
ball
->
ball
.
radius
,
LCD_BLACK
);
int
CollisionState
=
test_collision
(
&
ball
->
ball
);
if
(
CollisionState
!=
NO_COLLISION
){
//ralentissement de 10% de la vitesse de la balle
ball
->
ball
.
speed
.
x
=
ball
->
ball
.
speed
.
x
-
(
ball
->
ball
.
speed
.
x
/
10
);
ball
->
ball
.
speed
.
y
=
ball
->
ball
.
speed
.
y
-
(
ball
->
ball
.
speed
.
y
/
10
);
if
(
CollisionState
&
TOUCH_LEFT
){
un_ou_moins_un_x
=
-
1
;
ball
->
ball
.
pos
.
x
+=
ball
->
ball
.
radius
/
2
;
}
if
(
CollisionState
&
TOUCH_UP
){
un_ou_moins_un_y
=
-
1
;
ball
->
ball
.
pos
.
y
+=
ball
->
ball
.
radius
/
2
;
}
if
(
CollisionState
&
TOUCH_RIGHT
){
un_ou_moins_un_x
=
-
1
;
ball
->
ball
.
pos
.
x
-=
ball
->
ball
.
radius
/
2
;
}
if
(
CollisionState
&
TOUCH_DOWN
){
un_ou_moins_un_y
=
-
1
;
ball
->
ball
.
pos
.
y
-=
ball
->
ball
.
radius
/
2
;
}
}
else
{
//lcd_filled_circle(ball->ball.pos.x, ball->ball.pos.y, ball->ball.radius, LCD_BLACK);
accel_read
(
&
ball_acc
);
ball
->
ball
.
speed
.
x
=
((
ball_acc
.
accel_x
*
0
.
1
)
+
ball
->
ball
.
speed
.
x
)
*
(
un_ou_moins_un_x
);
ball
->
ball
.
speed
.
y
=
((
ball_acc
.
accel_y
*
0
.
1
)
+
ball
->
ball
.
speed
.
y
)
*
(
un_ou_moins_un_y
);
ball
->
ball
.
pos
.
x
=
ball
->
ball
.
pos
.
x
+
ball
->
ball
.
speed
.
x
*
(
un_ou_moins_un_x
);
ball
->
ball
.
pos
.
y
=
ball
->
ball
.
pos
.
y
+
ball
->
ball
.
speed
.
y
*
(
un_ou_moins_un_y
);
un_ou_moins_un_y
=
1
;
un_ou_moins_un_x
=
1
;
}
//}
if
(
ball
->
ball
.
pos
.
x
<=
ball
->
ball
.
radius
){
ball
->
ball
.
pos
.
x
=
ball
->
ball
.
radius
+
1
;
}
if
(
ball
->
ball
.
pos
.
y
<=
ball
->
ball
.
radius
){
ball
->
ball
.
pos
.
y
=
ball
->
ball
.
radius
+
1
;
}
if
(
ball
->
ball
.
pos
.
x
==
LCD_MAX_WIDTH
-
ball
->
ball
.
radius
){
ball
->
ball
.
pos
.
x
-=
ball
->
ball
.
radius
;
}
if
(
ball
->
ball
.
pos
.
y
==
LCD_MAX_HEIGHT
-
ball
->
ball
.
radius
){
ball
->
ball
.
pos
.
y
-=
ball
->
ball
.
radius
;
}
lcd_filled_circle
(
ball
->
ball
.
pos
.
x
,
ball
->
ball
.
pos
.
y
,
ball
->
ball
.
radius
,
ball
->
ball
.
color
);
vTaskDelay
((
portTickType
)
20
/
portTICK_RATE_MS
);
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment