Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Xiao 52840 receiver board #152

Closed
wants to merge 4 commits into from
Closed
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
5 changes: 5 additions & 0 deletions .github/workflows/build-firmware.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@ jobs:
cd /src/firmware/src
pio run -e Head_Tracker-XIAOSense

- name: Build XIAO 52840 Firmware
run: |
cd /src/firmware/src
pio run -e Head_Tracker-XIAO52840

# Runs a set of commands using the runners shell
- name: Package Firmware
uses: 'actions/upload-artifact@v2'
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/build-gui_win.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,11 @@ jobs:
cached: ${{ steps.cache-qt.outputs.cache-hit }}

- name: Set up MinGW
uses: gcmcnutt/setup-mingw@v3
uses: egor-tensin/setup-mingw@v2
with:
platform: x64
static: 0


- name: Build
working-directory: ${{github.workspace}}
Expand Down
19 changes: 19 additions & 0 deletions firmware/src/platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
# default_envs = Head_Tracker-DTQSys
# default_envs = Head_Tracker-Nano33_BLE_Sense2
# default_envs = Head_Tracker-XIAOSense
# default_envs = Head_Tracker-XIAO52840

[common]
build_flags =
Expand Down Expand Up @@ -100,3 +101,21 @@
-DPCB_XIAOSENSE=y
-DFNAME=XIA
-DSEEED_BOOTLOADER=y

[env:Head_Tracker-XIAO52840]
#build_type = debug
extends = nrf52common
board_upload.offset_address = 0x27000
extra_scripts =
${env.extra_scripts}
post:tools/make_uf2.py
platform = [email protected]
board = xiao_sense
framework = zephyr
lib_deps = bblanchon/[email protected]
debug_tool = jlink
build_flags =
${common.build_flags}
-DPCB_XIAO52840=y
-DFNAME=XIA
-DSEEED_BOOTLOADER=y
4 changes: 4 additions & 0 deletions firmware/src/src/boards/xiaosense.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@
// Board Features
#define HAS_3DIODE_RGB
#define HAS_NOTIFYLED
#if defined(PCB_XIAOSENSE)
#define HAS_LSM6DS3
#else // Otherwise it's the XIAO52840
#define HAS_NOIMU
#endif
#define HAS_CENTERBTN
#define HAS_PPMIN
#define HAS_PPMOUT
Expand Down
12 changes: 7 additions & 5 deletions firmware/src/src/defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,22 @@
#define FW_GIT_REV "-------"
#endif

// The majority of features are the same on Sense2
#if defined(PCB_NANO33BLE_SENSE2)
#define PCB_NANO33BLE
#endif

#if defined(PCB_NANO33BLE)
#define FW_BOARD "NANO33BLE"
#include "boards/nano33board.h"
#elif defined(PCB_NANO33BLE_SENSE2)
#define PCB_NANO33BLE // Most items
#define FW_BOARD "NANO33BLESR2"
#include "boards/nano33board.h"
#elif defined(PCB_DTQSYS)
#define FW_BOARD "DTQSYS"
#include "boards/dtqsys_ht.h"
#elif defined(PCB_XIAOSENSE)
#define FW_BOARD "XIAOSENSE"
#include "boards/xiaosense.h"
#elif defined(PCB_XIAO52840)
#define FW_BOARD "XIAO52840"
#include "boards/xiaosense.h"
#else
#error NO PCB DEFINED
#endif
Expand Down
4 changes: 3 additions & 1 deletion firmware/src/src/io.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ void io_Thread()
digitalWrite(IO_LED, led_is_on);
}
#endif
// Unrecoverable error, Solid Red
// Unrecoverable sensor error, Solid Red
if(_ledmode & LED_HARDFAULT) {
led_sequence[0].RGB = RGB_RED;
led_sequence[0].time = 10;
Expand Down Expand Up @@ -322,7 +322,9 @@ void io_init()
pinMode(IO_AN3, GPIO_INPUT);
#endif

#if !defined(HAS_NOIMU)
setLEDFlag(LED_GYROCAL);
#endif

k_poll_signal_raise(&ioThreadRunSignal, 1);
}
8 changes: 8 additions & 0 deletions firmware/src/src/sense.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,11 @@ static float magx = 0, magy = 0, magz = 0;
static float gyrx = 0, gyry = 0, gyrz = 0;
static float tilt = 0, roll = 0, pan = 0;
static float rolloffset = 0, panoffset = 0, tiltoffset = 0;
#if !defined(HAS_NOIMU)
static float magxoff = 0, magyoff = 0, magzoff = 0;
static float accxoff = 0, accyoff = 0, acczoff = 0;
static float gyrxoff = 0, gyryoff = 0, gyrzoff = 0;
#endif
static bool trpOutputEnabled = false; // Default to disabled T/R/P output
static bool gyroCalibrated = false;

Expand Down Expand Up @@ -760,6 +762,8 @@ void sensor_Thread()
}
#endif

// Below is all IMU Related, if no IMU don't compile it in
#if !defined(HAS_NOIMU)
// Setup Rotations
float rotation[3] = {trkset.getRotX(), trkset.getRotY(), trkset.getRotZ()};

Expand Down Expand Up @@ -1017,6 +1021,8 @@ void sensor_Thread()

k_mutex_unlock(&sensor_mutex);

#endif // If no sensor

// Adjust sleep for a more accurate period
senseUsDuration = micros64() - senseUsDuration;
if (SENSOR_PERIOD - senseUsDuration <
Expand All @@ -1042,6 +1048,7 @@ void sensor_Thread()

void gyroCalibrate()
{
#if !defined(HAS_NOIMU)
static float last_gyro_mag = 0;
static float last_acc_mag = 0;
static float filt_gyrx = 0;
Expand Down Expand Up @@ -1110,6 +1117,7 @@ void gyroCalibrate()

// Output in CSV format for determining limits
// printk("%.4f,%.2f,%.2f\n", (float)time / 1000000.0f, gyro_dif, acc_dif);
#endif
}

// FROM https://stackoverflow.com/questions/1628386/normalise-orientation-between-0-and-360
Expand Down
2 changes: 1 addition & 1 deletion firmware/src/tools/make_uf2.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
def after_hex_build(source, target, env):
firmware_path = str(target[0])
firmware_name = os.path.splitext(firmware_path)[0]
command = "python ./tools/uf2conv.py " + firmware_path + " -o " + firmware_name + ".UF2 -f 0xADA52840 -c -b 0x27000"
command = "python ./tools/uf2conv.py " + firmware_path + " -o " + firmware_name + ".uf2 -f 0xADA52840 -c -b 0x27000"
print("Converting .bin to .uf2 file")
os.system(command)

Expand Down
18 changes: 16 additions & 2 deletions gui/src/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1417,7 +1417,8 @@ void MainWindow::boardDiscovered(BoardType *brd)
// GUI changes info depending on board type
if(brd->boardName() == "NANO33BLE" ||
brd->boardName() == "DTQSYS" ||
brd->boardName() == "XIAOSENSE" ) {
brd->boardName() == "XIAOSENSE" ||
brd->boardName() == "XIAO52840" ) {
addToLog(tr("Connected to a ") + brd->boardName() + "\n");
ui->cmdStartGraph->setVisible(false);
ui->cmdStopGraph->setVisible(false);
Expand All @@ -1434,9 +1435,14 @@ void MainWindow::boardDiscovered(BoardType *brd)
ui->cmdReboot->setEnabled(true);
ui->stackedWidget->setCurrentIndex(3);
ui->cmdChannelViewer->setEnabled(true);
ui->grpLocalGraph->setVisible(true);
ui->grpRangeSel->setVisible(true);
ui->lblGyroCal->setVisible(true);
ui->gyroLed->setVisible(true);

if(brd->boardName() == "DTQSYS" ||
brd->boardName() == "XIAOSENSE") { // Pins are all fixed
brd->boardName() == "XIAOSENSE" ||
brd->boardName() == "XIAO52840" ) { // Pins are all fixed
ui->cmbPpmInPin->setVisible(false);
ui->lblPPMInPin->setVisible(false);
ui->cmbPpmOutPin->setVisible(false);
Expand All @@ -1448,6 +1454,14 @@ void MainWindow::boardDiscovered(BoardType *brd)
ui->lblAn5->setText(tr("Analog 1 (0.29)"));
ui->lblAn6->setText(tr("Analog 2 (0.02)"));
ui->lblAn7->setText(tr("Analog 3 (0.28)"));
if(brd->boardName() == "XIAO52840") {
ui->grpLocalGraph->setVisible(false);
ui->grpRangeSel->setVisible(false);
ui->cmdResetCenter->setVisible(false);
ui->cmdCalibrate->setVisible(false);
ui->lblGyroCal->setVisible(false);
ui->gyroLed->setVisible(false);
}
} else {
ui->cmbPpmInPin->setVisible(true);
ui->lblPPMInPin->setVisible(true);
Expand Down
6 changes: 3 additions & 3 deletions gui/src/mainwindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@
</attribute>
<layout class="QGridLayout" name="gridLayout_12">
<item row="11" column="0" colspan="3">
<layout class="QHBoxLayout" name="horizontalLayout_12">
<layout class="QHBoxLayout" name="hlayGyroCal">
<item>
<widget class="Led" name="gyroLed" native="true">
<property name="sizePolicy">
Expand Down Expand Up @@ -3239,7 +3239,7 @@
</layout>
</item>
<item>
<widget class="QGroupBox" name="groupBox">
<widget class="QGroupBox" name="grpRangeSel">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Maximum">
<horstretch>0</horstretch>
Expand Down Expand Up @@ -4060,7 +4060,7 @@
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_4">
<widget class="QGroupBox" name="grpLocalGraph">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
Expand Down
Loading