Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions src/input/RotaryEncoderImpl.cpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
#ifdef T_LORA_PAGER
#include "configuration.h"
#if defined(FSM_ROTARY_ENCODER)

#include "RotaryEncoderImpl.h"
#include "InputBroker.h"
#include "RotaryEncoder.h"
#include "RotaryEncoderImpl.h"
extern bool osk_found;

#define ORIGIN_NAME "RotaryEncoder"

#ifndef FSM_ROTARY_ENCODER_DEBOUNCE
#define FSM_ROTARY_ENCODER_DEBOUNCE 200
#endif

#ifndef FSM_ROTARY_ENCODER_CHECK_INTERVAL
#define FSM_ROTARY_ENCODER_CHECK_INTERVAL 10
#endif

RotaryEncoderImpl *rotaryEncoderImpl;

RotaryEncoderImpl::RotaryEncoderImpl() : concurrency::OSThread(ORIGIN_NAME), originName(ORIGIN_NAME)
Expand Down Expand Up @@ -35,6 +45,7 @@ bool RotaryEncoderImpl::init()
LOG_INFO("RotaryEncoder initialized pins(%d, %d, %d), events(%d, %d, %d)", moduleConfig.canned_message.inputbroker_pin_a,
moduleConfig.canned_message.inputbroker_pin_b, moduleConfig.canned_message.inputbroker_pin_press, eventCw, eventCcw,
eventPressed);
osk_found = true;
return true;
}

Expand All @@ -43,7 +54,7 @@ int32_t RotaryEncoderImpl::runOnce()
InputEvent e{originName, INPUT_BROKER_NONE, 0, 0, 0};
static uint32_t lastPressed = millis();
if (rotary->readButton() == RotaryEncoder::ButtonState::BUTTON_PRESSED) {
if (lastPressed + 200 < millis()) {
if (lastPressed + FSM_ROTARY_ENCODER_DEBOUNCE < millis()) {
LOG_DEBUG("Rotary event Press");
lastPressed = millis();
e.inputEvent = this->eventPressed;
Expand All @@ -67,7 +78,7 @@ int32_t RotaryEncoderImpl::runOnce()
this->notifyObservers(&e);
}

return 10;
return FSM_ROTARY_ENCODER_CHECK_INTERVAL;
}

#endif
2 changes: 1 addition & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1448,7 +1448,7 @@ void setup()
#endif
#endif

#if defined(HAS_TRACKBALL) || (defined(INPUTDRIVER_ENCODER_TYPE) && INPUTDRIVER_ENCODER_TYPE == 2)
#if defined(HAS_TRACKBALL) || (defined(INPUTDRIVER_ENCODER_TYPE) && INPUTDRIVER_ENCODER_TYPE == 2) || defined(FSM_ROTARY_ENCODER)
osk_found = true;
#endif

Expand Down
2 changes: 1 addition & 1 deletion src/mesh/NodeDB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -831,7 +831,7 @@ void NodeDB::installDefaultModuleConfig()
moduleConfig.external_notification.output_ms = 1000;
moduleConfig.external_notification.nag_timeout = 60;
#endif
#ifdef T_LORA_PAGER
#if defined(FSM_ROTARY_ENCODER)
moduleConfig.canned_message.updown1_enabled = true;
moduleConfig.canned_message.inputbroker_pin_a = ROTARY_A;
moduleConfig.canned_message.inputbroker_pin_b = ROTARY_B;
Expand Down
2 changes: 1 addition & 1 deletion src/modules/Modules.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ void setupModules()
delete rotaryEncoderInterruptImpl1;
rotaryEncoderInterruptImpl1 = nullptr;
}
#ifdef T_LORA_PAGER
#if defined(FSM_ROTARY_ENCODER)
// use a special FSM based rotary encoder version for T-LoRa Pager
rotaryEncoderImpl = new RotaryEncoderImpl();
if (!rotaryEncoderImpl->init()) {
Expand Down
24 changes: 24 additions & 0 deletions variants/esp32c3/diy/esp32c3_nova_lora/pins_arduino.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#ifndef Pins_Arduino_h
#define Pins_Arduino_h

#include <stdint.h>

static const uint8_t TX = 0;
static const uint8_t RX = 0;

static const uint8_t SDA = 10;
static const uint8_t SCL = 20;

static const uint8_t SS = 7;
static const uint8_t MOSI = 5;
static const uint8_t MISO = 6;
static const uint8_t SCK = 4;

static const uint8_t A0 = 0;
static const uint8_t A1 = 1;
static const uint8_t A2 = 2;
static const uint8_t A3 = 3;
static const uint8_t A4 = 4;
static const uint8_t A5 = 5;

#endif /* Pins_Arduino_h */
20 changes: 20 additions & 0 deletions variants/esp32c3/diy/esp32c3_nova_lora/platformio.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
; ESP32 C3 Super Mini + Ebyte E22 400M30S Board
; https://www.espboards.dev/esp32/esp32-c3-super-mini/
[env:esp32c3_nova_lora]
extends = esp32c3_base
board = esp32-c3-devkitm-1
board_level = extra
build_flags =
${esp32_base.build_flags}
-D PRIVATE_HW
-D NOVA_LORA
-I variants/esp32c3/diy/esp32c3_nova_lora
-D ARDUINO_USB_MODE=1
-D ARDUINO_USB_CDC_ON_BOOT=1
-D MESHTASTIC_EXCLUDE_ATAK=1
-D MESHTASTIC_EXCLUDE_DETECTIONSENSOR=1

lib_deps = ${esp32c3_base.lib_deps}
https://github.com/mverch67/BQ27220/archive/07d92be846abd8a0258a50c23198dac0858b22ed.zip
https://github.com/mverch67/RotaryEncoder/archive/25a59d5745a6645536f921427d80b08e78f886d4.zip

89 changes: 89 additions & 0 deletions variants/esp32c3/diy/esp32c3_nova_lora/variant.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
#ifndef _VARIANT_ESP32C3_NOVA_LORA_
#define _VARIANT_ESP32C3_NOVA_LORA_

/*----------------------------------------------------------------------------
* Headers
*----------------------------------------------------------------------------*/

#ifdef __cplusplus
extern "C" {
#endif // __cplusplus

// Status
#define LED_PIN 8
#define LED_STATE_ON 1 // State when LED is lit

// I2C (Wire) & OLED
#define WIRE_INTERFACES_COUNT (1)
#define I2C_SDA (10)
#define I2C_SCL (20)

#define HAS_SCREEN 1
#define USE_SSD1306
#define DISPLAY_FLIP_SCREEN

// Button
#define HAS_BUTTON 1
#define BUTTON_PIN (9) // BOOT button

#define FSM_ROTARY_ENCODER 1
#define FSM_ROTARY_ENCODER_DEBOUNCE 300
#define FSM_ROTARY_ENCODER_CHECK_INTERVAL 2
#define ROTARY_A (2)
#define ROTARY_B (1)
#define ROTARY_PRESS (9)

// #define USE_VIRTUAL_KEYBOARD 1
#define CANNED_MESSAGE_MODULE_ENABLE 1

// LoRa
#define USE_LLCC68
#define USE_SX1262
// #define USE_RF95
#define USE_SX1268

#define LORA_DIO0 RADIOLIB_NC
#define LORA_RESET (0)
#define LORA_DIO1 (3)
#define LORA_BUSY (21)
#define LORA_SCK (4)
#define LORA_MISO (6)
#define LORA_MOSI (5)
#define LORA_CS (7)

#define LORA_RXEN RADIOLIB_NC
#define LORA_TXEN RADIOLIB_NC
#define SX126X_DIO2_AS_RF_SWITCH

#define SX126X_CS LORA_CS
#define SX126X_DIO1 LORA_DIO1
#define SX126X_BUSY LORA_BUSY
#define SX126X_RESET LORA_RESET
#define SX126X_RXEN LORA_RXEN
#define SX126X_TXEN LORA_TXEN

// Power
// Outputting 22dBm from SX1262 results in ~30dBm E22-900M30S output (module only uses last stage of the YP2233W PA)
#define SX126X_MAX_POWER 22 // SX126xInterface.cpp defaults to 22 if not defined, but here we define it for good practice
// #ifdef EBYTE_E22_900M30S
// 10dB PA gain and 30dB rated output; based on measurements from
// https://github.com/S5NC/EBYTE_ESP32-S3/blob/main/E22-900M30S%20power%20output%20testing.txt
// #define TX_GAIN_LORA 7
// #define SX126X_MAX_POWER 22
// #endif

// E22 series TCXO voltage is 1.8V per https://www.ebyte.com/en/pdf-down.aspx?id=781 (source
// https://github.com/jgromes/RadioLib/issues/12#issuecomment-520695575), so set it as such
#define SX126X_DIO3_TCXO_VOLTAGE 1.8
// #define SX126X_DIO3_TCXO_VOLTAGE 2.2
#define TCXO_OPTIONAL // make it so that the firmware can try both TCXO and XTAL

#ifdef __cplusplus
}
#endif

/*----------------------------------------------------------------------------
* Arduino objects - C++ only
*----------------------------------------------------------------------------*/

#endif
1 change: 1 addition & 0 deletions variants/esp32s3/tlora-pager/variant.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
#define HAS_RTC 1

// Rotary
#define FSM_ROTARY_ENCODER
#define ROTARY_A (40)
#define ROTARY_B (41)
#define ROTARY_PRESS (7)
Expand Down