diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7551c2fd..a39a5c40 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -14,17 +14,10 @@ jobs: fail-fast: false matrix: os: [ubuntu-latest] - # os: [ubuntu-latest, windows-latest, macos-latest] include: - os: ubuntu-latest path: ~/.cache/pip platformio-path: ~/.platformio - # - os: macos-latest - # path: ~/Library/Caches/pip - # platformio-path: ~/Library/Caches/platformio - # - os: windows-latest - # path: ~\AppData\Local\pip\Cache - # platformio-path: ~\AppData\Local\platformio\Cache board: [ generic.h, @@ -94,3 +87,50 @@ jobs: env: CI_HALFILE: ${{ matrix.board }} run: pio run -e ci + + build-s3-usb-stick: + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest] + include: + - os: ubuntu-latest + path: ~/.cache/pip + platformio-path: ~/.platformio + board: [ttgotdongles3.h, ttgotdongledisplays3.h] + runs-on: ${{ matrix.os }} + + steps: + - uses: actions/checkout@v3 + - name: Cache pip + uses: actions/cache@v3 + with: + path: ${{ matrix.path }} + key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} + restore-keys: | + ${{ runner.os }}-pip- + - name: Cache PlatformIO + uses: actions/cache@v3 + with: + path: ${{ matrix.platformio-path }} + key: ${{ runner.os }}-${{ hashFiles('**/lockfiles') }} + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: "3.9.13" + - name: Install PlatformIO + run: | + python -m pip install --upgrade pip + pip install --upgrade platformio + - name: Copy of necessary files + run: | + cp platformio_orig_s3-usb-stick.ini platformio.ini + cp src/loraconf_sample.h src/loraconf.h + cp src/ota_sample.conf src/ota.conf + cp src/paxcounter_orig.conf src/paxcounter.conf + - name: Clean + run: pio run -t clean -e ci + - name: Run PlatformIO CI for ${{ matrix.board }} + env: + CI_HALFILE: ${{ matrix.board }} + run: pio run -e ci diff --git a/include/display.h b/include/display.h index 4965f526..926cf90e 100644 --- a/include/display.h +++ b/include/display.h @@ -86,6 +86,10 @@ extern BB_SPI_LCD *dp; #define MY_DISPLAY_HEIGHT 64 // Height in pixels of OLED-display, must be 64X #endif +#ifndef MY_DISPLAY_FIRSTLINE +#define MY_DISPLAY_FIRSTLINE 0 +#endif + // settings for qr code generator #define QR_VERSION 3 // 29 x 29px diff --git a/include/i2c.h b/include/i2c.h index a8c7c8ea..2fc6e64c 100644 --- a/include/i2c.h +++ b/include/i2c.h @@ -4,6 +4,15 @@ #include #include #include +#include + +#ifndef MY_DISPLAY_SDA +#define MY_DISPLAY_SDA SDA +#endif + +#ifndef MY_DISPLAY_SCL +#define MY_DISPLAY_SCL SCL +#endif #define SSD1306_PRIMARY_ADDRESS (0x3D) #define SSD1306_SECONDARY_ADDRESS (0x3C) @@ -14,14 +23,6 @@ #define MCP_24AA02E64_PRIMARY_ADDRESS (0x50) #define QUECTEL_GPS_PRIMARY_ADDRESS (0x10) -#ifndef MY_DISPLAY_SDA -#define MY_DISPLAY_SDA SDA -#endif - -#ifndef MY_DISPLAY_SCL -#define MY_DISPLAY_SCL SCL -#endif - extern SemaphoreHandle_t I2Caccess; void i2c_init(void); diff --git a/platformio_orig_s3-usb-stick.ini b/platformio_orig_s3-usb-stick.ini new file mode 100644 index 00000000..b51b27cc --- /dev/null +++ b/platformio_orig_s3-usb-stick.ini @@ -0,0 +1,70 @@ +[board] +halfile = ttgotdongles3.h +;halfile = ttgotdongledisplays3.h + +[platformio] +; upload firmware to board with usb cable +default_envs = usb +description = Paxcounter is a device for metering passenger flows in realtime. It counts how many mobile devices are around. + +[common] +; for release_version use max. 10 chars total, use any decimal format like "a.b.c" +release_version = 3.3.2 +; DEBUG LEVEL: For production run set to 0, otherwise device will leak RAM while running! +; 0=None, 1=Error, 2=Warn, 3=Info, 4=Debug, 5=Verbose +debug_level = 5 +extra_scripts = pre:build.py +otakeyfile = ota.conf +lorakeyfile = loraconf.h +lmicconfigfile = lmic_config.h +platform_espressif32 = espressif32@5.2.0 +monitor_speed = 115200 +upload_speed = 115200 ; set by build.py and taken from hal file +lib_deps_all = + bitbank2/BitBang_I2C@^2.2.1 + https://github.com/bitbank2/bb_spi_lcd.git + fastled/FastLED @ ^3.5.0 + ;greyrook/libpax @ ^1.0.1 + https://github.com/cyberman54/libpax.git + https://github.com/SukkoPera/Arduino-Rokkit-Hash.git + bblanchon/ArduinoJson @ ^6 + spacehuhn/SimpleButton + 256dpi/MQTT @ ^2.5.0 + ricmoo/QRCode @ ^0.0.1 +build_flags_basic = + -include "src/paxcounter.conf" + '-DCORE_DEBUG_LEVEL=${common.debug_level}' + '-DLOG_LOCAL_LEVEL=${common.debug_level}' + '-DPROGVERSION="${common.release_version}"' + '-D LIBPAX_WIFI' + '-D LIBPAX_BLE' + '-D LIBPAX_ARDUINO' +build_flags_all = + ${common.build_flags_basic} + -mfix-esp32-psram-cache-issue + +[env] +framework = arduino +board = esp32-s3-devkitc-1 +board_build.partitions = min_spiffs.csv +build_type = release +upload_speed = ${common.upload_speed} +;upload_port = COM6 +platform = ${common.platform_espressif32} +lib_deps = ${common.lib_deps_all} +build_flags = + -include "src/hal/${board.halfile}" + ${common.build_flags_all} +upload_protocol = ${common.upload_protocol} +extra_scripts = ${common.extra_scripts} +monitor_speed = ${common.monitor_speed} +monitor_filters = time, esp32_exception_decoder, default + +[env:usb] +upload_protocol = esptool + +[env:ci] +build_flags = + -include "src/hal/${sysenv.CI_HALFILE}" ; set by CI + ${common.build_flags_all} +upload_protocol = esptool \ No newline at end of file diff --git a/src/hal/ttgotdisplays3.h b/src/hal/ttgotdisplays3.h index 0c8f13aa..108dae1e 100644 --- a/src/hal/ttgotdisplays3.h +++ b/src/hal/ttgotdisplays3.h @@ -1,6 +1,6 @@ // clang-format off // upload_speed 1500000 -// board ESP32-S3-DevKitC-1 +// board esp32-s3-devkitc-1 #ifndef _TTGOTDISPLAYS3_H #define _TTGOTDISPLAYS3_H diff --git a/src/hal/ttgotdongledisplays3.h b/src/hal/ttgotdongledisplays3.h new file mode 100644 index 00000000..e198275c --- /dev/null +++ b/src/hal/ttgotdongledisplays3.h @@ -0,0 +1,31 @@ +// clang-format off +// upload_speed 1500000 +// board esp32-s3-devkitc-1 + +// see https://github.com/Xinyuan-LilyGO/T-Dongle-S3 + +#ifndef _TTGOTDONGLES3_H +#define _TTGOTDONGLES3_H + +#include + +#define HAS_LED NOT_A_PIN +#define HAS_BUTTON 0 + +#define HAS_SDCARD 2 // this board has a SD MMC card-reader/writer +#define SDCARD_SLOTWIDTH 4 // 4-line interface + +#define HAS_DISPLAY 2 // TFT-LCD +#define TFT_TYPE DISPLAY_T_DISPLAY_S3 +#define MY_DISPLAY_FLIP 1 // use if display is rotated +#define MY_DISPLAY_WIDTH 80 +#define MY_DISPLAY_HEIGHT 160 + +#define TFT_CS_PIN 4 +#define TFT_SDA_PIN 3 +#define TFT_SCL_PIN 5 +#define TFT_DC_PIN 2 +#define TFT_RES_PIN 1 +#define TFT_LEDA_PIN 38 + +#endif \ No newline at end of file diff --git a/src/hal/ttgotdongles3.h b/src/hal/ttgotdongles3.h new file mode 100644 index 00000000..caee4780 --- /dev/null +++ b/src/hal/ttgotdongles3.h @@ -0,0 +1,21 @@ +// clang-format off +// upload_speed 1500000 +// board esp32-s3-devkitc-1 + +// for pinouts see https://github.com/Xinyuan-LilyGO/T-Dongle-S3 + +#ifndef _TTGOTDONGLES3_H +#define _TTGOTDONGLES3_H + +#include + +#define HAS_LED NOT_A_PIN +#define RGB_LED_COUNT 1 +#define HAS_RGB_LED FastLED.addLeds(leds, RGB_LED_COUNT) +#define FASTLED_INTERNAL +#define HAS_BUTTON 0 // dongle button is on GPIO0 +#define HAS_SDCARD 2 // dongle has a SD MMC card-reader/writer +#define SDCARD_SLOTWIDTH 4 // dongle has 4 line interface +#define SDCARD_SLOTCONFIG { .clk = GPIO_NUM_12, .cmd = GPIO_NUM_16, .d0 = GPIO_NUM_14, .d1 = GPIO_NUM_17, .d2 = GPIO_NUM_21, .d3 = GPIO_NUM_18, .cd = SDMMC_SLOT_NO_CD, .wp = SDMMC_SLOT_NO_WP, .width = 4, .flags = 0, } + +#endif \ No newline at end of file