Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
R
raspberry_Holographic
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张泽仁
raspberry_Holographic
Commits
bedf4827
Commit
bedf4827
authored
Oct 27, 2023
by
Your Name
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
release for sent uart success, not done with angle,vedio and media
parent
226d9d1e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
137 additions
and
51 deletions
+137
-51
interface.c
raspberrypi_spi/LocalDimming/interface.c
+137
-51
No files found.
raspberrypi_spi/LocalDimming/interface.c
View file @
bedf4827
...
@@ -31,6 +31,9 @@ int count = 1;
...
@@ -31,6 +31,9 @@ int count = 1;
int
fileusb
;
int
fileusb
;
int
fileuart
;
int
fileuart
;
int
t
=
0
;
int
spi_fd
;
int
spi_fd
;
...
@@ -55,7 +58,7 @@ int xfm_Init()
...
@@ -55,7 +58,7 @@ int xfm_Init()
}
}
printf
(
"/dev/ttyUSB0 Open success
\r\n
"
);
printf
(
"/dev/ttyUSB0 Open success
\r\n
"
);
if
((
fileuart
=
serialOpen
(
"/dev/ttyAMA0"
,
9600
))
<
0
)
//changed from 115200 to 9600
if
((
fileuart
=
serialOpen
(
"/dev/ttyAMA0"
,
9600
))
<
0
)
{
{
printf
(
"/dev/ttyAMA0 Open Faild
\r\n
"
);
printf
(
"/dev/ttyAMA0 Open Faild
\r\n
"
);
return
0
;
return
0
;
...
@@ -69,7 +72,7 @@ int xfm_Init()
...
@@ -69,7 +72,7 @@ int xfm_Init()
void
protocalAck
(
int
fileusb
)
void
protocalAck
(
int
fileusb
)
{
{
printf
(
"protocalAck..
\n
"
);
printf
(
"protocalAck..
\n
"
);
char
retExmaple
[
12
]
=
{
0
};
char
retExmaple
[
12
]
=
{
0
};
strcpy
(
retExmaple
,
ret
);
strcpy
(
retExmaple
,
ret
);
retExmaple
[
3
]
=
0x04
;
retExmaple
[
3
]
=
0x04
;
...
@@ -114,9 +117,8 @@ uint16_t getAngle(char *rece)
...
@@ -114,9 +117,8 @@ uint16_t getAngle(char *rece)
angle
=
result
;
angle
=
result
;
return
angle
;
return
angle
;
}
}
// crc
// crc
uint16_t
CrcValueCalc
(
const
uint8_t
*
cpucData
,
uint16_t
usLength
)
uint16_t
CrcValueCalc
(
uint8_t
*
cpucData
,
uint16_t
usLength
)
//changed
{
{
uint16_t
crcValue
=
0xffff
;
uint16_t
crcValue
=
0xffff
;
int
i
;
int
i
;
...
@@ -137,8 +139,10 @@ uint16_t CrcValueCalc(const uint8_t *cpucData, uint16_t usLength)
...
@@ -137,8 +139,10 @@ uint16_t CrcValueCalc(const uint8_t *cpucData, uint16_t usLength)
}
}
return
crcValue
;
return
crcValue
;
}
}
extern
int
get_audio_device_id
();
void
sendMessageHead
(
int
mode
,
char
*
message
)
void
sendMessageHead
(
int
mode
,
char
*
message
)
//changed
{
{
*
(
message
)
=
0x40
;
*
(
message
)
=
0x40
;
*
(
message
+
1
)
=
0x38
;
// head
*
(
message
+
1
)
=
0x38
;
// head
...
@@ -153,78 +157,162 @@ void sendMessageHead(int mode, char* message)
...
@@ -153,78 +157,162 @@ void sendMessageHead(int mode, char* message)
*
(
message
+
2
)
=
0x0b
;
//length
*
(
message
+
2
)
=
0x0b
;
//length
*
(
message
+
3
)
=
0x06
;
//instru
*
(
message
+
3
)
=
0x06
;
//instru
*
(
message
+
4
)
=
0x00
;
//reg0
*
(
message
+
4
)
=
0x00
;
//reg0
*
(
message
+
5
)
=
0x02
;
//reg1 write angle
*
(
message
+
5
)
=
0x02
;
//reg1 write
*
(
message
+
6
)
=
0x00
;
//ack
*
(
message
+
6
)
=
0x00
;
*
(
message
+
7
)
=
0x00
;
*
(
message
+
8
)
=
0x00
;
}
}
}
}
void
sentMessageAngle
(
int
fileuart
,
uint16_t
angle
)
//changed
void
sentMessageAngle
(
int
fileuart
,
uint16_t
angle
)
//changed
{
{
char
messageAngle
[
1
3
];
char
messageAngle
[
1
1
];
sendMessageHead
(
1
,
messageAngle
);
sendMessageHead
(
1
,
messageAngle
);
messageAngle
[
7
]
=
0x00
;
messageAngle
[
8
]
=
0x00
;
messageAngle
[
9
]
=
(
angle
>>
8
)
&
0xff
;
messageAngle
[
9
]
=
(
angle
>>
8
)
&
0xff
;
messageAngle
[
10
]
=
angle
&
0xff
;
messageAngle
[
10
]
=
angle
&
0xff
;
uint16_t
crc
;
uint16_t
crc
;
crc
=
CrcValueCalc
(
messageAngle
,
11
);
crc
=
CrcValueCalc
(
messageAngle
,
11
);
messageAngle
[
11
]
=
crc
&
0xff
;
messageAngle
[
12
]
=
(
crc
>>
8
)
&
0xff
;
messageAngle
[
12
]
=
(
crc
>>
8
)
&
0xff
;
messageAngle
[
11
]
=
crc
&
0xff
;
write
(
fileuart
,
messageAngle
,
1
1
);
write
(
fileuart
,
messageAngle
,
1
3
);
}
}
extern
int
get_audio_device_id
();
char
*
readMessageAngle
(
int
fileuart
)
void
releaseAckeachwakenwords
(
char
*
totalbuf
)
//used for test
{
{
char
*
p
=
totalbuf
;
char
*
result
=
malloc
(
sizeof
(
char
));
while
(
*
p
!=
'k'
||
*
(
p
+
1
)
!=
'e'
)
return
result
;
}
char
*
readMessageStatus
(
int
fileuart
)
{
char
message
[
9
];
sendMessageHead
(
0
,
message
);
message
[
5
]
=
0x01
;
uint16_t
crc
;
crc
=
CrcValueCalc
(
message
,
7
);
message
[
7
]
=
(
crc
>>
8
)
&
0xff
;
message
[
8
]
=
crc
&
0xff
;
int
t
=
0
;
while
(
!
t
)
{
{
p
++
;
write
(
fileuart
,
message
,
9
);
}
int
recbyte
=
serialDataAvail
(
fileuart
);
p
+=
12
;
if
(
g_callback
!=
NULL
){
while
(
1
);
char
buf
[
256
]
=
{
0
};
snprintf
(
buf
,
256
,
"cvlc --play-and-exit --aout alsa --alsa-audio-device hw:%d,0 /usr/local/bin/Videos/aaaa.mp3 &"
,
get_audio_device_id
());
//system("mpg321 /usr/local/bin/Videos/aaaa.mp3 &");
//system("cvlc --play-and-exit --aout alsa --alsa-audio-device hw:2,0 /usr/local/bin/Videos/aaaa.mp3 &");
system
(
buf
);
}
}
uint16_t
angle
;
char
*
result
=
malloc
(
sizeof
(
char
));
angle
=
getAngle
(
totalbuf
);
return
result
;
sentMessageAngle
(
fileuart
,
angle
);
}
switch
(
*
p
)
int
judgeData
()
{
return
1
;
}
void
waitforReady
(
int
fileuart
)
{
int
t
=
0
;
while
(
!
t
)
{
{
case
'x'
:
int
recbytenum
=
serialDataAvail
(
fileuart
);
g_callback
(
g_callback_ctx
,
2
);
if
(
recbytenum
>
1
)
break
;
{
case
'z'
:
char
buf
[
24
]
=
{
0
};
g_callback
(
g_callback_ctx
,
4
);
int
temp
=
0
;
break
;
while
(
recbytenum
--
)
//recbyte
case
'y'
:
{
g_callback
(
g_callback_ctx
,
3
);
buf
[
temp
++
]
=
serialGetchar
(
fileuart
);
}
if
(
!
judgeData
)
//judge data if not right
{
usleep
(
500
);
readMessageStatus
(
fileuart
);
continue
;
}
// check receive data .....
serialFlush
(
fileuart
);
//make status ready for next place
break
;
break
;
default:
}
}
}
void
waitforReady_test
(
int
fileuart
)
//test_version
{
while
(
1
)
{
int
recbytenum
=
serialDataAvail
(
fileuart
);
if
(
recbytenum
>
1
)
{
char
buf
[
24
]
=
{
0
};
int
temp
=
0
;
while
(
recbytenum
--
)
{
buf
[
temp
++
]
=
serialGetchar
(
fileuart
);
}
for
(
int
i
=
0
;
i
<
temp
;
i
++
)
{
printf
(
"%x"
,
buf
[
i
]);
if
(
(
i
%
2
)
==
0
)
printf
(
" "
);
}
printf
(
"
\n
"
);
serialFlush
(
fileuart
);
break
;
break
;
}
}
}
usleep
(
100
);
}
}
void
sentUart
(
char
*
buf
,
int
fileuart
)
void
sentUart
(
char
*
buf
,
int
fileuart
,
int
fileusb
)
//changed
{
{
if
(
count
==
9
)
if
(
count
==
9
)
{
{
strcat
(
totalbuf
,
buf
);
strcat
(
totalbuf
,
buf
);
uint16_t
angle
;
angle
=
getAngle
(
totalbuf
);
printf
(
"angle = %x
\n
"
,
angle
);
sentMessageAngle
(
fileuart
,
angle
);
//sentMessageAngle(fileuart, angle);
// 0x40 0x38 0x0b 0x06 0x00 0x02 0x01 00 -- -- -- 1d 08 0
// 04 b0 1e 7c 120
// char message1[13] = {0x40, 0x38, 0x0b, 0x06, 0x00, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x1d, 0x08};
// char message2[13] = {0x40, 0x38, 0x0b, 0x06, 0x00, 0x02, 0x01, 0x00, 0x00, 0x04, 0xb0, 0x1e, 0x7c};
// if (t == 0){
// write(fileuart, message1, 13);
// t = 1;
// }
// else{
// write(fileuart, message2, 13);
// t = 0;
// }
count
=
1
;
count
=
1
;
memset
(
totalbuf
,
0
,
1024
);
memset
(
totalbuf
,
0
,
1024
);
protocalAck
(
fileusb
);
if
(
g_callback
!=
NULL
){
char
buf
[
256
]
=
{
0
};
snprintf
(
buf
,
256
,
"cvlc --play-and-exit --aout alsa --alsa-audio-device hw:%d,0 /usr/local/bin/Videos/aaaa.mp3 &"
,
get_audio_device_id
());
//system("mpg321 /usr/local/bin/Videos/aaaa.mp3 &");
//system("cvlc --play-and-exit --aout alsa --alsa-audio-device hw:2,0 /usr/local/bin/Videos/aaaa.mp3 &");
system
(
buf
);
g_callback
(
g_callback_ctx
,
2
);
}
//waitforReady_test(fileuart);
releaseAckeachwakenwords
(
totalbuf
);
}
}
else
else
{
{
...
@@ -234,7 +322,7 @@ void sentUart(char *buf, int fileuart)
...
@@ -234,7 +322,7 @@ void sentUart(char *buf, int fileuart)
}
}
void
circleReading
()
void
circleReading
()
//changed
{
{
printf
(
"cicleReading..
\n
"
);
printf
(
"cicleReading..
\n
"
);
serialFlush
(
fileusb
);
serialFlush
(
fileusb
);
...
@@ -257,16 +345,14 @@ void circleReading()
...
@@ -257,16 +345,14 @@ void circleReading()
}
}
else
else
{
{
sentUart
(
buf
,
fileuart
);
printf
(
" %d
\n
"
,
__LINE__
);
sentUart
(
buf
,
fileuart
,
fileusb
);
printf
(
" %d
\n
"
,
__LINE__
);
serialFlush
(
fileusb
);
//guarantee buf wont affect next input
serialFlush
(
fileusb
);
}
}
}
}
}
}
return
;
return
;
}
}
//localdimming
//localdimming
void
LocalDimming_Init
()
void
LocalDimming_Init
()
{
{
...
...
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