Approved content
The content below is provided by a partner.
This PXT package is to enable the use of the Annikken Andee app on the BBC micro:bit. Users can create UI widgets like sliders, buttons and more to control the micro:bit using their BLE enabled smartphone/tablets.
This package has been updated to support the increased storage of the microbit V2. If you are using microbit V1, use this extension instead.
No extra hardware is required to use Andee on the micro:bit. Andee uses the BLE that is already present on the micro:bit. Andee might not be compatible with other packages running BLE
Andee can be used either with the paired connection or the unpaired one. We recommend using the paired connection especially when there are multiple micro:bits running Andee in close proximity to each other.
For more information about how Bluetooth pairing on the micro:bit works and how to pair,click here
If you are unable to pair your micro:bit to your mobile device or would prefer not to pair the micro:bit to your device, you can follow the steps below:
Project Settings
No Pairing Required: Anyone can connect via Bluetooth.
Save
The Andee app will now be able to scan and detect your micro:bit
For video examples on how to get started with Andee and create the widgets, click here
The ||Andee.begin()||
block is required to start using Andee widgets
Andee.begin();
These are examples on how to create each type of widget that Andee supports. For explanation on all the properties of the widget look here.
let widget = Andee.createWidget(
WidgetId.Widget_1,
WidgetType.Databox,
WidgetPosition.Row0_Column0,
WidgetLength.Half,
WidgetColour.Red,
"Title",
"Data",
"Units"
);
let widget = Andee.createWidget(
WidgetId.Widget_1,
WidgetType.Databox_Circle,
WidgetPosition.Row0_Column0,
WidgetLength.Half,
WidgetColour.Red,
"Title",
"Data",
"Units"
);
let widget = Andee.createWidget(
WidgetId.Widget_1,
WidgetType.Databox_Header,
WidgetPosition.Row0_Column0,
WidgetLength.Half,
WidgetColour.Red,
"Title",
"Not Used",
"Not Used"
);
let widget = Andee.createWidget(
WidgetId.Widget_1,
WidgetType.Databox,
WidgetPosition.Row0_Column0,
WidgetLength.Half,
WidgetColour.Red,
"Title",
"Data",
"Units"
);
let widget = Andee.createWidget(
WidgetId.Widget_1,
WidgetType.Button_Circle,
WidgetPosition.Row0_Column0,
WidgetLength.Half,
WidgetColour.Red,
"Title",
"Data",
"Units"
);
let widget = Andee.createWidget(
WidgetId.Widget_1,
WidgetType.Keyboard_In,
WidgetPosition.Row0_Column0,
WidgetLength.Half,
WidgetColour.Red,
"Title",
"Data",
"Units"
);
let widget = Andee.createSliderWidget(
WidgetId.Widget_1,
WidgetTypeInput.Slider,
WidgetPosition.Row0_Column0,
WidgetLength.Full,
WidgetColour.Red,
"Title",
"Units",
"0",
"100",
"0",
100
);
let widget = Andee.createSliderWidget(
WidgetId.Widget_1,
WidgetTypeInput.Analog_Dial,
WidgetPosition.Row0_Column0,
WidgetLength.Full,
WidgetColour.Red,
"Title",
"Units",
"0",
"100",
"0",
100
);
Once the widget parameters have been set, the block ||widget.update()||
has to be used for each widget created.This block will tell the app to draw out the widget or update it.
basic.forever(() => {
widget.update()
})
This block is used to create triggers for widgets like buttons, sliders and keyboard. Users can specify the actions to be done when the events are triggered. Each event will be shown below.
Button events work for both normal and circle buttons. For example, if a button widget with id 2 has been created, the event block needed is
Andee.WidgetEvent(WidgetId.Widget_2, () => {
});
Andee.WidgetEvent(WidgetId.Widget_3, () => {
let reply = Andee.getSlider();
});
Note: For sliders, a variable has to be created to store the value from the slider widget. ||Andee.getSlider()||
returns a number
Andee.WidgetEvent(WidgetId.Widget_1, () => {
let reply = Andee.getKeyboard();
widget.ack();
});
Note: For keyboard input, a variable has to be created to store the string from the Keyboard widget. ||Andee.getKeyboard()||
returns a string
Each widget has a few properties that can be customised. {parameter} The properties are
The blocks below are used to change the properties of a widget while the sketch is running. This enables the user to create e a more interactive UI.
Every time a widget property is changed, ||widget.update()||
has to be called for the changes to take place in the app. The widget property can be changed in an event or in the Forever
loop.
This block changes the title of the widget and only accepts a string
basic.forever(() => {
widget.setTitle("Title");
widget.update();
})
This block changes the data section of the widget and only accepts a string
basic.forever(() => {
widget.setData("Data");
widget.update();
})
This block changes the units section of the widget and only accepts a string
basic.forever(() => {
widget.setUnit("Units");
widget.update();
})
This block changes the colour of the widget
basic.forever(() => {
widget.setColour(WidgetColour.Red)
widget.update();
})
This block changes the width of the widget with a number
of range 0 to 100
basic.forever(() => {
widget.setWidth(50)
widget.update();
})
This block changes the height of the widget with a number
of range 0 to 100
basic.forever(() => {
widget.setHeight(25)
widget.update();
})
This block changes the X coordinate of the top-left hand corner of the widget with a number
of range 0 to 100.
basic.forever(() => {
widget.setCoordX(50)
widget.update();
})
This block changes the Y coordinate of the top-left hand corner of the widget with a number
of range 0 to 100.
basic.forever(() => {
widget.setCoordY(50)
widget.update();
})
This block changes the keyboard layout to either AlphaNumeric or Numeric keyboard. Default mode is the AlphaNumeric keyboard
basic.forever(() => {
widget.setKeyboardInputMode(KeyboardMode.AlphaNumeric)
widget.update();
})
This block changes the input mode of the slider to either “register value on finger release” or “register value on change”. Default mode is “register value on finger release”
basic.forever(() => {
widget.setSliderInputMode(SliderMode.On_Finger_Release)
widget.update();
})
This block changes the button to either unpress immediately or wait for an acknowledgment before unpressing itself. Default mode is to unpress immediately
basic.forever(() => {
widget.setButtonInputMode(ButtonMode.Acknowledge)
widget.update();
})
This block will return true
if the button widget has been pressed more than once and will return false
when not.
In this example, the happy face icon will show on the LED array on the microbit when the button is pressed twice, while pressing the button once will show a sad face icon
Andee.WidgetEvent(WidgetId.Widget_2, () => {
if (Andee.getButtonPress()) {
basic.showIcon(IconNames.Happy)
} else {
basic.showIcon(IconNames.Sad)
}
})
This block will cause the widget to send an update after a specified number of loops have passed. All widgets will update after 100 loops as a default. If a more frequent update is required for faster response, this block should be used
basic.forever(() => {
widget.updateLoop(50)
})
This block forces the widget to update immediately
basic.forever(() => {
widget.forceUpdate()
})
This block converts numbers to string
. Usually used when a number is needed to be displayed on ||widget.setData()||
, ||widget.setTitle()||
or ||widget.setUnit()||
basic.forever(() => {
let value = 50;
widget.setData(Andee.convertNumberToString(value));
})
This block will clear all widgets in the app. Use ||widget.update()||
block to display the widgets again
basic.forever(() => {
Andee.clear()
})
This block will clear a widget one at a time
basic.forever(() => {
widget.remove()
})
MIT
Andee=github:Annikken/pxt-Andee#v1.0.6