Skip to content

Commit

Permalink
Merge branch 'master' of ssh://github.com/lancaster-university/microb…
Browse files Browse the repository at this point in the history
…it-v2-samples
  • Loading branch information
JohnVidler committed Jan 15, 2023
2 parents 4bdd515 + a8224e4 commit 5580068
Show file tree
Hide file tree
Showing 11 changed files with 58 additions and 57 deletions.
8 changes: 4 additions & 4 deletions 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 ***");
Expand All @@ -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--;
Expand Down
4 changes: 2 additions & 2 deletions source/samples/AudioTest.cpp
Expand Up @@ -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 {
Expand All @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions source/samples/BLETest.cpp
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions source/samples/BlinkyTest.cpp
Expand Up @@ -53,7 +53,7 @@ void off_power_test()
}


void setDisplay(int mode)
static void setDisplay(int mode)
{
DMESG(mode ? "RED\n" : "GREEN\n");

Expand All @@ -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;

Expand Down
8 changes: 4 additions & 4 deletions source/samples/ButtonTest.cpp
Expand Up @@ -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");
}
Expand Down
12 changes: 6 additions & 6 deletions source/samples/CapTouchTest.cpp
Expand Up @@ -99,7 +99,7 @@ calibrateTest(float sample)
//DMESG("[SAMPLE: %d]", (int)sample);
}

void
static void
onCalibrate(MicroBitEvent)
{

Expand All @@ -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");
}
Expand Down
50 changes: 25 additions & 25 deletions source/samples/DeepSleepTest.cpp
Expand Up @@ -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
Expand All @@ -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)
{
Expand All @@ -60,7 +60,7 @@ void deepsleep_test1_fiber()
}
}

void deepsleep_test1()
static void deepsleep_test1()
{
deepsleep_test_send_time( "deepsleep_test2\n");

Expand All @@ -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)
{
Expand All @@ -93,7 +93,7 @@ void deepsleep_test2_fiber()
}


void deepsleep_test2()
static void deepsleep_test2()
{
deepsleep_test_send_time( "deepsleep_test2\n");

Expand All @@ -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();
Expand All @@ -121,7 +121,7 @@ void deepsleep_test3_onTimer(MicroBitEvent e)
}


void deepsleep_test3()
static void deepsleep_test3()
{
deepsleep_test_send_time( "deepsleep_test3\n");

Expand All @@ -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();
Expand All @@ -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();

Expand All @@ -170,7 +170,7 @@ void deepsleep_test4_onButtonB(MicroBitEvent e)
}


void deepsleep_test4()
static void deepsleep_test4()
{
deepsleep_test_send_time( "deepsleep_test4\n");

Expand All @@ -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();

Expand All @@ -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();

Expand All @@ -225,7 +225,7 @@ void deepsleep_test5_onTimer2(MicroBitEvent e)
}


void deepsleep_test5()
static void deepsleep_test5()
{
deepsleep_test_send_time( "deepsleep_test5\n");

Expand All @@ -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);
Expand All @@ -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;

Expand Down

0 comments on commit 5580068

Please sign in to comment.