Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
scripts-perso
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
Operations
Operations
Incidents
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Daniel Stan
scripts-perso
Commits
2b3cfbc0
Commit
2b3cfbc0
authored
Feb 12, 2017
by
Daniel STAN
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lotus first draft
parent
537e57ee
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
119 deletions
+32
-119
arduino/lotus/lotus.ino
arduino/lotus/lotus.ino
+24
-118
remote/remote.py
remote/remote.py
+8
-1
No files found.
arduino/lotus/lotus.ino
View file @
2b3cfbc0
/* Arduino directement connecté à kugel, pour communiquer
avec programme python coté port série*/
// Pin du recepteur Infrarouge
//#define RECV_PIN 13
#define RECV_PIN A2
// Pin du moteur
#define RF_M_CONT 12 //EN 3,4, ex 10
#define RF_M_DRV1 11 //3A
...
...
@@ -15,24 +12,11 @@ avec programme python coté port série*/
#define POS_LOW 107
#define BOUNCE 3
#include <IRLib.h>
#include "remote.h"
IRrecv
My_Receiver
(
RECV_PIN
);
// For ir-decoder
IRdecodeNEC
My_Decoder
;
unsigned
int
Buffer
[
RAWBUF
];
void
setup
()
{
Serial
.
begin
(
9600
);
delay
(
2000
);
while
(
!
Serial
);
//delay for Leonardo
My_Receiver
.
enableIRIn
();
// Start the receiver
My_Decoder
.
UseExtnBuf
(
Buffer
);
pinMode
(
RF_M_CONT
,
OUTPUT
);
pinMode
(
RF_M_DRV1
,
OUTPUT
);
pinMode
(
RF_M_DRV2
,
OUTPUT
);
...
...
@@ -59,23 +43,27 @@ void move(bool going_up) {
digitalWrite
(
RF_M_DRV2
,
HIGH
);
}
digitalWrite
(
RF_M_CONT
,
HIGH
);
delay
(
1
);
while
((
val
=
analogRead
(
PIN_POS
)
*
comp
)
<
target
*
comp
)
{
if
(
My_Receiver
.
GetResults
(
&
My_Decoder
))
{
My_Receiver
.
resume
();
if
(
My_Decoder
.
decode
()
==
BTN_STOP
)
{
Serial
.
println
(
"Manual stop"
);
break
;
}
}
if
(
false
)
{
delay
(
1
);
while
((
val
=
analogRead
(
PIN_POS
)
*
comp
)
<
target
*
comp
)
{
//if(My_Receiver.GetResults(&My_Decoder)) {
// My_Receiver.resume();
//if( My_Decoder.decode() == BTN_STOP ) {
// Serial.println("Manual stop");
// break;
//}
//}
delay
(
1
);
}
Serial
.
print
(
"Stopping because"
);
Serial
.
println
(
val
);
report_pos
();
}
else
{
delay
(
300
);
if
(
going_up
)
delay
(
200
);
}
Serial
.
print
(
"Stopping because"
);
Serial
.
println
(
val
);
report_pos
();
/*delay(300);
if(going_up)
delay(200);*/
digitalWrite
(
RF_M_CONT
,
LOW
);
digitalWrite
(
RF_M_DRV1
,
LOW
);
digitalWrite
(
RF_M_DRV2
,
LOW
);
...
...
@@ -88,99 +76,17 @@ void report_pos() {
void
loop
()
{
int
val
;
int
incomingByte
=
0
;
bool
going_up
=
true
;
val
=
analogRead
(
PIN_POS
);
// if(val > POS_HIGH + BOUNCE && going_up) {
// Serial.println(val);
// Serial.println("Going down");
// digitalWrite(RF_M_CONT, HIGH);
// digitalWrite(RF_M_DRV1, LOW);
// digitalWrite(RF_M_DRV2, HIGH);
// going_up = false;
// } else if( val < POS_LOW - BOUNCE && !going_up) {
// Serial.println(val);
// Serial.println("Going up");
// digitalWrite(RF_M_CONT, HIGH);
// digitalWrite(RF_M_DRV1, HIGH);
// digitalWrite(RF_M_DRV2, LOW);
// going_up = true;
// }
if
(
Serial
.
available
())
{
incomingByte
=
Serial
.
read
();
if
(
incomingByte
==
'0'
)
{
Serial
.
println
(
"Going down"
);
digitalWrite
(
RF_M_CONT
,
HIGH
);
digitalWrite
(
RF_M_DRV1
,
LOW
);
digitalWrite
(
RF_M_DRV2
,
HIGH
);
}
else
if
(
incomingByte
==
'1'
)
{
Serial
.
println
(
"Going up"
);
digitalWrite
(
RF_M_CONT
,
HIGH
);
digitalWrite
(
RF_M_DRV1
,
HIGH
);
digitalWrite
(
RF_M_DRV2
,
LOW
);
}
else
if
(
incomingByte
==
'r'
)
{
if
(
incomingByte
==
'0'
)
move
(
false
);
else
if
(
incomingByte
==
'1'
)
move
(
true
);
else
if
(
incomingByte
==
'r'
)
{
report_pos
();
}
}
if
(
My_Receiver
.
GetResults
(
&
My_Decoder
))
{
Serial
.
println
(
"Reading"
);
//Restart the receiver so it can be capturing another code
//while we are working on decoding this one.
My_Receiver
.
resume
();
if
(
My_Decoder
.
decode
()
)
switch
(
My_Decoder
.
value
)
{
case
BTN_UP
:
move
(
true
);
break
;
case
BTN_DOWN
:
move
(
false
);
break
;
case
BTN_PAUSE
:
Serial
.
println
(
"Control: PPause"
);
break
;
case
BTN_VOL_DOWN
:
Serial
.
println
(
"Control: Vol-"
);
break
;
case
BTN_VOL_UP
:
Serial
.
println
(
"Control: Vol+"
);
break
;
case
BTN_1
:
Serial
.
println
(
"Control: 1"
);
break
;
case
BTN_2
:
Serial
.
println
(
"Control: 2"
);
break
;
case
BTN_3
:
Serial
.
println
(
"Control: 3"
);
break
;
case
BTN_4
:
Serial
.
println
(
"Control: 4"
);
break
;
case
BTN_LEFT
:
Serial
.
println
(
"Control: Prev"
);
break
;
case
BTN_RIGHT
:
Serial
.
println
(
"Control: Next"
);
break
;
case
BTN_SETUP
:
Serial
.
println
(
"Control: Setup"
);
break
;
case
BTN_STOP
:
Serial
.
println
(
"Control: Stop"
);
break
;
case
BTN_ENTER
:
Serial
.
println
(
"Control: Enter"
);
break
;
case
BTN_RETURN
:
Serial
.
println
(
"Control: Return"
);
break
;
default:
Serial
.
print
(
"Unkwon: "
);
Serial
.
println
(
My_Decoder
.
value
);
}
}
}
remote/remote.py
View file @
2b3cfbc0
...
...
@@ -10,7 +10,7 @@ import sys
import
os
import
time
SERIALPORT
=
"/dev/ttyUSB
1
"
SERIALPORT
=
"/dev/ttyUSB
0
"
BAUDRATE
=
9600
CONTROL
=
b
'Control:'
SOCK_P
=
'/var/run/user/%d/remote'
%
os
.
getuid
()
...
...
@@ -74,6 +74,13 @@ def process_line(response):
#if response.startswith(b'Unkwon: 4294967295'):
# ss.Lock()
# return
# TODO
if
response
.
startswith
(
b
'Unkwon: 16621663'
):
call
([
'lotus'
,
'1'
])
return
if
response
.
startswith
(
b
'Unkwon: 16625743'
):
call
([
'lotus'
,
'0'
])
return
if
response
.
startswith
(
CONTROL
):
key
=
response
[
len
(
CONTROL
):].
strip
().
lower
()
if
key
==
b
'pause'
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment