Autoformat

This commit is contained in:
Ludovic BOUÉ 2024-10-13 21:05:15 +00:00
parent f6c019c948
commit 27a0d03ab6
4 changed files with 35 additions and 34 deletions

View File

@ -339,38 +339,40 @@ 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");
if (duration >= LONG_PRESS_THRESHOLD) {
LOG_INFO("Long Press Detected\n");
powerFSM.trigger(EVENT_PRESS);
screen->startAlert("Shutting down...");
screen->forceDisplay(true);
// Executive logic, such as shutdown, display menu, etc
// To avoid duplicate detection, set is_touching to false here
is_touching = false;
is_touching = false;
M5.Speaker.tone(3000, 300);
delay(1000);
M5.Power.powerOff();
@ -380,13 +382,13 @@ void ScreenTouch(){
if (t.wasReleased()) {
if (is_touching) {
unsigned long duration = millis() - touch_start_time;
if (duration < LONG_PRESS_THRESHOLD) {
unsigned long currentTime = millis();
if (duration < LONG_PRESS_THRESHOLD) {
unsigned long currentTime = millis();
// Check whether it is a double click
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);
@ -397,24 +399,23 @@ void ScreenTouch(){
screen->print("Sent ad-hoc nodeinfo\n");
screen->forceDisplay(true); // Force a new UI frame, then force an EInk update
}
clickCount = 0;
clickCount = 0;
}
} else {
clickCount = 1;
clickCount = 1;
}
lastClickTime = currentTime; // Update last click time
}
}
// Reset the touch status
is_touching = false;
is_touching = false;
}
// You can add more status checks, such as sliding and dragging
if (t.wasFlickStart()) {
LOG_INFO("Flick Start Detected\n");
M5.Speaker.tone(1000, 100);
powerFSM.trigger(EVENT_PRESS);
}
}
}

View File

@ -71,8 +71,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#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
using namespace meshtastic; /** @todo remove */
@ -1635,7 +1635,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
@ -1654,7 +1654,7 @@ void Screen::handleSetOn(bool on, FrameCallback einkScreensaver)
pinMode(TFT_BL, OUTPUT);
digitalWrite(TFT_BL, LOW);
#endif
#if defined(M5STACK_CORE2)
#if defined(M5STACK_CORE2)
M5.Power.Axp192.setDCDC3(0);
#endif
#ifdef USE_ST7789

View File

@ -328,9 +328,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
@ -732,7 +732,8 @@ void TFTDisplay::sendCommand(uint8_t com)
unphone.backlight(true); // using unPhone library
#endif
#ifdef RAK14014
#elif !defined(M5STACK) && !defined(ST7789_CS) && !defined(M5STACK_CORE2) // T-Deck gets brightness set in Screen.cpp in the handleSetOn function
#elif !defined(M5STACK) && !defined(ST7789_CS) && \
!defined(M5STACK_CORE2) // T-Deck gets brightness set in Screen.cpp in the handleSetOn function
tft->setBrightness(172);
#endif
break;
@ -864,4 +865,4 @@ bool TFTDisplay::connect()
return true;
}
#endif
#endif

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,10 +16,10 @@
#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 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
@ -40,5 +39,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