Skip to content

Commit

Permalink
remove multiple MorseOutput display hardcoding, add support for Displ…
Browse files Browse the repository at this point in the history
…ayWrapper and Heltec VM-T190 (#113)
  • Loading branch information
haklein authored Jan 28, 2025
1 parent 476e7de commit 5cb0e3a
Show file tree
Hide file tree
Showing 3 changed files with 95 additions and 19 deletions.
46 changes: 31 additions & 15 deletions Software/src/Version 6/MorseOutput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,33 @@

////////////////////////////// New scrolling display

#ifndef CONFIG_DISPLAYWRAPPER
/// circular buffer: 14 chars by NoOfLines lines (bottom 3 are visible)
#define NoOfLines 15
#define NoOfCharsPerLine 14
#define SCROLL_TOP 15
#define LINE_HEIGHT 16
#define C_WIDTH 9
#else
#define NoOfCharsPerLine 512
#define LINE_HEIGHT display.getStringHeight("A")
#define C_WIDTH display.getStringWidth("A")
#define SCROLL_TOP display.getHeight()==64 ? 15 : 31
#endif

#include <Arduino.h>
#include "MorseOutput.h"
#include "morsedefs.h"
#include "wklfonts.h"
#include "MorsePreferences.h"

#ifndef CONFIG_DISPLAYWRAPPER
#include "wklfonts.h"
#include "SSD1306Wire.h"
SSD1306Wire display(0x3c, OLED_SDA, OLED_SCL, GEOMETRY_128_64, I2C_TWO, 700000);
#else
#include "DisplayWrapper.h"
DisplayWrapper display;
#endif

#ifdef CONFIG_SOUND_I2S
#include "I2S_Sidetone.hpp"
Expand Down Expand Up @@ -211,7 +223,11 @@ void MorseOutput::printToScroll_internal(FONT_ATTRIB style, String text, boolean
text.replace("\n", "");
l = text.length();
}
#ifdef CONFIG_DISPLAYWRAPPER
int textTooLong = (screenPos + l > display.getWidth()/display.getStringWidth("A"));
#else
int textTooLong = (screenPos + l > NoOfCharsPerLine);
#endif

if (textTooLong) { // we need to scroll up and start a new line
MorseOutput::newLine(scroll);
Expand Down Expand Up @@ -301,7 +317,7 @@ void MorseOutput::refreshScrollLine(int bufferLine, int displayLine) {
uint8_t charsPrinted;

display.setColor(BLACK);
display.fillRect(0, SCROLL_TOP + displayLine * LINE_HEIGHT , 127, LINE_HEIGHT + 1); // black out the line on screen
display.fillRect(0, SCROLL_TOP + displayLine * LINE_HEIGHT , display.getWidth()-1, LINE_HEIGHT + 1); // black out the line on screen
for (int i = 0; (c = textBuffer[bufferLine][i]) ; ++i) {
// if (c == ' ') DEBUG("Blank!");
if (c < 5) { /// a flag
Expand Down Expand Up @@ -415,7 +431,7 @@ uint8_t MorseOutput::printOnScrollSmall(uint8_t line, FONT_ATTRIB how, uint8_t x
void MorseOutput::clearThreeLines() {
for (int i = 0; i < 3; ++i) {
display.setColor(BLACK);
display.fillRect(0, SCROLL_TOP + i * LINE_HEIGHT , 127, LINE_HEIGHT + 1);
display.fillRect(0, SCROLL_TOP + i * LINE_HEIGHT , display.getWidth()-1, LINE_HEIGHT + 1);
display.setColor(WHITE);
}
}
Expand Down Expand Up @@ -456,12 +472,12 @@ void MorseOutput::displayScrollBar(boolean visible) { /// display a scr

if (visible) {
display.setColor(WHITE);
display.drawVerticalLine(127, 15, 49);
display.drawVerticalLine(display.getWidth()-1, 15, 49);
display.setColor(BLACK);
display.drawVerticalLine(127, 15 + (relPos * (49 - l_bar) / maxPos), l_bar);
display.drawVerticalLine(display.getWidth()-1, 15 + (relPos * (49 - l_bar) / maxPos), l_bar);
} else {
display.setColor(BLACK);
display.drawVerticalLine(127, 15, 49);
display.drawVerticalLine(display.getWidth()-1, 15, 49);
}
display.display();
resetTOT();
Expand Down Expand Up @@ -505,7 +521,7 @@ void MorseOutput::displayEmptyBattery(void (*f)()) {

/// display volume as a progress bar: vol = 1-100
void MorseOutput::displayVolume (boolean speedsetting, uint8_t volume) {
drawVolumeCtrl(speedsetting ? false : true, 93, 0, 28, 15, volume);
drawVolumeCtrl(speedsetting ? false : true, display.getWidth()-35, 0, 28, SCROLL_TOP, volume);
display.display();
}

Expand All @@ -520,11 +536,11 @@ void MorseOutput::updateSMeter(int rssi) {
if (wasZero)
return;
else {
drawVolumeCtrl( false, 93, 0, 28, 15, 0);
drawVolumeCtrl( false, display.getWidth()-35, 0, 28, 15, 0);
wasZero = true;
}
else {
drawVolumeCtrl( false, 93, 0, 28, 15, constrain(map(rssi, -150, -20, 0, 100), 0, 100));
drawVolumeCtrl( false, display.getWidth()-35, 0, 28, 15, constrain(map(rssi, -150, -20, 0, 100), 0, 100));
wasZero = false;
}
display.display();
Expand All @@ -544,14 +560,14 @@ void MorseOutput::drawInputStatus( boolean on) {

void MorseOutput::dispLoraLogo() { /// display a small logo in the top right corner to indicate we operate with LoRa
display.setColor(BLACK);
display.drawXbm(121, 2, lora_width, lora_height, lora_bits);
display.drawXbm(display.getWidth()-7, 2, lora_width, lora_height, lora_bits);
display.setColor(WHITE);
display.display();
}

void MorseOutput::dispWifiLogo() { // display a small logo in the top right corner to indicate we operate with WiFi
display.setColor(BLACK);
display.drawXbm(121, 2, wifi_width, wifi_height, wifi_bits);
display.drawXbm(display.getWidth()-7, 2, wifi_width, wifi_height, wifi_bits);
display.setColor(WHITE);
display.display();
}
Expand All @@ -570,25 +586,25 @@ void MorseOutput::printOnStatusLine(boolean strong, uint8_t xpos, String string)
display.setTextAlignment(TEXT_ALIGN_LEFT);
uint8_t w = display.getStringWidth(string);
display.setColor(WHITE);
display.fillRect(xpos * 7, 0 , w, 15);
display.fillRect(xpos * display.getStringWidth("A"), 0 , w, LINE_HEIGHT-1);
display.setColor(BLACK);
display.drawString(xpos * 7, 0, string);
display.drawString(xpos * display.getStringWidth("A"), 0, string);
display.setColor(WHITE);
display.display();
resetTOT();
}

void MorseOutput::clearStatusLine() { // the status line is at the top, and inverted!
display.setColor(WHITE);
display.fillRect(0, 0, 128, 15);
display.fillRect(0, 0, display.getWidth(), LINE_HEIGHT-1);
display.setColor(BLACK);

display.display();
}

void MorseOutput::clearLine(uint8_t line) { /// clear a line - display is done somewhere else!
display.setColor(BLACK);
display.fillRect(0, SCROLL_TOP + line * LINE_HEIGHT , 127, LINE_HEIGHT+1);
display.fillRect(0, SCROLL_TOP + line * LINE_HEIGHT , display.getWidth()-1, LINE_HEIGHT+1);
display.setColor(WHITE);
}

Expand Down
12 changes: 8 additions & 4 deletions Software/src/Version 6/m32_v6.ino
Original file line number Diff line number Diff line change
Expand Up @@ -470,9 +470,13 @@ void setup()
pinMode(modeButtonPin, INPUT);
#endif

#ifndef VEXT_ON_VALUE
#define VEXT_ON_VALUE LOW
#endif

#ifdef PIN_VEXT
pinMode(PIN_VEXT, OUTPUT);
digitalWrite(PIN_VEXT, LOW);
digitalWrite(PIN_VEXT, VEXT_ON_VALUE);
#endif

//DEBUG("Volt: " + String(volt));
Expand Down Expand Up @@ -2156,10 +2160,10 @@ int16_t batteryVoltage() { /// measure battery voltage and return result in
#ifdef PIN_VEXT
// board version 3 requires Vext being on for reading the battery voltage
if (MorsePreferences::boardVersion == 3)
digitalWrite(PIN_VEXT,LOW);
digitalWrite(PIN_VEXT,VEXT_ON_VALUE);
// board version 4 requires Vext being off for reading the battery voltage
else if (MorsePreferences::boardVersion == 4)
digitalWrite(PIN_VEXT,HIGH);
digitalWrite(PIN_VEXT,! VEXT_ON_VALUE);
#endif
#ifdef ARDUINO_heltec_wifi_kit_32_V3
digitalWrite(ADC_Ctrl,LOW);
Expand Down Expand Up @@ -2254,7 +2258,7 @@ void shutMeDown() {
delay(100);
MorseOutput::soundSuspend();
#ifdef PIN_VEXT
digitalWrite(PIN_VEXT,HIGH);
digitalWrite(PIN_VEXT, ! VEXT_ON_VALUE);
delay(100);
#endif
/*esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_PERIPH, ESP_PD_OPTION_ON);
Expand Down
56 changes: 56 additions & 0 deletions Software/src/platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -160,3 +160,59 @@ lib_deps =
${common.lib_deps_external}
https://github.com/haklein/cw-i2s-sidetone.git
WiFiClientSecure

[env:heltec-vision-master-t190]
platform = espressif32
board = heltec_wifi_lora_32_V3
framework = arduino
monitor_speed = 115200
upload_speed = 921600
board_upload.use_1200bps_touch = true

build_flags =
-D INTERNAL_PULLUP=1
-D SKIP_BATTERY_PROTECT=1
-D SKIP_LEGACY_PINDEFS=1
-D LORA_DISABLED=1
-D PIN_TOUCH_LEFT=4
-D PIN_TOUCH_RIGHT=3
-D PIN_ROT_DT=12
-D PIN_ROT_CLK=43
-D PIN_ROT_BTN=14
-D PIN_PADDLE_LEFT=16
-D PIN_PADDLE_RIGHT=15
-D PIN_KEYER=44
-D CONFIG_SOUND_I2S=1
-D CONFIG_DECODER_I2S=1
-D CONFIG_I2S_BCK_PIN=10
-D CONFIG_I2S_LRCK_PIN=9
-D CONFIG_I2S_DATA_PIN=8
-D CONFIG_I2S_DATA_IN_PIN=11
-D CONFIG_TLV320AIC3100=1
-D CONFIG_TLV320AIC3100_SDA=2
-D CONFIG_TLV320AIC3100_SCL=1
-D PIN_VEXT=5
-D VEXT_ON_VALUE=HIGH
-D PIN_VTFT_CTRL=7
-D CONFIG_DISPLAYWRAPPER=1
-D ST7789_DRIVER=1
-D TFT_WIDTH=170
-D TFT_HEIGHT=320
-D TFT_MISO=-1
-D TFT_MOSI=48
-D TFT_SCLK=38
-D TFT_CS=39
-D TFT_DC=47
-D TFT_RST=40
-D TFT_BL=17
-D TFT_OFFSET_X=35 ; T190 & CYD 1.9
-D HELTEC_VISION_MASTER_T190

lib_deps =
bblanchon/[email protected]
madhephaestus/ESP32Encoder @ ^0.11.7
https://github.com/haklein/cw-i2s-sidetone.git
https://github.com/haklein/tlv320aic31xx.git
https://github.com/haklein/DisplayWrapper.git
WiFiClientSecure
lovyan03/LovyanGFX

0 comments on commit 5cb0e3a

Please sign in to comment.