commit
dd2ab4a071
@ -2,6 +2,7 @@
|
||||
#define _DISPLAY_H
|
||||
|
||||
#include <libpax_api.h>
|
||||
#include <Wire.h>
|
||||
#include "cyclic.h"
|
||||
#include "qrcode.h"
|
||||
#include "power.h"
|
||||
@ -48,7 +49,7 @@ extern BB_SPI_LCD *dp;
|
||||
#endif
|
||||
|
||||
// settings for TFT display library
|
||||
#elif (HAS_DISPLAY == 2)
|
||||
#elif (HAS_DISPLAY) == 2
|
||||
|
||||
#define MY_FONT_SMALL 2
|
||||
#define MY_FONT_NORMAL 2
|
||||
@ -74,10 +75,6 @@ extern BB_SPI_LCD *dp;
|
||||
#define OLED_TYPE OLED_128x64
|
||||
#endif
|
||||
|
||||
#ifndef MY_DISPLAY_INVERT
|
||||
#define MY_DISPLAY_INVERT 0
|
||||
#endif
|
||||
|
||||
#ifndef MY_DISPLAY_FLIP
|
||||
#define MY_DISPLAY_FLIP 0
|
||||
#endif
|
||||
|
@ -12,7 +12,10 @@
|
||||
#include <set>
|
||||
#include <array>
|
||||
#include <algorithm>
|
||||
|
||||
#ifdef HAS_BME680
|
||||
#include <bsec.h>
|
||||
#endif
|
||||
|
||||
#define _bit(b) (1U << (b))
|
||||
#define _bitl(b) (1UL << (b))
|
||||
|
@ -2,6 +2,7 @@
|
||||
#define _I2C_H
|
||||
|
||||
#include <Arduino.h>
|
||||
#include <Wire.h>
|
||||
#include <BitBang_I2C.h>
|
||||
|
||||
#define SSD1306_PRIMARY_ADDRESS (0x3D)
|
||||
|
@ -1,8 +1,12 @@
|
||||
#ifndef _LED_H
|
||||
#define _LED_H
|
||||
|
||||
#ifdef RGB_LED_COUNT
|
||||
#include <SmartLeds.h>
|
||||
#endif
|
||||
#ifdef HAS_LORA
|
||||
#include "lorawan.h"
|
||||
#endif
|
||||
|
||||
#ifndef RGB_LED_COUNT
|
||||
#define RGB_LED_COUNT 1
|
||||
|
@ -2,7 +2,7 @@
|
||||
#define _RESET_H
|
||||
|
||||
#include <driver/rtc_io.h>
|
||||
#include <rom/rtc.h>
|
||||
#include <soc/reset_reasons.h>
|
||||
|
||||
#include "i2c.h"
|
||||
#include "lorawan.h"
|
||||
|
@ -68,16 +68,13 @@ void dp_setup(int contrast) {
|
||||
dp->setRotation(
|
||||
MY_DISPLAY_FLIP ? 2 : 0); // 0 = no rotation, 1 = 90°, 2 = 180°, 3 = 280°
|
||||
|
||||
#elif (HAS_DISPLAY) == 2 // SPI TFT
|
||||
#elif (HAS_DISPLAY) == 2 // TFT LCD
|
||||
|
||||
dp = new BB_SPI_LCD;
|
||||
dp->begin(TFT_TYPE, FLAGS_NONE, TFT_FREQUENCY, TFT_CS, TFT_DC, TFT_RST,
|
||||
TFT_BL, TFT_MISO, TFT_MOSI, TFT_SCLK);
|
||||
dp->begin(TFT_TYPE);
|
||||
dp->allocBuffer(); // render all outputs to lib internal backbuffer
|
||||
dp->setRotation(
|
||||
MY_DISPLAY_FLIP ? 1 : 3); // 0 = no rotation, 1 = 90°, 2 = 180°, 3 = 280°
|
||||
// dp->invertDisplay(MY_DISPLAY_INVERT ? true : false);
|
||||
// dp->setTextWrap(false);
|
||||
dp->setTextColor(MY_DISPLAY_FGCOLOR, MY_DISPLAY_BGCOLOR);
|
||||
|
||||
#endif
|
||||
@ -138,7 +135,7 @@ void dp_init(bool verbose) {
|
||||
#endif
|
||||
|
||||
#endif // HAS_LORA
|
||||
} // verbose
|
||||
} // verbose
|
||||
|
||||
dp_power(cfg.screenon); // set display off if disabled
|
||||
} // dp_init
|
||||
|
@ -48,8 +48,6 @@
|
||||
//#define MY_DISPLAY_FLIP 1 // use if display is rotated
|
||||
#define MY_DISPLAY_WIDTH 320
|
||||
#define MY_DISPLAY_HEIGHT 240
|
||||
#define MY_DISPLAY_INVERT 1
|
||||
#define TFT_TYPE LCD_ILI9341
|
||||
#define TFT_MOSI MOSI // SPI
|
||||
#define TFT_MISO MISO // SPI
|
||||
#define TFT_SCLK SCK // SPI
|
||||
@ -58,5 +56,6 @@
|
||||
#define TFT_RST GPIO_NUM_33 // Reset
|
||||
#define TFT_BL GPIO_NUM_32 // LED back-light
|
||||
#define TFT_FREQUENCY 40000000
|
||||
#define TFT_TYPE LCD_ILI9341, FLAGS_NONE, TFT_FREQUENCY, TFT_CS, TFT_DC, TFT_RST, TFT_BL, TFT_MISO, TFT_MOSI, TFT_SCLK
|
||||
|
||||
#endif
|
||||
|
@ -53,8 +53,6 @@
|
||||
//#define MY_DISPLAY_FLIP 1 // use if display is rotated
|
||||
#define MY_DISPLAY_WIDTH 320
|
||||
#define MY_DISPLAY_HEIGHT 240
|
||||
#define MY_DISPLAY_INVERT 1
|
||||
#define TFT_TYPE LCD_ILI9341
|
||||
#define TFT_MOSI MOSI // SPI
|
||||
#define TFT_MISO MISO // SPI
|
||||
#define TFT_SCLK SCK // SPI
|
||||
@ -63,5 +61,7 @@
|
||||
#define TFT_RST GPIO_NUM_33 // Reset
|
||||
#define TFT_BL GPIO_NUM_32 // LED back-light
|
||||
#define TFT_FREQUENCY 40000000
|
||||
#define TFT_TYPE LCD_ILI9341, FLAGS_NONE, TFT_FREQUENCY, TFT_CS, TFT_DC, TFT_RST, TFT_BL, TFT_MISO, TFT_MOSI, TFT_SCLK
|
||||
|
||||
|
||||
#endif
|
@ -18,18 +18,9 @@
|
||||
|
||||
// Display Settings
|
||||
#define HAS_DISPLAY 2 // TFT-LCD
|
||||
#define TFT_TYPE DISPLAY_T_DISPLAY
|
||||
#define MY_DISPLAY_FLIP 1 // use if display is rotated
|
||||
#define MY_DISPLAY_WIDTH 135
|
||||
#define MY_DISPLAY_HEIGHT 240
|
||||
#define MY_DISPLAY_INVERT 1
|
||||
#define TFT_TYPE LCD_ST7789_135 // size 135x240 px
|
||||
#define TFT_MOSI GPIO_NUM_19 // SPI
|
||||
#define TFT_MISO NOT_A_PIN // SPI
|
||||
#define TFT_SCLK GPIO_NUM_18 // SPI
|
||||
#define TFT_CS GPIO_NUM_5 // Chip select control
|
||||
#define TFT_DC GPIO_NUM_16 // Data Command control
|
||||
#define TFT_RST GPIO_NUM_23 // Reset
|
||||
#define TFT_BL GPIO_NUM_4 // LED back-light
|
||||
#define TFT_FREQUENCY 40000000
|
||||
|
||||
#endif
|
||||
|
24
src/hal/ttgotdisplays3.h
Normal file
24
src/hal/ttgotdisplays3.h
Normal file
@ -0,0 +1,24 @@
|
||||
// clang-format off
|
||||
// upload_speed 1500000
|
||||
// board ESP32-S3-DevKitC-1
|
||||
|
||||
#ifndef _TTGOTDISPLAYS3_H
|
||||
#define _TTGOTDISPLAYS3_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#define HAS_LED NOT_A_PIN
|
||||
#define HAS_BUTTON 14 // on board button (right side)
|
||||
|
||||
// power management settings
|
||||
//#define BAT_MEASURE_ADC ADC1_GPIO4_CHANNEL // battery probe GPIO pin -> ADC1_CHANNEL_6
|
||||
//#define BAT_VOLTAGE_DIVIDER 2.605f // voltage divider
|
||||
|
||||
// Display Settings
|
||||
#define HAS_DISPLAY 2 // TFT-LCD parallel
|
||||
#define TFT_TYPE DISPLAY_T_DISPLAY_S3
|
||||
#define MY_DISPLAY_FLIP 1 // use if display is rotated
|
||||
#define MY_DISPLAY_WIDTH 172
|
||||
#define MY_DISPLAY_HEIGHT 320
|
||||
|
||||
#endif
|
@ -21,8 +21,6 @@
|
||||
#define MY_DISPLAY_FLIP 1 // use if display is rotated
|
||||
#define MY_DISPLAY_WIDTH 80
|
||||
#define MY_DISPLAY_HEIGHT 160
|
||||
#define MY_DISPLAY_INVERT 1
|
||||
#define TFT_TYPE LCD_ST7735S
|
||||
#define TFT_MOSI GPIO_NUM_19 // SPI
|
||||
#define TFT_MISO NOT_A_PIN // SPI
|
||||
#define TFT_SCLK GPIO_NUM_18 // SPI
|
||||
@ -31,6 +29,7 @@
|
||||
#define TFT_RST GPIO_NUM_26 // Reset
|
||||
#define TFT_BL GPIO_NUM_27 // LED back-light
|
||||
#define TFT_FREQUENCY 27000000
|
||||
#define TFT_TYPE LCD_ST7735S, FLAGS_NONE, TFT_FREQUENCY, TFT_CS, TFT_DC, TFT_RST, TFT_BL, TFT_MISO, TFT_MOSI, TFT_SCLK
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -324,9 +324,15 @@ void get_config(uint8_t val[]) {
|
||||
void get_status(uint8_t val[]) {
|
||||
ESP_LOGI(TAG, "Remote command: get device status");
|
||||
payload.reset();
|
||||
#ifdef CONFIG_IDF_TARGET_ESP32S3
|
||||
payload.addStatus(read_voltage(), (uint64_t)(uptime() / 1000ULL), 0,
|
||||
// temperatureRead(),
|
||||
getFreeRAM(), rtc_get_reset_reason(0), RTC_restarts);
|
||||
#else
|
||||
payload.addStatus(read_voltage(), (uint64_t)(uptime() / 1000ULL),
|
||||
temperatureRead(), getFreeRAM(), rtc_get_reset_reason(0),
|
||||
RTC_restarts);
|
||||
#endif
|
||||
SendPayload(STATUSPORT);
|
||||
};
|
||||
|
||||
|
@ -11,7 +11,6 @@ static const char TAG[] = __FILE__;
|
||||
// RTC_NOINIT_ATTR -> keep value after a software restart or system crash
|
||||
RTC_NOINIT_ATTR runmode_t RTC_runmode;
|
||||
RTC_NOINIT_ATTR uint32_t RTC_restarts;
|
||||
|
||||
// RTC_DATA_ATTR -> keep values after a wakeup from sleep
|
||||
RTC_DATA_ATTR struct timeval RTC_sleep_start_time;
|
||||
RTC_DATA_ATTR unsigned long long RTC_millis = 0;
|
||||
@ -53,18 +52,17 @@ void do_after_reset(void) {
|
||||
#endif
|
||||
|
||||
switch (rtc_get_reset_reason(0)) {
|
||||
case POWERON_RESET: // 0x01 Vbat power on reset
|
||||
case RTCWDT_BROWN_OUT_RESET: // 0x0f Reset when the vdd voltage is not
|
||||
// stable
|
||||
case RESET_REASON_CHIP_POWER_ON:
|
||||
case RESET_REASON_SYS_BROWN_OUT:
|
||||
reset_rtc_vars();
|
||||
break;
|
||||
|
||||
case SW_CPU_RESET: // 0x0c Software reset CPU
|
||||
case RESET_REASON_CPU0_SW:
|
||||
// keep previous set runmode (update / normal / maintenance)
|
||||
RTC_restarts++;
|
||||
break;
|
||||
|
||||
case DEEPSLEEP_RESET: // 0x05 Deep Sleep reset digital core
|
||||
case RESET_REASON_CORE_DEEP_SLEEP:
|
||||
// calculate time spent in deep sleep
|
||||
gettimeofday(&sleep_stop_time, NULL);
|
||||
sleep_time_ms =
|
||||
@ -72,26 +70,13 @@ void do_after_reset(void) {
|
||||
(sleep_stop_time.tv_usec - RTC_sleep_start_time.tv_usec) / 1000;
|
||||
RTC_millis += sleep_time_ms; // increment system monotonic time
|
||||
ESP_LOGI(TAG, "Time spent in deep sleep: %d ms", sleep_time_ms);
|
||||
|
||||
// do we have a valid time? -> set global variable
|
||||
timeSource = timeIsValid(sleep_stop_time.tv_sec) ? _set : _unsynced;
|
||||
|
||||
// set wakeup state, not if we have pending OTA update
|
||||
if (RTC_runmode == RUNMODE_SLEEP)
|
||||
RTC_runmode = RUNMODE_WAKEUP;
|
||||
break;
|
||||
|
||||
case SW_RESET: // 0x03 Software reset digital core
|
||||
case OWDT_RESET: // 0x04 Legacy watch dog reset digital core
|
||||
case SDIO_RESET: // 0x06 Reset by SLC module, reset digital core
|
||||
case TG0WDT_SYS_RESET: // 0x07 Timer Group0 Watch dog reset digital core
|
||||
case TG1WDT_SYS_RESET: // 0x08 Timer Group1 Watch dog reset digital core
|
||||
case RTCWDT_SYS_RESET: // 0x09 RTC Watch dog Reset digital core
|
||||
case INTRUSION_RESET: // 0x0a Instrusion tested to reset CPU
|
||||
case TGWDT_CPU_RESET: // 0x0b Time Group reset CPU
|
||||
case RTCWDT_CPU_RESET: // 0x0d RTC Watch dog Reset CPU
|
||||
case EXT_CPU_RESET: // 0x0e for APP CPU, reseted by PRO CPU
|
||||
case RTCWDT_RTC_RESET: // 0x10 RTC Watch dog reset digital core and rtc mode
|
||||
default:
|
||||
RTC_runmode = RUNMODE_POWERCYCLE;
|
||||
RTC_restarts++;
|
||||
@ -108,7 +93,6 @@ void enter_deepsleep(const uint64_t wakeup_sec, gpio_num_t wakeup_gpio) {
|
||||
// validate wake up pin, if we have
|
||||
if (!GPIO_IS_VALID_GPIO(wakeup_gpio))
|
||||
wakeup_gpio = GPIO_NUM_MAX;
|
||||
|
||||
// stop further enqueuing of senddata and MAC processing
|
||||
libpax_counter_stop();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user