Skip to content

Commit

Permalink
Preparatory work for supporting input shaping
Browse files Browse the repository at this point in the history
  • Loading branch information
dc42 committed Dec 23, 2022
1 parent b72de30 commit 30af212
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/CanId.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ enum class CanMessageType : uint16_t
m569p6 = 6051,
m569p7 = 6052,
heaterModelNewNew = 6053,
setInputShapingParameters = 6054,

// Responses, broadcasts etc. sent by expansion boards
standardReply = 4510,
Expand Down
26 changes: 24 additions & 2 deletions src/CanMessageFormats.h
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,10 @@ struct __attribute__((packed)) CanMessageMovementLinear
uint32_t pressureAdvanceDrives : 8, // which drivers have pressure advance applied
numDrivers : 4, // how many drivers we included
seq : 7, // sequence number
zero : 13; // unused
shapeAcceleration : 1, // true if input shaping should be applied to acceleration segment
shapeDeceleration : 1, // true if input shaping should be applied to deceleration segment
replacement : 1, // true if this is a modification to a previously-sent move with the same whenToExecute value
zero : 10; // unused

float initialSpeedFraction; // the initial speed divided by the top speed
float finalSpeedFraction; // the final speed divided by the top speed
Expand All @@ -150,7 +153,14 @@ struct __attribute__((packed)) CanMessageMovementLinear

PerDriveValues perDrive[MaxLinearDriversPerCanSlave];

void SetRequestId(CanRequestId rid) noexcept { zero = 0; } // these messages don't have RIDs
void SetRequestId(CanRequestId rid) noexcept // these messages don't have RIDs
{
shapeAcceleration = 0;
shapeDeceleration = 0;
replacement = 0;
zero = 0;
}

void DebugPrint() const noexcept;

size_t GetActualDataLength() const noexcept
Expand Down Expand Up @@ -625,6 +635,7 @@ struct __attribute__((packed)) CanMessageHeaterTuningCommand
void SetRequestId(CanRequestId rid) noexcept { requestId = rid; zero = 0; zero2 = 0; }
};

// Configure heater feedforward
struct __attribute__((packed)) CanMessageHeaterFeedForward
{
static constexpr CanMessageType messageType = CanMessageType::heaterFeedForward;
Expand All @@ -639,6 +650,17 @@ struct __attribute__((packed)) CanMessageHeaterFeedForward
void SetRequestId(CanRequestId rid) noexcept { requestId = rid; zero = 0; zero2 = 0; }
};

// Configure input shaping
struct __attribute__((packed)) CanMessageSetInputShaping
{
static constexpr CanMessageType messageType = CanMessageType::setInputShapingParameters;

uint16_t requestId : 12,
zero : 4;

// remainder TODO
};

// Request to send a chunk of a firmware or bootloader file
struct __attribute__((packed)) CanMessageFirmwareUpdateRequest
{
Expand Down

0 comments on commit 30af212

Please sign in to comment.