Skip to content

Commit ebb9972

Browse files
committed
bbx.log_out
1 parent 4aa3140 commit ebb9972

File tree

3 files changed

+32
-40
lines changed

3 files changed

+32
-40
lines changed

src/bbx/bbx.cpp

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -318,24 +318,20 @@ void Bbx::log_out() {
318318
BinLog bl("OUT");
319319
bl.TimeUS();
320320
char lbl[3] = {};
321-
lbl[2] = 0;
322321
for(int i = 0; i < 8; i++) {
323-
lbl[1] = '0' + i;
324-
switch(out.type(i)) {
325-
case 'M':
326-
lbl[0] = 'm';
327-
bl.i16(lbl, out.get_output(i) * 1000, 1e-3, "");
328-
break;
329-
case 'D':
330-
lbl[0] = 'm';
331-
bl.i16(lbl, out.get_output(i) * 1000, 1e-3, "");
332-
lbl[0] = 'r';
333-
bl.u16(lbl, out.rpm(i), 1, "rpm");
334-
break;
335-
case 'S':
336-
lbl[0] = 's';
337-
bl.i16(lbl, out.get_output(i) * 1000, 1e-3, "");
338-
break;
322+
if(out.type(i)) {
323+
lbl[0] = out.type(i);
324+
lbl[1] = '0' + i;
325+
lbl[2] = 0;
326+
bl.i16(lbl, out.get_output(i) * 1000, 1e-3, ""); //range -1000 to +1000
327+
}
328+
}
329+
for(int i = 0; i < 8; i++) {
330+
if(out.type(i) == Out::type_enum::DSHOTBIDIR) {
331+
lbl[0] = 'R';
332+
lbl[1] = '0' + i;
333+
lbl[2] = 0;
334+
bl.u16(lbl, out.rpm(i), 1, "rpm");
339335
}
340336
}
341337
}

src/cli/FreeRTOS_ps.cpp

Lines changed: 16 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -31,29 +31,23 @@ SOFTWARE.
3131

3232
#if configUSE_TRACE_FACILITY != 1
3333
void freertos_ps() {
34-
Serial.println("FreeRTOS_ps() needs configUSE_TRACE_FACILITY = 1 for uxTaskGetSystemState()");
34+
p.println("FreeRTOS_ps() needs configUSE_TRACE_FACILITY = 1 for uxTaskGetSystemState()");
3535
}
3636
#else
3737

3838
static char freertos_taskStatusChar(eTaskState eCurrentState) {
3939
switch(eCurrentState)
4040
{
41-
case eRunning:
42-
return 'X';
43-
case eReady:
44-
return 'R';
45-
case eBlocked:
46-
return 'B';
47-
case eSuspended:
48-
return 'S';
49-
case eDeleted:
50-
return 'D';
51-
default: // Should not get here, but it is included to prevent static checking errors.
52-
return '-';
41+
case eRunning: return 'X';
42+
case eReady: return 'R';
43+
case eBlocked: return 'B';
44+
case eSuspended: return 'S';
45+
case eDeleted: return 'D';
46+
default: return '-'; // Should not get here, but it is included to prevent static checking errors.
5347
}
5448
}
5549

56-
void freertos_ps()
50+
void freertos_ps(Print &p)
5751
{
5852
static struct taskarr_s {
5953
TaskStatus_t pxTaskStatusArray[FREERTOS_PS_MAX_TASKS];
@@ -75,12 +69,12 @@ void freertos_ps()
7569
uint32_t totalRunTime = tanew.ulTotalRunTime - taold.ulTotalRunTime;
7670
uint64_t tot = 0;
7771

78-
Serial.printf("\n=== FreeRTOS Tasks - Measurement Period: %.2f seconds ===\n\n", dt);
79-
Serial.print("TID Name CPU% Free St Pr Ni");
72+
p.printf("\n=== FreeRTOS Tasks - Measurement Period: %.2f seconds ===\n\n", dt);
73+
p.print("TID Name CPU% Free St Pr Ni");
8074
#if ( ( configUSE_CORE_AFFINITY == 1 ) && ( configNUMBER_OF_CORES > 1 ) )
81-
Serial.print(" Core");
75+
p.print(" Core");
8276
#endif
83-
Serial.println();
77+
p.println();
8478

8579
float perc_sum = 0;
8680
for( uint32_t i = 0; i < tanew.uxArraySize; i++ )
@@ -96,7 +90,7 @@ void freertos_ps()
9690
}
9791
float perc = (float)runtime / totalRunTime * 100;
9892
perc_sum += perc;
99-
Serial.printf("%3d %-12s%7.2f%% %5d %c %2d %2d",
93+
p.printf("%3d %-12s%7.2f%% %5d %c %2d %2d",
10094
(int)t.xTaskNumber,
10195
t.pcTaskName,
10296
(float)perc,
@@ -106,13 +100,13 @@ void freertos_ps()
106100
(int)t.uxCurrentPriority
107101
);
108102
#if ( ( configUSE_CORE_AFFINITY == 1 ) && ( configNUMBER_OF_CORES > 1 ) )
109-
Serial.printf(" %2lX",
103+
p.printf(" %2lX",
110104
t.uxCoreAffinityMask & ((1<<configNUMBER_OF_CORES)-1)
111105
);
112106
#endif
113-
Serial.printf("\n");
107+
p.printf("\n");
114108
tot += runtime;
115109
}
116-
Serial.printf(" Total %7.2f%%\n", perc_sum);
110+
p.printf(" Total %7.2f%%\n", perc_sum);
117111
}
118112
#endif //configUSE_TRACE_FACILITY != 1

src/cli/FreeRTOS_ps.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,6 @@ TID Name CPU% Free St Pr Ni Core
6161

6262
#pragma once
6363

64-
void freertos_ps();
64+
#include <Arduino.h>
65+
66+
void freertos_ps(Print &p = Serial);

0 commit comments

Comments
 (0)