Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
John, Fabian
cosa-tools-matlab
Commits
97910138
Commit
97910138
authored
Aug 04, 2021
by
Lindenberg, Arthur-Vincent
Browse files
Mqtt GPIO Pin change example on the Red Pitaya
parent
681f564e
Changes
1
Hide whitespace changes
Inline
Side-by-side
examples/redpitaya/GPIO_example.m
0 → 100644
View file @
97910138
%% alter path to your python (3.8 is tested) distribution here
py_path
=
'C:\Users\Arthur-Vincent\AppData\Local\Programs\Python\Python38\python.exe'
;
broker_ip
=
'169.254.153.32'
;
addpath
(
'../../lib'
);
addpath
(
'../../lib/redpitaya'
);
myMqtt
=
mqtt_py_matlab
(
py_path
);
myMqtt
.
connect_mqtt
(
broker_ip
);
%% Mqtt subscriptions
% Subscription to topic without wildcard
%%myMqtt.sub_mqtt_topics(broker_ip, "RP1/CONFIGURE/GPIO");
%%
% Table of avaiable GPIO Pins in rp.h
%{
typedef
enum
{
RP_LED0
,
//
!
<
LED
0
interal
RP_LED1
,
//
!
<
LED
1
interal
RP_LED2
,
//
!
<
LED
2
interal
RP_LED3
,
//
!
<
LED
3
interal
RP_LED4
,
//
!
<
LED
4
interal
RP_LED5
,
//
!
<
LED
5
interal
RP_LED6
,
//
!
<
LED
6
interal
RP_LED7
,
//
!
<
LED
7
interal
RP_DIO0_P
,
//
!
<
DIO_P
0
at
Extension
connector
1
RP_DIO1_P
,
//
!
<
DIO_P
1
at
Extension
connector
1
RP_DIO2_P
,
//
!
<
DIO_P
2
at
Extension
connector
1
RP_DIO3_P
,
//
!
<
DIO_P
3
at
Extension
connector
1
RP_DIO4_P
,
//
!
<
DIO_P
4
at
Extension
connector
1
RP_DIO5_P
,
//
!
<
DIO_P
5
at
Extension
connector
1
RP_DIO6_P
,
//
!
<
DIO_P
6
at
Extension
connector
1
RP_DIO7_P
,
//
!
<
DIO_P
7
at
Extension
connector
1
RP_DIO0_N
,
//
!
<
DIO_N
0
at
Extension
connector
1
RP_DIO1_N
,
//
!
<
DIO_N
1
at
Extension
connector
1
RP_DIO2_N
,
//
!
<
DIO_N
2
at
Extension
connector
1
RP_DIO3_N
,
//
!
<
DIO_N
3
at
Extension
connector
1
RP_DIO4_N
,
//
!
<
DIO_N
4
at
Extension
connector
1
RP_DIO5_N
,
//
!
<
DIO_N
5
at
Extension
connector
1
RP_DIO6_N
,
//
!
<
DIO_N
6
at
Extension
connector
1
RP_DIO7_N
//
!
<
DIO_N
7
at
Extension
connector
1
}
rp_dpin_t
;
%}
% Configure GPIO Pin as Input
%myMqtt.pub_mqtt(broker_ip, "RP1/CONFIGURE/GPIO/INPUT", "RP_DIO1_P");
% Configure GPIO Pin as Output
%myMqtt.pub_mqtt(broker_ip, "RP1/CONFIGURE/GPIO/OUTPUT", "RP_DIO1_P");
% Configure GPIO Pin Output State as High
%myMqtt.pub_mqtt(broker_ip, "RP1/CONFIGURE/GPIO/HIGH", "RP_DIO1_P");
% Configure GPIO Pin Output State as Low
myMqtt
.
pub_mqtt
(
broker_ip
,
"RP1/CONFIGURE/GPIO/LOW"
,
"RP_DIO1_P"
);
%Configure internal LED State as High
%myMqtt.pub_mqtt(broker_ip, "RP1/CONFIGURE/GPIO/LEDHIGH", "RP_LED1");
%Configure internal LED State as Low
myMqtt
.
pub_mqtt
(
broker_ip
,
"RP1/CONFIGURE/GPIO/LEDLOW"
,
"RP_LED1"
);
fprintf
(
"Done"
);
Write
Preview
Supports
Markdown
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