Skip to content

Instantly share code, notes, and snippets.

@liamcottle
Created December 30, 2024 12:35
Show Gist options
  • Save liamcottle/df8866c072638b0f318594b4f3064cf2 to your computer and use it in GitHub Desktop.
Save liamcottle/df8866c072638b0f318594b4f3064cf2 to your computer and use it in GitHub Desktop.
Heltec T114 Display in Arduino
/**
* Simple demo for using Heltec T114 Display
* Author: Liam Cottle <[email protected]>
*
* Install Heltec_nRF52 Board from GitHub
* - https://github.com/HelTecAutomation/Heltec_nRF52
*
* Once board is installed, you may need to "chmod +x" the following files:
* - ~/Documents/Arduino/hardware/heltec/Heltec_nRF52/tools/uf2conv/uf2conv.py
* - ~/Documents/Arduino/hardware/heltec/Heltec_nRF52/tools/adafruit-nrfutil/macos/adafruit-nrfutil
*
* I also had to modify a few of the platform*.txt files, to remove the "python" prefix on macOS, otherwise I got "file not found"
* - tools.uf2conv.cmd.macosx
*
* Sources:
* - https://github.com/meshtastic/firmware/blob/58d80b8557a849b7d3331fb3318d521a0c6cbcab/variants/heltec_mesh_node_t114/variant.h
* - http://community.heltec.cn/t/heltec-meshnode-t114-display/17164
* - https://github.com/lyusupov/SoftRF/blob/80d8eb42d7df0500614b7c7f1f7217f672b5bfbf/software/firmware/source/SoftRF/src/platform/nRF52.cpp#L1057
*/
#include <Adafruit_GFX.h>
#include <Adafruit_ST7789.h>
#include <Arduino.h>
/* ADC */
#define SOC_GPIO_PIN_T114_ADC_EN 6 // P0.06
/* Ext. sensors */
#define SOC_GPIO_PIN_T114_VEXT_EN 21 // P0.21
/* TFT */
#define TFT_WIDTH 135
#define TFT_HEIGHT 240
#define SOC_GPIO_PIN_T114_TFT_MOSI 9 // P1.09
#define SOC_GPIO_PIN_T114_TFT_MISO 11 // P1.11 NC
#define SOC_GPIO_PIN_T114_TFT_SCK 8 // P1.08
#define SOC_GPIO_PIN_T114_TFT_SS 11 // P0.11
#define SOC_GPIO_PIN_T114_TFT_DC 12 // P0.12
#define SOC_GPIO_PIN_T114_TFT_RST 2 // P0.02
#define SOC_GPIO_PIN_T114_TFT_EN 3 // P0.03
#define SOC_GPIO_PIN_T114_TFT_BLGT 15 // P0.15
void setup(void) {
// enable vext (not required for screen to work, but probably for antenna boost?)
digitalWrite(SOC_GPIO_PIN_T114_VEXT_EN, HIGH);
pinMode(SOC_GPIO_PIN_T114_VEXT_EN, OUTPUT);
// enable power to display
digitalWrite(SOC_GPIO_PIN_T114_TFT_EN, LOW);
pinMode(SOC_GPIO_PIN_T114_TFT_EN, OUTPUT);
// enable backlight led (display is off without this)
digitalWrite(SOC_GPIO_PIN_T114_TFT_BLGT, LOW);
pinMode(SOC_GPIO_PIN_T114_TFT_BLGT, OUTPUT);
// enable adc (not required for screen to work, but probably for measuring battery level)
digitalWrite(SOC_GPIO_PIN_T114_ADC_EN, HIGH);
pinMode(SOC_GPIO_PIN_T114_ADC_EN, OUTPUT);
// init tft
Adafruit_ST7789 tft(&SPI1, SOC_GPIO_PIN_T114_TFT_SS, SOC_GPIO_PIN_T114_TFT_DC, SOC_GPIO_PIN_T114_TFT_RST);
tft.init(TFT_WIDTH, TFT_HEIGHT);
tft.setRotation(3);
tft.setSPISpeed(40000000);
// show something on the display
tft.fillScreen(ST77XX_BLACK); // clear the screen
tft.setTextColor(ST77XX_WHITE); // set text color to white
tft.setTextSize(2); // set text size
tft.setCursor(0, 0); // set cursor position
tft.print("Testing...");
}
void loop() {
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment