Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
f7114aa
Command interface buffer size changes
Ultrawipf Aug 26, 2024
b33edde
SPI allow speed range
Ultrawipf Sep 28, 2023
fd7c1b3
Task delay in i2c eeprom
Ultrawipf Oct 21, 2023
a6aa0e1
Dynamic biss-c speed presets
Ultrawipf Oct 23, 2023
7b99444
Add force erase flag for debugging
Ultrawipf Dec 8, 2023
ca8468f
Set initial spi device config to actual current port config
Ultrawipf Jan 23, 2024
67fb5fd
Add analog encoder cal skip option
Ultrawipf Jan 30, 2024
f940e34
.gitignore added Debug
Ultrawipf Feb 7, 2024
4dd799e
TMC4671 restructured hw conf constants
Ultrawipf Feb 20, 2024
6fbe1a5
TMC allow autotuning I term definition
Ultrawipf Feb 22, 2024
ed65676
Commandhandler split register command template and prepared overriding
Ultrawipf Feb 22, 2024
5febed3
Make FFB capable axes optionally report 32b gamepad values
Ultrawipf Feb 26, 2024
785a4f5
Allow changing FFB update rates
Ultrawipf Mar 4, 2024
c2f784e
Added tasklist
Ultrawipf Mar 6, 2024
862b383
Periodic effect sampling using microsecond counter
Ultrawipf Mar 6, 2024
ffde94f
Corrected tmc hw config defines
Ultrawipf Mar 6, 2024
b4497d5
TMC4671 corrected brake pin settings.
Ultrawipf Mar 12, 2024
b9aeefe
Removed micros timer from canbridge
Ultrawipf Mar 19, 2024
2e368c3
Default ffb rate option
Ultrawipf Mar 19, 2024
8a4683f
Axis always returns a 32b value. mainclass does the scaling in 16b mode.
Ultrawipf Apr 2, 2024
29ddbd3
Prepared usb descriptor splitting.
Ultrawipf Apr 2, 2024
2b47451
Split HID gamepad report buffer into helper class
Ultrawipf Apr 4, 2024
3c02223
Cleanup
Ultrawipf Apr 8, 2024
bca95eb
I2C eeprom using port class.
Ultrawipf Apr 16, 2024
e67f11f
TMC check if motor is set before encoder init
Ultrawipf Apr 23, 2024
9843a8f
FFBWheel supporting variable range in 32b desc mode
Ultrawipf Apr 29, 2024
d396f62
HID command interface using reference in loop
Ultrawipf Apr 29, 2024
da0b439
Fixed first 16b axis being scaled incorrectly
Ultrawipf May 3, 2024
f616395
Axis updates friction and inertia filters on samplerate change
Ultrawipf Jun 14, 2024
1cda177
Allow overriding flash defaults. Requires >CPP20
Ultrawipf Aug 26, 2024
15ae944
Wait at least 1ms if no TIM_FFB defined
Ultrawipf Feb 10, 2025
ce15222
TMC4671 fix ext encoder timer not starting
Ultrawipf Feb 26, 2025
6026b4c
TMC4671 make ext enc timer ARR a define
Ultrawipf Feb 26, 2025
c1dc72c
Fixed timerless FFB updating waiting 1ms too long
Ultrawipf Jan 10, 2026
af7885f
Enabled TIM_FFB for F407VG target
Ultrawipf Jan 10, 2026
8d49485
Enable freertos task formatting for F407VG
Ultrawipf Jan 15, 2026
0d9c851
Write task info directly into string buffer
Ultrawipf Jan 15, 2026
4aaecc5
Fix SPI_Buttons constructor procedure (#164)
dracc Jan 16, 2026
cf7dd4d
Version bump 1.16.7
Ultrawipf Jan 18, 2026
45b62e7
Add RP2040 SPI_Buttons mode
dracc Nov 5, 2025
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: 2 additions & 3 deletions Firmware/.gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*Debug/
**/Debug/
**/Release/
**/.settings/
*.launch
Expand All @@ -7,5 +7,4 @@
.mxproject
fixlang
/build/
/OpenFFBoard/
/*Targets/F407VG/*.cfg
/OpenFFBoard/
4 changes: 2 additions & 2 deletions Firmware/FFBoard/Inc/AxesManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ class AxesManager
void emergencyStop(bool reset);
void resetPosZero();

void updateSamplerate(float newSamplerate);

private:
volatile Control_t* control;
volatile bool *p_usb_disabled;
volatile bool *p_emergency;
std::shared_ptr<EffectsCalculator> effects_calc;
uint16_t axis_count = 0;
std::vector<std::unique_ptr<Axis>> axes;
Expand Down
7 changes: 5 additions & 2 deletions Firmware/FFBoard/Inc/Axis.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ struct AxisConfig
struct metric_t {
float accel = 0; // in deg/s²
float speed = 0; // in deg/s
int32_t pos = 0; // scaled position as 16b int -0x7fff to 0x7fff
int32_t pos_scaled_16b = 0; // scaled position as 16b int -0x7fff to 0x7fff matching FFB ranges
float pos_f = 0; // scaled position as float. -1 to 1 range
float posDegrees = 0; // Position in degrees. Not scaled to selected range
int32_t torque = 0; // total of effect + endstop torque
Expand Down Expand Up @@ -171,6 +171,9 @@ class Axis : public PersistentStorage, public CommandHandler, public ErrorHandle
bool updateTorque(int32_t* totalTorque);


void updateSamplerate(float newSamplerate);
void updateFilters(uint8_t profileId);

void setGearRatio(uint8_t numerator,uint8_t denominator);

static const std::vector<class_entry<MotorDriver>> axis1_drivers;
Expand Down Expand Up @@ -259,7 +262,7 @@ class Axis : public PersistentStorage, public CommandHandler, public ErrorHandle
const biquad_constant_t filterFrictionCst = {50, 20};
const biquad_constant_t filterInertiaCst = {20, 20};
uint8_t filterProfileId = 1; // Default medium (1) as this is the most common encoder resolution and users can go lower or higher if required.
const float filter_f = 1000; // 1khz
float filter_f = 1000; // 1khz default. should be set at runtime once the actual rate is known
const int32_t intFxClip = 20000;
uint8_t damperIntensity = 30;

Expand Down
2 changes: 2 additions & 0 deletions Firmware/FFBoard/Inc/CmdParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@
#include "CommandHandler.h"
#include "ringbufferwrapper.h"

#ifndef CMDPARSER_MAX_VALID_CAPACITY
#define CMDPARSER_MAX_VALID_CAPACITY 2048
#endif

class CommandHandler;
class CommandInterface;
Expand Down
27 changes: 18 additions & 9 deletions Firmware/FFBoard/Inc/CommandHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#include "mutex.hpp"
#include "ClassIDs.h"
#include <vector>

#include <span>

#define CMDFLAG_GET 0x01
#define CMDFLAG_SET 0x02
Expand All @@ -22,6 +22,7 @@
#define CMDFLAG_SETADR 0x20
#define CMDFLAG_HIDDEN 0x40
#define CMDFLAG_DEBUG 0x80
#define CMDFLAG_EXTOVERRIDE 0x80000000

#define CMDFLAG_STR_ONLY 0x100
#define CMDFLAG_HID_ONLY 0x200 // Command not available for string based parsers
Expand Down Expand Up @@ -50,8 +51,8 @@ class CmdHandlerCommanddef
{};
const char* cmd = nullptr;
const char* helpstring = nullptr;
const uint32_t cmdId;
const uint32_t flags;
uint32_t cmdId;
uint32_t flags;
};

struct CmdHandlerInfo
Expand Down Expand Up @@ -260,17 +261,22 @@ class CommandHandler {
*/
template<typename ID>
void registerCommand(const char* cmd,const ID cmdid,const char* help=nullptr,uint32_t flags = 0){
for(CmdHandlerCommanddef& cmdDef : registeredCommands){
if(cmdDef.cmdId == static_cast<uint32_t>(cmdid))
return; //already present
}
registerCommand_INT(cmd, static_cast<uint32_t>(cmdid), help, flags);
}

this->registeredCommands.emplace_back(cmd, help,static_cast<uint32_t>(cmdid),flags);
this->registeredCommands.shrink_to_fit();

virtual void postCmdhandlerInit(){}; // Can implement in external file to override command flags
template<typename ID>
/**
* Can override command flags to make it read only
*/
void overrideCommandFlags(const ID cmdid,uint32_t flagmask = 0){
overrideCommandFlags_INT(static_cast<uint32_t>(cmdid), flagmask);
}




protected:
void setInstance(uint8_t instance);
bool commandsEnabled = true;
Expand All @@ -287,6 +293,9 @@ class CommandHandler {

CmdHandlerInfo cmdHandlerInfo;

void registerCommand_INT(const char* cmd,const uint32_t cmdid,const char* help=nullptr,uint32_t flags = 0);
void overrideCommandFlags_INT(const uint32_t cmdid,uint32_t flagmask = CMDFLAG_GET | CMDFLAG_GETADR);

};

#endif /* COMMANDHANDLER_H_ */
4 changes: 2 additions & 2 deletions Firmware/FFBoard/Inc/CommandInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class StringCommandInterface : public CommandInterface{
CmdParser parser; // String parser
};


#define CDC_CMD_BUFFER_SIZE (TUD_OPT_HIGH_SPEED ? 4096 : 1024)
//receives bytes from mainclass. calls its own parser instance, calls global parser thread, passes replies back to cdc port.
class CDC_CommandInterface : public StringCommandInterface,public cpp_freertos::Thread{
public:
Expand All @@ -83,7 +83,7 @@ class CDC_CommandInterface : public StringCommandInterface,public cpp_freertos::
bool nextFormat = false;
std::string sendBuffer;
uint32_t bufferLength = 0;
const uint32_t maxSendBuffer = 1024; // Max buffered command size before sending immediately
const uint32_t maxSendBuffer = CDC_CMD_BUFFER_SIZE; // Max buffered command size before sending immediately
};


Expand Down
11 changes: 7 additions & 4 deletions Firmware/FFBoard/Inc/EffectsCalculator.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class EffectsCalculator: public PersistentStorage,
uint8_t getGain();
void logEffectType(uint8_t type,bool remove = false);
//void setDirectionEnableMask(uint8_t mask);
void calcStatsEffectType(uint8_t type, int16_t force,uint8_t axis);
void calcStatsEffectType(uint8_t type, int32_t force,uint8_t axis);
void logEffectState(uint8_t type,uint8_t state);
void resetLoggedActiveEffects(bool reinit);

Expand All @@ -100,6 +100,8 @@ class EffectsCalculator: public PersistentStorage,
// Thread impl
void Run();

void updateSamplerate(float newSamplerate); // Must be called if update rate is changed to update filters and effects


protected:

Expand All @@ -108,7 +110,7 @@ class EffectsCalculator: public PersistentStorage,
// Filters
effect_biquad_t filter[2]; // 0 is the default profile and the custom for CFFilter, CUSTOM_PROFILE_ID is the custom slot
uint8_t filterProfileId = 0;
const uint32_t calcfrequency = 1000; // HID frequency 1khz
uint32_t calcfrequency = 1000; // HID frequency 1khz
const float qfloatScaler = 0.01;

// Rescale factor for conditional effect to boost or decrease the intensity
Expand Down Expand Up @@ -150,10 +152,11 @@ class EffectsControlItf{
virtual void set_gain(uint8_t gain) = 0;
virtual void cfUpdateEvent();
virtual void fxUpdateEvent();
virtual void updateSamplerate(float newSamplerate) = 0; // Should be called when update loop rate is changed

private:
FastMovingAverage<float> fxPeriodAvg{20};
FastMovingAverage<float> cfUpdatePeriodAvg{20};
FastMovingAverage<float> fxPeriodAvg{5};
FastMovingAverage<float> cfUpdatePeriodAvg{5};

uint32_t lastFxUpdate = 0;
uint32_t lastCfUpdate = 0;
Expand Down
1 change: 1 addition & 0 deletions Firmware/FFBoard/Inc/HidFFB.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class HidFFB: public UsbHidHandler, public EffectsControlItf {

void sendStatusReport(uint8_t effect);
void setDirectionEnableMask(uint8_t mask);
void updateSamplerate(float newSamplerate);

private:
// HID
Expand Down
3 changes: 2 additions & 1 deletion Firmware/FFBoard/Inc/SPI.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

#include "SpiHandler.h"
#include "semaphore.hpp"
#include <math.h>

struct SPIConfig {
SPIConfig(OutputPin cs,bool cspol = true)
Expand Down Expand Up @@ -77,7 +78,7 @@ class SPIPort: public SpiHandler {
bool hasFreePins();

uint32_t getBaseClk();
std::pair<uint32_t,float> getClosestPrescaler(float clock);
std::pair<uint32_t,float> getClosestPrescaler(float clock,float min = 0, float max = INFINITY);

SPI_HandleTypeDef* getPortHandle();

Expand Down
1 change: 1 addition & 0 deletions Firmware/FFBoard/Inc/SerialFFB.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class SerialFFB : public CommandHandler, public EffectsControlItf{
void setMagnitude(uint8_t idx,int16_t magnitude);

void setEffectState(uint8_t id, bool state);
void updateSamplerate(float newSamplerate);

private:
static ClassIdentifier info;
Expand Down
2 changes: 1 addition & 1 deletion Firmware/FFBoard/Inc/SystemCommands.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#include "CommandHandler.h"

enum class FFBoardMain_commands : uint32_t{
help=0,save=1,reboot=2,dfu=3,swver=4,hwtype=5,lsmain,main,lsactive,format,errors,errorsclr,flashdump,flashraw,vint,vext,mallinfo,heapfree,taskstats,debug,devid,uid,temp,otp,signature
help=0,save=1,reboot=2,dfu=3,swver=4,hwtype=5,lsmain,main,lsactive,format,errors,errorsclr,flashdump,flashraw,vint,vext,mallinfo,heapfree,taskstats,debug,devid,uid,temp,otp,signature,tasklist
};

class SystemCommands : public CommandHandler {
Expand Down
10 changes: 9 additions & 1 deletion Firmware/FFBoard/Inc/constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* For more settings see target_constants.h in a target specific folder
*/

static const uint8_t SW_VERSION_INT[3] = {1,16,6}; // Version as array. 8 bit each!
static const uint8_t SW_VERSION_INT[3] = {1,16,7}; // Version as array. 8 bit each!
#ifndef MAX_AXIS
#define MAX_AXIS 2 // ONLY USE 2 for now else screws HID Reports
#endif
Expand All @@ -31,11 +31,19 @@ static const uint8_t SW_VERSION_INT[3] = {1,16,6}; // Version as array. 8 bit ea

#ifdef FFBWHEEL
#ifdef FFBWHEEL_USE_1AXIS_DESC
#ifdef HIDAXISRES_USE_32B_DESC
#define AXIS1_FFB_HID_DESC_32B
#else
#define AXIS1_FFB_HID_DESC
#endif
#else
#ifdef HIDAXISRES_USE_32B_DESC
#define AXIS2_FFB_HID_DESC_32B
#else
#define AXIS2_FFB_HID_DESC
#endif
#endif
#endif

#ifdef FFBJOYSTICK
#define AXIS2_FFB_HID_DESC
Expand Down
4 changes: 4 additions & 0 deletions Firmware/FFBoard/Inc/cpp_target_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,8 @@ extern const OutputPin debugpin;
extern const OutputPin gpMotor;
#endif

#if defined(I2C_PORT_EEPROM)
extern I2CPort i2cport_int;
#endif

#endif
Loading