2020-02-01 08:30:53 -08:00
|
|
|
/*
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
https://github.com/matthijskooijman/arduino-lmic
|
|
|
|
|
|
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
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>
|
2022-06-05 09:50:06 -05:00
|
|
|
|
2022-04-27 11:05:08 +02:00
|
|
|
#ifdef RV3028_RTC
|
|
|
|
|
#include "Melopero_RV3028.h"
|
|
|
|
|
#endif
|
2022-04-28 08:18:03 +02:00
|
|
|
#ifdef PCF8563_RTC
|
|
|
|
|
#include "pcf8563.h"
|
|
|
|
|
#endif
|
2022-04-27 11:05:08 +02:00
|
|
|
|
2020-02-01 08:30:53 -08:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
// Version
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
|
2020-02-18 16:18:01 -08:00
|
|
|
// If app version is not specified we assume we are not being invoked by the build script
|
2020-02-14 14:00:08 -08:00
|
|
|
#ifndef APP_VERSION
|
2020-12-10 11:28:15 +08:00
|
|
|
#error APP_VERSION must be set by the build environment
|
|
|
|
|
#endif
|
|
|
|
|
|
2022-03-20 11:53:37 +01:00
|
|
|
// FIXME: This is still needed by the Bluetooth Stack and needs to be replaced by something better. Remnant of the old versioning system.
|
2020-12-10 11:28:15 +08:00
|
|
|
#ifndef HW_VERSION
|
2022-03-20 11:53:37 +01:00
|
|
|
#define HW_VERSION "1.0"
|
2020-02-14 14:00:08 -08:00
|
|
|
#endif
|
2020-02-18 16:18:01 -08:00
|
|
|
|
2020-02-01 08:30:53 -08:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
// Configuration
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
|
2020-02-03 20:18:36 -08:00
|
|
|
// If we are using the JTAG port for debugging, some pins must be left free for that (and things like GPS have to be disabled)
|
2020-02-05 22:13:27 -08:00
|
|
|
// we don't support jtag on the ttgo - access to gpio 12 is a PITA
|
2020-03-03 08:23:58 -08:00
|
|
|
#define REQUIRE_RADIO true // If true, we will fail to start if the radio is not found
|
2020-02-01 08:30:53 -08:00
|
|
|
|
2020-05-12 17:57:51 -07:00
|
|
|
/// Convert a preprocessor name into a quoted string
|
2020-03-03 08:23:58 -08:00
|
|
|
#define xstr(s) str(s)
|
|
|
|
|
#define str(s) #s
|
2020-02-01 08:30:53 -08:00
|
|
|
|
2020-05-12 17:57:51 -07:00
|
|
|
/// Convert a preprocessor name into a quoted string and if that string is empty use "unset"
|
|
|
|
|
#define optstr(s) (xstr(s)[0] ? xstr(s) : "unset")
|
|
|
|
|
|
2020-09-04 15:03:22 -07:00
|
|
|
#ifdef PORTDUINO
|
|
|
|
|
|
|
|
|
|
#define NO_ESP32 // Don't use ESP32 libs (mainly bluetooth)
|
|
|
|
|
|
2020-09-04 17:23:17 -07:00
|
|
|
#elif defined(NRF52_SERIES) // All of the NRF52 targets are configured using variant.h, so this section shouldn't need to be
|
2020-09-06 16:09:07 -07:00
|
|
|
// board specific
|
2020-02-01 08:30:53 -08:00
|
|
|
|
2020-05-10 12:33:17 -07:00
|
|
|
//
|
|
|
|
|
// Standard definitions for NRF52 targets
|
|
|
|
|
//
|
2020-02-01 08:30:53 -08:00
|
|
|
|
2020-05-10 12:33:17 -07:00
|
|
|
#define NO_ESP32 // Don't use ESP32 libs (mainly bluetooth)
|
2020-03-19 20:15:51 -07:00
|
|
|
|
2020-05-10 12:33:17 -07:00
|
|
|
// We bind to the GPS using variant.h instead for this platform (Serial1)
|
2020-04-14 20:22:27 -07:00
|
|
|
|
2020-05-10 12:33:17 -07:00
|
|
|
#define LED_PIN PIN_LED1 // LED1 on nrf52840-DK
|
2020-07-09 21:27:34 -07:00
|
|
|
|
|
|
|
|
// If the variant filed defines as standard button
|
|
|
|
|
#ifdef PIN_BUTTON1
|
2020-05-10 12:33:17 -07:00
|
|
|
#define BUTTON_PIN PIN_BUTTON1
|
2020-07-10 14:37:01 -07:00
|
|
|
#endif
|
2020-02-01 08:30:53 -08:00
|
|
|
|
2020-09-28 13:10:27 -07:00
|
|
|
#ifdef PIN_BUTTON2
|
|
|
|
|
#define BUTTON_PIN_ALT PIN_BUTTON2
|
|
|
|
|
#endif
|
|
|
|
|
|
2022-01-07 09:57:29 +03:00
|
|
|
#ifdef PIN_BUTTON_TOUCH
|
|
|
|
|
#define BUTTON_PIN_TOUCH PIN_BUTTON_TOUCH
|
|
|
|
|
#endif
|
|
|
|
|
|
2020-05-10 12:33:17 -07:00
|
|
|
#else
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// Standard definitions for ESP32 targets
|
|
|
|
|
//
|
2020-02-01 08:30:53 -08:00
|
|
|
|
2020-09-18 10:48:39 -07:00
|
|
|
#define HAS_WIFI
|
|
|
|
|
|
2020-05-10 12:33:17 -07:00
|
|
|
#define GPS_SERIAL_NUM 1
|
2020-03-03 08:23:58 -08:00
|
|
|
#define GPS_RX_PIN 34
|
2020-02-03 20:18:36 -08:00
|
|
|
#ifdef USE_JTAG
|
2020-03-03 08:23:58 -08:00
|
|
|
#define GPS_TX_PIN -1
|
2020-02-03 20:18:36 -08:00
|
|
|
#else
|
2020-03-03 08:23:58 -08:00
|
|
|
#define GPS_TX_PIN 12
|
2020-02-01 08:30:53 -08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
// LoRa SPI
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
|
2020-07-10 14:37:01 -07:00
|
|
|
// NRF52 boards will define this in variant.h
|
|
|
|
|
#ifndef RF95_SCK
|
2020-07-10 11:02:29 -07:00
|
|
|
#define RF95_SCK 5
|
|
|
|
|
#define RF95_MISO 19
|
|
|
|
|
#define RF95_MOSI 27
|
|
|
|
|
#define RF95_NSS 18
|
2020-07-10 14:37:01 -07:00
|
|
|
#endif
|
2020-02-01 14:23:21 -08:00
|
|
|
|
2020-05-10 12:33:17 -07:00
|
|
|
#endif
|
2020-09-04 17:23:17 -07:00
|
|
|
|
2022-05-18 18:29:26 +02:00
|
|
|
#ifndef TTGO_T_ECHO
|
|
|
|
|
#define GPS_UBLOX
|
|
|
|
|
#endif
|
|
|
|
|
|
2020-09-04 17:23:17 -07:00
|
|
|
//
|
|
|
|
|
// Standard definitions for !ESP32 targets
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
#ifdef NO_ESP32
|
|
|
|
|
// Nop definition for these attributes - not used on NRF52
|
|
|
|
|
#define EXT_RAM_ATTR
|
|
|
|
|
#define IRAM_ATTR
|
|
|
|
|
#define RTC_DATA_ATTR
|
|
|
|
|
#endif
|
2020-05-10 12:33:17 -07:00
|
|
|
|
2022-04-13 19:23:35 -07:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
// Feature toggles
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
|
2022-04-14 15:51:48 -07:00
|
|
|
// Disable use of the NTP library and related features
|
2022-04-13 19:23:35 -07:00
|
|
|
//#define DISABLE_NTP
|
|
|
|
|
|
2022-04-14 15:51:48 -07:00
|
|
|
// Disable the welcome screen and allow
|
2022-06-03 21:51:47 -07:00
|
|
|
#define DISABLE_WELCOME_UNSET
|
2022-04-13 21:59:25 -07:00
|
|
|
|
2020-05-10 12:33:17 -07:00
|
|
|
// -----------------------------------------------------------------------------
|
2022-03-28 16:55:58 +02:00
|
|
|
// OLED & Input
|
2020-05-10 12:33:17 -07:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
#define SSD1306_ADDRESS 0x3C
|
2020-10-23 18:00:43 +08:00
|
|
|
#define ST7567_ADDRESS 0x3F
|
2020-05-10 12:33:17 -07:00
|
|
|
|
2020-06-14 10:28:23 +02:00
|
|
|
// The SH1106 controller is almost, but not quite, the same as SSD1306
|
|
|
|
|
// Define this if you know you have that controller or your "SSD1306" misbehaves.
|
|
|
|
|
//#define USE_SH1106
|
|
|
|
|
|
2020-05-10 12:33:17 -07:00
|
|
|
// Flip the screen upside down by default as it makes more sense on T-BEAM
|
|
|
|
|
// devices. Comment this out to not rotate screen 180 degrees.
|
2020-10-24 08:16:15 +08:00
|
|
|
#define SCREEN_FLIP_VERTICALLY
|
2020-05-10 12:33:17 -07:00
|
|
|
|
2020-10-24 08:16:15 +08:00
|
|
|
// Define if screen should be mirrored left to right
|
|
|
|
|
// #define SCREEN_MIRROR
|
2020-05-10 12:33:17 -07:00
|
|
|
|
2022-03-28 16:55:58 +02:00
|
|
|
// The m5stack I2C Keyboard (also RAK14004)
|
|
|
|
|
#define CARDKB_ADDR 0x5F
|
|
|
|
|
|
|
|
|
|
// The older M5 Faces I2C Keyboard
|
|
|
|
|
#define FACESKB_ADDR 0x88
|
|
|
|
|
|
2022-06-05 09:50:06 -05:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
// SENSOR
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
#define BME_ADDR 0x76
|
|
|
|
|
#define BME_ADDR_ALTERNATE 0x77
|
|
|
|
|
#define MCP9808_ADDR 0x18
|
2022-06-11 16:44:56 -05:00
|
|
|
#define INA_ADDR 0x40
|
|
|
|
|
#define INA_ADDR_ALTERNATE 0x41
|
2022-06-05 09:50:06 -05:00
|
|
|
|
2020-05-10 12:33:17 -07:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
// GPS
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
#define GPS_BAUDRATE 9600
|
|
|
|
|
|
2022-04-02 12:52:50 +02:00
|
|
|
#ifndef GPS_THREAD_INTERVAL
|
|
|
|
|
#define GPS_THREAD_INTERVAL 100
|
|
|
|
|
#endif
|
|
|
|
|
|
2020-03-28 15:31:22 -07:00
|
|
|
#if defined(TBEAM_V10)
|
2020-02-24 11:21:34 -08:00
|
|
|
// This string must exactly match the case used in release file names or the android updater won't work
|
2021-03-14 10:48:20 +08:00
|
|
|
#define HW_VENDOR HardwareModel_TBEAM
|
2020-02-01 14:23:21 -08:00
|
|
|
|
2020-03-28 15:31:22 -07:00
|
|
|
#elif defined(TBEAM_V07)
|
|
|
|
|
// This string must exactly match the case used in release file names or the android updater won't work
|
2021-03-14 10:48:20 +08:00
|
|
|
#define HW_VENDOR HardwareModel_TBEAM0p7
|
2020-03-28 15:31:22 -07:00
|
|
|
|
2021-09-19 16:05:21 +03:00
|
|
|
#elif defined(DIY_V1)
|
|
|
|
|
// This string must exactly match the case used in release file names or the android updater won't work
|
|
|
|
|
#define HW_VENDOR HardwareModel_DIY_V1
|
|
|
|
|
|
2022-02-02 12:41:07 -06:00
|
|
|
#elif defined(RAK_11200)
|
|
|
|
|
// This string must exactly match the case used in release file names or the android updater won't work
|
|
|
|
|
#define HW_VENDOR HardwareModel_RAK11200
|
|
|
|
|
|
2020-03-27 13:20:52 -07:00
|
|
|
#elif defined(ARDUINO_HELTEC_WIFI_LORA_32_V2)
|
2020-02-03 20:18:36 -08:00
|
|
|
|
2021-05-11 09:44:41 +08:00
|
|
|
#ifdef HELTEC_V2_0
|
|
|
|
|
// This string must exactly match the case used in release file names or the android updater won't work
|
|
|
|
|
#define HW_VENDOR HardwareModel_HELTEC_V2_0
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifdef HELTEC_V2_1
|
|
|
|
|
// This string must exactly match the case used in release file names or the android updater won't work
|
|
|
|
|
#define HW_VENDOR HardwareModel_HELTEC_V2_1
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
2021-12-30 22:16:46 +01:00
|
|
|
#elif defined(ARDUINO_HELTEC_WIFI_LORA_32)
|
|
|
|
|
|
|
|
|
|
#define HW_VENDOR HardwareModel_HELTEC_V1
|
|
|
|
|
|
2020-07-14 16:16:49 +02:00
|
|
|
#elif defined(TLORA_V1)
|
2020-03-27 16:55:19 -07:00
|
|
|
|
2022-01-18 18:35:42 -06:00
|
|
|
#define HW_VENDOR HardwareModel_TLORA_V1
|
2020-07-17 12:06:57 -07:00
|
|
|
|
2020-07-14 16:16:49 +02:00
|
|
|
#elif defined(TLORA_V2)
|
2020-03-27 16:55:19 -07:00
|
|
|
// This string must exactly match the case used in release file names or the android updater won't work
|
2021-03-14 10:48:20 +08:00
|
|
|
#define HW_VENDOR HardwareModel_TLORA_V2
|
2020-03-27 16:55:19 -07:00
|
|
|
|
2021-02-02 17:34:50 -08:00
|
|
|
#elif defined(TLORA_V1_3)
|
|
|
|
|
// This string must exactly match the case used in release file names or the android updater won't work
|
2021-03-20 20:47:48 -07:00
|
|
|
#define HW_VENDOR HardwareModel_TLORA_V1_1p3
|
2021-02-02 17:34:50 -08:00
|
|
|
|
2020-07-14 16:16:49 +02:00
|
|
|
#elif defined(TLORA_V2_1_16)
|
|
|
|
|
// This string must exactly match the case used in release file names or the android updater won't work
|
2021-03-19 23:40:41 +08:00
|
|
|
#define HW_VENDOR HardwareModel_TLORA_V2_1_1p6
|
2020-07-14 16:16:49 +02:00
|
|
|
|
2020-12-29 18:08:11 +03:00
|
|
|
#elif defined(GENIEBLOCKS)
|
|
|
|
|
// This string must exactly match the case used in release file names or the android updater won't work
|
2021-03-14 10:48:20 +08:00
|
|
|
#define HW_VENDOR HardwareModel_GENIEBLOCKS
|
2020-12-29 18:08:11 +03:00
|
|
|
|
2022-02-01 15:08:03 +01:00
|
|
|
#elif defined(PRIVATE_HW)
|
|
|
|
|
// This string must exactly match the case used in release file names or the android updater won't work
|
|
|
|
|
#define HW_VENDOR HardwareModel_PRIVATE_HW
|
|
|
|
|
|
2020-05-10 12:33:17 -07:00
|
|
|
#endif
|
2020-04-27 07:39:50 -07:00
|
|
|
|
2020-05-10 12:33:17 -07:00
|
|
|
#ifdef ARDUINO_NRF52840_PCA10056
|
2020-04-27 07:39:50 -07:00
|
|
|
|
2020-03-31 21:56:35 -07:00
|
|
|
// This string must exactly match the case used in release file names or the android updater won't work
|
2021-03-14 10:48:20 +08:00
|
|
|
#define HW_VENDOR HardwareModel_NRF52840DK
|
2020-04-14 20:22:27 -07:00
|
|
|
|
|
|
|
|
// This board uses 0 to be mean LED on
|
|
|
|
|
#undef LED_INVERTED
|
|
|
|
|
#define LED_INVERTED 1
|
|
|
|
|
|
2020-05-10 12:33:17 -07:00
|
|
|
#elif defined(ARDUINO_NRF52840_PPR)
|
|
|
|
|
|
2021-03-14 10:48:20 +08:00
|
|
|
#define HW_VENDOR HardwareModel_PPR
|
2020-05-10 12:33:17 -07:00
|
|
|
|
2021-04-12 13:25:55 +08:00
|
|
|
#elif defined(RAK4630)
|
|
|
|
|
|
|
|
|
|
#define HW_VENDOR HardwareModel_RAK4631
|
|
|
|
|
|
2021-04-29 09:51:10 +08:00
|
|
|
#elif defined(TTGO_T_ECHO)
|
|
|
|
|
|
|
|
|
|
#define HW_VENDOR HardwareModel_T_ECHO
|
|
|
|
|
|
2022-04-04 18:16:19 +08:00
|
|
|
#elif defined(NANO_G1)
|
|
|
|
|
|
|
|
|
|
#define HW_VENDOR HardwareModel_NANO_G1
|
|
|
|
|
|
2022-04-05 18:46:07 +02:00
|
|
|
#elif defined(NORDIC_PCA10059)
|
|
|
|
|
|
|
|
|
|
#define HW_VENDOR HardwareModel_NRF52840_PCA10059
|
|
|
|
|
|
2022-05-10 11:10:32 +02:00
|
|
|
#elif defined(M5STACK)
|
|
|
|
|
|
|
|
|
|
#define HW_VENDOR HardwareModel_M5STACK
|
|
|
|
|
|
2020-07-09 21:27:34 -07:00
|
|
|
#elif NRF52_SERIES
|
|
|
|
|
|
2021-03-14 10:48:20 +08:00
|
|
|
#define HW_VENDOR HardwareModel_NRF52_UNKNOWN
|
2020-07-09 21:27:34 -07:00
|
|
|
|
2020-09-05 12:34:48 -07:00
|
|
|
#elif PORTDUINO
|
|
|
|
|
|
2021-03-14 10:48:20 +08:00
|
|
|
#define HW_VENDOR HardwareModel_PORTDUINO
|
2020-09-06 16:09:07 -07:00
|
|
|
|
2020-02-01 14:23:21 -08:00
|
|
|
#endif
|
|
|
|
|
|
2022-01-18 18:35:42 -06:00
|
|
|
#include "variant.h"
|
|
|
|
|
#include "RF95Configuration.h"
|
2022-03-20 11:53:37 +01:00
|
|
|
#include "DebugConfiguration.h"
|