Skip to content

Commit

Permalink
Merge branch 'release/v1.0.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
matteocarnelos committed Feb 1, 2022
2 parents 1788809 + cd87644 commit 9ede9a7
Show file tree
Hide file tree
Showing 5 changed files with 166 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -220,3 +220,7 @@ $RECYCLE.BIN/
*.lnk

# End of https://www.toptal.com/developers/gitignore/api/c++,macos,linux,windows,clion+all,platformio,visualstudiocode

### VisualStudioCode Patch ###
# Ignore .vscode folder
.vscode
39 changes: 39 additions & 0 deletions include/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@

This directory is intended for project header files.

A header file is a file containing C declarations and macro definitions
to be shared between several project source files. You request the use of a
header file in your project source file (C, C++, etc) located in `src` folder
by including it, with the C preprocessing directive `#include'.

```src/main.c

#include "header.h"

int main (void)
{
...
}
```

Including a header file produces the same results as copying the header file
into each source file that needs it. Such copying would be time-consuming
and error-prone. With a header file, the related declarations appear
in only one place. If they need to be changed, they can be changed in one
place, and programs that include the header file will automatically use the
new version when next recompiled. The header file eliminates the labor of
finding and changing all the copies as well as the risk that a failure to
find one copy will result in inconsistencies within a program.

In C, the usual convention is to give header files names that end with `.h'.
It is most portable to use only letters, digits, dashes, and underscores in
header file names, and at most one dot.

Read more about using header files in official GCC documentation:

* Include Syntax
* Include Operation
* Once-Only Headers
* Computed Includes

https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html
25 changes: 25 additions & 0 deletions platformio.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
; PlatformIO Project Configuration File
;
; Build options: build flags, source filter
; Upload options: custom upload port, speed and extra flags
; Library options: dependencies, extra library storages
; Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html

[env:LilyGo TTGO T-Beam]
platform = espressif32
board = ttgo-t-beam
framework = arduino
lib_deps =
bblanchon/ArduinoJson@^6.18.2
lewisxhe/AXP202X_Library@^1.1.3
sparkfun/SparkFun u-blox GNSS Arduino Library@^2.0.9
metisvela/SailTrack Module@^1.0.0
monitor_speed = 115200

[env:LilyGo TTGO T-Beam OTA]
extends = env:LilyGo TTGO T-Beam
upload_protocol = espota
upload_port = sailtrack-radio.local
87 changes: 87 additions & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
#include <Arduino.h>
#include <ArduinoJson.h>
#include <axp20x.h>
#include "SparkFun_u-blox_GNSS_Arduino_Library.h"
#include "SailtrackModule.h"

#define I2C_SDA 21
#define I2C_SCL 22

#define GPS_RX_PIN 34
#define GPS_TX_PIN 12
#define GPS_BAND_RATE 9600

SFE_UBLOX_GNSS GPS;
AXP20X_Class PMU;

class ModuleCallbacks: public SailtrackModuleCallbacks {
void onWifiConnectionBegin() {
// TODO: Notify user
}

void onWifiConnectionResult(wl_status_t status) {
// TODO: Notify user
}

DynamicJsonDocument getStatus() {
DynamicJsonDocument payload(300);
JsonObject battery = payload.createNestedObject("battery");
JsonObject cpu = payload.createNestedObject("cpu");
battery["voltage"] = PMU.getBattVoltage() / 1000;
battery["charging"] = PMU.isChargeing();
cpu["temperature"] = temperatureRead();
return payload;
}
};

void onGPSData(UBX_NAV_PVT_data_t ubxDataStruct) {
DynamicJsonDocument payload(300);
payload["latitude"] = ubxDataStruct.lat;
payload["longitude"] = ubxDataStruct.lon;
payload["speed"] = ubxDataStruct.gSpeed;
payload["heading"] = ubxDataStruct.headMot;
payload["vacc"] = ubxDataStruct.vAcc;
payload["hacc"] = ubxDataStruct.hAcc;
payload["sacc"] = ubxDataStruct.sAcc;
payload["headacc"] = ubxDataStruct.headAcc;
STModule.publish("sensor/gps0", "gps0", payload);
}

void beginPMU() {
Wire.begin(I2C_SDA, I2C_SCL);
PMU.begin(Wire, AXP192_SLAVE_ADDRESS);
PMU.setPowerOutPut(AXP192_DCDC2, AXP202_OFF);
PMU.setPowerOutPut(AXP192_LDO2, AXP202_OFF);
PMU.setPowerOutPut(AXP192_LDO3, AXP202_OFF);
PMU.setPowerOutPut(AXP192_EXTEN, AXP202_OFF);
}

void beginGPS() {
PMU.setLDO3Voltage(3300);
PMU.setPowerOutPut(AXP192_LDO3, AXP202_ON);
Serial1.begin(GPS_BAND_RATE, SERIAL_8N1, GPS_RX_PIN, GPS_TX_PIN);
GPS.begin(Serial1);
GPS.setUART1Output(COM_TYPE_UBX);
GPS.setMeasurementRate(200);
GPS.setAutoPVTcallback(&onGPSData);
}

void beginLora() {
PMU.setLDO2Voltage(3300);
PMU.setPowerOutPut(AXP192_LDO2, AXP202_ON);
// TODO: Init LoRa
}

void setup() {
beginPMU();
STModule.begin("radio", "sailtrack-radio", IPAddress(192, 168, 42, 101));
STModule.setCallbacks(new ModuleCallbacks());
beginGPS();
//beginLora();
}

void loop() {
GPS.checkUblox();
GPS.checkCallbacks();
delay(50);
}
11 changes: 11 additions & 0 deletions test/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@

This directory is intended for PlatformIO Unit Testing and project tests.

Unit Testing is a software testing method by which individual units of
source code, sets of one or more MCU program modules together with associated
control data, usage procedures, and operating procedures, are tested to
determine whether they are fit for use. Unit testing finds problems early
in the development cycle.

More information about PlatformIO Unit Testing:
- https://docs.platformio.org/page/plus/unit-testing.html

0 comments on commit 9ede9a7

Please sign in to comment.