Skip to content

Commit c833e61

Browse files
committed
very minor refactors from long debugging session... and no fix
1 parent 7bb1923 commit c833e61

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

main/Tasks/screen_pcd8544/screen_pcd8544.c

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,10 @@ pcd8544_config_t config = {
3030

3131
// screen control variables
3232

33-
bool screenPowerdownMode = false;
34-
TickType_t lastScreenChange = 0;
35-
// screen number to render
36-
uint8_t currentScreenIdx = 1;
37-
38-
uint8_t bigCharPositions[6];
33+
static bool screenPowerdownMode = false;
34+
static TickType_t lastScreenChange = 0;
35+
static uint8_t currentScreenIdx = 1;
36+
static uint8_t bigCharPositions[6];
3937

4038
/**
4139
* Used to display current speed compared to average as bar on the right side of the screen
@@ -198,14 +196,18 @@ static void vDrawTotalScreen() {
198196
// @warning each screen method must sync buffer for itself
199197
static void screenRenderer() {
200198
TickType_t currentTickCount = xTaskGetTickCount();
201-
int timeInactive = ((int)currentTickCount - (int)lastScreenChange) * (int)portTICK_PERIOD_MS;
199+
uint32_t timeInactive = (currentTickCount - lastScreenChange) * portTICK_PERIOD_MS;
200+
201+
// ESP_LOGI(TAG, "Rendering screen %d after %"PRIu32" ms. Tick %"PRIu32" change tick %"PRIu32,
202+
// currentScreenIdx, timeInactive, currentTickCount, lastScreenChange);
203+
202204

203205
if (timeInactive >= (rideParams.moving ? SCREEN_TIMINGS[currentScreenIdx] : SCREEN_TIMINGS_STOPPED[currentScreenIdx])) {
204-
lastScreenChange = xTaskGetTickCount();
205206
currentScreenIdx++;
206207
if (currentScreenIdx > IMPLEMENTED_SCREENS - 1) {
207208
currentScreenIdx = 0;
208209
}
210+
lastScreenChange = currentTickCount;
209211
}
210212

211213
pcd8544_clear_display();
@@ -252,9 +254,10 @@ static void vRideStopEventHandler() {
252254
}
253255

254256
void vScreenRefreshTask(void *data) {
255-
ESP_LOGI(TAG, "Screen refresher started");
256257
TickType_t xLastWakeTime;
257258

259+
ESP_LOGI(TAG, "Screen refresher started");
260+
258261
ESP_ERROR_CHECK(esp_event_handler_register_with(obc_events_loop, OBC_EVENTS, RIDE_STOP_EVENT, vRideStopEventHandler, NULL));
259262
ESP_ERROR_CHECK(esp_event_handler_register_with(obc_events_loop, OBC_EVENTS, RIDE_START_EVENT, vRideStartEventHandler, NULL));
260263

0 commit comments

Comments
 (0)