My environment
[env:heltec-display] ; Heltec ESP32 Board with SSD1306 display
platform = ${com.esp32_platform}
board = heltec_wifi_lora_32_V2
build_type = debug
monitor_filters = esp32_exception_decoder
board_build.partitions = min_spiffs.csv
extra_scripts = pre:scripts/omg_firmware_version.py
lib_deps =
${com-esp.lib_deps}
${libraries.wifimanager32}
${libraries.heltec}
; ${libraries.m5stickcp}
build_flags =
${com-esp.build_flags}
${test_env.build_flags}
; *** OpenMQTTGateway Config ***
'-UZmqttDiscovery' ; disables MQTT Discovery
'-DvalueAsATopic=true'
'-DLOG_LEVEL=LOG_LEVEL_TRACE'
; *** OpenMQTTGateway Modules ***
'-DZboardHELTEC="HELTEC"'
; *** Heltec Board Options ***
'-DDEBUG_OLEDDISPLAY(...)=Serial.printf( __VA_ARGS__ )'
'-DLOG_TO_LCD=true' ; Enable log to LCD
'-DLED_ERROR=2'
'-DONBOARD_LED=25' ; Onboard LED is GPIO 25 on the Heltec Board
monitor_port = /dev/cu.SLAB_USBtoUART
monitor_speed = 921600
upload_port = /dev/cu.SLAB_USBtoUART
upload_speed = 921600
1 - Set default LCD log level to WARNING
2 - Implemented a macro based displayPrint function that will be usable across different displays
- Added logo display when idle
- Fixed log-lcd mqtt function
- Enable OLED Display on Heltec Boards
116 lines
3.4 KiB
C++
116 lines
3.4 KiB
C++
/*
|
|
OpenMQTTGateway Addon - ESP8266 or Arduino program for home automation
|
|
|
|
Act as a wifi or ethernet gateway between your 433mhz/infrared IR signal and a MQTT broker
|
|
Send and receiving command by MQTT
|
|
|
|
HELTEC ESP32 LORA - SSD1306 / Onboard 0.96-inch 128*64 dot matrix OLED display
|
|
|
|
Copyright: (c)Florian ROBERT
|
|
|
|
Contributors:
|
|
- 1technophile
|
|
- NorthernMan54
|
|
|
|
This file is part of OpenMQTTGateway.
|
|
|
|
OpenMQTTGateway is free software: you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
(at your option) any later version.
|
|
|
|
OpenMQTTGateway is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
#ifndef config_HELTEC_h
|
|
#define config_HELTEC_h
|
|
|
|
#include <Arduino.h>
|
|
#include <Wire.h>
|
|
|
|
#include "SSD1306Wire.h"
|
|
|
|
#ifdef ZboardHELTEC
|
|
# define OLED_WIDTH 128
|
|
# define OLED_HEIGHT 64
|
|
# define OLED_TEXT_BUFFER 1000
|
|
# define OLED_TEXT_ROWS 5
|
|
#endif
|
|
|
|
extern void setupHELTEC();
|
|
extern void loopHELTEC();
|
|
size_t OledPrint(String msg);
|
|
|
|
/*-------------------DEFINE LOG LEVEL----------------------*/
|
|
#ifndef LOG_LEVEL_LCD
|
|
# define LOG_LEVEL_LCD LOG_LEVEL_WARNING // Default to only display Notice level messages
|
|
#endif
|
|
#ifndef LOG_TO_LCD
|
|
# define LOG_TO_LCD false // Default to not display log messages on display
|
|
#endif
|
|
/*-------------------DEFINE MQTT TOPIC FOR CONFIG----------------------*/
|
|
#define subjectMQTTtoHELTECset "/commands/MQTTtoHELTEC/config"
|
|
|
|
// Simple construct for displaying message in lcd and oled displays
|
|
|
|
#define displayPrint(...) \
|
|
if (lowpowermode < 2) heltecPrint(__VA_ARGS__) // only print if not in low power mode
|
|
#define lpDisplayPrint(...) heltecPrint(__VA_ARGS__) // print in low power mode
|
|
|
|
void heltecPrint(char*, char*, char*);
|
|
void heltecPrint(char*, char*);
|
|
void heltecPrint(char*);
|
|
|
|
// This pattern was borrowed from HardwareSerial and modified to support the ssd1306 display
|
|
|
|
class OledSerial : public Stream {
|
|
private:
|
|
void displayIntro(int scale, int displayWidth, int displayHeight);
|
|
|
|
public:
|
|
OledSerial(int);
|
|
void begin();
|
|
void drawLogo(int logoSize, int circle1X, int circle1Y, bool circle1, bool circle2, bool circle3, bool line1, bool line2, bool name);
|
|
|
|
SSD1306Wire* display;
|
|
|
|
int available(void); // Dummy functions
|
|
int peek(void); // Dummy functions
|
|
int read(void); // Dummy functions
|
|
void flush(void); // Dummy functions
|
|
|
|
void fillScreen(OLEDDISPLAY_COLOR); // fillScreen display and set color
|
|
|
|
size_t write(uint8_t);
|
|
size_t write(const uint8_t* buffer, size_t size);
|
|
inline size_t write(const char* buffer, size_t size) {
|
|
return write((uint8_t*)buffer, size);
|
|
}
|
|
inline size_t write(const char* s) {
|
|
return write((uint8_t*)s, strlen(s));
|
|
}
|
|
inline size_t write(unsigned long n) {
|
|
return write((uint8_t)n);
|
|
}
|
|
inline size_t write(long n) {
|
|
return write((uint8_t)n);
|
|
}
|
|
inline size_t write(unsigned int n) {
|
|
return write((uint8_t)n);
|
|
}
|
|
inline size_t write(int n) {
|
|
return write((uint8_t)n);
|
|
}
|
|
|
|
protected:
|
|
};
|
|
|
|
extern OledSerial Oled;
|
|
|
|
#endif |