Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Michal Rybka
Antenna HF Switch SO2V SOSB
Commits
d2abecb4
Commit
d2abecb4
authored
Oct 21, 2020
by
Ondřej Kučera
Browse files
add firmware
parent
af6e56ab
Changes
1
Hide whitespace changes
Inline
Side-by-side
FW/band-master/band-master.ino
0 → 100644
View file @
d2abecb4
// BAND-MASTER FW v1.0
// @oktkas
//RX TX LEDs
#define RX 12
#define TX 13
//radio RX/TX state
#define PTT 11
// S/SC; SW1-4
const
int
SW
[]
=
{
18
,
3
,
5
,
7
,
9
};
const
int
LSW
[]
=
{
19
,
4
,
6
,
8
,
10
};
// RE1-4
const
int
RE
[]
=
{
14
,
15
,
16
,
17
};
bool
SWval
[]
=
{
0
,
0
,
0
,
0
,
0
};
bool
SWlastVal
[]
=
{
0
,
0
,
0
,
0
,
0
};
bool
LSWval
[]
=
{
0
,
0
,
0
,
0
,
0
};
bool
REval
[]
=
{
0
,
0
,
0
,
0
};
void
setup
()
{
//BTNs & LEDs
for
(
int
i
=
0
;
i
<
sizeof
(
SW
)
/
sizeof
(
SW
[
0
]);
i
++
)
{
pinMode
(
SW
[
i
],
INPUT_PULLUP
);
pinMode
(
LSW
[
i
],
OUTPUT
);
digitalWrite
(
LSW
[
i
],
LOW
);
}
//RX TX LEDs
pinMode
(
RX
,
OUTPUT
);
digitalWrite
(
RX
,
LOW
);
pinMode
(
TX
,
OUTPUT
);
digitalWrite
(
TX
,
LOW
);
// Relays
for
(
int
i
=
0
;
i
<
sizeof
(
RE
)
/
sizeof
(
RE
[
0
]);
i
++
)
{
pinMode
(
RE
[
i
],
OUTPUT
);
digitalWrite
(
RE
[
i
],
LOW
);
}
// radio state
pinMode
(
PTT
,
INPUT_PULLUP
);
}
void
loop
()
{
// načtení hodnot tlačítek do pole
for
(
int
i
=
0
;
i
<
sizeof
(
SW
)
/
sizeof
(
SW
[
0
]);
i
++
)
{
int
val
=
digitalRead
(
SW
[
i
]);
//načti hodnotu tlačítka
if
(
!
val
&&
SWlastVal
[
i
])
{
//tlačítko je zmáčknuto(0) a hodnota posledního čtení není 0
if
(
i
==
0
)
{
// Single/Couple přepínač
if
(
SWval
[
0
]
==
1
)
{
//při přepnutí z Couple na Single všechno odpojím a připojím Re3
SWval
[
1
]
=
0
;
SWval
[
2
]
=
0
;
SWval
[
3
]
=
0
;
SWval
[
4
]
=
0
;
}
SWval
[
i
]
=
!
SWval
[
i
];
// přepnu S/C
}
else
if
(
SWval
[
0
]
==
1
)
{
// pro režim Couple zapoj/odpoj anténu
SWval
[
i
]
=
!
SWval
[
i
];
}
else
{
// pro režim Single odpoj všechny a připoj jednu anténu
if
(
i
==
3
)
{
//invertované chování pro Re3
SWval
[
1
]
=
0
;
SWval
[
2
]
=
0
;
SWval
[
3
]
=
0
;
SWval
[
4
]
=
0
;
}
else
{
SWval
[
1
]
=
0
;
SWval
[
2
]
=
0
;
SWval
[
3
]
=
1
;
//invertované chování pro Re3
SWval
[
4
]
=
0
;
SWval
[
i
]
=
1
;
}
}
}
SWlastVal
[
i
]
=
val
;
//zaznamenej aktuální čtení pro příští vyhodnocení
}
// rozsvícení LED
for
(
int
i
=
0
;
i
<
sizeof
(
SW
)
/
sizeof
(
SW
[
0
]);
i
++
)
{
if
(
i
==
3
)
{
//invertované chování pro Re3
digitalWrite
(
LSW
[
i
],
!
SWval
[
i
]);
}
else
{
digitalWrite
(
LSW
[
i
],
SWval
[
i
]);
}
}
if
(
!
digitalRead
(
PTT
))
{
// rádio vysílá
digitalWrite
(
RE
[
0
],
LOW
);
//Re1
digitalWrite
(
RE
[
1
],
LOW
);
//Re2
digitalWrite
(
RE
[
2
],
HIGH
);
//Re3
digitalWrite
(
RE
[
3
],
LOW
);
//Re4
digitalWrite
(
TX
,
HIGH
);
//TX LED
digitalWrite
(
RX
,
LOW
);
//RX LED
}
else
{
// rádio přijímá
digitalWrite
(
TX
,
LOW
);
//TX LED
digitalWrite
(
RX
,
HIGH
);
//RX LED
//zapíšu hodnoty čudlíků antén na relé antén
for
(
int
i
=
0
;
i
<
sizeof
(
RE
)
/
sizeof
(
RE
[
0
]);
i
++
)
{
digitalWrite
(
RE
[
i
],
SWval
[
i
+
1
]);
}
}
}
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