diff --git a/ESPMegaPRO-OS-SDK/lib/ESPMegaPRO/DigitalOutputCard.cpp b/ESPMegaPRO-OS-SDK/lib/ESPMegaPRO/DigitalOutputCard.cpp index 2a7b616..cefa8e8 100644 --- a/ESPMegaPRO-OS-SDK/lib/ESPMegaPRO/DigitalOutputCard.cpp +++ b/ESPMegaPRO-OS-SDK/lib/ESPMegaPRO/DigitalOutputCard.cpp @@ -146,7 +146,7 @@ uint8_t DigitalOutputCard::getType() { */ void DigitalOutputCard::setState(uint8_t pin, bool state) { this-> state_buffer[pin] = state; - this->pwm.setPin(pin, state*value_buffer[pin]); + this->pwm.setPin(virtualPinMap[pin], state*value_buffer[pin]); if(this->framAutoSave) { this->saveStateToFRAM(); } @@ -165,7 +165,7 @@ void DigitalOutputCard::setValue(uint8_t pin, uint16_t value) { // If value is greater than 4095, set it to 4095 if (value > 4095) value = 4095; this-> value_buffer[pin] = value; - this->pwm.setPin(pin, state_buffer[pin]*value); + this->pwm.setPin(virtualPinMap[pin], state_buffer[pin]*value); if (this->framAutoSave) { this->savePinValueToFRAM(pin); } diff --git a/ESPMegaPRO-OS-SDK/src/main.cpp b/ESPMegaPRO-OS-SDK/src/main.cpp.disabled similarity index 100% rename from ESPMegaPRO-OS-SDK/src/main.cpp rename to ESPMegaPRO-OS-SDK/src/main.cpp.disabled diff --git a/ESPMegaPRO-OS-SDK/src/map_test.cpp b/ESPMegaPRO-OS-SDK/src/map_test.cpp new file mode 100644 index 0000000..4c78a72 --- /dev/null +++ b/ESPMegaPRO-OS-SDK/src/map_test.cpp @@ -0,0 +1,25 @@ +#include + +ESPMegaPRO espmega = ESPMegaPRO(); + +void setup() { + espmega.begin(); + uint8_t outputPinMap[16] = {8,9,10,11,12,13,14,15,0,1,2,3,4,5,6,7}; + espmega.outputs.loadPinMap(outputPinMap); +} + +void loop() { + espmega.loop(); + // Loop through all outputs, turning them on one at a time + // for 1.5 seconds each + for (uint8_t i = 0; i < 16; i++) { + Serial.printf("Turning on output %d\n", i); + espmega.outputs.digitalWrite(i, true); + // Print out the state of all outputs + for (uint8_t j = 0; j < 16; j++) { + Serial.printf("Output %d: %d\n", j, espmega.outputs.getState(j)); + } + delay(1500); + espmega.outputs.digitalWrite(i, false); + } +}