Skip to content

Commit 78c15ba

Browse files
committed
Fine control of PPS request message
1 parent 7eef3f1 commit 78c15ba

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/Braccio.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -155,18 +155,22 @@ void BraccioClass::connectJoystickTo(lv_obj_t* obj) {
155155

156156
void BraccioClass::pd_thread() {
157157
start_pd_burst = millis();
158+
size_t last_time_ask_pps = 0;
158159
while (1) {
159160
auto ret = pd_events.wait_any(0xFF);
160161
if ((ret & 1) && (millis() - start_pd_burst > 1000)) {
161-
PD_UFP.set_PPS(PPS_V(7.2), PPS_A(2.0));
162162
pd_timer.detach();
163-
pd_timer.attach(mbed::callback(this, &BraccioClass::unlock_pd_semaphore), 1s);
163+
pd_timer.attach(mbed::callback(this, &BraccioClass::unlock_pd_semaphore), 5s);
164164
}
165165
if (ret & 2) {
166166
pd_timer.detach();
167-
pd_timer.attach(mbed::callback(this, &BraccioClass::unlock_pd_semaphore), 10ms);
167+
pd_timer.attach(mbed::callback(this, &BraccioClass::unlock_pd_semaphore), 50ms);
168168
}
169169
i2c_mutex.lock();
170+
if (millis() - last_time_ask_pps > 5000) {
171+
PD_UFP.set_PPS(PPS_V(7.2), PPS_A(2.0));
172+
last_time_ask_pps = millis();
173+
}
170174
PD_UFP.run();
171175
i2c_mutex.unlock();
172176
if (PD_UFP.is_power_ready() && PD_UFP.is_PPS_ready()) {

0 commit comments

Comments
 (0)