From a8224e4c1947bea134dd8b91a7c08188ed7140e9 Mon Sep 17 00:00:00 2001 From: Carlos Pereira Atencio Date: Thu, 12 Jan 2023 15:01:38 +0000 Subject: [PATCH] Set to static any non *_test functions. (#45) --- source/samples/AccelerometerTest.cpp | 8 ++--- source/samples/AudioTest.cpp | 4 +-- source/samples/BLETest.cpp | 6 ++-- source/samples/BlinkyTest.cpp | 4 +-- source/samples/ButtonTest.cpp | 8 ++--- source/samples/CapTouchTest.cpp | 12 +++---- source/samples/DeepSleepTest.cpp | 50 ++++++++++++++-------------- source/samples/DisplayTest.cpp | 14 ++++---- source/samples/MicrophoneTest.cpp | 4 +-- source/samples/RadioTestRx.cpp | 4 +-- source/samples/Tests.h | 1 + 11 files changed, 58 insertions(+), 57 deletions(-) diff --git a/source/samples/AccelerometerTest.cpp b/source/samples/AccelerometerTest.cpp index f242094..43af373 100644 --- a/source/samples/AccelerometerTest.cpp +++ b/source/samples/AccelerometerTest.cpp @@ -1,19 +1,19 @@ #include "MicroBit.h" #include "Tests.h" -void +static void onCompassData(MicroBitEvent) { DMESGN("C"); } -void +static void onAccelerometerData(MicroBitEvent) { DMESGN("A"); } -void +static void onShake(MicroBitEvent) { DMESG(" *** SHAKE ***"); @@ -34,7 +34,7 @@ accelerometer_test1() } } -int g_to_pix(int g) +static int g_to_pix(int g) { int v = 2; if ( g < -200) v--; diff --git a/source/samples/AudioTest.cpp b/source/samples/AudioTest.cpp index d0cde88..36f5420 100644 --- a/source/samples/AudioTest.cpp +++ b/source/samples/AudioTest.cpp @@ -56,7 +56,7 @@ static Pin *pin = NULL; static uint8_t pitchVolume = 0xff; // Pin control as per MakeCode. -void analogPitch(int frequency, int ms) { +static void analogPitch(int frequency, int ms) { if (frequency <= 0 || pitchVolume == 0) { pin->setAnalogValue(0); } else { @@ -74,7 +74,7 @@ void analogPitch(int frequency, int ms) { } } -void playScale() { +static void playScale() { const int beat = 500; analogPitch(Note::C5, beat); analogPitch(Note::B, beat); diff --git a/source/samples/BLETest.cpp b/source/samples/BLETest.cpp index 2d93b1c..64190be 100644 --- a/source/samples/BLETest.cpp +++ b/source/samples/BLETest.cpp @@ -31,17 +31,17 @@ extern MicroBit uBit; MicroBitUARTService *uart; // we use events abd the 'connected' variable to keep track of the status of the Bluetooth connection -void onConnected(MicroBitEvent) +static void onConnected(MicroBitEvent) { uBit.display.print("C"); } -void onDisconnected(MicroBitEvent) +static void onDisconnected(MicroBitEvent) { uBit.display.print("D"); } -void onDelim(MicroBitEvent) +static void onDelim(MicroBitEvent) { ManagedString r = uart->readUntil("\r\n"); uart->send(r); diff --git a/source/samples/BlinkyTest.cpp b/source/samples/BlinkyTest.cpp index 05e9b94..eb287fd 100644 --- a/source/samples/BlinkyTest.cpp +++ b/source/samples/BlinkyTest.cpp @@ -53,7 +53,7 @@ void off_power_test() } -void setDisplay(int mode) +static void setDisplay(int mode) { DMESG(mode ? "RED\n" : "GREEN\n"); @@ -70,7 +70,7 @@ void setDisplay(int mode) uBit.io.col5.setDigitalValue(!mode); } -void setCol(int col, int mode) +static void setCol(int col, int mode) { int c = 0; diff --git a/source/samples/ButtonTest.cpp b/source/samples/ButtonTest.cpp index 5b9f21b..f3486e2 100644 --- a/source/samples/ButtonTest.cpp +++ b/source/samples/ButtonTest.cpp @@ -39,25 +39,25 @@ button_test2() } } -void +static void onButtonA(MicroBitEvent) { uBit.display.print("Aa"); } -void +static void onButtonB(MicroBitEvent) { uBit.display.print("Bb"); } -void +static void onButtonAB(MicroBitEvent) { uBit.display.print("Cc"); } -void listenerRemoved(MicroBitListener *) +static void listenerRemoved(MicroBitListener *) { DMESG("Listener deleted"); } diff --git a/source/samples/CapTouchTest.cpp b/source/samples/CapTouchTest.cpp index e27c324..a4c1228 100644 --- a/source/samples/CapTouchTest.cpp +++ b/source/samples/CapTouchTest.cpp @@ -99,7 +99,7 @@ calibrateTest(float sample) //DMESG("[SAMPLE: %d]", (int)sample); } -void +static void onCalibrate(MicroBitEvent) { @@ -109,26 +109,26 @@ onCalibrate(MicroBitEvent) c2 = last_t2; } -void +static void onPrint(MicroBitEvent) { while(1) uBit.display.scroll(last_t2); } -void onTouchP0(MicroBitEvent e) +static void onTouchP0(MicroBitEvent e) { DMESG("TOUCH: P0"); } -void onTouchP1(MicroBitEvent e) +static void onTouchP1(MicroBitEvent e) { DMESG("TOUCH: P1"); } -void onTouchP2(MicroBitEvent e) +static void onTouchP2(MicroBitEvent e) { DMESG("TOUCH: P2"); } -void onTouchFace(MicroBitEvent e) +static void onTouchFace(MicroBitEvent e) { DMESG("TOUCH: FACE"); } diff --git a/source/samples/DeepSleepTest.cpp b/source/samples/DeepSleepTest.cpp index 5d4702b..5afd951 100644 --- a/source/samples/DeepSleepTest.cpp +++ b/source/samples/DeepSleepTest.cpp @@ -6,19 +6,19 @@ // TESTS // A fiber that sleeps for a few seconds -void deepsleep_test1(); +static void deepsleep_test1(); // A fiber that sleeps until woken by button A or B -void deepsleep_test2(); +static void deepsleep_test2(); // A timer event handler that sleeps between events -void deepsleep_test3(); +static void deepsleep_test3(); // Wake to run button A or B handlers -void deepsleep_test4(); +static void deepsleep_test4(); // Two timer event handlers with different periods that sleep between events -void deepsleep_test5(); +static void deepsleep_test5(); //////////////////////////////////////////////////////////////// // TEST @@ -40,16 +40,16 @@ void deepsleep_test( int test) //////////////////////////////////////////////////////////////// // HELPERS -void deepsleep_test_zeroone(); -void deepsleep_test_threefour(); -void deepsleep_test_send_time( const char *suffix); +static void deepsleep_test_zeroone(); +static void deepsleep_test_threefour(); +static void deepsleep_test_send_time( const char *suffix); //////////////////////////////////////////////////////////////// // TEST 1 // A fiber that sleeps for a few seconds -void deepsleep_test1_fiber() +static void deepsleep_test1_fiber() { while (true) { @@ -60,7 +60,7 @@ void deepsleep_test1_fiber() } } -void deepsleep_test1() +static void deepsleep_test1() { deepsleep_test_send_time( "deepsleep_test2\n"); @@ -75,7 +75,7 @@ void deepsleep_test1() // A fiber that sleeps until woken by button A or B -void deepsleep_test2_fiber() +static void deepsleep_test2_fiber() { while (true) { @@ -93,7 +93,7 @@ void deepsleep_test2_fiber() } -void deepsleep_test2() +static void deepsleep_test2() { deepsleep_test_send_time( "deepsleep_test2\n"); @@ -111,7 +111,7 @@ void deepsleep_test2() // A timer event handler that sleeps between events -void deepsleep_test3_onTimer(MicroBitEvent e) +static void deepsleep_test3_onTimer(MicroBitEvent e) { deepsleep_test_send_time( "deepsleep_test3_onTimer\n"); deepsleep_test_zeroone(); @@ -121,7 +121,7 @@ void deepsleep_test3_onTimer(MicroBitEvent e) } -void deepsleep_test3() +static void deepsleep_test3() { deepsleep_test_send_time( "deepsleep_test3\n"); @@ -143,7 +143,7 @@ void deepsleep_test3() // Wake to run button A or B handlers -void deepsleep_test4_onButtonA(MicroBitEvent e) +static void deepsleep_test4_onButtonA(MicroBitEvent e) { // Disable deep sleep power down until we have finished uBit.power.powerDownDisable(); @@ -157,7 +157,7 @@ void deepsleep_test4_onButtonA(MicroBitEvent e) } -void deepsleep_test4_onButtonB(MicroBitEvent e) +static void deepsleep_test4_onButtonB(MicroBitEvent e) { uBit.power.powerDownDisable(); @@ -170,7 +170,7 @@ void deepsleep_test4_onButtonB(MicroBitEvent e) } -void deepsleep_test4() +static void deepsleep_test4() { deepsleep_test_send_time( "deepsleep_test4\n"); @@ -191,7 +191,7 @@ void deepsleep_test4() // Two timer event handlers with different periods that sleep between events -void deepsleep_test5_onTimer1(MicroBitEvent e) +static void deepsleep_test5_onTimer1(MicroBitEvent e) { uBit.power.powerDownDisable(); @@ -208,7 +208,7 @@ void deepsleep_test5_onTimer1(MicroBitEvent e) } -void deepsleep_test5_onTimer2(MicroBitEvent e) +static void deepsleep_test5_onTimer2(MicroBitEvent e) { uBit.power.powerDownDisable(); @@ -225,7 +225,7 @@ void deepsleep_test5_onTimer2(MicroBitEvent e) } -void deepsleep_test5() +static void deepsleep_test5() { deepsleep_test_send_time( "deepsleep_test5\n"); @@ -248,13 +248,13 @@ void deepsleep_test5() //////////////////////////////////////////////////////////////// // HELPERS -void deepsleep_test_togglePixel( int x, int y) +static void deepsleep_test_togglePixel( int x, int y) { uBit.display.image.setPixelValue( x, y, uBit.display.image.getPixelValue( x, y) ? 0 : 255); } -void deepsleep_test_sirenPixels( int x0, int y0, int x1, int y1, int ms) +static void deepsleep_test_sirenPixels( int x0, int y0, int x1, int y1, int ms) { deepsleep_test_togglePixel( x0, y0); uBit.sleep(ms); @@ -265,21 +265,21 @@ void deepsleep_test_sirenPixels( int x0, int y0, int x1, int y1, int ms) } -void deepsleep_test_zeroone() +static void deepsleep_test_zeroone() { deepsleep_test_send_time( "deepsleep_test_zeroone\n"); deepsleep_test_sirenPixels( 0, 0, 1, 0, 150); } -void deepsleep_test_threefour() +static void deepsleep_test_threefour() { deepsleep_test_send_time( "deepsleep_test_threefour\n"); deepsleep_test_sirenPixels( 3, 0, 4, 0, 500); } -void deepsleep_test_send_time( const char *suffix) +static void deepsleep_test_send_time( const char *suffix) { uint64_t second = 1000000; diff --git a/source/samples/DisplayTest.cpp b/source/samples/DisplayTest.cpp index beb6a56..d18c0fe 100644 --- a/source/samples/DisplayTest.cpp +++ b/source/samples/DisplayTest.cpp @@ -53,7 +53,7 @@ const char * const sad_emoji ="\ Image happy(happy_emoji); Image sad(sad_emoji); -void +static void concurrent_display_test_t1() { while(1) @@ -63,7 +63,7 @@ concurrent_display_test_t1() } } -void +static void concurrent_display_test_t2() { uBit.sleep(500); @@ -245,7 +245,7 @@ raw_blinky_test() } -void +static void onButtonAPressed(MicroBitEvent) { const char * const a_emoji ="\ @@ -259,7 +259,7 @@ onButtonAPressed(MicroBitEvent) uBit.display.print(img_a); } -void +static void onButtonBPressed(MicroBitEvent) { const char * const b_emoji ="\ @@ -272,7 +272,7 @@ onButtonBPressed(MicroBitEvent) uBit.display.print(img_b); } -void +static void onButtonABPressed(MicroBitEvent) { const char * const c_emoji ="\ @@ -285,7 +285,7 @@ onButtonABPressed(MicroBitEvent) uBit.display.print(img_c); } -void +static void onShakePressed(MicroBitEvent) { const char * const d_emoji ="\ @@ -298,7 +298,7 @@ onShakePressed(MicroBitEvent) uBit.display.print(img_d); } -void +static void do_something_forever() { uBit.sleep(10); diff --git a/source/samples/MicrophoneTest.cpp b/source/samples/MicrophoneTest.cpp index ff57583..b4903d6 100644 --- a/source/samples/MicrophoneTest.cpp +++ b/source/samples/MicrophoneTest.cpp @@ -13,7 +13,7 @@ static LevelDetectorSPL *levelSPL = NULL; static int claps = 0; static volatile int sample; -void +static void onLoud(MicroBitEvent) { DMESG("LOUD"); @@ -24,7 +24,7 @@ onLoud(MicroBitEvent) uBit.display.print(claps); } -void +static void onQuiet(MicroBitEvent) { DMESG("QUIET"); diff --git a/source/samples/RadioTestRx.cpp b/source/samples/RadioTestRx.cpp index b82ff27..15b6ed5 100644 --- a/source/samples/RadioTestRx.cpp +++ b/source/samples/RadioTestRx.cpp @@ -3,7 +3,7 @@ int data_received; -void onData(MicroBitEvent) +static void onData(MicroBitEvent) { PacketBuffer b = uBit.radio.datagram.recv(); @@ -14,7 +14,7 @@ void onData(MicroBitEvent) uBit.display.print("B"); } -void onData2(MicroBitEvent) +static void onData2(MicroBitEvent) { PacketBuffer b = uBit.radio.datagram.recv(); DMESG("RECV"); diff --git a/source/samples/Tests.h b/source/samples/Tests.h index 6a8a74e..0181943 100644 --- a/source/samples/Tests.h +++ b/source/samples/Tests.h @@ -72,6 +72,7 @@ void mems_mic_drift_test(); void mc_clap_test(); void synthesizer_test(); void version_test(); +void off_test(); void power_consumption_test(); void power_source_test(); void standby_test();