mirror of
https://github.com/meshtastic/firmware.git
synced 2025-10-05 22:42:08 +00:00
Modify macro definition, remove and open some features
This commit is contained in:
parent
d6d29a7959
commit
194580532a
@ -13,7 +13,7 @@
|
||||
#ifdef ARCH_PORTDUINO
|
||||
#include "platform/portduino/PortduinoGlue.h"
|
||||
#endif
|
||||
#if defined(M5STACK_COREBASIC) || defined(M5STACK_CORE2)
|
||||
#if defined(M5STACK_CORE2)
|
||||
#include <M5Unified.h>
|
||||
#endif
|
||||
#define DEBUG_BUTTONS 0
|
||||
@ -126,9 +126,6 @@ int32_t ButtonThread::runOnce()
|
||||
switch (btnEvent) {
|
||||
case BUTTON_EVENT_PRESSED: {
|
||||
LOG_BUTTON("press!\n");
|
||||
#if defined(M5STACK_COREBASIC)
|
||||
M5.Speaker.tone(1000, 100);
|
||||
#endif
|
||||
#ifdef BUTTON_PIN
|
||||
if (((config.device.button_gpio ? config.device.button_gpio : BUTTON_PIN) !=
|
||||
moduleConfig.canned_message.inputbroker_pin_press) ||
|
||||
@ -149,9 +146,6 @@ int32_t ButtonThread::runOnce()
|
||||
|
||||
case BUTTON_EVENT_DOUBLE_PRESSED: {
|
||||
LOG_BUTTON("Double press!\n");
|
||||
#if defined(M5STACK_COREBASIC)
|
||||
M5.Speaker.tone(2000, 100);
|
||||
#endif
|
||||
service->refreshLocalMeshNode();
|
||||
auto sentPosition = service->trySendPosition(NODENUM_BROADCAST, true);
|
||||
if (screen) {
|
||||
@ -193,9 +187,6 @@ int32_t ButtonThread::runOnce()
|
||||
|
||||
case BUTTON_EVENT_LONG_PRESSED: {
|
||||
LOG_BUTTON("Long press!\n");
|
||||
#if defined(M5STACK_COREBASIC)
|
||||
M5.Speaker.tone(3000, 300);
|
||||
#endif
|
||||
powerFSM.trigger(EVENT_PRESS);
|
||||
if (screen) {
|
||||
screen->startAlert("Shutting down...");
|
||||
@ -208,9 +199,6 @@ int32_t ButtonThread::runOnce()
|
||||
// may wake the board immediatedly.
|
||||
case BUTTON_EVENT_LONG_RELEASED: {
|
||||
LOG_INFO("Shutdown from long press\n");
|
||||
#if defined(M5STACK_COREBASIC)
|
||||
M5.Speaker.tone(4000, 300);
|
||||
#endif
|
||||
playShutdownMelody();
|
||||
delay(3000);
|
||||
power->shutdown();
|
||||
|
@ -62,10 +62,15 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#if ARCH_PORTDUINO
|
||||
#include "platform/portduino/PortduinoGlue.h"
|
||||
#endif
|
||||
#if defined(M5STACK_COREBASIC) || defined(M5STACK_CORE2)
|
||||
#if defined(M5STACK_CORE2)
|
||||
#include "M5Unified.h"
|
||||
extern DataInfo DataRegion;
|
||||
#define OLED_BLACK OLEDDISPLAY_COLOR::BLACK
|
||||
#define OLED_WHITE OLEDDISPLAY_COLOR::WHITE
|
||||
#else
|
||||
#define OLED_BLACK BLACK
|
||||
#define OLED_WHITE WHITE
|
||||
#endif
|
||||
extern DataInfo DataRegion;
|
||||
using namespace meshtastic; /** @todo remove */
|
||||
|
||||
namespace graphics
|
||||
@ -952,9 +957,7 @@ bool deltaToTimestamp(uint32_t secondsAgo, uint8_t *hours, uint8_t *minutes, int
|
||||
validCached = true;
|
||||
return validCached;
|
||||
}
|
||||
#if defined(M5STACK_COREBASIC) || defined(M5STACK_CORE2)
|
||||
static void drawLoraMessage(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y){
|
||||
display->clear();
|
||||
display->drawString(x + 0, y + 0, myRegion->name);
|
||||
display->setFont(FONT_MEDIUM);
|
||||
display->drawString(x + 10, y + 30,"channel: "+String(DataRegion.lora_channel_num+1));
|
||||
@ -971,7 +974,6 @@ static void drawLoraMessage(OLEDDisplay *display, OLEDDisplayUiState *state, int
|
||||
display->drawString(x + SCREEN_WIDTH, y,String(DataRegion.lora_channel_name));
|
||||
display->setTextAlignment(TEXT_ALIGN_LEFT); // Restore left align, just to be kind to any other unsuspecting code
|
||||
}
|
||||
#endif
|
||||
/// Draw the last text message we received
|
||||
static void drawTextMessageFrame(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y)
|
||||
{
|
||||
@ -990,11 +992,7 @@ static void drawTextMessageFrame(OLEDDisplay *display, OLEDDisplayUiState *state
|
||||
display->setFont(FONT_SMALL);
|
||||
if (config.display.displaymode == meshtastic_Config_DisplayConfig_DisplayMode_INVERTED) {
|
||||
display->fillRect(0 + x, 0 + y, x + display->getWidth(), y + FONT_HEIGHT_SMALL);
|
||||
#if defined(M5STACK_COREBASIC) || defined(M5STACK_CORE2)
|
||||
display->setColor(OLEDDISPLAY_COLOR::BLACK);
|
||||
#else
|
||||
display->setColor(BLACK);
|
||||
#endif
|
||||
display->setColor(OLED_BLACK);
|
||||
}
|
||||
|
||||
// For time delta
|
||||
@ -1028,11 +1026,7 @@ static void drawTextMessageFrame(OLEDDisplay *display, OLEDDisplayUiState *state
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(M5STACK_COREBASIC) || defined(M5STACK_CORE2)
|
||||
display->setColor(OLEDDISPLAY_COLOR::WHITE);
|
||||
#else
|
||||
display->setColor(WHITE);
|
||||
#endif
|
||||
display->setColor(OLED_WHITE);
|
||||
#ifndef EXCLUDE_EMOJI
|
||||
if (strcmp(reinterpret_cast<const char *>(mp.decoded.payload.bytes), u8"\U0001F44D") == 0) {
|
||||
display->drawXbm(x + (SCREEN_WIDTH - thumbs_width) / 2,
|
||||
@ -1105,15 +1099,10 @@ void Screen::drawColumns(OLEDDisplay *display, int16_t x, int16_t y, const char
|
||||
int xo = x, yo = y;
|
||||
while (*f) {
|
||||
display->drawString(xo, yo, *f);
|
||||
#if defined(M5STACK_COREBASIC) || defined(M5STACK_CORE2)
|
||||
if ((display->getColor() == OLEDDISPLAY_COLOR::BLACK) && config.display.heading_bold)
|
||||
|
||||
if ((display->getColor() == OLED_BLACK) && config.display.heading_bold)
|
||||
display->drawString(xo + 1, yo, *f);
|
||||
display->setColor(OLEDDISPLAY_COLOR::WHITE);
|
||||
#else
|
||||
if ((display->getColor() == BLACK) && config.display.heading_bold)
|
||||
display->drawString(xo + 1, yo, *f);
|
||||
display->setColor(WHITE);
|
||||
#endif
|
||||
display->setColor(OLED_WHITE);
|
||||
yo += FONT_HEIGHT_SMALL;
|
||||
if (yo > SCREEN_HEIGHT - FONT_HEIGHT_SMALL) {
|
||||
xo += SCREEN_WIDTH / 2;
|
||||
@ -1523,11 +1512,7 @@ static void drawNodeInfo(OLEDDisplay *display, OLEDDisplayUiState *state, int16_
|
||||
display->drawCircle(compassX, compassY, compassDiam / 2);
|
||||
|
||||
if (config.display.displaymode == meshtastic_Config_DisplayConfig_DisplayMode_INVERTED) {
|
||||
#if defined(M5STACK_COREBASIC) || defined(M5STACK_CORE2)
|
||||
display->setColor(OLEDDISPLAY_COLOR::BLACK);
|
||||
#else
|
||||
display->setColor(BLACK);
|
||||
#endif
|
||||
display->setColor(OLED_BLACK);
|
||||
}
|
||||
// Must be after distStr is populated
|
||||
screen->drawColumns(display, x, y, fields);
|
||||
@ -1641,7 +1626,7 @@ void Screen::handleSetOn(bool on, FrameCallback einkScreensaver)
|
||||
digitalWrite(VTFT_LEDA, TFT_BACKLIGHT_ON);
|
||||
#endif
|
||||
#endif
|
||||
#if defined(M5STACK_COREBASIC)
|
||||
#ifdef TFT_BL
|
||||
pinMode(TFT_BL, OUTPUT);
|
||||
digitalWrite(TFT_BL, HIGH);
|
||||
#endif
|
||||
@ -1660,10 +1645,11 @@ void Screen::handleSetOn(bool on, FrameCallback einkScreensaver)
|
||||
#endif
|
||||
LOG_INFO("Turning off screen\n");
|
||||
dispdev->displayOff();
|
||||
#if defined(M5STACK_COREBASIC)
|
||||
#ifdef TFT_BL
|
||||
pinMode(TFT_BL, OUTPUT);
|
||||
digitalWrite(TFT_BL, LOW);
|
||||
#elif defined(M5STACK_CORE2)
|
||||
#endif
|
||||
#if defined(M5STACK_CORE2)
|
||||
M5.Power.Axp192.setDCDC3(0);
|
||||
#endif
|
||||
#ifdef USE_ST7789
|
||||
@ -2157,14 +2143,8 @@ void Screen::setFrames(FrameFocus focus)
|
||||
fsi.positions.textMessage = numframes;
|
||||
if (devicestate.has_rx_text_message && shouldDrawMessage(&devicestate.rx_text_message)) {
|
||||
normalFrames[numframes++] = drawTextMessageFrame;
|
||||
#if defined(M5STACK_COREBASIC) || defined(M5STACK_CORE2)
|
||||
M5.Speaker.tone(3000, 400);
|
||||
#endif
|
||||
}
|
||||
#if defined(M5STACK_COREBASIC) || defined(M5STACK_CORE2)
|
||||
normalFrames[numframes++] = drawLoraMessage;
|
||||
#endif
|
||||
|
||||
// then all the nodes
|
||||
// We only show a few nodes in our scrolling list - because meshes with many nodes would have too many screens
|
||||
size_t numToShow = min(numMeshNodes, 4U);
|
||||
@ -2425,11 +2405,7 @@ void DebugInfo::drawFrame(OLEDDisplay *display, OLEDDisplayUiState *state, int16
|
||||
|
||||
if (config.display.displaymode == meshtastic_Config_DisplayConfig_DisplayMode_INVERTED) {
|
||||
display->fillRect(0 + x, 0 + y, x + display->getWidth(), y + FONT_HEIGHT_SMALL);
|
||||
#if defined(M5STACK_COREBASIC) || defined(M5STACK_CORE2)
|
||||
display->setColor(OLEDDISPLAY_COLOR::BLACK);
|
||||
#else
|
||||
display->setColor(BLACK);
|
||||
#endif
|
||||
display->setColor(OLED_BLACK);
|
||||
}
|
||||
|
||||
char channelStr[20];
|
||||
@ -2470,11 +2446,7 @@ void DebugInfo::drawFrame(OLEDDisplay *display, OLEDDisplayUiState *state, int16
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#if defined(M5STACK_COREBASIC) || defined(M5STACK_CORE2)
|
||||
display->setColor(OLEDDISPLAY_COLOR::WHITE);
|
||||
#else
|
||||
display->setColor(WHITE);
|
||||
#endif
|
||||
display->setColor(OLED_WHITE);
|
||||
// Draw the channel name
|
||||
display->drawString(x, y + FONT_HEIGHT_SMALL, channelStr);
|
||||
// Draw our hardware ID to assist with bluetooth pairing. Either prefix with Info or S&F Logo
|
||||
@ -2547,11 +2519,7 @@ void DebugInfo::drawFrameWiFi(OLEDDisplay *display, OLEDDisplayUiState *state, i
|
||||
|
||||
if (config.display.displaymode == meshtastic_Config_DisplayConfig_DisplayMode_INVERTED) {
|
||||
display->fillRect(0 + x, 0 + y, x + display->getWidth(), y + FONT_HEIGHT_SMALL);
|
||||
#if defined(M5STACK_COREBASIC) || defined(M5STACK_CORE2)
|
||||
display->setColor(OLEDDISPLAY_COLOR::BLACK);
|
||||
#else
|
||||
display->setColor(BLACK);
|
||||
#endif
|
||||
display->setColor(OLED_BLACK);
|
||||
}
|
||||
|
||||
if (WiFi.status() != WL_CONNECTED) {
|
||||
@ -2571,11 +2539,7 @@ void DebugInfo::drawFrameWiFi(OLEDDisplay *display, OLEDDisplayUiState *state, i
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(M5STACK_COREBASIC) || defined(M5STACK_CORE2)
|
||||
display->setColor(OLEDDISPLAY_COLOR::WHITE);
|
||||
#else
|
||||
display->setColor(WHITE);
|
||||
#endif
|
||||
display->setColor(OLED_WHITE);
|
||||
|
||||
/*
|
||||
- WL_CONNECTED: assigned when connected to a WiFi network;
|
||||
@ -2635,11 +2599,7 @@ void DebugInfo::drawFrameSettings(OLEDDisplay *display, OLEDDisplayUiState *stat
|
||||
|
||||
if (config.display.displaymode == meshtastic_Config_DisplayConfig_DisplayMode_INVERTED) {
|
||||
display->fillRect(0 + x, 0 + y, x + display->getWidth(), y + FONT_HEIGHT_SMALL);
|
||||
#if defined(M5STACK_COREBASIC) || defined(M5STACK_CORE2)
|
||||
display->setColor(OLEDDISPLAY_COLOR::BLACK);
|
||||
#else
|
||||
display->setColor(BLACK);
|
||||
#endif
|
||||
display->setColor(OLED_BLACK);
|
||||
}
|
||||
|
||||
char batStr[20];
|
||||
@ -2678,11 +2638,7 @@ void DebugInfo::drawFrameSettings(OLEDDisplay *display, OLEDDisplayUiState *stat
|
||||
// minutes %= 60;
|
||||
// hours %= 24;
|
||||
|
||||
#if defined(M5STACK_COREBASIC) || defined(M5STACK_CORE2)
|
||||
display->setColor(OLEDDISPLAY_COLOR::WHITE);
|
||||
#else
|
||||
display->setColor(WHITE);
|
||||
#endif
|
||||
display->setColor(OLED_WHITE);
|
||||
|
||||
// Show uptime as days, hours, minutes OR seconds
|
||||
std::string uptime = screen->drawTimeDelta(days, hours, minutes, seconds);
|
||||
|
@ -761,9 +761,6 @@ void setup()
|
||||
#endif
|
||||
#if defined(M5STACK_COREBASIC) || defined(M5STACK_CORE2)
|
||||
M5.begin();
|
||||
M5.Speaker.tone(2000, 600);
|
||||
M5.Display.init();
|
||||
M5.Display.fillScreen(TFT_BLACK);
|
||||
#endif
|
||||
#if !MESHTASTIC_EXCLUDE_I2C
|
||||
// Don't call screen setup until after nodedb is setup (because we need
|
||||
|
@ -42,7 +42,6 @@ extern bool isUSBPowered;
|
||||
#if !defined(ARCH_PORTDUINO) && !defined(ARCH_STM32WL)
|
||||
extern ATECCX08A atecc;
|
||||
#endif
|
||||
#if defined(M5STACK_COREBASIC) || defined(M5STACK_CORE2)
|
||||
struct DataInfo {
|
||||
int lora_channel_num;
|
||||
double lora_freq;
|
||||
@ -52,7 +51,6 @@ struct DataInfo {
|
||||
int lora_sf;
|
||||
int lora_cr;
|
||||
};
|
||||
#endif
|
||||
#ifdef T_WATCH_S3
|
||||
#include <Adafruit_DRV2605.h>
|
||||
extern Adafruit_DRV2605 drv;
|
||||
|
@ -11,9 +11,8 @@
|
||||
#include <assert.h>
|
||||
#include <pb_decode.h>
|
||||
#include <pb_encode.h>
|
||||
#if defined(M5STACK_COREBASIC) || defined(M5STACK_CORE2)
|
||||
|
||||
DataInfo DataRegion;
|
||||
#endif
|
||||
#define RDEF(name, freq_start, freq_end, duty_cycle, spacing, power_limit, audio_permitted, frequency_switching, wide_lora) \
|
||||
{ \
|
||||
meshtastic_Config_LoRaConfig_RegionCode_##name, freq_start, freq_end, duty_cycle, spacing, power_limit, audio_permitted, \
|
||||
@ -203,10 +202,8 @@ uint32_t RadioInterface::getPacketTime(uint32_t pl)
|
||||
float tPacket = tPreamble + tPayload;
|
||||
|
||||
uint32_t msecs = tPacket * 1000;
|
||||
#if defined(M5STACK_COREBASIC) || defined(M5STACK_CORE2)
|
||||
DataRegion.lora_sf=sf;
|
||||
DataRegion.lora_cr=cr;
|
||||
#endif
|
||||
LOG_DEBUG("(bw=%d, sf=%d, cr=4/%d) packet symLen=%d ms, payloadSize=%u, time %d ms\n", (int)bw, sf, cr, (int)(tSym * 1000),
|
||||
pl, msecs);
|
||||
return msecs;
|
||||
@ -551,13 +548,11 @@ void RadioInterface::applyModemConfig()
|
||||
slotTimeMsec = computeSlotTimeMsec(bw, sf);
|
||||
preambleTimeMsec = getPacketTime((uint32_t)0);
|
||||
maxPacketTimeMsec = getPacketTime(meshtastic_Constants_DATA_PAYLOAD_LEN + sizeof(PacketHeader));
|
||||
#if defined(M5STACK_COREBASIC) || defined(M5STACK_CORE2)
|
||||
DataRegion.lora_channel_num=channel_num;
|
||||
DataRegion.lora_freq=getFreq();
|
||||
DataRegion.lora_channel_name=channelName;
|
||||
DataRegion.lora_power_output=power;
|
||||
DataRegion.lora_bw=bw;
|
||||
#endif
|
||||
LOG_INFO("Radio freq=%.3f, config.lora.frequency_offset=%.3f\n", freq, loraConfig.frequency_offset);
|
||||
LOG_INFO("Set radio: region=%s, name=%s, config=%u, ch=%d, power=%d\n", myRegion->name, channelName, loraConfig.modem_preset,
|
||||
channel_num, power);
|
||||
|
Loading…
Reference in New Issue
Block a user