bringup hardware

This commit is contained in:
2025-03-30 21:00:09 +02:00
parent f06cf9c3b1
commit d607cd867a
8 changed files with 126 additions and 142 deletions
+46 -31
View File
@@ -6,15 +6,18 @@
* @copyright Copyright (c) 2024
*/
// Conig-Key:
//
//
//
/* Watchface
6/
5 / 1
4 2
3
*/
struct {
const char *syslogDest = "syslogDst"; // example: "172.16.16.10"
const char *mqttBroker = "mqttBroker"; // example: "172.16.17.62"
const char *mqttBroker = "mqttBroker"; // example: "172.16.16.10"
const char *mqttPrefix = "mqttPrefix"; // example: "SomeTag"
const char *spitServer = "spitServer"; // example: "172.16.16.10"
} ConfigKeys;
// MQTT Topics
@@ -476,7 +479,7 @@ namespace Effect {
};
const Macro macDemoFlicker = {
{64, 1, &InitSlopeWave, StateMachine::UpdateWave, 0xFF},
{16, 1, &InitSlopeWave, StateMachine::UpdateWave, 0xFF},
{32, 1, StateMachine::UpdateFlicker, 0xFF},
};
}
@@ -511,15 +514,24 @@ void LightingTask() {
processors[5].setEffect(Effect::macDark, &colorSource, 0);
const std::array<Effect::Macro, 6> PictoEffects{
Effect::macDemoPulse, // 1
Effect::macDemoPulse,
Effect::macDemoPulse,
Effect::macDemoPulse,
Effect::macDemoPulse,
Effect::macDemoPulse,
Effect::macStartFlicker};
Effect::macStartFlicker,
Effect::macDemoPulse}; // 6
uint8_t lastPicto = 0;
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);
if (onPos) {
@@ -543,14 +555,6 @@ void LightingTask() {
}
}
std::array<uint16_t *, 6> startPoints{
&(values[0][4]),
&(values[0][8]),
&(values[0][12]),
&(values[1][4]),
&(values[1][8]),
&(values[1][12]),
};
for (size_t i = 0; i < processors.size(); i++) {
auto col = processors[i].tick();
auto sp = startPoints[i];
@@ -572,7 +576,7 @@ void MovementTask() {
StepperDriverDrv8833::Pins stepperPins{
LEDC_TIMER_0,
{LEDC_CHANNEL_0, LEDC_CHANNEL_1, LEDC_CHANNEL_2, LEDC_CHANNEL_3},
{GPIO_NUM_23, GPIO_NUM_22, GPIO_NUM_21, GPIO_NUM_20},
{GPIO_NUM_21, GPIO_NUM_20, GPIO_NUM_23, GPIO_NUM_22},
};
StepperDriverDrv8833 stepperDriver(stepperPins, MicroSteps, 0.25F);
stepperDriver.setPos(0);
@@ -591,7 +595,7 @@ void MovementTask() {
ESP_LOGI("Stepper", "Find Home");
stepper.findRef();
// Illum 1
pictoIllumQue.enqueue(std::make_unique<PictoIllumCommand>(1));
pictoIllumQue.enqueue(std::make_unique<PictoIllumCommand>(6));
ESP_LOGI(TAG, "Fist Position is %f.2", stepper.getScaledPos() * 6);
fos::Task::delayMs(1000);
@@ -603,7 +607,6 @@ void MovementTask() {
auto cmd = commandQueue.dequeue();
if (cmd->type == MoveType::StepTo) {
if (stepper.isIdle()) {
pictoIllumQue.enqueue(std::make_unique<PictoIllumCommand>(0));
int newPos = cmd->pos;
if ((newPos >= 1) && (newPos <= 6)) {
auto idx = newPos - 1;
@@ -727,33 +730,47 @@ void onProjectUpdate(SPIT_Client::ProjUpdate state, string projectId) {
* @return false = the SPITType is denied, true = the SPITType is accepted
*/
bool onCheckSpitTypeVeto(SPIT_Message::ReportSPITType *p_ReportSPITType) {
return true; // Bypass veto
if (p_ReportSPITType == NULL)
return true;
SPITType *ptrSPITType;
ptrSPITType = SPITType::getSPITType(p_ReportSPITType->getID());
// Don't allow foreign SPITTypes
if (ptrSPITType == NULL)
if (ptrSPITType == NULL) {
// ESP_LOGW(TAG, "ObjectVeto NoSpitType");
return false;
if (ptrSPITType->getCreatedByClient() == false)
}
if (ptrSPITType->getCreatedByClient() == false){
// ESP_LOGW(TAG, "getCreatedByClient");
return false;
}
return true;
}
bool onCheckSpitObjectVeto(SPIT_Message::ReportSPITObject *p_ReportSPITObject) {
return true; // Bypass veto
if (p_ReportSPITObject == NULL)
return true;
SPITType *ptrSPITType = SPITType::getSPITType(p_ReportSPITObject->getSPITTypeID());
if (ptrSPITType == NULL)
if (ptrSPITType == NULL) {
// ESP_LOGW(TAG, "ObjectVeto NoSpitObj");
return false;
}
// Don't allow SPITObjects which refers to a SPITType which is not created by this client - other SPITTypes cannot be handled here
if (ptrSPITType->getCreatedByClient() == false)
if (ptrSPITType->getCreatedByClient() == false) {
// ESP_LOGW(TAG, "getCreatedByClient");
return false;
}
SPITObject *ptrSPITObject = SPITObject::getSPITObject(p_ReportSPITObject->getID());
// Don't allow foreign SPITTypes
if (ptrSPITObject == NULL)
if (ptrSPITObject == NULL) {
// ESP_LOGE(TAG, "Unknown ID");
return false;
}
return true;
}
@@ -765,10 +782,6 @@ void onSpitType(SPIT_Client::ObjectEvent event, const SPITType &p_SPITType) {
// Whenever you provide an action for this SPITType take this over in your code.
// call _SpitClient.setActionSPITType(p_SPITType.getID(), true);
ESP_LOGI(TAG, "NEW SPIT-Type ID: %s GroupName: %s Name: %s confirmed: %d", p_SPITType.getID().data(), p_SPITType.getGroupName().data(), p_SPITType.getName().data(), p_SPITType.getConfirmed());
auto typeName = p_SPITType.getName();
if (ExpectedObjects.contains(typeName)) {
ExpectedObjects[typeName] = p_SPITType.getID();
}
} else if (event == SPIT_Client::ObjectEvent::Changed) {
ESP_LOGI(TAG, "SPIT-Type CHANGED ID: %s GroupName: %s Name: %s confirmed: %d", p_SPITType.getID().data(), p_SPITType.getGroupName().data(), p_SPITType.getName().data(), p_SPITType.getConfirmed());
} else if (event == SPIT_Client::ObjectEvent::Deleted) {
@@ -784,6 +797,10 @@ void onSpitType(SPIT_Client::ObjectEvent event, const SPITType &p_SPITType) {
void onSpitTypeRemote(SPIT_Client::ObjectEvent event, const SPITType &p_SPITType) {
if (event == SPIT_Client::ObjectEvent::Created) {
ESP_LOGI(TAG, "NEW SPIT-REMOTE-Type ID: %s GroupName: %s Name: %s confirmed: %d", p_SPITType.getID().data(), p_SPITType.getGroupName().data(), p_SPITType.getName().data(), p_SPITType.getConfirmed());
auto typeName = p_SPITType.getName();
if (ExpectedObjects.contains(typeName)) {
ExpectedObjects[typeName] = p_SPITType.getID();
}
} else if (event == SPIT_Client::ObjectEvent::Changed) {
// we had to inform all Remote SPITObjects using the p_SPITType
// perhaps the SPITObject uses information from the SPITType
@@ -964,8 +981,6 @@ void SpitClientApp() {
while (true) {
fos::Task::delayMs(10000);
ESP_LOGI(TAG, "Test LiveShow");
auto res = responseQueue.dequeue();
if (res->type == ResponseType::StartMoving) {
spitClient.sendRemoteObject(ExpectedObjects[expected.changingPos]);