Skip to content

Commit

Permalink
first test Heltec Wireless Paper
Browse files Browse the repository at this point in the history
  • Loading branch information
richonguzman committed Jun 3, 2024
1 parent 005f114 commit 4355b19
Show file tree
Hide file tree
Showing 6 changed files with 117 additions and 71 deletions.
13 changes: 13 additions & 0 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,19 @@ lib_deps =
${common.lib_deps}


[env:heltec_wireless_paper]
board = esp32-s3-devkitc-1
board_build.mcu = esp32s3
build_flags =
-Werror -Wall
-DHELTEC_WP
-DHAS_SX1262
-DHAS_EPAPER
-DELEGANTOTA_USE_ASYNC_WEBSERVER=1
lib_deps =
${common.lib_deps}


[env:heltec_ht-ct62]
board = heltec_wireless_stick_lite
board_build.mcu = esp32c3
Expand Down
4 changes: 2 additions & 2 deletions src/battery_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ namespace BATTERY_Utils {
int sample;
int sampleSum = 0;
#ifdef ADC_CTRL
#if defined(HELTEC_WSL_V3) || defined(HELTEC_WIRELESS_TRACKER)
#if defined(HELTEC_WSL_V3) || defined(HELTEC_WIRELESS_TRACKER) || defined(HELTEC_WP)
digitalWrite(ADC_CTRL, HIGH);
#endif
#if defined(HELTEC_V3) || defined(HELTEC_V2)
Expand All @@ -56,7 +56,7 @@ namespace BATTERY_Utils {
}

#ifdef ADC_CTRL
#if defined(HELTEC_WSL_V3) || defined(HELTEC_WIRELESS_TRACKER)
#if defined(HELTEC_WSL_V3) || defined(HELTEC_WIRELESS_TRACKER) || defined(HELTEC_WP)
digitalWrite(ADC_CTRL, LOW);
#endif
#if defined(HELTEC_V3) || defined(HELTEC_V2)
Expand Down
13 changes: 11 additions & 2 deletions src/boards_pinout.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@
#define RADIO_BUSY_PIN 26 // GPIO26 - SX1278 IRQ ---->DIO0
#endif

#if defined(HELTEC_V3) || defined(HELTEC_WSL_V3) || defined(HELTEC_WIRELESS_TRACKER) || defined(HELTEC_WS)
#if defined(HELTEC_V3) || defined(HELTEC_WSL_V3) || defined(HELTEC_WIRELESS_TRACKER) || defined(HELTEC_WS) || defined(HELTEC_WP)
#define RADIO_SCLK_PIN 9 // SX1262 SCK
#define RADIO_MISO_PIN 11 // SX1262 MISO
#define RADIO_MOSI_PIN 10 // SX1262 MOSI
#define RADIO_CS_PIN 8 // SX1262 NSS
#define RADIO_RST_PIN 12 // SX1262 RST
#define RADIO_RST_PIN 12 // SX1262 RST
#define RADIO_DIO1_PIN 14 // SX1262 DIO1
#define RADIO_BUSY_PIN 13 // SX1262 BUSY
#endif
Expand Down Expand Up @@ -176,6 +176,15 @@
#define BOARD_I2C_SCL 6
#endif

#ifdef HELTEC_WP
#define INTERNAL_LED_PIN 18
#define BATTERY_PIN 20
#define ADC_CTRL 19
#define VEXT_CTRL 45
#define BOARD_I2C_SDA 37
#define BOARD_I2C_SCL 36
#endif

#ifdef ESP32_C3_DIY_LoRa
#define OLED_SDA 8
#define OLED_SCL 9
Expand Down
154 changes: 89 additions & 65 deletions src/display.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,16 @@
#define lineSpacing 9
#endif
#else
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#if defined(HELTEC_V3)
#define OLED_DISPLAY_HAS_RST_PIN
#endif
Adafruit_SSD1306 display(128, 64, &Wire, OLED_RST);
#ifdef HAS_EPAPER
//
#else
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#if defined(HELTEC_V3)
#define OLED_DISPLAY_HAS_RST_PIN
#endif
Adafruit_SSD1306 display(128, 64, &Wire, OLED_RST);
#endif
#endif
#endif

Expand All @@ -48,29 +52,33 @@ void setup_display() {
}
tft.setTextFont(0);
tft.fillScreen(TFT_BLACK);
#else
#ifdef OLED_DISPLAY_HAS_RST_PIN
pinMode(OLED_RST, OUTPUT);
digitalWrite(OLED_RST, LOW);
delay(20);
digitalWrite(OLED_RST, HIGH);
#endif
Wire.begin(OLED_SDA, OLED_SCL);
#else
#ifdef HAS_EPAPER
//
#else
#ifdef OLED_DISPLAY_HAS_RST_PIN
pinMode(OLED_RST, OUTPUT);
digitalWrite(OLED_RST, LOW);
delay(20);
digitalWrite(OLED_RST, HIGH);
#endif
Wire.begin(OLED_SDA, OLED_SCL);

if(!display.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS)) {
Serial.println(F("SSD1306 allocation failed"));
for(;;); // Don't proceed, loop forever
}
if (Config.display.turn180) {
display.setRotation(2);
}
display.clearDisplay();
display.setTextColor(WHITE);
display.setTextSize(1);
display.setCursor(0, 0);
display.ssd1306_command(SSD1306_SETCONTRAST);
display.ssd1306_command(1);
display.display();
if(!display.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS)) {
Serial.println(F("SSD1306 allocation failed"));
for(;;); // Don't proceed, loop forever
}
if (Config.display.turn180) {
display.setRotation(2);
}
display.clearDisplay();
display.setTextColor(WHITE);
display.setTextSize(1);
display.setCursor(0, 0);
display.ssd1306_command(SSD1306_SETCONTRAST);
display.ssd1306_command(1);
display.display();
#endif
#endif
delay(1000);
#endif
Expand All @@ -82,13 +90,21 @@ void display_toggle(bool toggle) {
#ifdef HAS_TFT
digitalWrite(TFT_BL, HIGH);
#else
display.ssd1306_command(SSD1306_DISPLAYON);
#ifdef HAS_EPAPER
//
#else
display.ssd1306_command(SSD1306_DISPLAYON);
#endif
#endif
} else {
#ifdef HAS_TFT
digitalWrite(TFT_BL, LOW);
#else
display.ssd1306_command(SSD1306_DISPLAYOFF);
#ifdef HAS_EPAPER
//
#else
display.ssd1306_command(SSD1306_DISPLAYOFF);
#endif
#endif
}
#endif
Expand Down Expand Up @@ -139,20 +155,24 @@ void show_display(const String& header, const String& line1, const String& line2
tft.setCursor(0, ((lineSpacing * 4) - 2));
tft.print(line3);
#else
display.clearDisplay();
display.setTextColor(WHITE);
display.setTextSize(1);
display.setCursor(0, 0);
display.println(header);
display.setCursor(0, 8);
display.println(line1);
display.setCursor(0, 16);
display.println(line2);
display.setCursor(0, 24);
display.println(line3);
display.ssd1306_command(SSD1306_SETCONTRAST);
display.ssd1306_command(1);
display.display();
#ifdef HAS_EPAPER
//
#else
display.clearDisplay();
display.setTextColor(WHITE);
display.setTextSize(1);
display.setCursor(0, 0);
display.println(header);
display.setCursor(0, 8);
display.println(line1);
display.setCursor(0, 16);
display.println(line2);
display.setCursor(0, 24);
display.println(line3);
display.ssd1306_command(SSD1306_SETCONTRAST);
display.ssd1306_command(1);
display.display();
#endif
#endif
delay(wait);
#endif
Expand Down Expand Up @@ -182,27 +202,31 @@ void show_display(const String& header, const String& line1, const String& line2
tft.setCursor(0, ((lineSpacing * 7) - 2));
tft.print(line6);
#else
display.clearDisplay();
display.setTextColor(WHITE);
display.setTextSize(2);
display.setCursor(0, 0);
display.println(header);
display.setTextSize(1);
display.setCursor(0, 16);
display.println(line1);
display.setCursor(0, 24);
display.println(line2);
display.setCursor(0, 32);
display.println(line3);
display.setCursor(0, 40);
display.println(line4);
display.setCursor(0, 48);
display.println(line5);
display.setCursor(0, 56);
display.println(line6);
display.ssd1306_command(SSD1306_SETCONTRAST);
display.ssd1306_command(1);
display.display();
#ifdef HAS_EPAPER
//
#else
display.clearDisplay();
display.setTextColor(WHITE);
display.setTextSize(2);
display.setCursor(0, 0);
display.println(header);
display.setTextSize(1);
display.setCursor(0, 16);
display.println(line1);
display.setCursor(0, 24);
display.println(line2);
display.setCursor(0, 32);
display.println(line3);
display.setCursor(0, 40);
display.println(line4);
display.setCursor(0, 48);
display.println(line5);
display.setCursor(0, 56);
display.println(line6);
display.ssd1306_command(SSD1306_SETCONTRAST);
display.ssd1306_command(1);
display.display();
#endif
#endif
delay(wait);
#endif
Expand Down
2 changes: 1 addition & 1 deletion src/lora_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ namespace LoRa_Utils {
state = radio.setOutputPower(Config.loramodule.power); // max value 20dB for 400M30S as it has Low Noise Amp
radio.setCurrentLimit(100); // to be validated (80 , 100)?
#endif
#if defined(HELTEC_V3) || defined(HELTEC_WSL_V3) || defined(HELTEC_WS) || defined(TTGO_T_Beam_V1_0_SX1268) || defined(TTGO_T_Beam_V1_2_SX1262)
#if defined(HAS_SX1262) || defined(TTGO_T_Beam_V1_0_SX1268)
state = radio.setOutputPower(Config.loramodule.power + 2); // values available: 10, 17, 22 --> if 20 in tracker_conf.json it will be updated to 22.
radio.setCurrentLimit(140);
#endif
Expand Down
2 changes: 1 addition & 1 deletion src/power_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ namespace POWER_Utils {
pinMode(ADC_CTRL, OUTPUT);
#endif

#ifdef HELTEC_WIRELESS_TRACKER
#if defined(HELTEC_WIRELESS_TRACKER) || defined(HELTEC_WP)
Wire.begin(BOARD_I2C_SDA, BOARD_I2C_SCL);
#endif

Expand Down

0 comments on commit 4355b19

Please sign in to comment.