Added gps test
This commit is contained in:
parent
1019397033
commit
6d584dd674
7 changed files with 226 additions and 76 deletions
101
examples/AllFunction/board_def.h
Normal file
101
examples/AllFunction/board_def.h
Normal file
|
|
@ -0,0 +1,101 @@
|
|||
/*
|
||||
* This factory is just to test LilyGo T-Beam series hardware
|
||||
* Created by Lewis he
|
||||
* */
|
||||
#ifndef BOARD_DEF_H
|
||||
#define BOARD_DEF_H
|
||||
|
||||
// #define T_BEAM_V07
|
||||
#define T_BEAM_V10 //same v1.1 version
|
||||
|
||||
#define ENABLE_SSD1306
|
||||
#define ENABLE_GPS
|
||||
#define ENABLE_LOAR
|
||||
|
||||
#define SSD1306_ADDRESS 0x3C
|
||||
#ifdef ENABLE_SSD1306
|
||||
#include "SSD1306.h"
|
||||
#include "OLEDDisplayUi.h"
|
||||
#define SSD1306_OBJECT() SSD1306 oled(SSD1306_ADDRESS, I2C_SDA, I2C_SCL);OLEDDisplayUi ui(&oled)
|
||||
|
||||
#else
|
||||
#define SSD1306_OBJECT()
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_LOAR
|
||||
#include <RadioLib.h>
|
||||
|
||||
/*
|
||||
Replace the model according to the actual situation
|
||||
|
||||
RADIO_TYPE option:
|
||||
- SX1278
|
||||
- SX1276
|
||||
- SX1262
|
||||
*/
|
||||
#define RADIO_TYPE SX1262
|
||||
|
||||
/*
|
||||
Fill in the frequency according to the actual situation
|
||||
LORA_PERIOD option:
|
||||
- 433,470,868,915
|
||||
*/
|
||||
#define LORA_PERIOD 915
|
||||
|
||||
|
||||
#define LORA_SCK 5
|
||||
#define LORA_MISO 19
|
||||
#define LORA_MOSI 27
|
||||
#define LORA_SS 18
|
||||
#define LORA_DI0 26
|
||||
#define LORA_RST 23
|
||||
#define LORA_DIO1 33
|
||||
#define LORA_BUSY 32
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_GPS
|
||||
#include <TinyGPS++.h>
|
||||
#define UBLOX_GPS_OBJECT() TinyGPSPlus gps
|
||||
#define GPS_BANUD_RATE 9600
|
||||
|
||||
#if defined(T_BEAM_V07)
|
||||
#define GPS_RX_PIN 12
|
||||
#define GPS_TX_PIN 15
|
||||
#define BUTTON_PIN 39
|
||||
#define BUTTON_PIN_MASK GPIO_SEL_39
|
||||
#elif defined(T_BEAM_V10)
|
||||
#define GPS_RX_PIN 34
|
||||
#define GPS_TX_PIN 12
|
||||
#define BUTTON_PIN 38
|
||||
#define BUTTON_PIN_MASK GPIO_SEL_38
|
||||
#endif
|
||||
#else
|
||||
UBLOX_GPS_OBJECT()
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef ENABLE_LOAR
|
||||
#if LORA_PERIOD == 433
|
||||
#define BAND 433.0
|
||||
#elif LORA_PERIOD == 868
|
||||
#define BAND 868.0
|
||||
#elif LORA_PERIOD == 915
|
||||
#define BAND 915.0
|
||||
#elif LORA_PERIOD == 470
|
||||
#define BAND 470.0
|
||||
#else
|
||||
#define BAND 433.0
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
#define I2C_SDA 21
|
||||
#define I2C_SCL 22
|
||||
#define PMU_IRQ 35
|
||||
|
||||
#define ENABLE_BUZZER
|
||||
#define BUZZER_PIN 4
|
||||
|
||||
#endif /*BOARD_DEF_H*/
|
||||
27
examples/gps/board_def.h
Normal file
27
examples/gps/board_def.h
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
/*
|
||||
* This factory is just to test LilyGo T-Beam series hardware
|
||||
* Created by Lewis he
|
||||
* */
|
||||
#ifndef BOARD_DEF_H
|
||||
#define BOARD_DEF_H
|
||||
|
||||
// #define T_BEAM_V07
|
||||
#define T_BEAM_V10 //same v1.1 version
|
||||
|
||||
#if defined(T_BEAM_V07)
|
||||
#define GPS_RX_PIN 12
|
||||
#define GPS_TX_PIN 15
|
||||
#define BUTTON_PIN 39
|
||||
#define BUTTON_PIN_MASK GPIO_SEL_39
|
||||
#elif defined(T_BEAM_V10)
|
||||
#define GPS_RX_PIN 34
|
||||
#define GPS_TX_PIN 12
|
||||
#define BUTTON_PIN 38
|
||||
#define BUTTON_PIN_MASK GPIO_SEL_38
|
||||
#endif
|
||||
|
||||
#define I2C_SDA 21
|
||||
#define I2C_SCL 22
|
||||
#define PMU_IRQ 35
|
||||
|
||||
#endif /*BOARD_DEF_H*/
|
||||
48
examples/gps/gps.ino
Normal file
48
examples/gps/gps.ino
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
#include "board_def.h"
|
||||
#include "SPI.h"
|
||||
#include <Wire.h>
|
||||
#include "axp20x.h"
|
||||
|
||||
#define SerialGPS Serial1
|
||||
|
||||
AXP20X_Class axp;
|
||||
|
||||
bool findPower = false;
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
|
||||
Wire.begin(I2C_SDA, I2C_SCL);
|
||||
|
||||
SerialGPS.begin(9600, SERIAL_8N1, GPS_RX_PIN, GPS_TX_PIN);
|
||||
|
||||
findPower = !axp.begin(Wire, AXP192_SLAVE_ADDRESS);
|
||||
if (findPower) {
|
||||
// ! DC1 is the power supply of ESP32, do not control it
|
||||
// axp.setDCDC1Voltage(3300); //esp32 core VDD 3v3
|
||||
// axp.setPowerOutPut(AXP192_DCDC1, AXP202_ON);
|
||||
|
||||
//Setting LDO2 and LOD3 3300mV
|
||||
axp.setLDO2Voltage(3300); //LORA VDD 3v3
|
||||
axp.setLDO3Voltage(3300); //GPS VDD 3v3
|
||||
|
||||
//Enable LDO2 , It controls the lora power
|
||||
axp.setPowerOutPut(AXP192_LDO2, AXP202_ON);
|
||||
//Enable LDO3, It controls the GPS power
|
||||
axp.setPowerOutPut(AXP192_LDO3, AXP202_ON);
|
||||
|
||||
//Idle the power supply, turn it off
|
||||
axp.setPowerOutPut(AXP192_DCDC2, AXP202_OFF);
|
||||
axp.setPowerOutPut(AXP192_EXTEN, AXP202_OFF);
|
||||
} else {
|
||||
Serial.println("AXP192 not found");
|
||||
}
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
while (SerialGPS.available()) {
|
||||
Serial.write(SerialGPS.read());
|
||||
}
|
||||
}
|
||||
|
|
@ -13,8 +13,8 @@ platform = espressif32
|
|||
board = esp32dev
|
||||
framework = arduino
|
||||
|
||||
upload_port = COM26
|
||||
monitor_port = COM26
|
||||
; upload_port = COM63
|
||||
; monitor_port = COM63
|
||||
|
||||
monitor_speed = 115200
|
||||
upload_speed = 2000000
|
||||
|
|
|
|||
|
|
@ -8,58 +8,6 @@
|
|||
// #define T_BEAM_V07
|
||||
#define T_BEAM_V10 //same v1.1 version
|
||||
|
||||
#define ENABLE_SSD1306
|
||||
#define ENABLE_GPS
|
||||
#define ENABLE_LOAR
|
||||
|
||||
#define SSD1306_ADDRESS 0x3C
|
||||
#ifdef ENABLE_SSD1306
|
||||
#include "SSD1306.h"
|
||||
#include "OLEDDisplayUi.h"
|
||||
#define SSD1306_OBJECT() SSD1306 oled(SSD1306_ADDRESS, I2C_SDA, I2C_SCL);OLEDDisplayUi ui(&oled)
|
||||
|
||||
#else
|
||||
#define SSD1306_OBJECT()
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_LOAR
|
||||
#include <RadioLib.h>
|
||||
|
||||
/*
|
||||
Replace the model according to the actual situation
|
||||
|
||||
RADIO_TYPE option:
|
||||
- SX1278
|
||||
- SX1276
|
||||
- SX1262
|
||||
*/
|
||||
#define RADIO_TYPE SX1262
|
||||
|
||||
/*
|
||||
Fill in the frequency according to the actual situation
|
||||
LORA_PERIOD option:
|
||||
- 433,470,868,915
|
||||
*/
|
||||
#define LORA_PERIOD 915
|
||||
|
||||
|
||||
#define LORA_SCK 5
|
||||
#define LORA_MISO 19
|
||||
#define LORA_MOSI 27
|
||||
#define LORA_SS 18
|
||||
#define LORA_DI0 26
|
||||
#define LORA_RST 23
|
||||
#define LORA_DIO1 33
|
||||
#define LORA_BUSY 32
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_GPS
|
||||
#include <TinyGPS++.h>
|
||||
#define UBLOX_GPS_OBJECT() TinyGPSPlus gps
|
||||
#define GPS_BANUD_RATE 9600
|
||||
|
||||
#if defined(T_BEAM_V07)
|
||||
#define GPS_RX_PIN 12
|
||||
#define GPS_TX_PIN 15
|
||||
|
|
@ -71,31 +19,9 @@ LORA_PERIOD option:
|
|||
#define BUTTON_PIN 38
|
||||
#define BUTTON_PIN_MASK GPIO_SEL_38
|
||||
#endif
|
||||
#else
|
||||
UBLOX_GPS_OBJECT()
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef ENABLE_LOAR
|
||||
#if LORA_PERIOD == 433
|
||||
#define BAND 433.0
|
||||
#elif LORA_PERIOD == 868
|
||||
#define BAND 868.0
|
||||
#elif LORA_PERIOD == 915
|
||||
#define BAND 915.0
|
||||
#elif LORA_PERIOD == 470
|
||||
#define BAND 470.0
|
||||
#else
|
||||
#define BAND 433.0
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
#define I2C_SDA 21
|
||||
#define I2C_SCL 22
|
||||
#define PMU_IRQ 35
|
||||
|
||||
#define ENABLE_BUZZER
|
||||
#define BUZZER_PIN 4
|
||||
|
||||
#endif /*BOARD_DEF_H*/
|
||||
48
src/main.cpp
Normal file
48
src/main.cpp
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
#include "board_def.h"
|
||||
#include "SPI.h"
|
||||
#include <Wire.h>
|
||||
#include "axp20x.h"
|
||||
|
||||
#define SerialGPS Serial1
|
||||
|
||||
AXP20X_Class axp;
|
||||
|
||||
bool findPower = false;
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
|
||||
Wire.begin(I2C_SDA, I2C_SCL);
|
||||
|
||||
SerialGPS.begin(9600, SERIAL_8N1, GPS_RX_PIN, GPS_TX_PIN);
|
||||
|
||||
findPower = !axp.begin(Wire, AXP192_SLAVE_ADDRESS);
|
||||
if (findPower) {
|
||||
// ! DC1 is the power supply of ESP32, do not control it
|
||||
// axp.setDCDC1Voltage(3300); //esp32 core VDD 3v3
|
||||
// axp.setPowerOutPut(AXP192_DCDC1, AXP202_ON);
|
||||
|
||||
//Setting LDO2 and LOD3 3300mV
|
||||
axp.setLDO2Voltage(3300); //LORA VDD 3v3
|
||||
axp.setLDO3Voltage(3300); //GPS VDD 3v3
|
||||
|
||||
//Enable LDO2 , It controls the lora power
|
||||
axp.setPowerOutPut(AXP192_LDO2, AXP202_ON);
|
||||
//Enable LDO3, It controls the GPS power
|
||||
axp.setPowerOutPut(AXP192_LDO3, AXP202_ON);
|
||||
|
||||
//Idle the power supply, turn it off
|
||||
axp.setPowerOutPut(AXP192_DCDC2, AXP202_OFF);
|
||||
axp.setPowerOutPut(AXP192_EXTEN, AXP202_OFF);
|
||||
} else {
|
||||
Serial.println("AXP192 not found");
|
||||
}
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
while (SerialGPS.available()) {
|
||||
Serial.write(SerialGPS.read());
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue