Sfoglia il codice sorgente

Cleanup hybrid code

Thomas Hondema 1 settimana fa
parent
commit
fa6a290579

+ 1 - 1
README.md

@@ -31,4 +31,4 @@ internal members that hold them have descriptive names (for example `brewSetpoin
 This project is inspired by the open-source spirit of the original meCoffee community. Feel free to submit pull requests, report issues, or suggest new features to help make the perfect shot.
 This project is inspired by the open-source spirit of the original meCoffee community. Feel free to submit pull requests, report issues, or suggest new features to help make the perfect shot.
 
 
 ---
 ---
-*Disclaimer: this meCoffee firmware is an independent project and is not officially affiliated with the hardware manufacturer.*
+*Disclaimer: this meCoffee firmware is an independent project and is not officially affiliated with the hardware manufacturer.*

+ 0 - 26
lib/meCoffee_controller_logic/src/command_protocol.cpp

@@ -9,18 +9,8 @@
 #include "serial_output.h"
 #include "serial_output.h"
 #include "telemetry_reports.h"
 #include "telemetry_reports.h"
 
 
-#if defined(MECOFFEE_RUST_COMMAND_READER)
-extern "C" uint16_t mecoffee_rust_accept_command_byte(uint8_t* bytes, uint8_t length, uint8_t receivedByte);
-#endif
-
 namespace meCoffee {
 namespace meCoffee {
 
 
-#if defined(MECOFFEE_RUST_COMMAND_HANDLERS)
-extern "C" void mecoffee_rust_dispatch_command(void*, const uint8_t*, uint8_t);
-void dispatchCommandLine(FirmwareState* state, char* text, uint8_t length) {
-    mecoffee_rust_dispatch_command(state, reinterpret_cast<const uint8_t*>(text), length);
-}
-#else
 namespace {
 namespace {
 
 
 constexpr uint8_t kMaximumArgumentCount = 4;
 constexpr uint8_t kMaximumArgumentCount = 4;
@@ -411,22 +401,7 @@ void dispatchCommandLine(FirmwareState* state, char* commandLineText, uint8_t co
     }
     }
 }
 }
 
 
-#endif
-
 void acceptReceivedByte(FirmwareState* state, uint8_t receivedByte) {
 void acceptReceivedByte(FirmwareState* state, uint8_t receivedByte) {
-#if defined(MECOFFEE_RUST_COMMAND_READER)
-    static_assert(kCommandLineCapacity == 31, "Rust command buffer capacity must match");
-    // Rust borrows only the 31 payload bytes for this call. Dispatch can mutate
-    // the buffer and append its NUL only after the Rust borrow has ended.
-    const uint16_t result = mecoffee_rust_accept_command_byte(
-        reinterpret_cast<uint8_t*>(state->commandLine), state->commandLineLength, receivedByte);
-    if ((result & 0x100u) != 0) {
-        state->commandLineLength = 0;
-        dispatchCommandLine(state, state->commandLine, static_cast<uint8_t>(result));
-    } else {
-        state->commandLineLength = static_cast<uint8_t>(result);
-    }
-#else
     if (receivedByte == 0) {
     if (receivedByte == 0) {
         return;
         return;
     }
     }
@@ -439,7 +414,6 @@ void acceptReceivedByte(FirmwareState* state, uint8_t receivedByte) {
     if (state->commandLineLength < kCommandLineCapacity) {
     if (state->commandLineLength < kCommandLineCapacity) {
         state->commandLine[state->commandLineLength++] = static_cast<char>(receivedByte);
         state->commandLine[state->commandLineLength++] = static_cast<char>(receivedByte);
     }
     }
-#endif
 }
 }
 
 
 }  // namespace meCoffee
 }  // namespace meCoffee

+ 0 - 23
lib/meCoffee_controller_logic/src/diagnostic_queue.cpp

@@ -4,28 +4,6 @@
 #include "serial_output.h"
 #include "serial_output.h"
 
 
 namespace meCoffee {
 namespace meCoffee {
-#if defined(MECOFFEE_RUST_DIAGNOSTICS)
-extern "C" {
-void mecoffee_rust_enqueue_callback(DiagnosticQueue*,DiagnosticCallback);
-void mecoffee_rust_enqueue_flash(DiagnosticQueue*,const char*);
-uint8_t mecoffee_rust_service_queue(DiagnosticQueue*,void*,uint32_t);
-}
-static_assert(sizeof(DiagnosticQueue)==38,"Rust queue ABI");
-void enqueueDiagnosticCallback(DiagnosticQueue* q,DiagnosticCallback callback) { mecoffee_rust_enqueue_callback(q,callback); }
-void enqueueDiagnosticProgramMemoryText(DiagnosticQueue* q,const char* text) { mecoffee_rust_enqueue_flash(q,text); }
-bool serviceDiagnosticQueue(FirmwareState* s,uint32_t now) {
-    auto& queue=s->diagnosticQueue;
-    // Avoid a cross-language call on the hot, not-due/empty path. The Rust
-    // service rechecks these conditions before consuming a slot.
-    if(queue.isReportingInhibited || queue.nextServiceDeadline>=now) return false;
-    const auto& slot=queue.slots[queue.consumerIndex];
-    if(!slot.callback && !slot.ramText && !slot.programMemoryText) return false;
-    return mecoffee_rust_service_queue(&queue,s,now)!=0;
-}
-extern "C" void mecoffee_queue_ram_text(const char* text) { writeRamText(text); }
-extern "C" void mecoffee_queue_tail() { writeProgramMemoryText(MECOFFEE_PROGRAM_TEXT(" OK\r\n")); }
-#else
-
 
 
 namespace {
 namespace {
 
 
@@ -78,5 +56,4 @@ bool serviceDiagnosticQueue(FirmwareState* state, uint32_t foregroundSnapshotMil
     return true;
     return true;
 }
 }
 
 
-#endif
 }  // namespace meCoffee
 }  // namespace meCoffee

+ 0 - 18
lib/meCoffee_controller_logic/src/firmware_runtime.cpp

@@ -2,12 +2,6 @@
 
 
 #include <string.h>
 #include <string.h>
 
 
-#if defined(MECOFFEE_RUST_COMMAND_HANDLERS)
-#include <stddef.h>
-#include <avr/io.h>
-#include <avr/interrupt.h>
-#endif
-
 #include "command_protocol.h"
 #include "command_protocol.h"
 #include "diagnostic_queue.h"
 #include "diagnostic_queue.h"
 #include "hardware_seam.h"
 #include "hardware_seam.h"
@@ -148,19 +142,7 @@ void runAggregateServiceWhenDue(FirmwareState* state, uint32_t foregroundSnapsho
 
 
 void runForegroundIteration() {
 void runForegroundIteration() {
     FirmwareState& state = firmwareState();
     FirmwareState& state = firmwareState();
-#if defined(MECOFFEE_RUST_COMMAND_HANDLERS)
-    static_assert(offsetof(FirmwareState, foregroundSnapshotMilliseconds) == 0x24f,
-                  "timestamp publication probe layout");
-    // INT0 copies this four-byte foreground timestamp. Publishing a partial
-    // millisecond rollover can otherwise produce a spurious power-loss report.
-    const uint32_t now = hardware::readMillisecondCounter();
-    const uint8_t saved = SREG;
-    cli();
-    state.foregroundSnapshotMilliseconds = now;
-    SREG = saved;
-#else
     state.foregroundSnapshotMilliseconds = hardware::readMillisecondCounter();
     state.foregroundSnapshotMilliseconds = hardware::readMillisecondCounter();
-#endif
     const uint32_t foregroundSnapshotMilliseconds = state.foregroundSnapshotMilliseconds;
     const uint32_t foregroundSnapshotMilliseconds = state.foregroundSnapshotMilliseconds;
 
 
     reportPowerLossIfMainsStopped(&state, foregroundSnapshotMilliseconds);
     reportPowerLossIfMainsStopped(&state, foregroundSnapshotMilliseconds);

+ 0 - 3
lib/meCoffee_controller_logic/src/heater_controller.cpp

@@ -1,4 +1,3 @@
-#if !defined(MECOFFEE_RUST_HEATER)
 #include "heater_controller.h"
 #include "heater_controller.h"
 
 
 #include "diagnostic_queue.h"
 #include "diagnostic_queue.h"
@@ -232,5 +231,3 @@ uint16_t computePressureDemand(const SettingsValues& settings, uint32_t duration
 }
 }
 
 
 }  // namespace meCoffee
 }  // namespace meCoffee
-
-#endif

+ 0 - 3
lib/meCoffee_controller_logic/src/module_provisioning.cpp

@@ -1,4 +1,3 @@
-#if !defined(MECOFFEE_RUST_RADIO)
 #include "module_provisioning.h"
 #include "module_provisioning.h"
 
 
 #include "hardware_seam.h"
 #include "hardware_seam.h"
@@ -147,5 +146,3 @@ void captureRadioModuleReplyInAtMode(FirmwareState* state) {
 }
 }
 
 
 }  // namespace meCoffee
 }  // namespace meCoffee
-
-#endif

+ 0 - 37
lib/meCoffee_controller_logic/src/numeric_conversion.cpp

@@ -7,41 +7,6 @@
 
 
 namespace meCoffee {
 namespace meCoffee {
 
 
-#if defined(MECOFFEE_RUST_NUMERIC)
-extern "C" {
-float mecoffee_rust_parse_decimal(const char*, DecimalParseDiagnostics*);
-uint32_t mecoffee_rust_parse_integer(const char*);
-uint32_t mecoffee_rust_float_unsigned(float, bool*);
-int32_t mecoffee_rust_float_signed(float);
-uint8_t mecoffee_rust_format_unsigned(uint32_t, char*);
-}
-static_assert(sizeof(DecimalParseDiagnostics) == 11, "Rust decimal diagnostics layout");
-static_assert(sizeof(bool) == 1, "Rust status byte layout");
-float parseDecimalFloatingPoint(const char* text, DecimalParseDiagnostics* diagnostics) {
-    return mecoffee_rust_parse_decimal(text, diagnostics);
-}
-uint32_t convertFloatToUnsigned32(float value, bool* flagged) {
-    return mecoffee_rust_float_unsigned(value, flagged);
-}
-int32_t convertFloatToSigned32(float value) { return mecoffee_rust_float_signed(value); }
-uint16_t parseIntegerPrefixModulo65536(const char* text) {
-    return static_cast<uint16_t>(mecoffee_rust_parse_integer(text));
-}
-uint32_t parseIntegerPrefixModulo4294967296(const char* text) {
-    return mecoffee_rust_parse_integer(text);
-}
-uint8_t formatUnsignedDecimal(uint32_t value, char* output) {
-    return mecoffee_rust_format_unsigned(value, output);
-}
-uint8_t formatSignedDecimal(int32_t value, char* output) {
-    if (value < 0) {
-        output[0] = '-';
-        return 1 + formatUnsignedDecimal(0 - static_cast<uint32_t>(value), output + 1);
-    }
-    return formatUnsignedDecimal(static_cast<uint32_t>(value), output);
-}
-#else
-
 namespace {
 namespace {
 
 
 // binary32 bit patterns for 10^-w and 10^+w with w = 1, 2, 4, 8, 16, 32.
 // binary32 bit patterns for 10^-w and 10^+w with w = 1, 2, 4, 8, 16, 32.
@@ -320,6 +285,4 @@ uint8_t formatSignedDecimal(int32_t numericValue, char* outputBuffer) {
     return formatUnsignedDecimal(static_cast<uint32_t>(numericValue), outputBuffer);
     return formatUnsignedDecimal(static_cast<uint32_t>(numericValue), outputBuffer);
 }
 }
 
 
-
-#endif
 }  // namespace meCoffee
 }  // namespace meCoffee

+ 0 - 15
lib/meCoffee_controller_logic/src/oscillator_adjustment.cpp

@@ -1,23 +1,9 @@
 #include "oscillator_adjustment.h"
 #include "oscillator_adjustment.h"
 
 
-#if defined(MECOFFEE_RUST_OSCILLATOR)
-extern "C" uint32_t mecoffee_rust_adjust_oscillator(uint8_t events, int16_t offset,
-                                                 uint8_t baseline, uint8_t period);
-#endif
-
 namespace meCoffee {
 namespace meCoffee {
 
 
 OscillatorAdjustmentResult adjustOscillator(uint8_t qualifiedEventCount, int16_t oldOffset, uint8_t baselineByte,
 OscillatorAdjustmentResult adjustOscillator(uint8_t qualifiedEventCount, int16_t oldOffset, uint8_t baselineByte,
                                             uint8_t oldFractionPeriod) {
                                             uint8_t oldFractionPeriod) {
-#if defined(MECOFFEE_RUST_OSCILLATOR)
-    const uint32_t packed = mecoffee_rust_adjust_oscillator(qualifiedEventCount, oldOffset, baselineByte, oldFractionPeriod);
-    OscillatorAdjustmentResult result;
-    result.newOffset = static_cast<int16_t>(static_cast<uint16_t>(packed));
-    result.newFractionPeriod = static_cast<uint8_t>(packed >> 16);
-    result.calibrationValue = static_cast<uint8_t>(packed >> 24);
-    result.shouldWriteCalibration = result.calibrationValue != 0;
-    return result;
-#else
     OscillatorAdjustmentResult result;
     OscillatorAdjustmentResult result;
     result.newOffset = oldOffset;
     result.newOffset = oldOffset;
     result.newFractionPeriod = oldFractionPeriod;
     result.newFractionPeriod = oldFractionPeriod;
@@ -57,7 +43,6 @@ OscillatorAdjustmentResult adjustOscillator(uint8_t qualifiedEventCount, int16_t
         result.calibrationValue = calibrationValue;
         result.calibrationValue = calibrationValue;
     }
     }
     return result;
     return result;
-#endif
 }
 }
 
 
 }  // namespace meCoffee
 }  // namespace meCoffee

+ 0 - 14
lib/meCoffee_controller_logic/src/output_channels.cpp

@@ -1,10 +1,5 @@
 #include "output_channels.h"
 #include "output_channels.h"
 
 
-#if defined(MECOFFEE_RUST_COMMAND_HANDLERS)
-#include <avr/io.h>
-#include <avr/interrupt.h>
-#endif
-
 namespace meCoffee {
 namespace meCoffee {
 
 
 namespace {
 namespace {
@@ -14,18 +9,9 @@ constexpr uint8_t kPumpToggleCount = 200;
 constexpr uint8_t kValveToggleCount = 200;
 constexpr uint8_t kValveToggleCount = 200;
 
 
 void applyGroupStateToLeaf(const OutputGroup& group, OutputLeaf* leaf) {
 void applyGroupStateToLeaf(const OutputGroup& group, OutputLeaf* leaf) {
-#if defined(MECOFFEE_RUST_COMMAND_HANDLERS)
-    // Routing tables are foreground-only. Mask only the ISR-visible leaf
-    // publication, not the search/detach/attach traversal around it.
-    const uint8_t saved = SREG;
-    cli();
-#endif
     leaf->configuredToggleCount = group.configuredToggleCount;
     leaf->configuredToggleCount = group.configuredToggleCount;
     leaf->startThreshold = group.amplitude;
     leaf->startThreshold = group.amplitude;
     leaf->isEnabled = group.isEnabled;
     leaf->isEnabled = group.isEnabled;
-#if defined(MECOFFEE_RUST_COMMAND_HANDLERS)
-    SREG = saved;
-#endif
 }
 }
 
 
 void attachLeafToGroup(OutputGroup* group, OutputLeaf* leaf) {
 void attachLeafToGroup(OutputGroup* group, OutputLeaf* leaf) {

+ 0 - 37
lib/meCoffee_controller_logic/src/persistent_settings_store.cpp

@@ -3,41 +3,6 @@
 #include "hardware_seam.h"
 #include "hardware_seam.h"
 
 
 namespace meCoffee {
 namespace meCoffee {
-#if defined(MECOFFEE_RUST_PERSISTENCE)
-extern "C" {
-void mecoffee_rust_persistent_initialize();
-uint16_t mecoffee_rust_persistent_find(const uint8_t*, uint8_t);
-uint16_t mecoffee_rust_persistent_append(const uint8_t*, uint8_t, uint8_t);
-void mecoffee_rust_persistent_store(uint16_t, const uint8_t*);
-void mecoffee_rust_persistent_load(uint16_t, uint8_t*);
-void mecoffee_persistent_write(uint16_t address, uint8_t value) { hardware::writePersistentByte(address, value); }
-}
-namespace {
-uint8_t copyKey(const char* flash, uint8_t (&key)[10]) {
-    uint8_t length = 0;
-    while (length < sizeof key) {
-        const uint8_t value = hardware::readProgramMemoryByte(flash + length);
-        if (value == 0) break;
-        key[length++] = value;
-    }
-    return length;
-}
-}
-void ensurePersistentStoreIsInitialized() { mecoffee_rust_persistent_initialize(); }
-uint16_t findPersistentRecord(const char* key) {
-    uint8_t ram[10];
-    const uint8_t length = copyKey(key, ram);
-    return mecoffee_rust_persistent_find(ram, length);
-}
-uint16_t appendPersistentRecord(const char* key, uint8_t width) {
-    uint8_t ram[10];
-    const uint8_t length = copyKey(key, ram);
-    return mecoffee_rust_persistent_append(ram, length, width);
-}
-void storePersistentRecordPayload(uint16_t handle, const uint8_t* raw) { mecoffee_rust_persistent_store(handle, raw); }
-void loadPersistentRecordPayload(uint16_t handle, uint8_t* raw) { mecoffee_rust_persistent_load(handle, raw); }
-#else
-
 
 
 namespace {
 namespace {
 
 
@@ -162,8 +127,6 @@ void loadPersistentRecordPayload(uint16_t recordHandle, uint8_t* rawBytes) {
     }
     }
 }
 }
 
 
-#endif
-
 void registerAndRestoreSettings(SettingsValues* settings, uint16_t recordHandles[kSettingCount]) {
 void registerAndRestoreSettings(SettingsValues* settings, uint16_t recordHandles[kSettingCount]) {
     constexpr uint16_t kMaximumRestoredTwoByteValue = 32000;
     constexpr uint16_t kMaximumRestoredTwoByteValue = 32000;
     constexpr uint32_t kMaximumRestoredScheduleValue = 86400;
     constexpr uint32_t kMaximumRestoredScheduleValue = 86400;

+ 0 - 3
lib/meCoffee_controller_logic/src/power_schedule.cpp

@@ -1,4 +1,3 @@
-#if !defined(MECOFFEE_RUST_SCHEDULE)
 #include "power_schedule.h"
 #include "power_schedule.h"
 
 
 #include "diagnostic_queue.h"
 #include "diagnostic_queue.h"
@@ -118,5 +117,3 @@ ScheduleDecision runScheduleStages(FirmwareState* state, uint32_t foregroundSnap
 }
 }
 
 
 }  // namespace meCoffee
 }  // namespace meCoffee
-
-#endif

+ 0 - 25
lib/meCoffee_controller_logic/src/sensor_sampling.cpp

@@ -3,14 +3,6 @@
 #include "hardware_seam.h"
 #include "hardware_seam.h"
 
 
 namespace meCoffee {
 namespace meCoffee {
-#if defined(MECOFFEE_RUST_SENSOR)
-extern "C" uint16_t mecoffee_rust_sensor_transition(uint8_t, uint8_t, uint8_t);
-extern "C" uint16_t mecoffee_rust_sensor_aggregate(uint16_t*, uint8_t*, uint8_t, uint8_t);
-extern "C" void mecoffee_sensor_range_pin(uint8_t selector, uint8_t high) {
-    hardware::writeRangeIndicatorPin(selector, high != 0);
-}
-#endif
-
 
 
 namespace {
 namespace {
 
 
@@ -33,7 +25,6 @@ bool isControllerOnLightPath(const FirmwareState& state) {
     return isBelowUsableAggregate || isSteamBypass || isDiscreteControl || isControllerBlocked;
     return isBelowUsableAggregate || isSteamBypass || isDiscreteControl || isControllerBlocked;
 }
 }
 
 
-#if !defined(MECOFFEE_RUST_SENSOR)
 void sortAscending(uint16_t* ring) {
 void sortAscending(uint16_t* ring) {
     for (uint8_t position = 1; position < kSensorRingLength; ++position) {
     for (uint8_t position = 1; position < kSensorRingLength; ++position) {
         const uint16_t movingValue = ring[position];
         const uint16_t movingValue = ring[position];
@@ -46,21 +37,10 @@ void sortAscending(uint16_t* ring) {
     }
     }
 }
 }
 
 
-
-#endif
 }  // namespace
 }  // namespace
 
 
 uint8_t storeConversionResult(FirmwareState* state, uint16_t conversionResult) {
 uint8_t storeConversionResult(FirmwareState* state, uint16_t conversionResult) {
     SensorState& sensor = state->sensor;
     SensorState& sensor = state->sensor;
-#if defined(MECOFFEE_RUST_SENSOR)
-    const uint16_t transition = mecoffee_rust_sensor_transition(sensor.ringWriteIndex,
-        sensor.currentChannel, state->settings.secondSensorChannelEnabled != 0);
-    const uint8_t nextIndex = static_cast<uint8_t>(transition);
-    uint16_t* ring = (sensor.currentChannel & 1) != 0 ? sensor.firstRing : sensor.secondRing;
-    ring[nextIndex & (kSensorRingLength - 1)] = conversionResult;
-    sensor.ringWriteIndex = nextIndex;
-    return static_cast<uint8_t>(transition >> 8);
-#else
     if ((sensor.currentChannel & 1) != 0) {
     if ((sensor.currentChannel & 1) != 0) {
         sensor.firstRing[(sensor.ringWriteIndex + 1) & (kSensorRingLength - 1)] = conversionResult;
         sensor.firstRing[(sensor.ringWriteIndex + 1) & (kSensorRingLength - 1)] = conversionResult;
         sensor.ringWriteIndex = static_cast<uint8_t>(sensor.ringWriteIndex + 1);
         sensor.ringWriteIndex = static_cast<uint8_t>(sensor.ringWriteIndex + 1);
@@ -68,16 +48,12 @@ uint8_t storeConversionResult(FirmwareState* state, uint16_t conversionResult) {
     }
     }
     sensor.secondRing[sensor.ringWriteIndex & (kSensorRingLength - 1)] = conversionResult;
     sensor.secondRing[sensor.ringWriteIndex & (kSensorRingLength - 1)] = conversionResult;
     return kFirstTemperatureChannel;
     return kFirstTemperatureChannel;
-#endif
 }
 }
 
 
 uint16_t aggregateSensorRing(FirmwareState* state, uint16_t* ring, uint8_t rangeSelector) {
 uint16_t aggregateSensorRing(FirmwareState* state, uint16_t* ring, uint8_t rangeSelector) {
     SensorState& sensor = state->sensor;
     SensorState& sensor = state->sensor;
     uint8_t& rangeFlag = rangeSelector == 0 ? sensor.firstRangeFlag : sensor.secondRangeFlag;
     uint8_t& rangeFlag = rangeSelector == 0 ? sensor.firstRangeFlag : sensor.secondRangeFlag;
 
 
-#if defined(MECOFFEE_RUST_SENSOR)
-    return mecoffee_rust_sensor_aggregate(ring, &rangeFlag, sensor.isRangeMaintenanceDisabled, rangeSelector);
-#else
     sortAscending(ring);
     sortAscending(ring);
     uint16_t centralSum = 0;
     uint16_t centralSum = 0;
     for (uint8_t position = kCentralWindowStart; position < kCentralWindowEnd; ++position) {
     for (uint8_t position = kCentralWindowStart; position < kCentralWindowEnd; ++position) {
@@ -106,7 +82,6 @@ uint16_t aggregateSensorRing(FirmwareState* state, uint16_t* ring, uint8_t range
     }
     }
 
 
     return roundedAggregate != 0 ? static_cast<uint16_t>(aggregateBeforeOffset + 2) : 0;
     return roundedAggregate != 0 ? static_cast<uint16_t>(aggregateBeforeOffset + 2) : 0;
-#endif
 }
 }
 
 
 void initializeSensorSampling(FirmwareState* state) {
 void initializeSensorSampling(FirmwareState* state) {

+ 0 - 68
lib/meCoffee_controller_logic/src/shot_control.cpp

@@ -6,31 +6,10 @@
 #include "program_memory.h"
 #include "program_memory.h"
 #include "serial_output.h"
 #include "serial_output.h"
 
 
-#if defined(MECOFFEE_RUST_SHOT)
-#include <avr/io.h>
-#include <avr/interrupt.h>
-#include <stddef.h>
-struct RustShotSettings {uint16_t enabled,closed,pump,pause,maximum;};
-extern "C" {
-void mecoffee_rust_shot_event(meCoffee::ShotState*,uint8_t,uint32_t,uint32_t,void*);
-void mecoffee_rust_shot_active(meCoffee::ShotState*,const RustShotSettings*,uint8_t,uint32_t,uint32_t,void*);
-void mecoffee_rust_poll_input(meCoffee::DebouncedInput*,uint8_t,uint8_t,uint32_t,void*);
-uint16_t mecoffee_rust_shot_layout(uint8_t);
-}
-static_assert(sizeof(meCoffee::ShotState)==5,"shot state ABI");
-static_assert(sizeof(meCoffee::DebouncedInput)==15,"input state ABI");
-static_assert(offsetof(meCoffee::DebouncedInput,beginTimestamp)==3,"input begin ABI");
-#endif
-
 namespace meCoffee {
 namespace meCoffee {
 
 
 namespace {
 namespace {
 
 
-#if defined(MECOFFEE_RUST_TELEMETRY)
-extern "C" void mecoffee_rust_telemetry(void*,uint8_t);
-void reportShotBegin(FirmwareState& state) { mecoffee_rust_telemetry(&state,3); }
-void reportShotEnd(FirmwareState& state) { mecoffee_rust_telemetry(&state,4); }
-#else
 void reportShotBegin(FirmwareState& state) {
 void reportShotBegin(FirmwareState& state) {
     if (state.alternateModeSelection != 0) {
     if (state.alternateModeSelection != 0) {
         return;
         return;
@@ -52,39 +31,24 @@ void reportShotEnd(FirmwareState& state) {
     writeProgramMemoryText(MECOFFEE_PROGRAM_TEXT(" OK"));
     writeProgramMemoryText(MECOFFEE_PROGRAM_TEXT(" OK"));
     writeCarriageReturnLineFeed();
     writeCarriageReturnLineFeed();
 }
 }
-#endif
-
 
 
 void beginShotEvent(FirmwareState* state, uint32_t timestamp) {
 void beginShotEvent(FirmwareState* state, uint32_t timestamp) {
-#if defined(MECOFFEE_RUST_SHOT)
-    mecoffee_rust_shot_event(&state->shot,0,timestamp,0,state);
-#else
     // Observed in the original: a shot begin counts as user activity for the inactivity timer.
     // Observed in the original: a shot begin counts as user activity for the inactivity timer.
     state->powerSchedule.lastActivityTimestamp = timestamp;
     state->powerSchedule.lastActivityTimestamp = timestamp;
     state->shot.isTimeoutEventLatched = false;
     state->shot.isTimeoutEventLatched = false;
     beginShotFeedForward(state, timestamp);
     beginShotFeedForward(state, timestamp);
     enqueueDiagnosticCallback(&state->diagnosticQueue, reportShotBegin);
     enqueueDiagnosticCallback(&state->diagnosticQueue, reportShotBegin);
-#endif
 }
 }
 
 
 void endShotEvent(FirmwareState* state, uint32_t endTimestamp, uint32_t beginTimestamp) {
 void endShotEvent(FirmwareState* state, uint32_t endTimestamp, uint32_t beginTimestamp) {
-#if defined(MECOFFEE_RUST_SHOT)
-    mecoffee_rust_shot_event(&state->shot,1,endTimestamp,beginTimestamp,state);
-#else
     setGroupEnabled(&groupForRole(&state->outputChannels, OutputGroupRole::Pump), false);
     setGroupEnabled(&groupForRole(&state->outputChannels, OutputGroupRole::Pump), false);
     setGroupEnabled(&groupForRole(&state->outputChannels, OutputGroupRole::Valve), false);
     setGroupEnabled(&groupForRole(&state->outputChannels, OutputGroupRole::Valve), false);
     state->shot.lastShotDuration = endTimestamp - beginTimestamp;
     state->shot.lastShotDuration = endTimestamp - beginTimestamp;
     endShotFeedForward(state, endTimestamp);
     endShotFeedForward(state, endTimestamp);
     enqueueDiagnosticCallback(&state->diagnosticQueue, reportShotEnd);
     enqueueDiagnosticCallback(&state->diagnosticQueue, reportShotEnd);
-#endif
 }
 }
 
 
 void runShotActiveCallback(FirmwareState* state, uint32_t foregroundSnapshotMilliseconds, uint32_t beginTimestamp) {
 void runShotActiveCallback(FirmwareState* state, uint32_t foregroundSnapshotMilliseconds, uint32_t beginTimestamp) {
-#if defined(MECOFFEE_RUST_SHOT)
-    const auto& s=state->settings;
-    const RustShotSettings settings={s.preinfusionEnabled,s.preinfusionValveClosed,s.preinfusionPumpDuration,s.preinfusionPauseDuration,s.maximumShotDuration};
-    mecoffee_rust_shot_active(&state->shot,&settings,state->alternateModeSelection,foregroundSnapshotMilliseconds,beginTimestamp,state);
-#else
     const uint32_t elapsed = foregroundSnapshotMilliseconds - beginTimestamp;
     const uint32_t elapsed = foregroundSnapshotMilliseconds - beginTimestamp;
     const ShotOutputRequest request = evaluateShotOutputRequest(state->settings, state->alternateModeSelection, elapsed);
     const ShotOutputRequest request = evaluateShotOutputRequest(state->settings, state->alternateModeSelection, elapsed);
     OutputGroup& pump = groupForRole(&state->outputChannels, OutputGroupRole::Pump);
     OutputGroup& pump = groupForRole(&state->outputChannels, OutputGroupRole::Pump);
@@ -101,7 +65,6 @@ void runShotActiveCallback(FirmwareState* state, uint32_t foregroundSnapshotMill
     state->shot.isTimeoutEventLatched = false;
     state->shot.isTimeoutEventLatched = false;
     setGroupEnabled(&pump, request.isPumpRequested);
     setGroupEnabled(&pump, request.isPumpRequested);
     setGroupEnabled(&valve, request.isValveRequested);
     setGroupEnabled(&valve, request.isValveRequested);
-#endif
 }
 }
 
 
 // Begin (argument 1) and end (argument 0) of an input burst.
 // Begin (argument 1) and end (argument 0) of an input burst.
@@ -130,9 +93,6 @@ bool isInputQualified(const DebouncedInput& input) {
 }
 }
 
 
 void initializeDebouncedInput(DebouncedInput* input) {
 void initializeDebouncedInput(DebouncedInput* input) {
-#if defined(MECOFFEE_RUST_SHOT)
-    if(mecoffee_rust_shot_layout(0)!=5 || mecoffee_rust_shot_layout(1)!=15 || mecoffee_rust_shot_layout(2)!=10 || mecoffee_rust_shot_layout(3)!=3) {cli();for(;;){}}
-#endif
     *input = DebouncedInput{};
     *input = DebouncedInput{};
     input->isLastLevelHigh = true;
     input->isLastLevelHigh = true;
 }
 }
@@ -151,9 +111,6 @@ ShotOutputRequest evaluateShotOutputRequest(const SettingsValues& settings, uint
 
 
 void pollDebouncedInput(FirmwareState* state, DebouncedInput* input, InputRole role, bool isPinHigh,
 void pollDebouncedInput(FirmwareState* state, DebouncedInput* input, InputRole role, bool isPinHigh,
                         uint32_t foregroundSnapshotMilliseconds) {
                         uint32_t foregroundSnapshotMilliseconds) {
-#if defined(MECOFFEE_RUST_SHOT)
-    mecoffee_rust_poll_input(input,static_cast<uint8_t>(role),isPinHigh,foregroundSnapshotMilliseconds,state);
-#else
     if (isPinHigh != input->isLastLevelHigh) {
     if (isPinHigh != input->isLastLevelHigh) {
         input->isLastLevelHigh = isPinHigh;
         input->isLastLevelHigh = isPinHigh;
         input->lastChangeTimestamp = foregroundSnapshotMilliseconds;
         input->lastChangeTimestamp = foregroundSnapshotMilliseconds;
@@ -189,31 +146,6 @@ void pollDebouncedInput(FirmwareState* state, DebouncedInput* input, InputRole r
             runInputStateChange(state, role, 0, foregroundSnapshotMilliseconds, beginTimestamp);
             runInputStateChange(state, role, 0, foregroundSnapshotMilliseconds, beginTimestamp);
         }
         }
     }
     }
-#endif
-}
-
-#if defined(MECOFFEE_RUST_SHOT)
-extern "C" void mecoffee_shot_effect(void* context,uint8_t operation,uint32_t value) {
-    auto* state=static_cast<FirmwareState*>(context);
-    switch(operation) {
-        case 0: state->powerSchedule.lastActivityTimestamp=value;break;
-        case 1: {
-            const uint8_t saved=SREG;cli();
-            setGroupEnabled(&groupForRole(&state->outputChannels,static_cast<OutputGroupRole>(value&255)),(value&256)!=0);
-            SREG=saved;break;
-        }
-        case 2: beginShotFeedForward(state,value);break;
-        case 3: endShotFeedForward(state,value);break;
-        case 4: enqueueDiagnosticCallback(&state->diagnosticQueue,reportShotBegin);break;
-        case 5: enqueueDiagnosticCallback(&state->diagnosticQueue,reportShotEnd);break;
-    }
-}
-extern "C" void mecoffee_input_event(void* context,uint8_t role,uint8_t active,uint32_t now,uint32_t begin) {
-    auto* state=static_cast<FirmwareState*>(context);
-    // Use the supplied timestamp, never read the Rust-borrowed DebouncedInput.
-    if(active==2) runShotActiveCallback(state,now,begin);
-    else runInputStateChange(state,static_cast<InputRole>(role),active,now,begin);
 }
 }
-#endif
 
 
 }  // namespace meCoffee
 }  // namespace meCoffee

+ 0 - 3
lib/meCoffee_controller_logic/src/telemetry_reports.cpp

@@ -1,4 +1,3 @@
-#if !defined(MECOFFEE_RUST_TELEMETRY)
 #include "telemetry_reports.h"
 #include "telemetry_reports.h"
 
 
 #include "hardware_seam.h"
 #include "hardware_seam.h"
@@ -56,5 +55,3 @@ void reportHeaterTermsFrame(FirmwareState& state) {
 }
 }
 
 
 }  // namespace meCoffee
 }  // namespace meCoffee
-
-#endif