Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions inc/MicroBitDisplay.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ DEALINGS IN THE SOFTWARE.
#include "codal-core/inc/types/Event.h"
#include "NRF52LedMatrix.h"
#include "AnimatedDisplay.h"
#include "NRFLowLevelTimer.h"

namespace codal
{
Expand All @@ -49,9 +50,24 @@ namespace codal
* @param map The mapping information that relates pin inputs/outputs to physical screen coordinates.
* @param id The id the display should use when sending events on the MessageBus. Defaults to DEVICE_ID_DISPLAY.
*
* @note This constructor is deprecated. Please use MicroBitDisplay(NRFLowLevelTimer&, const MatrixMap, uint16_t), which provides better handling of the timer used to update the display.
*/
[[deprecated("Replaced by MicroBitDisplay(NRFLowLevelTimer&, const MatrixMap, uint16_t), which provides better handling of the timer used to update the display.")]]
MicroBitDisplay(const MatrixMap &map, uint16_t id = DEVICE_ID_DISPLAY);

/**
* Constructor.
*
* Create a software representation of the micro:bit's 5x5 LED matrix.
* The display is initially blank.
*
* @param t The timer to be used for display refresh.
* @param map The mapping information that relates pin inputs/outputs to physical screen coordinates.
* @param id The id the display should use when sending events on the MessageBus. Defaults to DEVICE_ID_DISPLAY.
*
*/
MicroBitDisplay(NRFLowLevelTimer& t, const MatrixMap &map, uint16_t id = DEVICE_ID_DISPLAY);

/**
* Destructor.
*/
Expand Down
5 changes: 3 additions & 2 deletions model/MicroBit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,10 @@ MicroBit::MicroBit() :

systemTimer(NRF_TIMER1, TIMER1_IRQn),
adcTimer(NRF_TIMER2, TIMER2_IRQn),

capTouchTimer(NRF_TIMER3, TIMER3_IRQn),
displayTimer(NRF_TIMER4, TIMER4_IRQn),
timer(systemTimer),

messageBus(),
adc(adcTimer, 91),
touchSensor(capTouchTimer),
Expand All @@ -79,7 +80,7 @@ MicroBit::MicroBit() :
ledRowPins{&io.row1, &io.row2, &io.row3, &io.row4, &io.row5},
ledColPins{&io.col1, &io.col2, &io.col3, &io.col4, &io.col5},
ledMatrixMap{ 5, 5, 5, 5, (Pin**)ledRowPins, (Pin**)ledColPins, ledMatrixPositions},
display(ledMatrixMap),
display(displayTimer, ledMatrixMap),
buttonA(io.P5, DEVICE_ID_BUTTON_A, DEVICE_BUTTON_ALL_EVENTS, ACTIVE_LOW, PullMode::None),
buttonB(io.P11, DEVICE_ID_BUTTON_B, DEVICE_BUTTON_ALL_EVENTS, ACTIVE_LOW, PullMode::None),
buttonAB(DEVICE_ID_BUTTON_A, DEVICE_ID_BUTTON_B, DEVICE_ID_BUTTON_AB),
Expand Down
2 changes: 2 additions & 0 deletions model/MicroBit.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,9 @@ namespace codal
NRFLowLevelTimer systemTimer;
NRFLowLevelTimer adcTimer;
NRFLowLevelTimer capTouchTimer;
NRFLowLevelTimer displayTimer;
Timer timer;

MessageBus messageBus;
NRF52ADC adc;
NRF52TouchSensor touchSensor;
Expand Down
18 changes: 17 additions & 1 deletion source/MicroBitDisplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ DEALINGS IN THE SOFTWARE.
* Class definition for MicroBitDisplay
*/
#include "MicroBitDisplay.h"
#include "NRFLowLevelTimer.h"

using namespace codal;

Expand All @@ -39,11 +38,28 @@ using namespace codal;
*
* @param map The mapping information that relates pin inputs/outputs to physical screen coordinates.
* @param id The id the display should use when sending events on the MessageBus. Defaults to DEVICE_ID_DISPLAY.
*
* @note This constructor is deprecated. Please use MicroBitDisplay(NRFLowLevelTimer&, const MatrixMap, uint16_t), which provides better handling of the timer used to update the display.
*/
[[deprecated("Replaced by MicroBitDisplay(NRFLowLevelTimer&, const MatrixMap, uint16_t), which provides better handling of the timer used to update the display.")]]
MicroBitDisplay::MicroBitDisplay(const MatrixMap &map, uint16_t id) : NRF52LEDMatrix(*new NRFLowLevelTimer(NRF_TIMER4, TIMER4_IRQn), map, id, DisplayMode::DISPLAY_MODE_GREYSCALE), AnimatedDisplay(*this, id)
{
}

/**
* Constructor.
*
* Create a software representation of the micro:bit's 5x5 LED matrix.
* The display is initially blank.
*
* @param t The timer to be used for display refresh.
* @param map The mapping information that relates pin inputs/outputs to physical screen coordinates.
* @param id The id the display should use when sending events on the MessageBus. Defaults to DEVICE_ID_DISPLAY.
*/
MicroBitDisplay::MicroBitDisplay(NRFLowLevelTimer& t, const MatrixMap &map, uint16_t id) : NRF52LEDMatrix(t, map, id, DisplayMode::DISPLAY_MODE_GREYSCALE), AnimatedDisplay(*this, id)
{
}

/**
* Destructor.
*/
Expand Down
Loading