SCC131: weeks 7-12 Flashcards
(69 cards)
what does the DAPlink firmware of the microbit allow?
-creates a “bridge” between PC and SWD
-means microbit can be seen as a USB disk on source computer
-allows hex files to be dropped into microbit folder and run on microbit
what is bootloader mode on a microbit?
-hex files dropped into microbit folder will be written into interface MCU flash, not target MCU flash
-updates version of DAPlink
-name of USB becomes MAINTENANCE
what is the microbit function for displaying text scrolled?
uBit.display.scroll(“Hello”);
uBit.display.scroll(“Hello”,100);
uBit.display.scroll(26);
what is the microbit function for printing text?
uBit.display.print(“Hello”);
uBit.display.print(“Hello”,100);
uBit.display.print(26);
what are the options for display mode on a microbit?
-DISPLAY_MODE_BLACK_AND_WHITE
-DISPLAY_MODE_GREYSCALE
-DISPLAY_MODE_BLACK_AND_WHITE_LIGHT_SENSE
—display driver will sense the ambient brightness from the LEDs
what is the microbit function for changing the displau mode?
uBit.display.setDisplayMode(display_mode_name);
what is the function for setting the values of indiviual pixels on a microbit?
uBit.display.image.setPixelValue(x,y,255);
what is the function on a microbit for getting the pixel value?
uBit.display.image.getPixelValue(x,y);
what is the layout of the x and y coordinates on a microbit?
x—->0 1 2 3 4
0
1
2
3
4
y
how would you create an image to be displayed on a microbit?
MicroBitImage myImage(“x,x,x,x,x\n x,x,x,x,x\n x,x,x,x,x\n x,x,x,x,x\n x,x,x,x,x\n”);
-where x is a colour value 0-255
uBit.display.print(myImage);
list as many of the MicroBit classes encapsulated in MicroBit objects as possible (don’t NEED to know)
-uBit.i2c
-uBit.storage
-uBit.serial
-uBit.MessageBus
-uBit.buttonA
-uBit.buttonB
-uBit.buttonAB
-uBit.display
-uBit.accelerometer
-uBit.compass
-uBit.thermometer
-uBit.io
-uBit.radio
what do the MicroBitButton classes have that makes them functional?
-action listeners
-detect when buttons on the microbit are pressed
-method isPressed() returns 1 if button has been pressed
what is the key difference between a synchronous vs asynchronous implementation of microbit button activity?
-the synchronous uses a while loop and selection statements to constantly validate the buttons’ isPressed() functions to recognise when one has been pressed and perform the action
-the asynchronous implements an actionlistener for the button to raise an event only when a change is detected instead of constantly checking for change.
how would an asynchronous button action listener be implemented?
uBit.messageBus.listen(MICROBIT_ID_BUTTON_AB, MICROBIT_BUTTON_EVT_CLICK, onButtonAB);
void onButtonAB(MicroBitEvent e){
——> button action performed e.g print value
}
what are the three key parameters when using uBit.messageBus.listen() ?
-ID of component
-Event of interest, e.g button clicked
-Event handler to be called
what temperature does the microbit thermometer record?
-surface temperature of the application MCU
readTemp = uBit.thermometer.getTemperature();
how would room temperature be taken from a microbit?
-would need to measure the offset between what it records and the actual temperature, then subtract the offset in the code
-uBit.thermometer.setCalibration(readTemp- (offset));
-readTemp = uBit.thermometer.getTemperature();
what needs to be added to the code in order to utilise the MicrobitLog class?
include “MicroBitLog.h”
what is the function of the microbit log class?
-used to store things in a table-like format
what are some of the main functions associated with microbit log class?
-beginRow(): opens files, creates new rows
-logData(“column name”,value)
-endRow(): close file, complete logging
-isFull(): checks if log is full
-setVisibility(): log needs to be made visible first
-setTimeStamp(): to initiate the logger
What would be the difference between a sequentially and a asynchronously implemented thermometer sensor?
-sequential would continuously check the temperature within a while loop to identify any changes
-asynchronous implements an action listener that changes the temperature display only when a temperature change is sensed
How should a temperature action listener be implemented?
uBit.messageBus.listen(MICROBIT_ID_THERMOMETER,MICROBIT_THERMOMETER_EVT_UPDATE, event handler name);
how can the sampling period of a microbit thermometer be changed?
uBit.thermometer.setPeriod(time in ms);
what does the preprocessor do?
-macro expansion
-#include directives, essentially copies the code into your file
-#define statements, defines global constants