Skip to content

Commit f5fd529

Browse files
authored
Merge pull request #24 from meshtastic/chore/merge-upstream-oltaco
chore: merge upstream oltaco/master (ST7735 refactor, RAK3401/T096/T1 board support)
2 parents 18c3dc5 + 2c78941 commit f5fd529

15 files changed

Lines changed: 659 additions & 100 deletions

File tree

AGENTS.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,9 @@ Each board directory can carry:
6767
`src/screen.c`.
6868
- `board.mk` — Makefile board config (`MCU_SUB_VARIANT`, per-board
6969
`CFLAGS` like the BLE `DEVICE_NAME`).
70-
- `board.cmake`**only exists for 2 of 14 boards** (`heltec_t114`,
71-
`thinknode_m1`). `cmake -DBOARD=<anything else>` fails outright. Nobody
70+
- `board.cmake`**only exists for 4 of 17 boards** (`heltec_t096`,
71+
`heltec_t1`, `heltec_t114`, `thinknode_m1`). `cmake -DBOARD=<anything
72+
else>` fails outright. Nobody
7273
uses the CMake path in practice (CI and `tools/build_all.py` both use
7374
`make`); don't assume feature parity between the two build systems.
7475
- `pinconfig.c` — present on some boards, board-specific pin table.

README.md

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ Current release: **OTAFIX 2.2** — see [changelog.md](changelog.md) for version
1111

1212
- [How this fits together](#how-this-fits-together)
1313
- [Boards supported](#boards-supported)
14+
- [BLE advertising names](#ble-advertising-names)
1415
- [Installation](#installation)
1516
- [Bootloader upgrade from the Meshtastic Android app](#bootloader-upgrade-from-the-meshtastic-android-app)
1617
- [Troubleshooting](#troubleshooting)
@@ -69,10 +70,13 @@ bootloader and SoftDevice zip package").
6970
- Elecrow ThinkNode M1
7071
- Elecrow ThinkNode M3
7172
- Elecrow ThinkNode M6
72-
- Heltec Automation Mesh Node T114 / HT-nRF5262
73+
- Heltec T096
74+
- Heltec T1
75+
- Heltec T114 / HT-nRF5262
7376
- LilyGO T-Echo
7477
- Minewsemi MX25LE01
7578
- Nologo ProMicro NRF52840 (aka SuperMini NRF52840)
79+
- RAK 3401
7680
- RAK 4631 ([See note](#notes-on-rak4631-bootloader))
7781
- RAK WisMesh Tag
7882
- Seeed Studio SenseCAP Card Tracker T1000-E
@@ -83,6 +87,29 @@ bootloader and SoftDevice zip package").
8387

8488
If there is another nRF52840-based Meshtastic board you would like to see supported, please [raise a GitHub issue](https://github.com/meshtastic/Adafruit_nRF52_Bootloader_OTAFIX/issues/new/choose) — or see [Adding a new board](./CONTRIBUTING.md#adding-a-new-board) in `CONTRIBUTING.md` if you want to submit it yourself.
8589

90+
## BLE advertising names
91+
92+
When in OTA DFU mode, devices advertise using a board-specific name rather than the generic `AdaDFU`.
93+
94+
| Board | OTA DFU advertising name |
95+
| ---------------------------- | ------------------------ |
96+
| Elecrow ThinkNode M1 | `TNM1_DFU` |
97+
| Elecrow ThinkNode M3 | `TNM3_DFU` |
98+
| Elecrow ThinkNode M6 | `TNM6_DFU` |
99+
| Heltec T096 | `T096_DFU` |
100+
| Heltec T1 | `T1_DFU` |
101+
| Heltec T114 | `T114_DFU` |
102+
| LILYGO T-Echo | `LGTE_DFU` |
103+
| Minewsemi MX25LE01 | `MX25_DFU` |
104+
| ProMicro NRF52840 | `PROM_DFU` |
105+
| RAK 4631 | `4631_DFU` |
106+
| RAK 3401 | `3401_DFU` |
107+
| RAK WisMesh Tag | `RTAG_DFU` |
108+
| Seeed SenseCAP Solar Node P1 | `SCAP_DFU` |
109+
| Seeed T1000e | `T1KE_DFU` |
110+
| Seeed WioTracker L1 | `WTL1_DFU` |
111+
| XIAO NRF52 BLE / SENSE | `XIAO_DFU` |
112+
86113
---
87114

88115
## Installation

src/boards/boards.c

Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -777,3 +777,147 @@ static void tft_controller_init(void) {
777777
}
778778

779779
#endif
780+
781+
#ifdef DISPLAY_CONTROLLER_ST7735
782+
783+
#define ST_CMD_DELAY 0x80 // special signifier for command lists
784+
785+
// ST77XX common commands (shared with ST7789)
786+
#define ST77XX_NOP 0x00
787+
#define ST77XX_SWRESET 0x01
788+
#define ST77XX_RDDID 0x04
789+
#define ST77XX_RDDST 0x09
790+
791+
#define ST77XX_SLPIN 0x10
792+
#define ST77XX_SLPOUT 0x11
793+
#define ST77XX_PTLON 0x12
794+
#define ST77XX_NORON 0x13
795+
796+
#define ST77XX_INVOFF 0x20
797+
#define ST77XX_INVON 0x21
798+
#define ST77XX_DISPOFF 0x28
799+
#define ST77XX_DISPON 0x29
800+
#define ST77XX_CASET 0x2A
801+
#define ST77XX_RASET 0x2B
802+
#define ST77XX_RAMWR 0x2C
803+
#define ST77XX_RAMRD 0x2E
804+
805+
#define ST77XX_PTLAR 0x30
806+
#define ST77XX_TEOFF 0x34
807+
#define ST77XX_TEON 0x35
808+
#define ST77XX_MADCTL 0x36
809+
#define ST77XX_VSCSAD 0x37
810+
#define ST77XX_COLMOD 0x3A
811+
812+
#define ST77XX_MADCTL_MY 0x80
813+
#define ST77XX_MADCTL_MX 0x40
814+
#define ST77XX_MADCTL_MV 0x20
815+
#define ST77XX_MADCTL_ML 0x10
816+
#define ST77XX_MADCTL_RGB 0x00
817+
818+
#define ST77XX_RDID1 0xDA
819+
#define ST77XX_RDID2 0xDB
820+
#define ST77XX_RDID3 0xDC
821+
#define ST77XX_RDID4 0xDD
822+
823+
// ST7735-specific commands
824+
#define ST7735_FRMCTR1 0xB1
825+
#define ST7735_FRMCTR2 0xB2
826+
#define ST7735_FRMCTR3 0xB3
827+
#define ST7735_INVCTR 0xB4
828+
#define ST7735_PWCTR1 0xC0
829+
#define ST7735_PWCTR2 0xC1
830+
#define ST7735_PWCTR3 0xC2
831+
#define ST7735_PWCTR4 0xC3
832+
#define ST7735_PWCTR5 0xC4
833+
#define ST7735_VMCTR1 0xC5
834+
#define ST7735_GMCTRP1 0xE0
835+
#define ST7735_GMCTRN1 0xE1
836+
#define ST7735_MADCTL_BGR 0x08
837+
838+
// Some ready-made 16-bit ('565') color settings:
839+
#define ST77XX_BLACK 0x0000
840+
#define ST77XX_WHITE 0xFFFF
841+
#define ST77XX_RED 0xF800
842+
#define ST77XX_GREEN 0x07E0
843+
#define ST77XX_BLUE 0x001F
844+
#define ST77XX_CYAN 0x07FF
845+
#define ST77XX_MAGENTA 0xF81F
846+
#define ST77XX_YELLOW 0xFFE0
847+
#define ST77XX_ORANGE 0xFC00
848+
849+
static void tft_controller_init(void) {
850+
// Init commands for ST7735 mini 160x80 screens
851+
// Based on Adafruit INITR_MINI160x80 sequence
852+
uint8_t cmdinit_st7735[] = {
853+
#if !defined(DISPLAY_PIN_RST) || (DISPLAY_PIN_RST < 0)
854+
// Software reset if rst pin not available
855+
ST77XX_SWRESET, ST_CMD_DELAY, 150,
856+
#endif
857+
// Out of sleep mode, w/delay 255 = 500ms
858+
ST77XX_SLPOUT, ST_CMD_DELAY, 255,
859+
// Frame rate control - normal mode (3 args)
860+
ST7735_FRMCTR1, 3, 0x01, 0x2C, 0x2D,
861+
// Frame rate control - idle mode (3 args)
862+
ST7735_FRMCTR2, 3, 0x01, 0x2C, 0x2D,
863+
// Frame rate control - partial mode (6 args)
864+
ST7735_FRMCTR3, 6, 0x01, 0x2C, 0x2D, 0x01, 0x2C, 0x2D,
865+
// Display inversion control (1 arg)
866+
ST7735_INVCTR, 1, 0x07,
867+
// Power control 1 (3 args)
868+
ST7735_PWCTR1, 3, 0xA2, 0x02, 0x84,
869+
// Power control 2 (1 arg)
870+
ST7735_PWCTR2, 1, 0xC5,
871+
// Power control 3 - normal mode (2 args)
872+
ST7735_PWCTR3, 2, 0x0A, 0x00,
873+
// Power control 4 - idle mode (2 args)
874+
ST7735_PWCTR4, 2, 0x8A, 0x2A,
875+
// Power control 5 - partial mode (2 args)
876+
ST7735_PWCTR5, 2, 0x8A, 0xEE,
877+
// VCOM control (1 arg)
878+
ST7735_VMCTR1, 1, 0x0E,
879+
// Inversion off (required for Heltec T096)
880+
ST77XX_INVOFF, 0,
881+
// Set color mode, 1 arg: 16-bit color (0x05 for ST7735)
882+
ST77XX_COLMOD, 1 + ST_CMD_DELAY, 0x05, 10,
883+
// Mem access ctrl, 1 arg: row/col addr, color order
884+
ST77XX_MADCTL, 1, DISPLAY_MADCTL,
885+
// Column addr set, 4 args: XSTART/XEND (132 wide framebuffer)
886+
ST77XX_CASET, 4, 0x00, 0x00, 0x00, 0x83,
887+
// Row addr set, 4 args: YSTART/YEND (162 tall framebuffer)
888+
ST77XX_RASET, 4, 0x00, 0x00, 0x00, 0xA1,
889+
// Positive gamma correction (16 args)
890+
ST7735_GMCTRP1, 16,
891+
0x02, 0x1C, 0x07, 0x12, 0x37, 0x32, 0x29, 0x2D,
892+
0x29, 0x25, 0x2B, 0x39, 0x00, 0x01, 0x03, 0x10,
893+
// Negative gamma correction (16 args)
894+
ST7735_GMCTRN1, 16,
895+
0x03, 0x1D, 0x07, 0x06, 0x2E, 0x2C, 0x29, 0x2D,
896+
0x2E, 0x2E, 0x37, 0x3F, 0x00, 0x00, 0x02, 0x10,
897+
// Normal display on, w/delay 10ms
898+
ST77XX_NORON, ST_CMD_DELAY, 10,
899+
// Main screen turn on, w/delay 100ms
900+
ST77XX_DISPON, ST_CMD_DELAY, 100
901+
};
902+
903+
size_t count = 0;
904+
while (count < sizeof(cmdinit_st7735)) {
905+
uint8_t const cmd = cmdinit_st7735[count++];
906+
uint8_t const cmd_arg = cmdinit_st7735[count++];
907+
uint8_t const has_delay = cmd_arg & ST_CMD_DELAY;
908+
uint8_t const narg = cmd_arg & ~ST_CMD_DELAY;
909+
910+
tft_cmd(cmd, cmdinit_st7735 + count, narg);
911+
count += narg;
912+
913+
if (has_delay) {
914+
uint16_t delay = (uint16_t) cmdinit_st7735[count++];
915+
if (delay == 255) {
916+
delay = 500; // If 255, delay for 500 ms
917+
}
918+
NRFX_DELAY_MS(delay);
919+
}
920+
}
921+
}
922+
923+
#endif

src/boards/heltec_t096/board.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
set(MCU_VARIANT nrf52840)

src/boards/heltec_t096/board.h

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
/*
2+
* The MIT License (MIT)
3+
*
4+
* Copyright (c) 2018 Ha Thach for Adafruit Industries
5+
*
6+
* Permission is hereby granted, free of charge, to any person obtaining a copy
7+
* of this software and associated documentation files (the "Software"), to deal
8+
* in the Software without restriction, including without limitation the rights
9+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
* copies of the Software, and to permit persons to whom the Software is
11+
* furnished to do so, subject to the following conditions:
12+
*
13+
* The above copyright notice and this permission notice shall be included in
14+
* all copies or substantial portions of the Software.
15+
*
16+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22+
* THE SOFTWARE.
23+
*/
24+
25+
#ifndef _HELTEC_T096_H
26+
#define _HELTEC_T096_H
27+
28+
#define _PINNUM(port, pin) ((port)*32 + (pin))
29+
30+
/*------------------------------------------------------------------*/
31+
/* LED
32+
*------------------------------------------------------------------*/
33+
#define LEDS_NUMBER 1
34+
#define LED_PRIMARY_PIN _PINNUM(0, 28) // White
35+
#define LED_STATE_ON 0
36+
37+
// #define LED_NEOPIXEL _PINNUM(0, 14)
38+
// #define NEOPIXEL_POWER_PIN _PINNUM(0, 21)
39+
// #define NEOPIXELS_NUMBER 2
40+
#define BOARD_RGB_BRIGHTNESS 0x040404
41+
42+
/*------------------------------------------------------------------*/
43+
/* BUTTON
44+
*------------------------------------------------------------------*/
45+
#define BUTTONS_NUMBER 2
46+
#define BUTTON_1 _PINNUM(1, 10)
47+
#define BUTTON_2 _PINNUM(1, 2) // stock bootloader has this set to 34
48+
#define BUTTON_PULL NRF_GPIO_PIN_PULLUP
49+
50+
//--------------------------------------------------------------------+
51+
// Display
52+
//--------------------------------------------------------------------+
53+
54+
// VSensor required to power the display
55+
#define DISPLAY_VSENSOR_PIN _PINNUM(0, 26)
56+
#define DISPLAY_VSENSOR_ON 1
57+
58+
// #define DISPLAY_CONTROLLER_ST7789
59+
#define DISPLAY_CONTROLLER_ST7735
60+
61+
#define DISPLAY_PIN_SCK _PINNUM(0, 20)
62+
#define DISPLAY_PIN_MOSI _PINNUM(0, 17)
63+
64+
#define DISPLAY_PIN_CS _PINNUM(0, 22)
65+
#define DISPLAY_PIN_DC _PINNUM(0, 15)
66+
#define DISPLAY_PIN_RST _PINNUM(0, 13)
67+
#define DISPLAY_PIN_BL _PINNUM(1, 12)
68+
#define DISPLAY_BL_ON 0 // GPIO state to enable back light
69+
70+
#define DISPLAY_WIDTH 160
71+
#define DISPLAY_HEIGHT 80
72+
73+
// USB FACING LEFT
74+
#define DISPLAY_COL_OFFSET 24
75+
#define DISPLAY_ROW_OFFSET 0
76+
#define DISPLAY_MADCTL (ST77XX_MADCTL_MY | ST7735_MADCTL_BGR)
77+
78+
// USB FACING RIGHT
79+
//#define DISPLAY_COL_OFFSET 52
80+
//#define DISPLAY_ROW_OFFSET 40
81+
//#define DISPLAY_MADCTL (ST77XX_MADCTL_MX | ST7735_MADCTL_BGR)
82+
83+
#define DISPLAY_VSCSAD 0
84+
85+
#define DISPLAY_TITLE "T096"
86+
#define BANNER_TEXT "meshtastic.org - OTAFIX"
87+
#define FONT_SIZE_LARGE 3
88+
#define NOLABELS
89+
90+
#define SCREEN_BAR1_Y 0
91+
#define SCREEN_BAR1_H 32
92+
#define SCREEN_BAR2_Y 32
93+
#define SCREEN_BAR2_H 36
94+
#define SCREEN_BAR3_Y 68
95+
#define SCREEN_BAR3_H 12
96+
#define BANNER_TEXT_X 0
97+
#define BANNER_TEXT_Y 70
98+
#define DISPLAY_TITLE_Y 1
99+
#define UF2_VERSION_BASE_Y 24
100+
#define BLE_OTA_Y 38
101+
#define DRAG 34
102+
#define DRAGX 4
103+
104+
//--------------------------------------------------------------------+
105+
// BLE OTA
106+
//--------------------------------------------------------------------+
107+
#define BLEDIS_MANUFACTURER "Heltec AutoMation"
108+
#define BLEDIS_MODEL "Tracker"
109+
110+
//--------------------------------------------------------------------+
111+
// USB
112+
//--------------------------------------------------------------------+
113+
#define USB_DESC_VID 0x239A
114+
#define USB_DESC_UF2_PID 0x0071
115+
#define USB_DESC_CDC_ONLY_PID 0x0071
116+
117+
//------------- UF2 -------------//
118+
#define UF2_PRODUCT_NAME "Heltec-T096"
119+
#define UF2_VOLUME_LABEL "HeltecT096"
120+
#define UF2_BOARD_ID "Heltec-T096-v1"
121+
#define UF2_INDEX_URL "http://heltec.org/"
122+
123+
#endif

src/boards/heltec_t096/board.mk

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
MCU_SUB_VARIANT = nrf52840
2+
CFLAGS += -DDEVICE_NAME='"T096_DFU"'
3+

src/boards/heltec_t096/pinconfig.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#include "boards.h"
2+
#include "uf2/configkeys.h"
3+
4+
__attribute__((used, section(".bootloaderConfig")))
5+
const uint32_t bootloaderConfig[] =
6+
{
7+
/* CF2 START */
8+
CFG_MAGIC0, CFG_MAGIC1, // magic
9+
5, 100, // used entries, total entries
10+
11+
204, 0x100000, // FLASH_BYTES = 0x100000
12+
205, 0x40000, // RAM_BYTES = 0x40000
13+
208, (USB_DESC_VID << 16) | USB_DESC_UF2_PID, // BOOTLOADER_BOARD_ID = USB VID+PID, used for verification when updating bootloader via uf2
14+
209, 0xada52840, // UF2_FAMILY = 0xada52840
15+
210, 0x20, // PINS_PORT_SIZE = PA_32
16+
17+
0, 0, 0, 0, 0, 0, 0, 0
18+
/* CF2 END */
19+
};

src/boards/heltec_t1/board.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
set(MCU_VARIANT nrf52840)

0 commit comments

Comments
 (0)