1- #include < Arduino.h>
21#include " target.h"
2+
3+ #include < Arduino.h>
34#include < helpers/ArduinoHelpers.h>
45#include < helpers/sensors/MicroNMEALocationProvider.h>
56
@@ -16,29 +17,26 @@ NanoG2UltraSensorManager sensors = NanoG2UltraSensorManager(nmea);
1617
1718#ifdef DISPLAY_CLASS
1819DISPLAY_CLASS display;
20+ MomentaryButton user_btn (PIN_USER_BTN, 1000 , true );
1921#endif
2022
21- bool radio_init ()
22- {
23+ bool radio_init () {
2324 rtc_clock.begin (Wire);
2425 return radio.std_init (&SPI);
2526}
2627
27- uint32_t radio_get_rng_seed ()
28- {
28+ uint32_t radio_get_rng_seed () {
2929 return radio.random (0x7FFFFFFF );
3030}
3131
32- void radio_set_params (float freq, float bw, uint8_t sf, uint8_t cr)
33- {
32+ void radio_set_params (float freq, float bw, uint8_t sf, uint8_t cr) {
3433 radio.setFrequency (freq);
3534 radio.setSpreadingFactor (sf);
3635 radio.setBandwidth (bw);
3736 radio.setCodingRate (cr);
3837}
3938
40- void radio_set_tx_power (uint8_t dbm)
41- {
39+ void radio_set_tx_power (uint8_t dbm) {
4240 radio.setOutputPower (dbm);
4341}
4442
@@ -64,8 +62,7 @@ void NanoG2UltraSensorManager::stop_gps() {
6462 _location->stop ();
6563}
6664
67- bool NanoG2UltraSensorManager::begin ()
68- {
65+ bool NanoG2UltraSensorManager::begin () {
6966 digitalWrite (PIN_GPS_STANDBY, HIGH); // Wake GPS from standby
7067 Serial1.setPins (PIN_GPS_TX, PIN_GPS_RX);
7168 Serial1.begin (9600 );
@@ -83,29 +80,26 @@ bool NanoG2UltraSensorManager::begin()
8380 return true ;
8481}
8582
86- bool NanoG2UltraSensorManager::querySensors (uint8_t requester_permissions, CayenneLPP &telemetry)
87- {
88- if (requester_permissions & TELEM_PERM_LOCATION)
89- { // does requester have permission?
83+ bool NanoG2UltraSensorManager::querySensors (uint8_t requester_permissions, CayenneLPP &telemetry) {
84+ if (requester_permissions & TELEM_PERM_LOCATION) { // does requester have permission?
9085 telemetry.addGPS (TELEM_CHANNEL_SELF, node_lat, node_lon, node_altitude);
9186 }
9287 return true ;
9388}
9489
95- void NanoG2UltraSensorManager::loop ()
96- {
90+ void NanoG2UltraSensorManager::loop () {
9791 static long next_gps_update = 0 ;
9892
9993 if (!gps_active) {
100- return ; // GPS is not active, skip further processing
94+ return ; // GPS is not active, skip further processing
10195 }
10296
10397 _location->loop ();
10498
10599 if (millis () > next_gps_update) {
106100 if (_location->isValid ()) {
107- node_lat = ((double )_location->getLatitude ())/ 1000000 .;
108- node_lon = ((double )_location->getLongitude ())/ 1000000 .;
101+ node_lat = ((double )_location->getLatitude ()) / 1000000 .;
102+ node_lon = ((double )_location->getLongitude ()) / 1000000 .;
109103 node_altitude = ((double )_location->getAltitude ()) / 1000.0 ;
110104 MESH_DEBUG_PRINTLN (" VALID location: lat %f lon %f" , node_lat, node_lon);
111105 } else {
@@ -116,24 +110,22 @@ void NanoG2UltraSensorManager::loop()
116110 }
117111}
118112
119- int NanoG2UltraSensorManager::getNumSettings () const { return 1 ; } // just one supported: "gps" (power switch)
113+ int NanoG2UltraSensorManager::getNumSettings () const {
114+ return 1 ;
115+ } // just one supported: "gps" (power switch)
120116
121- const char *NanoG2UltraSensorManager::getSettingName (int i) const
122- {
117+ const char *NanoG2UltraSensorManager::getSettingName (int i) const {
123118 return i == 0 ? " gps" : NULL ;
124119}
125120
126- const char *NanoG2UltraSensorManager::getSettingValue (int i) const
127- {
128- if (i == 0 )
129- {
121+ const char *NanoG2UltraSensorManager::getSettingValue (int i) const {
122+ if (i == 0 ) {
130123 return gps_active ? " 1" : " 0" ;
131124 }
132125 return NULL ;
133126}
134127
135- bool NanoG2UltraSensorManager::setSettingValue (const char *name, const char *value)
136- {
128+ bool NanoG2UltraSensorManager::setSettingValue (const char *name, const char *value) {
137129 if (strcmp (name, " gps" ) == 0 ) {
138130 if (strcmp (value, " 0" ) == 0 ) {
139131 stop_gps ();
@@ -145,8 +137,7 @@ bool NanoG2UltraSensorManager::setSettingValue(const char *name, const char *val
145137 return false ; // not supported
146138}
147139
148- mesh::LocalIdentity radio_new_identity ()
149- {
140+ mesh::LocalIdentity radio_new_identity () {
150141 RadioNoiseListener rng (radio);
151142 return mesh::LocalIdentity (&rng); // create new random identity
152143}
0 commit comments