fix the code format by use trunk

Signed-off-by: imliubo <imliubo@makingfun.xyz>
This commit is contained in:
imliubo 2025-02-27 16:19:43 +08:00
parent a981ea5440
commit 3729635ef5
8 changed files with 73 additions and 75 deletions

View File

@ -14,7 +14,7 @@
#ifdef ARCH_PORTDUINO
#include "platform/portduino/PortduinoGlue.h"
#endif
#if defined(M5STACK_CORE2)
#if defined(M5STACK_CORE2)
#include <M5Unified.h>
#endif
#define DEBUG_BUTTONS 0
@ -372,32 +372,34 @@ void ButtonThread::userButtonPressedLongStop()
}
#if defined(M5STACK_CORE2)
// Define a constant
const unsigned long LONG_PRESS_THRESHOLD = 5000; // Hold the threshold
const unsigned long LONG_PRESS_THRESHOLD = 5000; // Hold the threshold
const unsigned long DOUBLE_CLICK_THRESHOLD = 1000; // Double-click the threshold
const int MAX_CLICKS = 2; // Maximum hits
const int MAX_CLICKS = 2; // Maximum hits
// Global variable
unsigned long lastClickTime = 0; // The time of the last click
int clickCount = 0; // Click count
unsigned long touch_start_time; // Touch start time
bool is_touching = false; // Mark whether you are currently touching
void ScreenTouch(){
int clickCount = 0; // Click count
unsigned long touch_start_time; // Touch start time
bool is_touching = false; // Mark whether you are currently touching
void ScreenTouch()
{
M5.update();
auto count = M5.Touch.getCount();
if (count == 0) return;
if (count == 0)
return;
for (std::size_t i = 0; i < count; ++i) {
auto t = M5.Touch.getDetail(i);
// If touch starts
if (t.wasPressed()) {
touch_start_time = millis(); // Record the time when the touch began
is_touching = true; // Set to touch
is_touching = true; // Set to touch
}
//Check the current touch status
// Check the current touch status
if (is_touching) {
unsigned long duration = millis() - touch_start_time;
if (duration >= LONG_PRESS_THRESHOLD) {
LOG_INFO("Long Press Detected\n");
LOG_INFO("Long Press Detected\n");
powerFSM.trigger(EVENT_PRESS);
screen->startAlert("Shutting down...");
screen->forceDisplay(true);
@ -419,7 +421,7 @@ void ScreenTouch(){
if (currentTime - lastClickTime <= DOUBLE_CLICK_THRESHOLD) {
clickCount++;
if (clickCount == MAX_CLICKS) {
LOG_INFO("Double Click Detected\n");
LOG_INFO("Double Click Detected\n");
M5.Speaker.tone(2000, 100);
service->refreshLocalMeshNode();
auto sentPosition = service->trySendPosition(NODENUM_BROADCAST, true);
@ -447,7 +449,6 @@ void ScreenTouch(){
LOG_INFO("Flick Start Detected\n");
M5.Speaker.tone(1000, 100);
powerFSM.trigger(EVENT_PRESS);
}
}
}

View File

@ -64,15 +64,15 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "modules/StoreForwardModule.h"
#include "platform/portduino/PortduinoGlue.h"
#endif
#if defined(M5STACK_CORE2)
#if defined(M5STACK_CORE2)
#include "M5Unified.h"
#define OLED_BLACK OLEDDISPLAY_COLOR::BLACK
#define OLED_WHITE OLEDDISPLAY_COLOR::WHITE
#else
#define OLED_BLACK BLACK
#define OLED_WHITE WHITE
#define OLED_BLACK BLACK
#define OLED_WHITE WHITE
#endif
extern DataInfo DataRegion;
extern DataInfo DataRegion;
using namespace meshtastic; /** @todo remove */
namespace graphics
@ -956,21 +956,22 @@ bool deltaToTimestamp(uint32_t secondsAgo, uint8_t *hours, uint8_t *minutes, int
validCached = true;
return validCached;
}
static void drawLoraMessage(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y){
static void drawLoraMessage(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y)
{
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));
display->drawString(x + 10, y + 60,"bw: "+ String(DataRegion.lora_bw));
display->drawString(x + SCREEN_WIDTH/2+10, y+30,"freq: "+String(DataRegion.lora_freq));
display->drawString(x + SCREEN_WIDTH/2+10, y+60,"power: "+ String(DataRegion.lora_power_output));
display->drawString(x + 10, y + 90,"sf: "+String(DataRegion.lora_sf));
display->drawString(x + SCREEN_WIDTH/2+10, y+90,"cr: 4/:"+ String(DataRegion.lora_cr));
display->drawString(x + 10, y + 30, "channel: " + String(DataRegion.lora_channel_num + 1));
display->drawString(x + 10, y + 60, "bw: " + String(DataRegion.lora_bw));
display->drawString(x + SCREEN_WIDTH / 2 + 10, y + 30, "freq: " + String(DataRegion.lora_freq));
display->drawString(x + SCREEN_WIDTH / 2 + 10, y + 60, "power: " + String(DataRegion.lora_power_output));
display->drawString(x + 10, y + 90, "sf: " + String(DataRegion.lora_sf));
display->drawString(x + SCREEN_WIDTH / 2 + 10, y + 90, "cr: 4/:" + String(DataRegion.lora_cr));
display->setTextAlignment(TEXT_ALIGN_LEFT);
const char *title = "LoRa";
display->drawString(x + SCREEN_WIDTH/2-20, y +0, title);
display->drawString(x + SCREEN_WIDTH / 2 - 20, y + 0, title);
display->setFont(FONT_SMALL);
display->setTextAlignment(TEXT_ALIGN_RIGHT);
display->drawString(x + SCREEN_WIDTH, y,String(DataRegion.lora_channel_name));
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
}
/// Draw the last text message we received
@ -991,7 +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);
display->setColor(OLED_BLACK);
display->setColor(OLED_BLACK);
}
// For time delta
@ -1659,7 +1660,7 @@ void Screen::handleSetOn(bool on, FrameCallback einkScreensaver)
pinMode(TFT_BL, OUTPUT);
digitalWrite(TFT_BL, HIGH);
#endif
#if defined(M5STACK_CORE2)
#if defined(M5STACK_CORE2)
M5.Power.Axp192.setDCDC3(1000);
M5.Display.setBrightness(130);
#endif
@ -2512,7 +2513,7 @@ void DebugInfo::drawFrame(OLEDDisplay *display, OLEDDisplayUiState *state, int16
}
}
#endif
display->setColor(OLED_WHITE);
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
@ -2605,7 +2606,7 @@ void DebugInfo::drawFrameWiFi(OLEDDisplay *display, OLEDDisplayUiState *state, i
}
}
display->setColor(OLED_WHITE);
display->setColor(OLED_WHITE);
/*
- WL_CONNECTED: assigned when connected to a WiFi network;

View File

@ -310,9 +310,9 @@ class LGFX : public lgfx::LGFX_Device
cfg.dummy_read_bits = 1; // Number of bits for dummy read before non-pixel data read
cfg.readable = true; // Set to true if data can be read
#if defined(M5STACK_COREBASIC)
cfg.invert = true; // Set to true if the light/darkness of the panel is reversed
cfg.invert = true; // Set to true if the light/darkness of the panel is reversed
#else
cfg.invert = false; // Set to true if the light/darkness of the panel is reversed
cfg.invert = false; // Set to true if the light/darkness of the panel is reversed
#endif
cfg.rgb_order = false; // Set to true if the panel's red and blue are swapped
cfg.dlen_16bit =
@ -332,9 +332,9 @@ class LGFX : public lgfx::LGFX_Device
auto cfg = _light_instance.config(); // Gets a structure for backlight settings.
#if !defined(M5STACK_CORE2)
cfg.pin_bl = TFT_BL; // Pin number to which the backlight is connected
cfg.pin_bl = TFT_BL; // Pin number to which the backlight is connected
#endif
cfg.invert = false; // true to invert the brightness of the backlight
cfg.invert = false; // true to invert the brightness of the backlight
// cfg.freq = 44100; // PWM frequency of backlight
// cfg.pwm_channel = 1; // PWM channel number to use
@ -747,7 +747,8 @@ void TFTDisplay::sendCommand(uint8_t com)
unphone.backlight(true); // using unPhone library
#endif
#ifdef RAK14014
#elif !defined(M5STACK) && !defined(ST7789_CS) && !defined(M5STACK_COREBASIC) && !defined(M5STACK_CORE2)// T-Deck gets brightness set in Screen.cpp in the handleSetOn function
#elif !defined(M5STACK) && !defined(ST7789_CS) && !defined(M5STACK_COREBASIC) && \
!defined(M5STACK_CORE2) // T-Deck gets brightness set in Screen.cpp in the handleSetOn function
tft->setBrightness(172);
#endif
break;
@ -857,7 +858,7 @@ bool TFTDisplay::connect()
tft->init();
#endif
#if defined(M5STACK) || defined(M5STACK_COREBASIC) || defined(M5STACK_CORE2)
#if defined(M5STACK) || defined(M5STACK_COREBASIC) || defined(M5STACK_CORE2)
tft->setRotation(0);
#elif defined(RAK14014)
tft->setRotation(1);

View File

@ -115,11 +115,10 @@ AccelerometerThread *accelerometerThread = nullptr;
AudioThread *audioThread = nullptr;
#endif
#if defined(TCXO_OPTIONAL)
float tcxoVoltage = SX126X_DIO3_TCXO_VOLTAGE; // if TCXO is optional, put this here so it can be changed further down.
#endif
#if defined(M5STACK_COREBASIC) || defined(M5STACK_CORE2)
#if defined(M5STACK_COREBASIC) || defined(M5STACK_CORE2)
#include <M5Unified.h>
#endif
@ -1234,6 +1233,5 @@ void loop()
#if defined(M5STACK_CORE2)
ScreenTouch();
#endif
}
#endif

View File

@ -39,14 +39,13 @@ extern bool pmu_found;
extern bool isCharging;
extern bool isUSBPowered;
struct DataInfo {
int lora_channel_num;
double lora_freq;
const char* lora_channel_name;
int lora_power_output;
const char *lora_channel_name;
int lora_power_output;
float lora_bw;
int lora_sf;
int lora_sf;
int lora_cr;
};

View File

@ -12,7 +12,7 @@
#include <pb_decode.h>
#include <pb_encode.h>
DataInfo DataRegion;
DataInfo DataRegion;
#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, \
@ -213,8 +213,8 @@ uint32_t RadioInterface::getPacketTime(uint32_t pl)
float tPacket = tPreamble + tPayload;
uint32_t msecs = tPacket * 1000;
DataRegion.lora_sf=sf;
DataRegion.lora_cr=cr;
DataRegion.lora_sf = sf;
DataRegion.lora_cr = cr;
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;
@ -574,11 +574,11 @@ void RadioInterface::applyModemConfig()
preambleTimeMsec = getPacketTime((uint32_t)0);
maxPacketTimeMsec = getPacketTime(meshtastic_Constants_DATA_PAYLOAD_LEN + sizeof(PacketHeader));
DataRegion.lora_channel_num=channel_num;
DataRegion.lora_freq=getFreq();
DataRegion.lora_channel_name=channelName;
DataRegion.lora_power_output=power;
DataRegion.lora_bw=bw;
DataRegion.lora_channel_num = channel_num;
DataRegion.lora_freq = getFreq();
DataRegion.lora_channel_name = channelName;
DataRegion.lora_power_output = power;
DataRegion.lora_bw = bw;
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);

View File

@ -1,14 +1,13 @@
// #define BUTTON_NEED_PULLUP // if set we need to turn on the internal CPU pullup during sleep
// #define BUTTON_PIN 39 // 38, 37
// #define BUTTON_PIN 0
#define BUTTON_NEED_PULLUP
// #define EXT_NOTIFY_OUT 13 // Default pin to use for Ext Notify Plugin.
//#define BUTTON_PIN
// #define BUTTON_PIN
//#define PIN_BUZZER 25
// #define PIN_BUZZER 25
#undef LORA_SCK
#undef LORA_MISO
#undef LORA_MOSI
@ -17,11 +16,11 @@
#define LORA_SCK 18
#define LORA_MISO 38
#define LORA_MOSI 23
#define LORA_CS 33 //NSS
#define LORA_CS 33 // NSS
#define USE_RF95
#define RF95_MAX_POWER 17
#define LORA_DIO0 35 // IRQ
#define LORA_DIO0 35 // IRQ
#define LORA_RESET 19
#define LORA_DIO1 RADIOLIB_NC // Not really used
#define LORA_DIO2 RADIOLIB_NC // Not really used
@ -41,5 +40,5 @@
// LCD screens are slow, so slowdown the wipe so it looks better
#define SCREEN_TRANSITION_FRAMERATE 30 // fps
// Picomputer gets a white on black display
#define TFT_MESH COLOR565 (0xA0, 0xFF, 0x00)//(0x94, 0xEA, 0x67)
#define ILI9341_SPI_HOST VSPI_HOST // VSPI_HOST or HSPI_HOST
#define TFT_MESH COLOR565(0xA0, 0xFF, 0x00) //(0x94, 0xEA, 0x67)
#define ILI9341_SPI_HOST VSPI_HOST // VSPI_HOST or HSPI_HOST

View File

@ -20,12 +20,12 @@
#define LORA_SCK 18
#define LORA_MISO 19
#define LORA_MOSI 23
#define LORA_CS 5 //NSS
#define LORA_CS 5 // NSS
#define USE_RF95
#define RF95_MAX_POWER 17
#define LORA_DIO0 35 // IRQ
#define LORA_RESET 13 // RST
#define LORA_DIO0 35 // IRQ
#define LORA_RESET 13 // RST
#define LORA_DIO1 RADIOLIB_NC // Not really used
#define LORA_DIO2 RADIOLIB_NC // Not really used
@ -35,10 +35,9 @@
#define GPS_RX_PIN 16
#define GPS_TX_PIN 17
//Note: If you use corebasic version 2.7 or later,
//you need to go to the src>graphics>TFTDisplay.cpp file to change the value of cfg.invert,
//this one is to set the color inversion
// Note: If you use corebasic version 2.7 or later,
// you need to go to the src>graphics>TFTDisplay.cpp file to change the value of cfg.invert,
// this one is to set the color inversion
#define TFT_HEIGHT 240
#define TFT_WIDTH 320
#define TFT_OFFSET_X 0