diff --git a/.gitignore b/.gitignore index e9ee0fb..a5218a6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,9 @@ -build -.vscode \ No newline at end of file +.pio +.vscode/.browse.c_cpp.db* +.vscode/c_cpp_properties.json +.vscode/launch.json +.vscode/ipch +.vscode +test +.gitignore +.travis.yml \ No newline at end of file diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index b00a338..0000000 --- a/.gitmodules +++ /dev/null @@ -1,12 +0,0 @@ -[submodule "libraries/TinyGPSPlus"] - path = libraries/TinyGPSPlus - url = https://github.com/mikalhart/TinyGPSPlus.git -[submodule "libraries/AXP202X_Library"] - path = libraries/AXP202X_Library - url = https://github.com/lewisxhe/AXP202X_Library.git -[submodule "libraries/Button2"] - path = libraries/Button2 - url = https://github.com/lewisxhe/Button2.git -[submodule "libraries/esp8266-oled-ssd1306"] - path = libraries/esp8266-oled-ssd1306 - url = https://github.com/ThingPulse/esp8266-oled-ssd1306.git diff --git a/README.MD b/README.MD index 2254547..fa26259 100644 --- a/README.MD +++ b/README.MD @@ -2,7 +2,7 @@ TTGO-T-Beam ===================== -![](images/1.png) +![](image/product.jpg) ## PinOut @@ -43,13 +43,11 @@ TTGO-T-Beam - The boot will scan the I2C device. If the OLED is found, all log information will be displayed in the OLED. If not, it will be printed on the serial port. ## How to use -- The repository depends on other library files, please recursively clone the repository - ``` - git clone --recursive https://github.com/Xinyuan-LilyGO/TTGO-T-Beam.git - ``` +- For dependencies on other files please see `platformio.ini` +- Regarding the board, you can modify the board version and lora frequency in `board_def.h` +- If you use the Arduino IDE for compilation, please store `board_def.h` and `LilyGO-T-Beam.ino` in the same directory, and the directory folder name must be the same as ino -- Then move the library files in the `libraries` directory to - ``` - C:\Users\\Documents\Arduino\libraries - ``` -- In the Arduino board select `T-Beam` \ No newline at end of file +## Deepsleep +- Regarding deep sleep, except for DCDC3, power off all channels of AXP192, the current consumption is about 0.9mA + +![](image/deepsleep.jpg) \ No newline at end of file diff --git a/images/1.png b/images/1.png deleted file mode 100644 index ac76a68..0000000 Binary files a/images/1.png and /dev/null differ diff --git a/images/deepsleep.jpg b/images/deepsleep.jpg new file mode 100644 index 0000000..9859d99 Binary files /dev/null and b/images/deepsleep.jpg differ diff --git a/images/product.jpg b/images/product.jpg new file mode 100644 index 0000000..844c77b Binary files /dev/null and b/images/product.jpg differ diff --git a/libraries/AXP202X_Library b/libraries/AXP202X_Library deleted file mode 160000 index 31933cb..0000000 --- a/libraries/AXP202X_Library +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 31933cb5ce47607922697668fd6c0573709c3e35 diff --git a/libraries/Button2 b/libraries/Button2 deleted file mode 160000 index fed9e73..0000000 --- a/libraries/Button2 +++ /dev/null @@ -1 +0,0 @@ -Subproject commit fed9e73972c8c3436dde5fe56d98ac7b7e7e9d41 diff --git a/libraries/TinyGPSPlus b/libraries/TinyGPSPlus deleted file mode 160000 index b4c8e29..0000000 --- a/libraries/TinyGPSPlus +++ /dev/null @@ -1 +0,0 @@ -Subproject commit b4c8e29d1def35806fb1fc75fe0013036843d643 diff --git a/libraries/esp8266-oled-ssd1306 b/libraries/esp8266-oled-ssd1306 deleted file mode 160000 index cb294b0..0000000 --- a/libraries/esp8266-oled-ssd1306 +++ /dev/null @@ -1 +0,0 @@ -Subproject commit cb294b0d5e938864ba935a8e917082e5496399ca diff --git a/platformio.ini b/platformio.ini new file mode 100644 index 0000000..b08149b --- /dev/null +++ b/platformio.ini @@ -0,0 +1,33 @@ +; PlatformIO Project Configuration File +; +; Build options: build flags, source filter +; Upload options: custom upload port, speed and extra flags +; Library options: dependencies, extra library storages +; Advanced options: extra scripting +; +; Please visit documentation for the other options and examples +; https://docs.platformio.org/page/projectconf.html + +[env:esp32dev] +platform = espressif32 +board = esp32dev +framework = arduino + +upload_port = COM11 +monitor_port = COM11 +; upload_port = COM8 +; monitor_port = COM8 + +monitor_speed = 115200 +upload_speed = 2000000 + +lib_deps = + https://github.com/lewisxhe/Button2.git + AXP202X_Library ;https://github.com/lewisxhe/AXP202X_Library + TinyGPSPlus ;https://github.com/mikalhart/TinyGPSPlus + ESP8266_SSD1306 ;https://github.com/ThingPulse/esp8266-oled-ssd1306 + LoRa ;https://github.com/dragino/Lora + + + + diff --git a/TTGO-T-Beam.ino b/src/LilyGO-T-Beam.ino similarity index 93% rename from TTGO-T-Beam.ino rename to src/LilyGO-T-Beam.ino index b34c401..ada795a 100644 --- a/TTGO-T-Beam.ino +++ b/src/LilyGO-T-Beam.ino @@ -13,7 +13,6 @@ SSD1306_OBJECT(); UBLOX_GPS_OBJECT(); AXP20X_Class axp; -static String recv = ""; uint8_t program = 0; bool ssd1306_found = false; bool axp192_found = false; @@ -33,6 +32,9 @@ uint8_t g_btns[] = BUTTONS_MAP; Ticker btnTick; +String baChStatus = "No charging"; +String recv = ""; + /************************************ * BUTTON * *********************************/ @@ -84,10 +86,6 @@ void button_init() }); } -/************************************ - * SCREEN - * *********************************/ -String baChStatus = "No charging"; void msOverlay(OLEDDisplay *display, OLEDDisplayUiState *state) { static char volbuffer[128]; @@ -99,21 +97,20 @@ void msOverlay(OLEDDisplay *display, OLEDDisplayUiState *state) if (axp.isBatteryConnect()) { snprintf(volbuffer, sizeof(volbuffer), "%.2fV/%.2fmA", axp.getBattVoltage() / 1000.0, axp.isChargeing() ? axp.getBattChargeCurrent() : axp.getBattDischargeCurrent()); display->drawString(62, 0, volbuffer); + } else { + multi_heap_info_t info; + heap_caps_get_info(&info, MALLOC_CAP_INTERNAL); + snprintf(volbuffer, sizeof(volbuffer), "%u/%uKB", info.total_allocated_bytes / 1024, info.total_free_bytes / 1024); + display->drawString(75, 0, volbuffer); } } - - - - - void drawFrame1(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y) { display->setFont(ArialMT_Plain_10); display->setTextAlignment(TEXT_ALIGN_CENTER); - if (!gps.location.isValid()) { display->drawString(64 + x, 11 + y, buff[0]); display->drawString(64 + x, 22 + y, buff[1]); @@ -187,6 +184,45 @@ void ssd1306_init() } + +void scanI2Cdevice(void) +{ + byte err, addr; + int nDevices = 0; + for (addr = 1; addr < 127; addr++) { + Wire.beginTransmission(addr); + err = Wire.endTransmission(); + if (err == 0) { + Serial.print("I2C device found at address 0x"); + if (addr < 16) + Serial.print("0"); + Serial.print(addr, HEX); + Serial.println(" !"); + nDevices++; + + if (addr == SSD1306_ADDRESS) { + ssd1306_found = true; + Serial.println("ssd1306 display found"); + } + if (addr == AXP192_SLAVE_ADDRESS) { + axp192_found = true; + Serial.println("axp192 PMU found"); + } + } else if (err == 4) { + Serial.print("Unknow error at address 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"); +} + + + void playSound() { #ifdef ENABLE_BUZZER @@ -196,6 +232,22 @@ void playSound() #endif } + + +void lora_init() +{ +#ifdef ENABLE_LOAR + SPI.begin(LORA_SCK, LORA_MISO, LORA_MOSI, LORA_SS); + LoRa.setPins(LORA_SS, LORA_RST, LORA_DI0); + if (!LoRa.begin(BAND)) + Serial.println("LORA Begin FAIL"); + else { + loraBeginOK = true; + Serial.println("LORA Begin PASS"); + } +#endif +} + void setup() { Serial.begin(115200); @@ -281,25 +333,10 @@ void setup() } -void lora_init() -{ -#ifdef ENABLE_LOAR - SPI.begin(LORA_SCK, LORA_MISO, LORA_MOSI, LORA_SS); - LoRa.setPins(LORA_SS, LORA_RST, LORA_DI0); - if (!LoRa.begin(BAND)) - Serial.println("LORA Begin FAIL"); - else { - loraBeginOK = true; - Serial.println("LORA Begin PASS"); - } -#endif -} - void loop() { - static uint32_t sendCount = 0; - static uint64_t loraMap = 0; + static uint32_t loraMap = 0; static uint64_t gpsMap = 0; if (axp192_found && pmu_irq) { @@ -331,6 +368,7 @@ void loop() } if (!gps.location.isValid()) { if (millis() - gpsMap > 1000) { + snprintf(buff[0], sizeof(buff[0]), "T-Beam GPS"); snprintf(buff[1], sizeof(buff[1]), "Positioning(%llu)", gpsSec++); if (!ssd1306_found) { Serial.println(buff[1]); @@ -367,10 +405,9 @@ void loop() if (millis() - loraMap > 3000) { LoRa.beginPacket(); LoRa.print("lora: "); - LoRa.print(sendCount); + LoRa.print(loraMap); LoRa.endPacket(); - ++sendCount; - snprintf(buff[1], sizeof(buff[1]), "Send %u", sendCount); + snprintf(buff[1], sizeof(buff[1]), "Send %u", loraMap); loraMap = millis(); if (!ssd1306_found) { Serial.println(buff[1]); @@ -417,40 +454,3 @@ void loop() } } } - -void scanI2Cdevice(void) -{ - byte err, addr; - int nDevices = 0; - for (addr = 1; addr < 127; addr++) { - Wire.beginTransmission(addr); - err = Wire.endTransmission(); - if (err == 0) { - Serial.print("I2C device found at address 0x"); - if (addr < 16) - Serial.print("0"); - Serial.print(addr, HEX); - Serial.println(" !"); - nDevices++; - - if (addr == SSD1306_ADDRESS) { - ssd1306_found = true; - Serial.println("ssd1306 display found"); - } - if (addr == AXP192_SLAVE_ADDRESS) { - axp192_found = true; - Serial.println("axp192 PMU found"); - } - } else if (err == 4) { - Serial.print("Unknow error at address 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"); -} - diff --git a/board_def.h b/src/board_def.h similarity index 85% rename from board_def.h rename to src/board_def.h index 9b3fbe7..becd424 100644 --- a/board_def.h +++ b/src/board_def.h @@ -1,15 +1,14 @@ #ifndef BOARD_DEF_H #define BOARD_DEF_H -#define T_BEAM_V07 -// #define T_BEAM_V10 +// #define T_BEAM_V07 +#define T_BEAM_V10 #define ENABLE_SSD1306 #define ENABLE_GPS #define ENABLE_LOAR -//ssd1306 oled显示屏 #define SSD1306_ADDRESS 0x3c #ifdef ENABLE_SSD1306 #include "SSD1306.h" @@ -20,7 +19,6 @@ #define SSD1306_OBJECT() #endif -//lora模块 #ifdef ENABLE_LOAR #include @@ -33,8 +31,6 @@ #define LORA_DI0 26 #define LORA_RST 23 -//设置为1则设定为lora 发送, 0 则为接收 -#define LORA_SENDER 1 #endif //GPS模块