Skip to content

Commit 54675ed

Browse files
authored
Merge pull request #812 from khudson/source-cleanup
Ikoka Stick: Naming Convention, LED behavior, device strings
2 parents 262e986 + 9e46056 commit 54675ed

File tree

6 files changed

+24
-18
lines changed

6 files changed

+24
-18
lines changed

variants/ikoka_stick_nrf/ikoka_stick_nrf_board.cpp renamed to variants/ikoka_stick_nrf/IkokaStickNRFBoard.cpp

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,26 @@
11
#ifdef XIAO_NRF52
22

33
#include <Arduino.h>
4-
#include "ikoka_stick_nrf_board.h"
4+
#include "IkokaStickNRFBoard.h"
55

66
#include <bluefruit.h>
77
#include <Wire.h>
88

99
static BLEDfu bledfu;
1010

11-
static void connect_callback(uint16_t conn_handle)
12-
{
11+
static void connect_callback(uint16_t conn_handle) {
1312
(void)conn_handle;
1413
MESH_DEBUG_PRINTLN("BLE client connected");
1514
}
1615

17-
static void disconnect_callback(uint16_t conn_handle, uint8_t reason)
18-
{
16+
static void disconnect_callback(uint16_t conn_handle, uint8_t reason) {
1917
(void)conn_handle;
2018
(void)reason;
2119

2220
MESH_DEBUG_PRINTLN("BLE client disconnected");
2321
}
2422

25-
void ikoka_stick_nrf_board::begin() {
23+
void IkokaStickNRFBoard::begin() {
2624
// for future use, sub-classes SHOULD call this from their begin()
2725
startup_reason = BD_STARTUP_NORMAL;
2826

@@ -50,7 +48,7 @@ void ikoka_stick_nrf_board::begin() {
5048
delay(10); // give sx1262 some time to power up
5149
}
5250

53-
bool ikoka_stick_nrf_board::startOTAUpdate(const char* id, char reply[]) {
51+
bool IkokaStickNRFBoard::startOTAUpdate(const char *id, char reply[]) {
5452
// Config the peripheral connection with maximum bandwidth
5553
// more SRAM required by SoftDevice
5654
// Note: All config***() function must be called before begin()
@@ -91,9 +89,6 @@ bool ikoka_stick_nrf_board::startOTAUpdate(const char* id, char reply[]) {
9189

9290
strcpy(reply, "OK - started");
9391
return true;
94-
95-
96-
return false;
9792
}
9893

9994
#endif

variants/ikoka_stick_nrf/ikoka_stick_nrf_board.h renamed to variants/ikoka_stick_nrf/IkokaStickNRFBoard.h

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
#ifdef XIAO_NRF52
77

8-
class ikoka_stick_nrf_board : public mesh::MainBoard {
8+
class IkokaStickNRFBoard : public mesh::MainBoard {
99
protected:
1010
uint8_t startup_reason;
1111

@@ -16,9 +16,17 @@ class ikoka_stick_nrf_board : public mesh::MainBoard {
1616
#if defined(P_LORA_TX_LED)
1717
void onBeforeTransmit() override {
1818
digitalWrite(P_LORA_TX_LED, LOW); // turn TX LED on
19+
#if defined(LED_BLUE)
20+
// turn off that annoying blue LED before transmitting
21+
digitalWrite(LED_BLUE, HIGH);
22+
#endif
1923
}
2024
void onAfterTransmit() override {
2125
digitalWrite(P_LORA_TX_LED, HIGH); // turn TX LED off
26+
#if defined(LED_BLUE)
27+
// do it after transmitting too, just in case
28+
digitalWrite(LED_BLUE, HIGH);
29+
#endif
2230
}
2331
#endif
2432

@@ -38,15 +46,15 @@ class ikoka_stick_nrf_board : public mesh::MainBoard {
3846
return (adcvalue * ADC_MULTIPLIER * AREF_VOLTAGE) / 4.096;
3947
}
4048

41-
const char* getManufacturerName() const override {
42-
return "Ikoka Stick (Xiao-nrf52)";
49+
const char *getManufacturerName() const override {
50+
return MANUFACTURER_STRING;
4351
}
4452

4553
void reboot() override {
4654
NVIC_SystemReset();
4755
}
4856

49-
bool startOTAUpdate(const char* id, char reply[]) override;
57+
bool startOTAUpdate(const char *id, char reply[]) override;
5058
};
5159

5260
#endif

variants/ikoka_stick_nrf/platformio.ini

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ extends = ikoka_stick_nrf_baseboard
6161
; No PA in this model, full 22dBm
6262
build_flags =
6363
${ikoka_stick_nrf_baseboard.build_flags}
64+
-D MANUFACTURER_STRING='"Ikoka Stick-E22-22dBm (Xiao_nrf52)"'
6465
-D LORA_TX_POWER=22
6566
build_src_filter = ${nrf52840_xiao.build_src_filter}
6667
+<helpers/*.cpp>
@@ -75,6 +76,7 @@ extends = ikoka_stick_nrf_baseboard
7576
; cause distortion in the PA output. 20dBm in -> 30dBm out
7677
build_flags =
7778
${ikoka_stick_nrf_baseboard.build_flags}
79+
-D MANUFACTURER_STRING='"Ikoka Stick-E22-30dBm (Xiao_nrf52)"'
7880
-D LORA_TX_POWER=20
7981
build_src_filter = ${nrf52840_xiao.build_src_filter}
8082
+<helpers/*.cpp>
@@ -89,6 +91,7 @@ extends = ikoka_stick_nrf_baseboard
8991
; to the rf amplifier frontend. 9dBm in -> 33dBm out
9092
build_flags =
9193
${ikoka_stick_nrf_baseboard.build_flags}
94+
-D MANUFACTURER_STRING='"Ikoka Stick-E22-33dBm (Xiao_nrf52)"'
9295
-D LORA_TX_POWER=9
9396
build_src_filter = ${nrf52840_xiao.build_src_filter}
9497
+<helpers/*.cpp>

variants/ikoka_stick_nrf/target.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#include "target.h"
33
#include <helpers/ArduinoHelpers.h>
44

5-
ikoka_stick_nrf_board board;
5+
IkokaStickNRFBoard board;
66

77
#ifdef DISPLAY_CLASS
88
DISPLAY_CLASS display;

variants/ikoka_stick_nrf/target.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#define RADIOLIB_STATIC_ONLY 1
44
#include <RadioLib.h>
55
#include <helpers/radiolib/RadioLibWrappers.h>
6-
#include <ikoka_stick_nrf_board.h>
6+
#include <IkokaStickNRFBoard.h>
77
#include <helpers/radiolib/CustomSX1262Wrapper.h>
88
#include <helpers/AutoDiscoverRTCClock.h>
99
#include <helpers/ArduinoHelpers.h>
@@ -16,7 +16,7 @@
1616
extern MomentaryButton user_btn;
1717
#endif
1818

19-
extern ikoka_stick_nrf_board board;
19+
extern IkokaStickNRFBoard board;
2020
extern WRAPPER_CLASS radio_driver;
2121
extern AutoDiscoverRTCClock rtc_clock;
2222
extern EnvironmentSensorManager sensors;

variants/ikoka_stick_nrf/variant.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ extern "C"
3535
#define LED_GREEN (13)
3636
#define LED_BLUE (12)
3737

38-
#define LED_STATE_ON (1) // State when LED is litted
38+
#define LED_STATE_ON (0) // State when LED is litted
3939

4040
// Buttons
4141
#define PIN_BUTTON1 (PINS_COUNT)

0 commit comments

Comments
 (0)