Cleaned up Configuration and debug messages

pull/6/head
Max-Plastix 2021-12-19 11:07:00 -08:00
rodzic 611c4ed2db
commit bed4b1ca27
3 zmienionych plików z 56 dodań i 58 usunięć

Wyświetl plik

@ -1,7 +1,9 @@
/*
TTGO T-Beam Mapper for Helium
Copyright (C) 2021 by @Max_Plastix
Forked from:
TTGO T-BEAM Tracker for The Things Network
Copyright (C) 2018 by Xose Pérez <xose dot perez at gmail dot com>
This code requires LMIC library by Matthijs Kooijman
@ -19,63 +21,57 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <Arduino.h>
#include <lmic.h>
// -----------------------------------------------------------------------------
// CONFIGURATION
// Stuff you might reasonably want to change is here:
// -----------------------------------------------------------------------------
// Select which T-Beam board is being used. Only uncomment one.
//#define T_BEAM_V07 // AKA Rev0 (first board released)
#define T_BEAM_V10 // AKA Rev1 (second board released), also for "v1.1"
#define MIN_DIST 68.0 // Minimum distance in meters from the last sent location before we can send again. A hex is about 340m.
#define STATIONARY_TX_INTERVAL ( 2 * 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, start sending even slower
#define REST_TX_INTERVAL (10 * 60) // Slow resting ping frequency in seconds
#define BATTERY_LOW_VOLTAGE 3.4 // Below this voltage, power off until USB power allows charging
#define LORAWAN_PORT 2 // FPort for Uplink messages -- must match Helium Console Decoder script!
#define LORAWAN_CONFIRMED_EVERY 0 // Send confirmed message for ACK every N messages (0 means never, 1 means always)
#define LORAWAN_SF DR_SF7 // Spreading factor (recommended DR_SF7 for network map purposes, DR_SF10 is slower/more-reach)
// Uncomment to enable discarding network settings by long pressing second button
#define PREFS_DISCARD
// -----------------------------------------------------------------------------
// Version
// -----------------------------------------------------------------------------
#define APP_NAME "Helium TTGO"
#define APP_VERSION "1.5.1 MaxP"
#define APP_VERSION "1.5.2 MaxP"
// -----------------------------------------------------------------------------
// Configuration
// Less common Configuration iteams
// -----------------------------------------------------------------------------
// Select which T-Beam board is being used. Only uncomment one.
//#define T_BEAM_V07 // AKA Rev0 (first board released)
#define T_BEAM_V10 // AKA Rev1 (second board released)
#define ALWAYS_SHOW_LOGO // It's a great logo. Display it with pride.
#define LOGO_DELAY 2000 // Time to show logo on first boot (ms)
// Select the payload format. Change on TTN as well. Only uncomment one.
// #define PAYLOAD_USE_FULL
// #define PAYLOAD_USE_CAYENNE
#define PAYLOAD_USE_MAPPER
#define DEBUG_PORT Serial // Serial debug port
#define SERIAL_BAUD 115200 // Serial debug baud rate (note that bootloader is fixed at 115200)
// If using a single-channel gateway, uncomment this next option and set to your gateway's channel
//#define SINGLE_CHANNEL_GATEWAY 0
// Uncomment if you always want to see the boot logo at boot time
#define ALWAYS_SHOW_LOGO
// Uncomment to enable discarding network settings by long pressing second button
#define PREFS_DISCARD
#define LORAWAN_ADR 0 // Do not enable ADR
// If you are having difficulty sending messages to TTN after the first successful send,
// uncomment the next option and experiment with values (~ 1 - 5)
//#define CLOCK_ERROR 5
#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 ( 2 * 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, start sending even slower
#define REST_TX_INTERVAL (10 * 60) // Slow resting packet frequency in seconds
#define BATTERY_LOW_VOLTAGE 3.4 // Below this voltage, power off until charging
#define LORAWAN_PORT 2 // Port the messages will be sent to -- must match console Decoder script!
#define LORAWAN_CONFIRMED_EVERY 0 // Send confirmed message for ACK every N messages (0 means never, 1 means always)
#define LORAWAN_SF DR_SF7 // Spreading factor (recommended DR_SF7 for ttn network map purposes, DR_SF10 works for slow moving trackers)
#define LORAWAN_ADR 0 // Enable ADR
#define DEBUG_PORT Serial // Serial debug port
#define SERIAL_BAUD 115200 // Serial debug baud rate (should match bootloader = 115200)
// If using a single-channel gateway, uncomment this next option and set to your gateway's channel
//#define SINGLE_CHANNEL_GATEWAY 0
// -----------------------------------------------------------------------------
// DEBUG
@ -125,7 +121,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
// -----------------------------------------------------------------------------
#define GPS_SERIAL_NUM 1 // SerialX
#define GPS_BAUDRATE 115200
#define GPS_BAUDRATE 115200 // Make haste! NMEA is big.. go fast
#define USE_GPS 1
#if defined(T_BEAM_V07)

Wyświetl plik

@ -37,9 +37,12 @@
*/
#include "configuration.h"
#include <Arduino.h>
#include <Wire.h>
#include <axp20x.h>
#include <lmic.h>
#include "gps.h"
// Defined in ttn.ino
@ -159,25 +162,23 @@ bool trySend()
screen_print(buffer);
#endif
char because_justsend = ' ';
char because_distance = ' ';
char because_stationary = ' ';
char because = '?';
if (justSendNow)
{
justSendNow = false;
Serial.println("** JUST_SEND_NOW");
because_justsend = '>';
because = '>';
}
else if (dist_moved > min_dist_moved)
{
Serial.println("** MOVING");
last_moved_millis = now_millis;
because_distance = '!';
because = 'D';
}
else if (now_millis - last_send_millis > tx_interval_ms)
{
Serial.println("** STATIONARY_TX");
because_stationary = '!';
because = 'T';
}
else
{
@ -188,10 +189,10 @@ bool trySend()
// The first distance-moved is crazy, since has no origin.. don't put it on screen.
if (dist_moved < 1000000) {
snprintf(buffer, sizeof(buffer), "%c%lus%c %.0fm%c",
because_justsend,
(now_millis - last_send_millis) / 1000, because_stationary,
dist_moved, because_distance);
snprintf(buffer, sizeof(buffer), "%c %4lus %4.0fm ",
because,
(now_millis - last_send_millis) / 1000,
dist_moved);
screen_print(buffer);
}
@ -292,7 +293,6 @@ void lora_msg_callback(uint8_t message)
if (EV_TXCOMPLETE == message && packetQueued) {
// screen_print("sent.\n");
packetQueued = false;
// packetSent = true;
axp.setChgLEDMode(AXP20X_LED_OFF);
}
@ -358,32 +358,33 @@ void scanI2Cdevice(void)
Wire.beginTransmission(addr);
err = Wire.endTransmission();
if (err == 0) {
#if 0
Serial.print("I2C device found at address 0x");
if (addr < 16)
Serial.print("0");
Serial.print(addr, HEX);
Serial.println(" !");
#endif
nDevices++;
if (addr == SSD1306_ADDRESS) {
ssd1306_found = true;
Serial.println("ssd1306 display found");
Serial.println("SSD1306 OLED display");
}
if (addr == AXP192_SLAVE_ADDRESS) {
axp192_found = true;
Serial.println("axp192 PMU found");
Serial.println("AXP192 PMU");
}
} else if (err == 4) {
Serial.print("Unknow error at address 0x");
Serial.print("Unknow i2c device at 0x");
if (addr < 16)
Serial.print("0");
Serial.println(addr, HEX);
}
}
if (nDevices == 0)
Serial.println("No I2C devices found\n");
else
Serial.println("done\n");
Serial.println("No I2C devices found!\n");
/* else Serial.println("done\n"); */
}
/**
@ -441,6 +442,7 @@ void axp192Init() {
axp.adc1Enable(AXP202_BATT_CUR_ADC1, 1);
axp.enableIRQ(AXP202_VBUS_REMOVED_IRQ | AXP202_VBUS_CONNECT_IRQ | AXP202_BATT_REMOVED_IRQ | AXP202_BATT_CONNECT_IRQ, 1);
axp.enableIRQ(0xFFFFFFFFFF, 1); // See this nerd badge? Give me all the interrupts you have.
axp.clearIRQ();
} else {
Serial.println("AXP192 not found");

Wyświetl plik

@ -24,8 +24,8 @@ build_flags = -Wall
-D LMIC_DEBUG_LEVEL=0
-D ARDUINO_TTGO_LoRa32_V1
monitor_speed = 115200
monitor_port = COM18
upload_port = COM18
monitor_port = COM19
upload_port = COM19
lib_deps =
mcci-catena/MCCI LoRaWAN LMIC library @ ^4.0.0
thingpulse/ESP8266 and ESP32 OLED driver for SSD1306 displays @ ^4.2.1