Skip to content

Commit

Permalink
Minor loop count optimisation.
Browse files Browse the repository at this point in the history
  • Loading branch information
noisymime committed Nov 7, 2024
1 parent 4e23e87 commit 9be81a6
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 4 deletions.
2 changes: 1 addition & 1 deletion speeduino/globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -648,7 +648,7 @@ struct statuses {
unsigned int PW8; ///< In uS
volatile byte runSecs; /**< Counter of seconds since cranking commenced (Maxes out at 255 to prevent overflow) */
volatile byte secl; /**< Counter incrementing once per second. Will overflow after 255 and begin again. This is used by TunerStudio to maintain comms sync */
volatile uint32_t loopsPerSecond; /**< A performance indicator showing the number of main loops that are being executed each second */
volatile uint16_t loopsPerSecond; /**< A performance indicator showing the number of main loops that are being executed each second */
bool launchingSoft; /**< Indicator showing whether soft launch control adjustments are active */
bool launchingHard; /**< Indicator showing whether hard launch control adjustments are active */
uint16_t freeRAM;
Expand Down
2 changes: 0 additions & 2 deletions speeduino/logger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,9 @@ byte getTSLogEntry(uint16_t byteNum)
case 25: statusValue = currentStatus.TPS; break; // TPS (0% to 100%)

case 26:
if(currentStatus.loopsPerSecond > 60000U) { currentStatus.loopsPerSecond = 60000U;}
statusValue = lowByte(currentStatus.loopsPerSecond);
break;
case 27:
if(currentStatus.loopsPerSecond > 60000U) { currentStatus.loopsPerSecond = 60000U;}
statusValue = highByte(currentStatus.loopsPerSecond);
break;

Expand Down
2 changes: 1 addition & 1 deletion speeduino/speeduino.ino
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ inline uint16_t applyFuelTrimToPW(trimTable3d *pTrimTable, int16_t fuelLoad, int
// it to inline, so we need to suppress the resulting warning.
void __attribute__((always_inline)) loop(void)
{
mainLoopCount++;
if(mainLoopCount < UINT16_MAX) { mainLoopCount++; }
LOOP_TIMER = TIMER_mask;

//SERIAL Comms
Expand Down

0 comments on commit 9be81a6

Please sign in to comment.