From dbaa6fb6d2e2324fe0bb348029e1c3150792856f Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 27 Dec 2011 07:24:36 +1100 Subject: [PATCH] TimerProcess: make some variables uint8_t save a couple of bytes --- libraries/AP_PeriodicProcess/AP_PeriodicProcessStub.cpp | 2 +- libraries/AP_PeriodicProcess/AP_PeriodicProcessStub.h | 4 ++-- libraries/AP_PeriodicProcess/AP_TimerProcess.cpp | 7 ++++--- libraries/AP_PeriodicProcess/AP_TimerProcess.h | 6 +++--- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/libraries/AP_PeriodicProcess/AP_PeriodicProcessStub.cpp b/libraries/AP_PeriodicProcess/AP_PeriodicProcessStub.cpp index 08b233e32c..aa6e0483bb 100644 --- a/libraries/AP_PeriodicProcess/AP_PeriodicProcessStub.cpp +++ b/libraries/AP_PeriodicProcess/AP_PeriodicProcessStub.cpp @@ -1,6 +1,6 @@ #include "AP_PeriodicProcessStub.h" -AP_PeriodicProcessStub::AP_PeriodicProcessStub(int period) {} +AP_PeriodicProcessStub::AP_PeriodicProcessStub(uint8_t period) {} void AP_PeriodicProcessStub::init( Arduino_Mega_ISR_Registry * isr_reg ){} void AP_PeriodicProcessStub::register_process(ap_procedure proc) {} void AP_PeriodicProcessStub::set_failsafe(ap_procedure proc) {} diff --git a/libraries/AP_PeriodicProcess/AP_PeriodicProcessStub.h b/libraries/AP_PeriodicProcess/AP_PeriodicProcessStub.h index da129da186..c9e9c35670 100644 --- a/libraries/AP_PeriodicProcess/AP_PeriodicProcessStub.h +++ b/libraries/AP_PeriodicProcess/AP_PeriodicProcessStub.h @@ -9,13 +9,13 @@ class AP_PeriodicProcessStub : public AP_PeriodicProcess { public: - AP_PeriodicProcessStub(int period = 0); + AP_PeriodicProcessStub(uint8_t period = 0); void init( Arduino_Mega_ISR_Registry * isr_reg ); void register_process(ap_procedure proc); void set_failsafe(ap_procedure proc); static void run(void); protected: - static int _period; + static uint8_t _period; static void (*_proc)(void); static void (*_failsafe)(void); }; diff --git a/libraries/AP_PeriodicProcess/AP_TimerProcess.cpp b/libraries/AP_PeriodicProcess/AP_TimerProcess.cpp index b747a1eb8d..58d05b9816 100644 --- a/libraries/AP_PeriodicProcess/AP_TimerProcess.cpp +++ b/libraries/AP_PeriodicProcess/AP_TimerProcess.cpp @@ -1,3 +1,4 @@ +/// -*- tab-width: 4; Mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*- #include "AP_TimerProcess.h" @@ -8,13 +9,13 @@ extern "C" { #include } -int AP_TimerProcess::_period; +uint8_t AP_TimerProcess::_period; ap_procedure AP_TimerProcess::_proc[AP_TIMERPROCESS_MAX_PROCS]; ap_procedure AP_TimerProcess::_failsafe; bool AP_TimerProcess::_in_timer_call; -int AP_TimerProcess::_pidx = 0; +uint8_t AP_TimerProcess::_pidx = 0; -AP_TimerProcess::AP_TimerProcess(int period) +AP_TimerProcess::AP_TimerProcess(uint8_t period) { _period = period; } diff --git a/libraries/AP_PeriodicProcess/AP_TimerProcess.h b/libraries/AP_PeriodicProcess/AP_TimerProcess.h index 8d588955c3..140c5996f8 100644 --- a/libraries/AP_PeriodicProcess/AP_TimerProcess.h +++ b/libraries/AP_PeriodicProcess/AP_TimerProcess.h @@ -13,16 +13,16 @@ class AP_TimerProcess : public AP_PeriodicProcess { public: - AP_TimerProcess(int period = TIMERPROCESS_PER_DEFAULT); + AP_TimerProcess(uint8_t period = TIMERPROCESS_PER_DEFAULT); void init( Arduino_Mega_ISR_Registry * isr_reg ); void register_process(ap_procedure proc); void set_failsafe(ap_procedure proc); static void run(void); protected: - static int _period; + static uint8_t _period; static ap_procedure _proc[AP_TIMERPROCESS_MAX_PROCS]; static ap_procedure _failsafe; - static int _pidx; + static uint8_t _pidx; static bool _in_timer_call; };