oled for nodes

This commit is contained in:
Timm Bogner 2023-02-25 20:56:58 -06:00
parent 62032a1d2a
commit 17d3276139
4 changed files with 33 additions and 14 deletions

View File

@ -3,10 +3,10 @@
// GATEWAY Main Functions
// Developed by Timm Bogner (timmbogner@gmail.com)
#ifndef __FDRS_FUNCTIONS_H__
#define __FDRS_FUNCTIONS_H__
#include "fdrs_datatypes.h"
#include "fdrs_globals.h"
#define FDRS_GATEWAY
#ifndef ESPNOWG_ACT
#define ESPNOWG_ACT
#endif
@ -46,8 +46,8 @@ bool is_ping = false;
DataReading fdrsData[256]; // buffer for loadFDRS()
uint8_t data_count = 0;
#include "fdrs_gateway_oled.h"
#include "fdrs_gateway_debug.h"
#include "fdrs_oled.h"
#include "fdrs_debug.h"
#include "fdrs_gateway_espnow.h"
#include "fdrs_gateway_lora.h"
#include "fdrs_gateway_wifi.h"
@ -193,4 +193,4 @@ void loopFDRS()
newData = event_clear;
}
}
#endif //__FDRS_FUNCTIONS_H__

View File

@ -6,6 +6,7 @@
//
#include <fdrs_datatypes.h>
#include <fdrs_globals.h>
#define FDRS_NODE
// CRC16 from https://github.com/4-20ma/ModbusMaster/blob/3a05ff87677a9bdd8e027d6906dc05ca15ca8ade/src/util/crc16.h#L71
@ -35,12 +36,6 @@ static uint16_t crc16_update(uint16_t crc, uint8_t a)
return crc;
}
#ifdef FDRS_DEBUG
#define DBG(a) (Serial.println(a))
#else
#define DBG(a)
#endif
#ifdef DEBUG_CONFIG
// #include "fdrs_checkConfig.h"
#endif
@ -64,8 +59,11 @@ uint32_t last_refresh;
void (*callback_ptr)(DataReading);
uint16_t subscription_list[256] = {};
bool active_subs[256] = {};
#include <fdrs_node_espnow.h>
#include <fdrs_node_lora.h>
#include "fdrs_oled.h"
#include "fdrs_debug.h"
#include "fdrs_node_espnow.h"
#include "fdrs_node_lora.h"
void beginFDRS()
{
@ -74,6 +72,11 @@ void beginFDRS()
// // find out the reset reason
// esp_reset_reason_t resetReason;
// resetReason = esp_reset_reason();
#endif
#ifdef USE_OLED
init_oled();
DBG("Display initialized!");
DBG("Hello, World!");
#endif
DBG("FDRS User Node initializing...");
DBG(" Reading ID " + String(READING_ID));

View File

@ -7,10 +7,11 @@ SSD1306Wire display(0x3c, OLED_SDA, OLED_SCL); // ADDRESS, SDA, SCL
void draw_OLED_header()
{
#ifdef FDRS_GATEWAY
display.setFont(ArialMT_Plain_10);
display.clear();
display.setTextAlignment(TEXT_ALIGN_LEFT);
display.drawString(0, 0, String(UNIT_MAC, HEX));
display.drawString(0, 0, "MAC: " + String(UNIT_MAC, HEX));
display.setTextAlignment(TEXT_ALIGN_CENTER);
display.drawString(63, 0, OLED_HEADER);
display.setTextAlignment(TEXT_ALIGN_RIGHT);
@ -18,7 +19,22 @@ void draw_OLED_header()
display.display();
display.setTextAlignment(TEXT_ALIGN_LEFT);
display.setFont(ArialMT_Plain_10);
#endif
#ifdef FDRS_NODE
display.setFont(ArialMT_Plain_10);
display.clear();
display.setTextAlignment(TEXT_ALIGN_LEFT);
display.drawString(0, 0, "ID: " + String(READING_ID));
display.setTextAlignment(TEXT_ALIGN_CENTER);
display.drawString(63, 0, OLED_HEADER);
display.setTextAlignment(TEXT_ALIGN_RIGHT);
display.drawString(127, 0, "GW: " + String(GTWY_MAC, HEX));
display.display();
display.setTextAlignment(TEXT_ALIGN_LEFT);
display.setFont(ArialMT_Plain_10);
#endif
}
void debug_OLED(String debug_text)
{
draw_OLED_header();