Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
U
uni_ete_hepialight_mqtt
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
jonas.stirnema
uni_ete_hepialight_mqtt
Commits
1c34ee94
Commit
1c34ee94
authored
1 year ago
by
abivarma.kandiah
Browse files
Options
Downloads
Patches
Plain Diff
Send text from server to matrix
parent
ada5a6e4
No related branches found
No related tags found
1 merge request
!2
Merge ESP code to master
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/mqtt_esp32/mqtt_esp32.ino
+43
-9
43 additions, 9 deletions
src/mqtt_esp32/mqtt_esp32.ino
src/mqtt_hepialight/MAIN.PY
+0
-14
0 additions, 14 deletions
src/mqtt_hepialight/MAIN.PY
with
43 additions
and
23 deletions
src/mqtt_esp32/mqtt_esp32.ino
+
43
−
9
View file @
1c34ee94
...
@@ -4,6 +4,7 @@
...
@@ -4,6 +4,7 @@
#define MATRIX_SIZE 10 // 10x10
#define MATRIX_SIZE 10 // 10x10
#define IMG_DATA_SIZE MATRIX_SIZE * MATRIX_SIZE * 3 //DATA SIZE FOR ONE MATRIX = RGB * MATRIX_SIZE
#define IMG_DATA_SIZE MATRIX_SIZE * MATRIX_SIZE * 3 //DATA SIZE FOR ONE MATRIX = RGB * MATRIX_SIZE
#define IS_TEXT 1
// WiFi
// WiFi
const
char
*
ssid
=
"uni-ete2"
;
// Enter your WiFi name
const
char
*
ssid
=
"uni-ete2"
;
// Enter your WiFi name
...
@@ -21,8 +22,8 @@ PubSubClient client(espClient);
...
@@ -21,8 +22,8 @@ PubSubClient client(espClient);
// UART2
// UART2
HardwareSerial
SerialPort
(
2
);
// use UART2
HardwareSerial
SerialPort
(
2
);
// use UART2
uint8_t
cluster_size_x
=
1
;
uint8_t
cluster_size_x
=
2
;
uint8_t
cluster_size_y
=
1
;
uint8_t
cluster_size_y
=
2
;
void
setup
()
void
setup
()
{
{
...
@@ -88,11 +89,13 @@ uint8_t* mqtt_packet_to_raw(uint8_t* packet, unsigned int* length)
...
@@ -88,11 +89,13 @@ uint8_t* mqtt_packet_to_raw(uint8_t* packet, unsigned int* length)
void
send_data_to_matrix
(
uint8_t
idx
,
uint8_t
idy
,
uint8_t
*
data
,
uint32_t
length
)
void
send_data_to_matrix
(
uint8_t
idx
,
uint8_t
idy
,
uint8_t
*
data
,
uint32_t
length
)
{
{
uint8_t
raw_data
[
202
];
uint8_t
raw_data
[
220
];
raw_data
[
0
]
=
idx
;
char
header
[]
=
"PT;x,y;IMAGE;"
;
raw_data
[
1
]
=
idy
;
strcpy
((
char
*
)
raw_data
,
header
);
raw_data
[
3
]
=
'0'
+
idx
;
raw_data
[
5
]
=
'0'
+
idy
;
uint8_t
send_len
=
2
;
uint8_t
send_len
=
13
;
// SEND RGB DATA
// SEND RGB DATA
for
(
int
i
=
0
;
i
<
length
;
i
+=
3
)
for
(
int
i
=
0
;
i
<
length
;
i
+=
3
)
...
@@ -130,7 +133,7 @@ void send_data_to_matrix(uint8_t idx, uint8_t idy, uint8_t* data, uint32_t lengt
...
@@ -130,7 +133,7 @@ void send_data_to_matrix(uint8_t idx, uint8_t idy, uint8_t* data, uint32_t lengt
// SEND UART PACKET HEADER
// SEND UART PACKET HEADER
SerialPort
.
print
((
char
)
0x77
);
SerialPort
.
print
((
char
)
0x77
);
SerialPort
.
print
((
char
)
202
);
SerialPort
.
print
((
char
)
send_len
);
uint8_t
crc
=
0
;
uint8_t
crc
=
0
;
for
(
int
i
=
0
;
i
<
send_len
;
i
++
)
for
(
int
i
=
0
;
i
<
send_len
;
i
++
)
...
@@ -139,11 +142,11 @@ void send_data_to_matrix(uint8_t idx, uint8_t idy, uint8_t* data, uint32_t lengt
...
@@ -139,11 +142,11 @@ void send_data_to_matrix(uint8_t idx, uint8_t idy, uint8_t* data, uint32_t lengt
{
{
crc
=
crc
^
0x10
;
crc
=
crc
^
0x10
;
SerialPort
.
print
((
char
)
0x10
);
SerialPort
.
print
((
char
)
0x10
);
Serial
.
println
(
0x10
);
//
Serial.println(0x10);
}
}
crc
=
crc
^
raw_data
[
i
];
crc
=
crc
^
raw_data
[
i
];
SerialPort
.
print
((
char
)
raw_data
[
i
]);
SerialPort
.
print
((
char
)
raw_data
[
i
]);
Serial
.
println
(
raw_data
[
i
]);
//
Serial.println(raw_data[i]);
}
}
// SEND UART PACKET FOOTER
// SEND UART PACKET FOOTER
...
@@ -169,6 +172,37 @@ void callback(char *topic, byte *payload, unsigned int length)
...
@@ -169,6 +172,37 @@ void callback(char *topic, byte *payload, unsigned int length)
// SerialPort.print((char)202);
// SerialPort.print((char)202);
// SerialPort.print((char)0xaa);
// SerialPort.print((char)0xaa);
if
(
IS_TEXT
)
{
char
data
[
100
];
char
header
[]
=
"PT;1,0;MOVING;16711680;0.1;"
;
memcpy
(
data
,
header
,
strlen
(
header
)
+
1
);
strncat
(
data
,
(
char
*
)
payload
,
length
);
uint32_t
len
=
strlen
(
data
);
// SEND UART PACKET HEADER
SerialPort
.
print
((
char
)
0x77
);
SerialPort
.
print
((
char
)
len
);
uint8_t
crc
=
0
;
for
(
int
i
=
0
;
i
<
len
;
i
++
)
{
if
(
data
[
i
]
==
0x77
||
data
[
i
]
==
0x10
||
data
[
i
]
==
0xAA
)
{
crc
=
crc
^
0x10
;
SerialPort
.
print
((
char
)
0x10
);
}
crc
=
crc
^
data
[
i
];
SerialPort
.
print
((
char
)
data
[
i
]);
}
// SEND UART PACKET FOOTER
SerialPort
.
print
((
char
)(
crc
^
len
));
SerialPort
.
print
((
char
)
0xAA
);
return
;
}
// GET RAW DATA
// GET RAW DATA
uint8_t
*
raw_data
=
mqtt_packet_to_raw
(
payload
,
&
length
);
uint8_t
*
raw_data
=
mqtt_packet_to_raw
(
payload
,
&
length
);
if
(
raw_data
==
NULL
)
if
(
raw_data
==
NULL
)
...
...
This diff is collapsed.
Click to expand it.
src/mqtt_hepialight/MAIN.PY
+
0
−
14
View file @
1c34ee94
r
=
0xA2142F
p
=
0x7E2F8E
data32
=
[
0xFFFFFF
]
*
100
r_16
=
0xF800
w_16
=
0xFFFF
y_16
=
0xfea7
b_16
=
0x0000
data16
=
[
b_16
,
y_16
]
*
50
def
color16_to_32
(
color
):
def
color16_to_32
(
color
):
color
=
int
(
color
)
color
=
int
(
color
)
r
=
((
color
>>
11
)
&
0xFF
)
*
2
**
3
r
=
((
color
>>
11
)
&
0xFF
)
*
2
**
3
...
@@ -22,7 +10,6 @@ def disp_img_data(data):
...
@@ -22,7 +10,6 @@ def disp_img_data(data):
for
j
in
range
(
NBR_COLONNES
):
for
j
in
range
(
NBR_COLONNES
):
allumer_led
(
i
,
j
,
data
[
i
*
NBR_LIGNES
+
j
])
allumer_led
(
i
,
j
,
data
[
i
*
NBR_LIGNES
+
j
])
def
data_to_color16
(
data
):
def
data_to_color16
(
data
):
d_color16
=
[]
d_color16
=
[]
...
@@ -36,7 +23,6 @@ def data_to_color16(data):
...
@@ -36,7 +23,6 @@ def data_to_color16(data):
return
list
(
map
(
color16_to_32
,
d_color16
))
return
list
(
map
(
color16_to_32
,
d_color16
))
#data32 = list(map(color16_to_32, data16))
r_data
=
[]
r_data
=
[]
while
(
True
):
while
(
True
):
r_data
=
recevoir_msg
(
S
)
r_data
=
recevoir_msg
(
S
)
...
...
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