diff --git a/components/spit/src/SPIT_Client.cpp b/components/spit/src/SPIT_Client.cpp index 9754ade..ad14445 100644 --- a/components/spit/src/SPIT_Client.cpp +++ b/components/spit/src/SPIT_Client.cpp @@ -1583,24 +1583,24 @@ void SPIT_Client::processSocketTask(SPIT_Client &instance) { auto nextWdTrigger = fos::Timing::getMilliSec() + WATCHDOGTIME; auto nextWdCheck = nextWdTrigger + WATCHDOGTIME; while (true) { - auto time = fos::Timing::getMilliSec(); - if (time > nextWdTrigger) { - instance.sAnswered = false; - instance.sendWatchdog(); - nextWdTrigger = nextWdCheck + WATCHDOGTIME; - } + // auto time = fos::Timing::getMilliSec(); + // if (time > nextWdTrigger) { + // instance.sAnswered = false; + // // instance.sendWatchdog(); + // nextWdTrigger = nextWdCheck + WATCHDOGTIME; + // } - if (time > nextWdCheck) { - if (!instance.sAnswered) { - ESP_LOGW(TAG, "TimeOut"); - instance.eventWatchdogLost(); - break; - } - nextWdCheck = nextWdTrigger + WATCHDOGTIME; - } + // if (time > nextWdCheck) { + // if (!instance.sAnswered) { + // ESP_LOGW(TAG, "TimeOut"); + // instance.eventWatchdogLost(); + // break; + // } + // nextWdCheck = nextWdTrigger + WATCHDOGTIME; + // } fos::Task::delayMs(25); - if (instance.m_StopReceiveSPITMessages) - break; + // if (instance.m_StopReceiveSPITMessages) + // break; } } } \ No newline at end of file diff --git a/components/watchFace/watchFace.hpp b/components/watchFace/watchFace.hpp index 5221b46..c7ceca3 100644 --- a/components/watchFace/watchFace.hpp +++ b/components/watchFace/watchFace.hpp @@ -40,6 +40,9 @@ class WatchMotor { _currentIndex = sign; } + float getScaled() { return _stepper.getScaledPos() * 6; } + uint8_t getIndex() { return _currentIndex; } + private: StepperMotor &_stepper; OutputPort &_motorSleep; diff --git a/doc/LiveShowProject/CatasWatchProject.ldv b/doc/LiveShowProject/CatasWatchProject.ldv index 0e173ba..7e827f5 100644 Binary files a/doc/LiveShowProject/CatasWatchProject.ldv and b/doc/LiveShowProject/CatasWatchProject.ldv differ diff --git a/doc/LiveShowProject/CatasWatchProject.lmv b/doc/LiveShowProject/CatasWatchProject.lmv index d664a98..7d346ae 100644 Binary files a/doc/LiveShowProject/CatasWatchProject.lmv and b/doc/LiveShowProject/CatasWatchProject.lmv differ diff --git a/doc/LiveShowProject/CatasWatchProject.lsb b/doc/LiveShowProject/CatasWatchProject.lsb index 55acd48..7323c01 100644 Binary files a/doc/LiveShowProject/CatasWatchProject.lsb and b/doc/LiveShowProject/CatasWatchProject.lsb differ diff --git a/doc/LiveShowProject/CatasWatchProject.lsc b/doc/LiveShowProject/CatasWatchProject.lsc index f40b98d..b0c0567 100644 Binary files a/doc/LiveShowProject/CatasWatchProject.lsc and b/doc/LiveShowProject/CatasWatchProject.lsc differ diff --git a/doc/LiveShowProject/CatasWatchProject.lsd b/doc/LiveShowProject/CatasWatchProject.lsd index e110324..d3b6637 100644 Binary files a/doc/LiveShowProject/CatasWatchProject.lsd and b/doc/LiveShowProject/CatasWatchProject.lsd differ diff --git a/doc/LiveShowProject/CatasWatchProject.lsh b/doc/LiveShowProject/CatasWatchProject.lsh index de1b114..c5f9c06 100644 Binary files a/doc/LiveShowProject/CatasWatchProject.lsh and b/doc/LiveShowProject/CatasWatchProject.lsh differ diff --git a/doc/LiveShowProject/CatasWatchProject.lsp b/doc/LiveShowProject/CatasWatchProject.lsp index 6b91b4b..4cfe637 100644 Binary files a/doc/LiveShowProject/CatasWatchProject.lsp and b/doc/LiveShowProject/CatasWatchProject.lsp differ diff --git a/doc/LiveShowProject/CatasWatchProject.lss b/doc/LiveShowProject/CatasWatchProject.lss index fbb39bc..7f842f9 100644 Binary files a/doc/LiveShowProject/CatasWatchProject.lss and b/doc/LiveShowProject/CatasWatchProject.lss differ diff --git a/doc/LiveShowProject/CatasWatchProject.lsu b/doc/LiveShowProject/CatasWatchProject.lsu index 826750c..a8a763e 100644 Binary files a/doc/LiveShowProject/CatasWatchProject.lsu and b/doc/LiveShowProject/CatasWatchProject.lsu differ diff --git a/doc/LiveShowProject/CatasWatchProject.lsv b/doc/LiveShowProject/CatasWatchProject.lsv index ba762e6..435b4dd 100644 Binary files a/doc/LiveShowProject/CatasWatchProject.lsv and b/doc/LiveShowProject/CatasWatchProject.lsv differ diff --git a/doc/LiveShowProject/CatasWatchProject.spi b/doc/LiveShowProject/CatasWatchProject.spi index 88c385a..a184f1b 100644 Binary files a/doc/LiveShowProject/CatasWatchProject.spi and b/doc/LiveShowProject/CatasWatchProject.spi differ diff --git a/doc/LiveShowProject/CatasWatchProject.uip b/doc/LiveShowProject/CatasWatchProject.uip index de1b114..efec254 100644 Binary files a/doc/LiveShowProject/CatasWatchProject.uip and b/doc/LiveShowProject/CatasWatchProject.uip differ diff --git a/main/watchMain.cpp b/main/watchMain.cpp index 55fc25e..5c1bb8c 100644 --- a/main/watchMain.cpp +++ b/main/watchMain.cpp @@ -77,17 +77,16 @@ struct DeviceState { uint8_t minJumps{6}; uint8_t maxJumps{32}; uint8_t profile{}; - uint8_t restTime{}; + uint8_t shuffleRate{}; float speed = 1.0; // Rad/sec float accel = 1.0; // Rad/sec^2 Color color{0x80, 0x80, 0x80}; - uint8_t pictogram{}; // 0..5 active Pictogramm }; enum class MoveType { StepTo, + Demo, Shuffle, - Demo }; enum class ResponseType { StepAt, @@ -98,7 +97,7 @@ struct MoveCommand { // 1..6 uint8_t pos; }; -struct Arrived { +struct WatchIndex { ResponseType type; // 1..6 uint8_t pos; @@ -108,7 +107,7 @@ struct PictoIllumCommand { }; static fos::Queue commandQueue(8); -static fos::Queue responseQueue(8); +static fos::Queue responseQueue(8); static fos::Queue pictoIllumQue(2); DeviceState activeState; @@ -286,7 +285,7 @@ static void UniverseCallback(const uint8_t *data, const uint16_t size) { Syslog::logv(Syslog::Severity::Debug, "Got DMX: r%0x g%0x b%0x i%0x m%i M%i p%i a%i w%i r%i", /* RGB*/ data[0], data[1], data[2], /*Intens*/ data[3], /* MinMaxJumps */ data[4], data[5], /*profile*/ data[6], /*accel/speed*/ data[7], data[8], - /*RestTime*/ data[9]); + /*shuffleRate*/ data[9]); float intens = (float)data[3] / UINT8_MAX; activeState.color = Color{ @@ -304,7 +303,7 @@ static void UniverseCallback(const uint8_t *data, const uint16_t size) { activeState.accel = (float)accel / 100 + 0.5; // min .5 / max 3 activeState.speed = (float)velo / 100 + 0.5; // min .5 / max 3 - activeState.restTime = data[9]; + activeState.shuffleRate = data[9]; } void moveToSubs(std::string data) { @@ -521,16 +520,16 @@ void LightingTask() { Effect::macStartFlicker, Effect::macDemoPulse}; // 6 - uint8_t lastPicto = 0; + uint8_t lastPicto = 1; - std::array startPoints{ - &(values[0][4]), // 1 - &(values[1][12]), - &(values[1][8]), - &(values[1][4]), - &(values[0][12]), - &(values[0][8]), // 6 - }; + std::array startPoints{ + &(values[0][4]), // 1 + &(values[1][12]), + &(values[1][8]), + &(values[1][4]), + &(values[0][12]), + &(values[0][8]), // 6 + }; while (true) { auto onPos = pictoIllumQue.dequeue(0); @@ -592,16 +591,27 @@ void MovementTask() { StepperMotor stepper(stepperCfg, stepperDriver, initSens); + WatchMotor watch(stepper, motorSleep); + ESP_LOGI("Stepper", "Find Home"); stepper.findRef(); - // Illum 1 - pictoIllumQue.enqueue(std::make_unique(6)); + // Todo Set by User-Interface + for (size_t i = 0; i < 7; i++) { + stepper.fullStep(1); + fos::Task::delayMs(40); + } + (void)stepper.zeroPosition(); + while (!stepper.isIdle()) { + fos::Task::delayMs(40); + } + // watch.moveTo(1, ProfileGenerator::Unitform); + ESP_LOGI("Stepper", "Got to 1"); + // Illum 6 + pictoIllumQue.enqueue(std::make_unique(0)); - ESP_LOGI(TAG, "Fist Position is %f.2", stepper.getScaledPos() * 6); + ESP_LOGI(TAG, "Fist Position is %.2f", watch.getScaled()); fos::Task::delayMs(1000); - activeState.pictogram = 0; - while (true) { ESP_LOGD(TAG, "Waiting for command"); auto cmd = commandQueue.dequeue(); @@ -609,7 +619,6 @@ void MovementTask() { if (stepper.isIdle()) { int newPos = cmd->pos; if ((newPos >= 1) && (newPos <= 6)) { - auto idx = newPos - 1; Syslog::logv(Syslog::Severity::Informational, "Triggered movement to picto pos:%i ", newPos); } else { @@ -617,43 +626,35 @@ void MovementTask() { "Got invalid index for illuminated pictogram =%i ", newPos); continue; } - int delta = newPos - activeState.pictogram; - if (delta <= 0) { - delta += 6; + + int jumps = newPos - watch.getIndex(); + if (jumps <= 0) { + jumps += 6; } - delta = delta + (activeState.minJumps % 6) * 6; - if (delta < activeState.minJumps) { - delta += 6; + jumps = jumps + (activeState.minJumps % 6) * 6; + if (jumps < activeState.minJumps) { + jumps += 6; } Syslog::logv(Syslog::Severity::Notice, "Running Stepper by %i steps with prof=%i a=%.2f w=%.2f", - delta, activeState.profile, activeState.accel, activeState.speed); + jumps, activeState.profile, activeState.accel, activeState.speed); pictoIllumQue.enqueue(std::make_unique(0)); - responseQueue.enqueue(std::make_unique(ResponseType::StartMoving, 0)); - stepper.moveBy(delta * std::numbers::pi / 3, - activeState.profile, activeState.accel, activeState.speed); + responseQueue.enqueue(std::make_unique(ResponseType::StartMoving, 0)); + watch.moveTo(newPos, activeState.profile); + pictoIllumQue.enqueue(std::make_unique(newPos)); - responseQueue.enqueue(std::make_unique(ResponseType::StepAt, newPos)); - activeState.pictogram = newPos; + responseQueue.enqueue(std::make_unique(ResponseType::StepAt, newPos)); } } else if (cmd->type == MoveType::Demo) { - int i = 0; - while (i++ < 80) { - stepperDriver.step(1); - stepperDriver.getSubPos(); - fos::Task::delayMs(100); - } - ESP_LOGI("Stepper", "Find Home"); - stepper.findRef(); - activeState.pictogram = -1; - stepper.findRef(); - fos::Task::delayMs(1000); - for (size_t i = 0; i < 6; i++) { - stepper.moveBy(std::numbers::pi / 3); - while (!stepper.isIdle()) { - fos::Task::delayMs(100); + ESP_LOGI(TAG, "Running Demo"); + for (size_t i = ProfileGenerator::Smooth; i < ProfileGenerator::NumProfiles; i++) { + ESP_LOGI(TAG, "Running Profile %d ", i); + fos::Task::delayMs(1000); + int steps[3]{4, 2, 0}; + for (size_t j = 0; j < 3; j++) { + watch.moveTo(steps[j], i); + fos::Task::delayMs(1000); } - ESP_LOGI(TAG, "Position is %f.2", stepper.getScaledPos() * 6); } } else { fos::Task::delayMs(100); @@ -731,7 +732,7 @@ void onProjectUpdate(SPIT_Client::ProjUpdate state, string projectId) { */ bool onCheckSpitTypeVeto(SPIT_Message::ReportSPITType *p_ReportSPITType) { return true; // Bypass veto - + if (p_ReportSPITType == NULL) return true; SPITType *ptrSPITType; @@ -742,7 +743,7 @@ bool onCheckSpitTypeVeto(SPIT_Message::ReportSPITType *p_ReportSPITType) { // ESP_LOGW(TAG, "ObjectVeto NoSpitType"); return false; } - if (ptrSPITType->getCreatedByClient() == false){ + if (ptrSPITType->getCreatedByClient() == false) { // ESP_LOGW(TAG, "getCreatedByClient"); return false; } @@ -913,7 +914,7 @@ void onPlaySpitType(string p_PlayerID, string spitTypeId, bool p_PlayerIsRunning auto command = ProvidedSpitActions[spitTypeId]; ESP_LOGI(TAG, "Player: %s is running: %s Object", p_PlayerID.data(), spitTypeId.c_str()); commandQueue.enqueue(std::make_unique(command)); - ESP_LOGI(TAG, "MyApp AKTION 1 started Value: %f and running: %d", p_Value, p_PlayerIsRunning); + Syslog::logv(Syslog::Severity::Informational, "Got SPIT command for move ot : r%d", command.pos); } } @@ -980,7 +981,6 @@ void SpitClientApp() { } while (true) { - fos::Task::delayMs(10000); auto res = responseQueue.dequeue(); if (res->type == ResponseType::StartMoving) { spitClient.sendRemoteObject(ExpectedObjects[expected.changingPos]); @@ -999,10 +999,11 @@ void app_main(void) { ESP_ERROR_CHECK(ret); initialize_ethernet(); NvsApi::init(); - static fos::Task lightingTask(LightingTask, "Lights", 0x4000uL); - static fos::Task movementTask(MovementTask, "Motor", 0x4000uL); + static fos::Task lightingTask(LightingTask, "Lights", 0x8000uL); + static fos::Task movementTask(MovementTask, "Motor", 0x8000uL); etherActive.take(); + fos::Task::delayMs(10000); ESP_LOGI(TAG, "Start net services"); static int ipVersion = AF_INET; diff --git a/test/integration/main/movementTests.cpp b/test/integration/main/movementTests.cpp index 69cd23c..9fc745e 100644 --- a/test/integration/main/movementTests.cpp +++ b/test/integration/main/movementTests.cpp @@ -247,7 +247,7 @@ void testMovementTask() { } /// - /// + /// Homing /// ESP_LOGD(TAG, "Find Home"); stepper.findRef(); @@ -289,8 +289,8 @@ void testMovementTask() { /// All other Profiles /// if constexpr (DoTurnProfiles) { - // for (size_t i = ProfileGenerator::Smooth; i < ProfileGenerator::NumProfiles; i++) { - for (size_t i = ProfileGenerator::JumpIn; i < ProfileGenerator::NumProfiles; i++) { + for (size_t i = ProfileGenerator::Smooth; i < ProfileGenerator::NumProfiles; i++) { + // for (size_t i = ProfileGenerator::JumpIn; i < ProfileGenerator::NumProfiles; i++) { // If only part is needed ESP_LOGI(TAG, "Running Profile %d ", i); ESP_LOGD(TAG, "Fist Position is %3d / %.2f / Micro %d", stepper.getQuanted(), stepper.getScaledPos() * 6, stepper.getSubPos()); fos::Task::delayMs(1000);