Fixed an off-by-1000 bug in interval (ms vs seconds)

pull/2/head
Max-Plastix 2021-12-05 22:23:04 -08:00
rodzic 012cd0b524
commit c89e4be748
4 zmienionych plików z 16 dodań i 14 usunięć

Wyświetl plik

@ -26,7 +26,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <Arduino.h>
#include <lmic.h>
void ttn_register(void (*callback)(uint8_t message));
// -----------------------------------------------------------------------------
// Version
@ -64,8 +63,8 @@ void ttn_register(void (*callback)(uint8_t message));
#define LOGO_DELAY 2000 // Time to show logo on first boot (ms)
#define MIN_DIST 50.0 // Minimum distance in meters from the last sent location before we can send again. A hex is about 340m.
#define STATIONARY_TX_INTERVAL 60 // If stationary, the LoRa frame will still be sent once every N seconds
#define REST_WAIT (30 * 60) // If we haven't moved in this many seconds, send slower
#define STATIONARY_TX_INTERVAL ( 1 * 60) // If no minimum movement, the LoRa frame will still be sent once every N seconds
#define REST_WAIT (30 * 60) // If we still haven't moved in this many seconds, send even slower
#define REST_TX_INTERVAL ( 5 * 60) // Slow resting packet frequency in seconds
//#define BATTERY_HI_VOLTAGE 4.0 // Above this voltage, send faster updates even while stationary

Wyświetl plik

@ -82,12 +82,12 @@ void buildPacket(uint8_t txBuffer[11]) {
sats = _gps.satellites.value();
// hdopGps = _gps.hdop.value() / 10;
sprintf(t, "Lat: %f", _gps.location.lat());
Serial.println(t);
sprintf(t, "Lng: %f", _gps.location.lng());
Serial.println(t);
sprintf(t, "Alt: %f", _gps.altitude.meters());
Serial.println(t);
sprintf(t, "Lat: %f, ", _gps.location.lat());
Serial.print(t);
sprintf(t, "Lng: %f, ", _gps.location.lng());
Serial.print(t);
sprintf(t, "Alt: %f, ", _gps.altitude.meters());
Serial.print(t);
// sprintf(t, "Hdop: %d", hdopGps);
// Serial.println(t);
sprintf(t, "Sats: %d", sats);

Wyświetl plik

@ -38,11 +38,13 @@
#include <Arduino.h>
#include "configuration.h"
#include "rom/rtc.h"
#include <TinyGPS++.h>
#include <Wire.h>
#include <axp20x.h>
// Defined in ttn.ino
void ttn_register(void (*callback)(uint8_t message));
bool justSendNow = true; // Start by sending
unsigned long int last_send_millis = 0;
unsigned long int last_moved_millis = 0;
@ -492,16 +494,17 @@ void update_activity()
/*
if (bat_volts > BATTERY_HI_VOLTAGE)
tx_interval_ms = STATIONARY_TX_INTERVAL * 1000;
else */
else
*/
unsigned long int now_interval;
if (millis() - last_moved_millis > REST_WAIT)
if (millis() - last_moved_millis > REST_WAIT * 1000)
now_interval = REST_TX_INTERVAL * 1000;
else
now_interval = STATIONARY_TX_INTERVAL * 1000;
if (now_interval != tx_interval_ms) {
tx_interval_ms = now_interval;
snprintf(buffer, sizeof(buffer), "Interval: %lu\n", now_interval / 1000);
screen_print(buffer);
// snprintf(buffer, sizeof(buffer), "Interval: %lus\n", now_interval / 1000);
// screen_print(buffer);
}
}