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
4c35b5cf
Commit
4c35b5cf
authored
Oct 25, 2023
by
张泽仁
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
still featuring, not done
parent
76e8723c
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
177 additions
and
19 deletions
+177
-19
settings.json
.vscode/settings.json
+2
-1
interface.c
raspberrypi_spi/LocalDimming/interface.c
+175
-18
No files found.
.vscode/settings.json
View file @
4c35b5cf
{
"files.associations"
:
{
"egl_ctx.h"
:
"c"
}
},
"C_Cpp.errorSquiggles"
:
"disabled"
}
\ No newline at end of file
raspberrypi_spi/LocalDimming/interface.c
View file @
4c35b5cf
...
...
@@ -118,7 +118,7 @@ uint16_t getAngle(char *rece)
}
// crc
uint16_t
CrcValueCalc
(
const
uint8_t
*
cpucData
,
uint16_t
usLength
)
uint16_t
CrcValueCalc
(
uint8_t
*
cpucData
,
uint16_t
usLength
)
{
uint16_t
crcValue
=
0xffff
;
int
i
;
...
...
@@ -142,7 +142,137 @@ uint16_t CrcValueCalc(const uint8_t *cpucData, uint16_t usLength)
extern
int
get_audio_device_id
();
void
sentUart
(
char
*
buf
,
int
fileuart
)
void
sendMessageHead
(
int
mode
,
char
*
message
)
{
*
(
message
)
=
0x40
;
*
(
message
+
1
)
=
0x38
;
// head
if
(
mode
==
0
)
// read
{
*
(
message
+
2
)
=
0x07
;
//length
*
(
message
+
3
)
=
0x03
;
//instru
*
(
message
+
4
)
=
0x00
;
//reg0
*
(
message
+
6
)
=
0x01
;
//ack
}
else
{
// write
*
(
message
+
2
)
=
0x09
;
//length
*
(
message
+
3
)
=
0x06
;
//instru
*
(
message
+
4
)
=
0x00
;
//reg0
*
(
message
+
5
)
=
0x02
;
//reg1 write angle
*
(
message
+
8
)
=
0x00
;
//ack
}
}
void
sentMessageAngle
(
int
fileuart
,
uint16_t
angle
)
//changed
{
char
messageAngle
[
11
];
sendMessageHead
(
1
,
messageAngle
);
messageAngle
[
6
]
=
(
angle
>>
8
)
&
0xff
;
messageAngle
[
7
]
=
angle
&
0xff
;
uint16_t
crc
;
crc
=
CrcValueCalc
(
messageAngle
,
9
);
messageAngle
[
9
]
=
(
crc
>>
8
)
&
0xff
;
messageAngle
[
10
]
=
crc
&
0xff
;
write
(
fileuart
,
messageAngle
,
11
);
}
char
*
readMessageAngle
(
int
fileuart
)
{
char
*
result
=
malloc
(
sizeof
(
char
));
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
)
{
write
(
fileuart
,
message
,
9
);
int
recbyte
=
serialDataAvail
(
fileuart
);
while
(
1
);
}
char
*
result
=
malloc
(
sizeof
(
char
));
return
result
;
}
int
judgeData
()
{
return
1
;
}
void
waitforReady
(
int
fileuart
)
{
int
t
=
0
;
while
(
!
t
)
{
int
recbytenum
=
serialDataAvail
(
fileuart
);
if
(
recbytenum
>
1
)
{
char
buf
[
24
]
=
{
0
};
int
temp
=
0
;
while
(
recbytenum
--
)
//recbyte
{
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
;
}
}
}
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
;
}
}
}
void
sentUart
(
char
*
buf
,
int
fileuart
,
int
fileusb
)
//changed
{
if
(
count
==
9
)
{
...
...
@@ -150,21 +280,15 @@ void sentUart(char *buf, int fileuart)
uint16_t
angle
;
angle
=
getAngle
(
totalbuf
);
printf
(
"angle = %x
\n
"
,
angle
);
char
angleret
[
2
];
angleret
[
1
]
=
angle
&
0xff
;
angleret
[
0
]
=
(
angle
>>
8
)
&
0xff
;
write
(
fileuart
,
angleret
,
2
);
sentMessageAngle
(
fileuart
,
angle
);
count
=
1
;
memset
(
totalbuf
,
0
,
1024
);
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
);
protocalAck
(
fileusb
);
waitforReady_test
(
fileuart
);
}
}
else
{
...
...
@@ -174,7 +298,7 @@ void sentUart(char *buf, int fileuart)
}
void
circleReading
()
void
circleReading
()
//changed
{
printf
(
"cicleReading..
\n
"
);
serialFlush
(
fileusb
);
...
...
@@ -197,14 +321,14 @@ void circleReading()
}
else
{
sentUart
(
buf
,
fileuart
);
printf
(
" %d
\n
"
,
__LINE__
);
sentUart
(
buf
,
fileuart
,
fileusb
);
printf
(
" %d
\n
"
,
__LINE__
);
serialFlush
(
fileusb
);
//guarantee buf wont affect next input
}
}
}
return
;
}
//localdimming
void
LocalDimming_Init
()
{
...
...
@@ -407,3 +531,36 @@ void eachPicWrite(int num, int pic)
}
}
// void sentUart(char *buf, int fileuart)
// {
// if (count == 9)
// {
// strcat(totalbuf, buf);
// uint16_t angle;
// angle = getAngle(totalbuf);
// printf("angle = %x\n", angle);
// char angleret[2];
// angleret[1] = angle & 0xff;
// angleret[0] = (angle >> 8) & 0xff;
// write(fileuart, angleret, 2);
// count = 1;
// memset(totalbuf, 0, 1024);
// 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);
// }
// }
// else
// {
// count++;
// strcat(totalbuf, buf);
// }
// }
\ No newline at end of file
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