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
|
2023-01-21 14:34:29 +01:00
|
|
|
#include "Melopero_RV3028.h"
|
2022-04-27 11:05:08 +02:00
|
|
|
#endif
|
2022-04-28 08:18:03 +02:00
|
|
|
#ifdef PCF8563_RTC
|
2023-01-21 14:34:29 +01:00
|
|
|
#include "pcf8563.h"
|
2022-04-28 08:18:03 +02:00
|
|
|
#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
|
|
|
|
|
|
2023-01-21 14:34:29 +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
|
2023-11-18 08:12:34 -06:00
|
|
|
#define xstr(s) ystr(s)
|
|
|
|
|
#define ystr(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")
|
|
|
|
|
|
2022-07-31 07:11:47 -05:00
|
|
|
// Nop definition for these attributes that are specific to ESP32
|
|
|
|
|
#ifndef EXT_RAM_ATTR
|
2023-01-21 14:34:29 +01:00
|
|
|
#define EXT_RAM_ATTR
|
2020-09-28 13:10:27 -07:00
|
|
|
#endif
|
2022-07-31 07:11:47 -05:00
|
|
|
#ifndef IRAM_ATTR
|
2023-01-21 14:34:29 +01:00
|
|
|
#define IRAM_ATTR
|
2022-01-07 09:57:29 +03:00
|
|
|
#endif
|
2022-07-31 07:11:47 -05:00
|
|
|
#ifndef RTC_DATA_ATTR
|
2023-01-21 14:34:29 +01:00
|
|
|
#define RTC_DATA_ATTR
|
2020-09-04 17:23:17 -07:00
|
|
|
#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-06-22 09:52:08 +02:00
|
|
|
// #define DISABLE_NTP
|
2022-04-13 19:23:35 -07:00
|
|
|
|
2023-01-21 14:34:29 +01:00
|
|
|
// Disable the welcome screen and allow
|
2023-03-23 11:32:04 -05: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.
|
2023-03-23 11:32:04 -05:00
|
|
|
// #define USE_SH1106
|
2020-06-14 10:28:23 +02: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
|
|
|
|
2023-07-30 14:51:26 +02:00
|
|
|
// I2C Keyboards (M5Stack, RAK14004, T-Deck)
|
2022-03-28 16:55:58 +02:00
|
|
|
#define CARDKB_ADDR 0x5F
|
2023-07-30 14:51:26 +02:00
|
|
|
#define TDECK_KB_ADDR 0x55
|
2023-08-19 15:37:42 +02:00
|
|
|
#define BBQ10_KB_ADDR 0x1F
|
2022-03-28 16:55:58 +02:00
|
|
|
|
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
|
2023-11-04 19:07:00 -06:00
|
|
|
#define INA3221_ADDR 0x42
|
2022-10-07 19:57:55 +08:00
|
|
|
#define QMC6310_ADDR 0x1C
|
|
|
|
|
#define QMI8658_ADDR 0x6B
|
2022-11-12 11:03:29 +01:00
|
|
|
#define QMC5883L_ADDR 0x1E
|
2022-10-15 09:11:05 -05:00
|
|
|
#define SHTC3_ADDR 0x70
|
2022-10-15 14:55:57 -05:00
|
|
|
#define LPS22HB_ADDR 0x5C
|
|
|
|
|
#define LPS22HB_ADDR_ALT 0x5D
|
2022-12-27 19:39:51 +08:00
|
|
|
#define SHT31_ADDR 0x44
|
2023-02-04 13:07:14 -06:00
|
|
|
#define PMSA0031_ADDR 0x12
|
2022-10-13 12:55:28 +02:00
|
|
|
|
2023-03-23 11:32:04 -05:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
// ACCELEROMETER
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
#define MPU6050_ADDR 0x68
|
|
|
|
|
#define LIS3DH_ADR 0x18
|
2023-07-22 09:26:54 -05:00
|
|
|
#define BMA423_ADDR 0x19
|
2023-03-23 11:32:04 -05:00
|
|
|
|
2023-05-06 07:17:40 -05:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
// LED
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
#define NCP5623_ADDR 0x38
|
|
|
|
|
|
2022-10-13 12:55:28 +02:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
// Security
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
#define ATECC608B_ADDR 0x35
|
|
|
|
|
|
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
|
2023-09-23 23:45:35 -05:00
|
|
|
#define GPS_THREAD_INTERVAL 200
|
2022-04-02 12:52:50 +02:00
|
|
|
#endif
|
|
|
|
|
|
2023-08-16 22:07:22 +02:00
|
|
|
// convert 24-bit color to 16-bit (56K)
|
|
|
|
|
#define COLOR565(r, g, b) (((r & 0xF8) << 8) | ((g & 0xFC) << 3) | ((b & 0xF8) >> 3))
|
|
|
|
|
|
2022-07-31 07:11:47 -05:00
|
|
|
/* Step #1: offer chance for variant-specific defines */
|
|
|
|
|
#include "variant.h"
|
2022-02-02 12:41:07 -06:00
|
|
|
|
2023-01-21 14:34:29 +01:00
|
|
|
/* Step #2: follow with defines common to the architecture;
|
2022-07-31 07:11:47 -05:00
|
|
|
also enable HAS_ option not specifically disabled by variant.h */
|
|
|
|
|
#include "architecture.h"
|
2020-02-03 20:18:36 -08:00
|
|
|
|
2022-07-31 07:11:47 -05:00
|
|
|
/* Step #3: mop up with disabled values for HAS_ options not handled by the above two */
|
2021-05-11 09:44:41 +08:00
|
|
|
|
2022-07-31 07:11:47 -05:00
|
|
|
#ifndef HAS_WIFI
|
2023-01-21 14:34:29 +01:00
|
|
|
#define HAS_WIFI 0
|
2021-05-11 09:44:41 +08:00
|
|
|
#endif
|
2022-10-22 16:29:50 +02:00
|
|
|
#ifndef HAS_ETHERNET
|
2023-01-21 14:34:29 +01:00
|
|
|
#define HAS_ETHERNET 0
|
2022-10-22 16:29:50 +02:00
|
|
|
#endif
|
2022-07-31 07:11:47 -05:00
|
|
|
#ifndef HAS_SCREEN
|
2023-01-21 14:34:29 +01:00
|
|
|
#define HAS_SCREEN 0
|
2021-05-11 09:44:41 +08:00
|
|
|
#endif
|
2022-07-31 07:11:47 -05:00
|
|
|
#ifndef HAS_WIRE
|
2023-01-21 14:34:29 +01:00
|
|
|
#define HAS_WIRE 0
|
2020-05-10 12:33:17 -07:00
|
|
|
#endif
|
2022-07-31 07:11:47 -05:00
|
|
|
#ifndef HAS_GPS
|
2023-01-21 14:34:29 +01:00
|
|
|
#define HAS_GPS 0
|
2022-07-31 07:11:47 -05:00
|
|
|
#endif
|
|
|
|
|
#ifndef HAS_BUTTON
|
2023-01-21 14:34:29 +01:00
|
|
|
#define HAS_BUTTON 0
|
2022-07-31 07:11:47 -05:00
|
|
|
#endif
|
2023-07-30 14:51:26 +02:00
|
|
|
#ifndef HAS_TRACKBALL
|
|
|
|
|
#define HAS_TRACKBALL 0
|
|
|
|
|
#endif
|
|
|
|
|
#ifndef HAS_TOUCHSCREEN
|
|
|
|
|
#define HAS_TOUCHSCREEN 0
|
|
|
|
|
#endif
|
2022-07-31 07:11:47 -05:00
|
|
|
#ifndef HAS_TELEMETRY
|
2023-01-21 14:34:29 +01:00
|
|
|
#define HAS_TELEMETRY 0
|
2022-07-31 07:11:47 -05:00
|
|
|
#endif
|
2023-11-08 21:58:33 +00:00
|
|
|
#ifndef HAS_SENSOR
|
|
|
|
|
#define HAS_SENSOR 0
|
|
|
|
|
#endif
|
2022-07-31 07:11:47 -05:00
|
|
|
#ifndef HAS_RADIO
|
2023-01-21 14:34:29 +01:00
|
|
|
#define HAS_RADIO 0
|
2022-07-31 07:11:47 -05:00
|
|
|
#endif
|
|
|
|
|
#ifndef HAS_RTC
|
2023-01-21 14:34:29 +01:00
|
|
|
#define HAS_RTC 0
|
2020-02-01 14:23:21 -08:00
|
|
|
#endif
|
2022-10-30 10:02:11 -05:00
|
|
|
#ifndef HAS_CPU_SHUTDOWN
|
2023-01-21 14:34:29 +01:00
|
|
|
#define HAS_CPU_SHUTDOWN 0
|
2022-10-30 10:02:11 -05:00
|
|
|
#endif
|
|
|
|
|
#ifndef HAS_BLUETOOTH
|
2023-01-21 14:34:29 +01:00
|
|
|
#define HAS_BLUETOOTH 0
|
2022-10-30 10:02:11 -05:00
|
|
|
#endif
|
2020-02-01 14:23:21 -08:00
|
|
|
|
2022-03-20 11:53:37 +01:00
|
|
|
#include "DebugConfiguration.h"
|
2023-01-21 14:34:29 +01:00
|
|
|
#include "RF95Configuration.h"
|
2022-07-31 07:11:47 -05:00
|
|
|
|
|
|
|
|
#ifndef HW_VENDOR
|
2023-01-21 14:34:29 +01:00
|
|
|
#error HW_VENDOR must be defined
|
2023-11-18 08:12:34 -06:00
|
|
|
#endif
|