fix: bringup with full project
This commit is contained in:
+57
-56
@@ -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<MoveCommand> commandQueue(8);
|
||||
static fos::Queue<Arrived> responseQueue(8);
|
||||
static fos::Queue<WatchIndex> responseQueue(8);
|
||||
static fos::Queue<PictoIllumCommand> 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<uint16_t *, 6> startPoints{
|
||||
&(values[0][4]), // 1
|
||||
&(values[1][12]),
|
||||
&(values[1][8]),
|
||||
&(values[1][4]),
|
||||
&(values[0][12]),
|
||||
&(values[0][8]), // 6
|
||||
};
|
||||
std::array<uint16_t *, 6> 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<PictoIllumCommand>(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<PictoIllumCommand>(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<PictoIllumCommand>(0));
|
||||
responseQueue.enqueue(std::make_unique<Arrived>(ResponseType::StartMoving, 0));
|
||||
stepper.moveBy(delta * std::numbers::pi / 3,
|
||||
activeState.profile, activeState.accel, activeState.speed);
|
||||
responseQueue.enqueue(std::make_unique<WatchIndex>(ResponseType::StartMoving, 0));
|
||||
watch.moveTo(newPos, activeState.profile);
|
||||
|
||||
pictoIllumQue.enqueue(std::make_unique<PictoIllumCommand>(newPos));
|
||||
responseQueue.enqueue(std::make_unique<Arrived>(ResponseType::StepAt, newPos));
|
||||
activeState.pictogram = newPos;
|
||||
responseQueue.enqueue(std::make_unique<WatchIndex>(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<MoveCommand>(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;
|
||||
|
||||
Reference in New Issue
Block a user