code cleanup
This commit is contained in:
parent
d5cde55774
commit
d924cc440f
2 changed files with 46 additions and 32 deletions
|
@ -10,22 +10,19 @@
|
||||||
#include "display.h"
|
#include "display.h"
|
||||||
|
|
||||||
#if !defined(ARDUINO_T_Beam_V0_7)
|
#if !defined(ARDUINO_T_Beam_V0_7)
|
||||||
#define RXPin 12
|
void setup_axp();
|
||||||
#define TXPin 34
|
AXP20X_Class axp;
|
||||||
#else
|
|
||||||
#define RXPin 15
|
|
||||||
#define TXPin 12
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void setup_lora();
|
HardwareSerial ss(1);
|
||||||
|
TinyGPSPlus gps;
|
||||||
|
void setup_gps();
|
||||||
String create_lat_aprs(RawDegrees lat);
|
String create_lat_aprs(RawDegrees lat);
|
||||||
String create_long_aprs(RawDegrees lng);
|
String create_long_aprs(RawDegrees lng);
|
||||||
|
|
||||||
HardwareSerial ss(1);
|
void setup_lora();
|
||||||
#if !defined(ARDUINO_T_Beam_V0_7)
|
|
||||||
AXP20X_Class axp;
|
|
||||||
#endif
|
|
||||||
TinyGPSPlus gps;
|
|
||||||
int next_update = -1;
|
int next_update = -1;
|
||||||
|
|
||||||
void setup()
|
void setup()
|
||||||
|
@ -38,28 +35,14 @@ void setup()
|
||||||
show_display("OE5BPA", "LoRa APRS Tracker", "by Peter Buchegger", 2000);
|
show_display("OE5BPA", "LoRa APRS Tracker", "by Peter Buchegger", 2000);
|
||||||
|
|
||||||
#if !defined(ARDUINO_T_Beam_V0_7)
|
#if !defined(ARDUINO_T_Beam_V0_7)
|
||||||
Wire.begin(SDA, SCL);
|
setup_axp();
|
||||||
if (!axp.begin(Wire, AXP192_SLAVE_ADDRESS))
|
|
||||||
{
|
|
||||||
Serial.println("LoRa-APRS / Init / AXP192 Begin PASS");
|
|
||||||
} else {
|
|
||||||
Serial.println("LoRa-APRS / Init / AXP192 Begin FAIL");
|
|
||||||
}
|
|
||||||
axp.setPowerOutPut(AXP192_LDO2, AXP202_ON); // LORA
|
|
||||||
axp.setPowerOutPut(AXP192_LDO3, AXP202_ON); // GPS
|
|
||||||
axp.setPowerOutPut(AXP192_DCDC1, AXP202_ON); // OLED
|
|
||||||
axp.setDCDC1Voltage(3300);
|
|
||||||
#endif
|
#endif
|
||||||
|
setup_gps();
|
||||||
ss.begin(9600, SERIAL_8N1, TXPin, RXPin);
|
|
||||||
|
|
||||||
setup_lora();
|
setup_lora();
|
||||||
|
|
||||||
delay(500);
|
delay(500);
|
||||||
}
|
}
|
||||||
|
|
||||||
#define BROADCAST_TIMEOUT 1
|
|
||||||
|
|
||||||
void loop()
|
void loop()
|
||||||
{
|
{
|
||||||
static int update_min = -1;
|
static int update_min = -1;
|
||||||
|
@ -78,10 +61,10 @@ void loop()
|
||||||
&& gps.location.isUpdated())
|
&& gps.location.isUpdated())
|
||||||
{
|
{
|
||||||
APRSMessage msg;
|
APRSMessage msg;
|
||||||
msg.setSource("OE5BPA-9");
|
msg.setSource(CALL);
|
||||||
msg.setDestination("APRS");
|
msg.setDestination("APLT0");
|
||||||
char body_char[50];
|
char body_char[50];
|
||||||
sprintf(body_char, "=%s/%s>LoRa APRS Tracker test", create_lat_aprs(gps.location.rawLat()).c_str(), create_long_aprs(gps.location.rawLng()).c_str());
|
sprintf(body_char, "=%s/%s>%s", create_lat_aprs(gps.location.rawLat()).c_str(), create_long_aprs(gps.location.rawLng()).c_str(), BEACON_MESSAGE);
|
||||||
msg.getAPRSBody()->setData(String(body_char));
|
msg.getAPRSBody()->setData(String(body_char));
|
||||||
String data = msg.encode();
|
String data = msg.encode();
|
||||||
Serial.println(data);
|
Serial.println(data);
|
||||||
|
@ -94,9 +77,9 @@ void loop()
|
||||||
// APRS Data:
|
// APRS Data:
|
||||||
LoRa.write((const uint8_t *)data.c_str(), data.length());
|
LoRa.write((const uint8_t *)data.c_str(), data.length());
|
||||||
LoRa.endPacket();
|
LoRa.endPacket();
|
||||||
update_min = (gps.time.minute() + BROADCAST_TIMEOUT) % 60;
|
update_min = (gps.time.minute() + BEACON_TIMEOUT) % 60;
|
||||||
}
|
}
|
||||||
show_display("OE5BPA",
|
show_display(CALL,
|
||||||
String("Time: ") + gps.time.hour() + String(":") + gps.time.minute() + String(":") + gps.time.second(),
|
String("Time: ") + gps.time.hour() + String(":") + gps.time.minute() + String(":") + gps.time.second(),
|
||||||
String("Date: ") + gps.date.day() + String(".") + gps.date.month() + String(".") + gps.date.year(),
|
String("Date: ") + gps.date.day() + String(".") + gps.date.month() + String(".") + gps.date.year(),
|
||||||
String("Sat's: ") + gps.satellites.value() + String(" HDOP: ") + gps.hdop.hdop(),
|
String("Sat's: ") + gps.satellites.value() + String(" HDOP: ") + gps.hdop.hdop(),
|
||||||
|
@ -111,6 +94,23 @@ void loop()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if !defined(ARDUINO_T_Beam_V0_7)
|
||||||
|
void setup_axp()
|
||||||
|
{
|
||||||
|
Wire.begin(SDA, SCL);
|
||||||
|
if (!axp.begin(Wire, AXP192_SLAVE_ADDRESS))
|
||||||
|
{
|
||||||
|
Serial.println("LoRa-APRS / Init / AXP192 Begin PASS");
|
||||||
|
} else {
|
||||||
|
Serial.println("LoRa-APRS / Init / AXP192 Begin FAIL");
|
||||||
|
}
|
||||||
|
axp.setPowerOutPut(AXP192_LDO2, AXP202_ON); // LORA
|
||||||
|
axp.setPowerOutPut(AXP192_LDO3, AXP202_ON); // GPS
|
||||||
|
axp.setPowerOutPut(AXP192_DCDC1, AXP202_ON); // OLED
|
||||||
|
axp.setDCDC1Voltage(3300);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void setup_lora()
|
void setup_lora()
|
||||||
{
|
{
|
||||||
Serial.println("[INFO] Set SPI pins!");
|
Serial.println("[INFO] Set SPI pins!");
|
||||||
|
@ -136,6 +136,18 @@ void setup_lora()
|
||||||
show_display("INFO", "LoRa init done!", 2000);
|
show_display("INFO", "LoRa init done!", 2000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setup_gps()
|
||||||
|
{
|
||||||
|
#if !defined(ARDUINO_T_Beam_V0_7)
|
||||||
|
#define GPS_RX 12
|
||||||
|
#define GPS_TX 34
|
||||||
|
#else
|
||||||
|
#define GPS_RX 15
|
||||||
|
#define GPS_TX 12
|
||||||
|
#endif
|
||||||
|
ss.begin(9600, SERIAL_8N1, GPS_TX, GPS_RX);
|
||||||
|
}
|
||||||
|
|
||||||
String create_lat_aprs(RawDegrees lat)
|
String create_lat_aprs(RawDegrees lat)
|
||||||
{
|
{
|
||||||
char str[20];
|
char str[20];
|
||||||
|
|
|
@ -3,5 +3,7 @@
|
||||||
#define SETTINGS_H_
|
#define SETTINGS_H_
|
||||||
|
|
||||||
#define CALL "OE5BPA-7"
|
#define CALL "OE5BPA-7"
|
||||||
|
#define BEACON_MESSAGE "LoRa APRS Tracker test"
|
||||||
|
#define BEACON_TIMEOUT 1
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue