Skip to content

Commit

Permalink
version bump & pxt v6.x updates
Browse files Browse the repository at this point in the history
  • Loading branch information
Juri committed Sep 11, 2020
1 parent ca075eb commit 21d0615
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 32 deletions.
14 changes: 7 additions & 7 deletions inc/MicroBit.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ Copyright (c) 2016 British Broadcasting Corporation.
This software is provided by Lancaster University by arrangement with the BBC.
Modifications Copyright (c) 2016 Calliope GbR
Modifications are provided by DELTA Systems (Georg Sommer) - Thomas Kern
und Björn Eberhardt GbR by arrangement with Calliope GbR.
Modifications are provided by DELTA Systems (Georg Sommer) - Thomas Kern
und Björn Eberhardt GbR by arrangement with Calliope GbR.
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
Expand Down Expand Up @@ -37,7 +37,6 @@ DEALINGS IN THE SOFTWARE.
#include "MicroBitDevice.h"
#include "ErrorNo.h"
#include "MicroBitSystemTimer.h"
#include "Matrix4.h"
#include "MicroBitCompat.h"
#include "MicroBitComponent.h"
#include "ManagedType.h"
Expand All @@ -52,9 +51,8 @@ DEALINGS IN THE SOFTWARE.
#include "MicroBitButton.h"
#include "MicroBitPin.h"
#include "MicroBitCompass.h"
#include "MicroBitCompass-bmx.h"
#include "MicroBitCompassCalibrator.h"
#include "MicroBitAccelerometer-bmx.h"
#include "MicroBitAccelerometer.h"
#include "MicroBitThermometer.h"
#include "MicroBitLightSensor.h"
#include "MicroBitMultiButton.h"
Expand Down Expand Up @@ -102,8 +100,10 @@ class MicroBit
// Serial Interface
MicroBitSerial serial;

#ifndef TARGET_NRF51_CALLIOPE
// Reset Button
InterruptIn resetButton;
#endif

// Persistent key value store
MicroBitStorage storage;
Expand All @@ -119,8 +119,8 @@ class MicroBit
MicroBitButton buttonA;
MicroBitButton buttonB;
MicroBitMultiButton buttonAB;
MicroBitAccelerometer accelerometer;
MicroBitCompass compass;
MicroBitAccelerometer &accelerometer;
MicroBitCompass &compass;
MicroBitCompassCalibrator compassCalibrator;
MicroBitThermometer thermometer;

Expand Down
4 changes: 2 additions & 2 deletions module.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"name": "microbit",
"version": "2.0.0-calliope-1.0.5",
"version": "2.2.0-rc6-calliope.rc3",
"description": "A simple to use collection of the most commonly used components in the micro:bit runtime",
"license": "MIT",
"dependencies": {
"microbit-dal": "calliope-mini/microbit-dal#v2.0.0-calliope-1.0.5"
"microbit-dal": "calliope-mini/microbit-dal#v2.2.0-rc6-calliope.rc3"
},
"extraIncludes": [
"inc"
Expand Down
59 changes: 36 additions & 23 deletions source/MicroBit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ Modifications are provided by DELTA Systems (Georg Sommer) - Thomas Kern
und Björn Eberhardt GbR by arrangement with Calliope GbR.
*/

#include <pinmap.h>
#include "MicroBitConfig.h"
/*
* The underlying Nordic libraries that support BLE do not compile cleanly with the stringent GCC settings we employ
Expand Down Expand Up @@ -66,17 +65,19 @@ RawSerial* SERIAL_DEBUG = NULL;
*/
MicroBit::MicroBit() :
serial(USBTX, USBRX),
#ifndef TARGET_NRF51_CALLIOPE
resetButton(MICROBIT_PIN_BUTTON_RESET),
#endif
storage(),
i2c(I2C_SDA0, I2C_SCL0),
messageBus(),
display(),
buttonA(MICROBIT_PIN_BUTTON_A, MICROBIT_ID_BUTTON_A),
buttonB(MICROBIT_PIN_BUTTON_B, MICROBIT_ID_BUTTON_B),
buttonAB(MICROBIT_ID_BUTTON_A,MICROBIT_ID_BUTTON_B, MICROBIT_ID_BUTTON_AB),
accelerometer(i2c),
compass(i2c, accelerometer, storage),
compassCalibrator(compass, accelerometer, display),
accelerometer(MicroBitAccelerometer::autoDetect(i2c)),
compass(MicroBitCompass::autoDetect(i2c)),
compassCalibrator(compass, accelerometer, display, storage),
thermometer(storage),
io(MICROBIT_ID_IO_P0,MICROBIT_ID_IO_P1,MICROBIT_ID_IO_P2,
MICROBIT_ID_IO_P3,MICROBIT_ID_IO_P4,MICROBIT_ID_IO_P5,
Expand All @@ -99,9 +100,12 @@ MicroBit::MicroBit() :
// Clear our status
status = 0;

// there is no soft reset pin available on the Callipo mini, it is resetted via the KL26z SWD
#ifndef TARGET_NRF51_CALLIOPE
// Bring up soft reset functionality as soon as possible.
resetButton.mode(PullUp);
resetButton.fall(this, &MicroBit::reset);
#endif
}

/**
Expand All @@ -124,14 +128,6 @@ void MicroBit::init()
if (status & MICROBIT_INITIALIZED)
return;

// configure the accelerometer
accelerometer.configure();

#if CONFIG_ENABLED(MICROBIT_HEAP_ALLOCATOR)
// Bring up a nested heap allocator.
microbit_create_nested_heap(MICROBIT_NESTED_HEAP_SIZE);
#endif

// Bring up fiber scheduler.
scheduler_init(messageBus);

Expand All @@ -146,17 +142,35 @@ void MicroBit::init()
status |= MICROBIT_INITIALIZED;

#if CONFIG_ENABLED(MICROBIT_BLE_PAIRING_MODE)
// Test if we need to enter BLE pairing mode...
int i=0;
int i=0;
// Test if we need to enter BLE pairing mode
// If a RebootMode Key has been set boot straight into BLE mode
KeyValuePair* RebootMode = storage.get("RebootMode");
KeyValuePair* flashIncomplete = storage.get("flashIncomplete");
sleep(100);
while (buttonA.isPressed() && buttonB.isPressed() && i<10)
// Animation
uint8_t x = 0; uint8_t y = 0;
while ((buttonA.isPressed() && buttonB.isPressed() && i<25) || RebootMode != NULL || flashIncomplete != NULL)
{
sleep(100);
i++;
display.image.setPixelValue(x,y,255);
sleep(50);
i++; x++;

if (i == 10)
// Gradually fill screen
if(x == 5){
y++; x = 0;
}

if (i == 25 || RebootMode != NULL)
{
#if CONFIG_ENABLED(MICROBIT_HEAP_ALLOCATOR) && CONFIG_ENABLED(MICROBIT_HEAP_REUSE_SD)
// Remove KV if it exists
if(RebootMode != NULL){
storage.remove("RebootMode");
}
delete RebootMode;
delete flashIncomplete;

#if CONFIG_ENABLED(MICROBIT_HEAP_REUSE_SD)
microbit_create_heap(MICROBIT_SD_GATT_TABLE_START + MICROBIT_SD_GATT_TABLE_SIZE, MICROBIT_SD_LIMIT);
#endif
// Start the BLE stack, if it isn't already running.
Expand All @@ -173,7 +187,7 @@ void MicroBit::init()
#endif

// Attempt to bring up a second heap region, using unused memory normally reserved for Soft Device.
#if CONFIG_ENABLED(MICROBIT_HEAP_ALLOCATOR) && CONFIG_ENABLED(MICROBIT_HEAP_REUSE_SD)
#if CONFIG_ENABLED(MICROBIT_HEAP_REUSE_SD)
#if CONFIG_ENABLED(MICROBIT_BLE_ENABLED)
microbit_create_heap(MICROBIT_SD_GATT_TABLE_START + MICROBIT_SD_GATT_TABLE_SIZE, MICROBIT_SD_LIMIT);
#else
Expand Down Expand Up @@ -218,16 +232,15 @@ void MicroBit::onListenerRegisteredEvent(MicroBitEvent evt)
case MICROBIT_ID_COMPASS:
// A listener has been registered for the compass.
// The compass uses lazy instantiation, we just need to read the data once to start it running.
// Touch the compass through the heading() function to ensure it is calibrated. if it isn't this will launch any associated calibration algorithms.
compass.heading();
compass.getSample();

break;

case MICROBIT_ID_ACCELEROMETER:
case MICROBIT_ID_GESTURE:
// A listener has been registered for the accelerometer.
// The accelerometer uses lazy instantiation, we just need to read the data once to start it running.
accelerometer.updateSample();
accelerometer.getSample();
break;

case MICROBIT_ID_THERMOMETER:
Expand Down

0 comments on commit 21d0615

Please sign in to comment.