optimize
This commit is contained in:
@@ -27,9 +27,14 @@ QueueHandle_t CommuTask::getKnobStateQueue() {
|
|||||||
return knob_state_queue_;
|
return knob_state_queue_;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CommuTask::setAngleValue(uint32_t angle)
|
void CommuTask::setAngleValue(int32_t angle)
|
||||||
{
|
{
|
||||||
|
if(angle_ != angle)
|
||||||
|
{
|
||||||
angle_ = angle;
|
angle_ = angle;
|
||||||
|
valuesUpdated = true;
|
||||||
|
log_d("new Angle valeu: %u", angle_);
|
||||||
|
}
|
||||||
//log_d("setAngleCalled = %u", angle);
|
//log_d("setAngleCalled = %u", angle);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -70,11 +75,14 @@ void CommuTask::run() {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(millis() - lastSensorUpdate > 1000)
|
setAngleValue(state.current_position);
|
||||||
|
|
||||||
|
if(millis() - lastSensorUpdate > 1000 && valuesUpdated)
|
||||||
{
|
{
|
||||||
angle.setValue(state.current_position);
|
angle.setValue(angle_);
|
||||||
log_d("new angle=%u", state.current_position);
|
log_d("new angle=%u", angle_);
|
||||||
lastSensorUpdate = millis();
|
lastSensorUpdate = millis();
|
||||||
|
valuesUpdated = false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ class CommuTask : public Task<CommuTask> {
|
|||||||
CommuTask(const uint8_t task_core);
|
CommuTask(const uint8_t task_core);
|
||||||
~CommuTask();
|
~CommuTask();
|
||||||
|
|
||||||
void setAngleValue(uint32_t angle);
|
void setAngleValue(int32_t angle);
|
||||||
QueueHandle_t getKnobStateQueue();
|
QueueHandle_t getKnobStateQueue();
|
||||||
|
|
||||||
|
|
||||||
@@ -33,9 +33,11 @@ class CommuTask : public Task<CommuTask> {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
uint32_t angle_ =0;
|
int32_t angle_ =0;
|
||||||
SemaphoreHandle_t mutex_;
|
SemaphoreHandle_t mutex_;
|
||||||
|
|
||||||
|
bool valuesUpdated = false;
|
||||||
|
|
||||||
QueueHandle_t knob_state_queue_;
|
QueueHandle_t knob_state_queue_;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user