Skip to content

Commit 55f33fb

Browse files
committed
Add beeper and LoRa switch support
1 parent 9190074 commit 55f33fb

File tree

1 file changed

+54
-5
lines changed

1 file changed

+54
-5
lines changed

Firmware/RTK_Everywhere/System.ino

Lines changed: 54 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -112,14 +112,24 @@ void beepOn()
112112
{
113113
// Disallow beeper if setting is turned off
114114
if ((pin_beeper != PIN_UNDEFINED) && (settings.enableBeeper == true))
115-
digitalWrite(pin_beeper, HIGH);
115+
{
116+
if (productVariant == RTK_TORCH)
117+
digitalWrite(pin_beeper, HIGH);
118+
else if (productVariant == RTK_FLEX)
119+
tone(pin_beeper, 523); // NOTE_C5
120+
}
116121
}
117122

118123
void beepOff()
119124
{
120125
// Disallow beeper if setting is turned off
121126
if ((pin_beeper != PIN_UNDEFINED) && (settings.enableBeeper == true))
122-
digitalWrite(pin_beeper, LOW);
127+
{
128+
if (productVariant == RTK_TORCH)
129+
digitalWrite(pin_beeper, LOW);
130+
else if (productVariant == RTK_FLEX)
131+
noTone(pin_beeper);
132+
}
123133
}
124134

125135
// Only useful for pin_chargerLED on Facet mosaic
@@ -895,13 +905,13 @@ void beginGpioExpanderSwitches()
895905
// PWRKILL is on pin 7. Driving it low will turn off the system
896906
for (int i = 0; i < 8; i++)
897907
{
898-
//Set all pins to low expect GNSS RESET and PWRKILL
908+
// Set all pins to low expect GNSS RESET and PWRKILL
899909
if (i == 5 || i == 7)
900910
gpioExpanderSwitches->digitalWrite(i, HIGH);
901911
else
902912
gpioExpanderSwitches->digitalWrite(i, LOW);
903913

904-
gpioExpanderSwitches->pinMode(i, OUTPUT);
914+
gpioExpanderSwitches->pinMode(i, OUTPUT);
905915
}
906916

907917
online.gpioExpanderSwitches = true;
@@ -938,8 +948,47 @@ void gpioExpanderSelectImu()
938948
gpioExpanderSwitches->digitalWrite(gpioExpanderSwitch_S3, LOW);
939949
}
940950

941-
void gpioExpanderSelectLora()
951+
//Connect ESP32 UART2 to LoRa UART2 for configuration and bootloading/firmware updates
952+
void gpioExpanderSelectLoraConfigure()
942953
{
943954
if (online.gpioExpanderSwitches == true)
944955
gpioExpanderSwitches->digitalWrite(gpioExpanderSwitch_S3, HIGH);
956+
}
957+
958+
// Connect Flex GNSS UART2 to LoRa UART0 for normal TX/RX of corrections and data
959+
void gpioExpanderSelectLoraCommunication()
960+
{
961+
if (online.gpioExpanderSwitches == true)
962+
gpioExpanderSwitches->digitalWrite(gpioExpanderSwitch_S4, HIGH);
963+
}
964+
965+
// Drive GPIO pin high to enable LoRa Radio
966+
void gpioExpanderEnableLora()
967+
{
968+
if (online.gpioExpanderSwitches == true)
969+
gpioExpanderSwitches->digitalWrite(gpioExpanderSwitch_LoraEnable, HIGH);
970+
}
971+
void gpioExpanderDisableLora()
972+
{
973+
if (online.gpioExpanderSwitches == true)
974+
gpioExpanderSwitches->digitalWrite(gpioExpanderSwitch_LoraEnable, LOW);
975+
}
976+
bool gpioExpanderLoraIsOn()
977+
{
978+
if (online.gpioExpanderSwitches == true)
979+
{
980+
if (gpioExpanderSwitches->digitalRead(gpioExpanderSwitch_LoraEnable) == HIGH)
981+
return (true);
982+
}
983+
return(false);
984+
}
985+
void gpioExpanderEnableLoraBoot()
986+
{
987+
if (online.gpioExpanderSwitches == true)
988+
gpioExpanderSwitches->digitalWrite(gpioExpanderSwitch_LoraBoot, HIGH);
989+
}
990+
void gpioExpanderDisableLoraBoot()
991+
{
992+
if (online.gpioExpanderSwitches == true)
993+
gpioExpanderSwitches->digitalWrite(gpioExpanderSwitch_LoraBoot, LOW);
945994
}

0 commit comments

Comments
 (0)