Skip to content

Commit 0df07b1

Browse files
committed
codal_app/microbithal: Add microbit_hal_display_rotate() function.
Signed-off-by: Damien George <[email protected]>
1 parent 251bd63 commit 0df07b1

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

src/codal_app/microbithal.cpp

+10
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,16 @@ int microbit_hal_display_read_light_level(void) {
375375
return uBit.display.readLightLevel();
376376
}
377377

378+
void microbit_hal_display_rotate(unsigned int rotation) {
379+
static DisplayRotation angle_map[4] = {
380+
MATRIX_DISPLAY_ROTATION_0,
381+
MATRIX_DISPLAY_ROTATION_90,
382+
MATRIX_DISPLAY_ROTATION_180,
383+
MATRIX_DISPLAY_ROTATION_270,
384+
};
385+
uBit.display.rotateTo(angle_map[rotation & 3]);
386+
}
387+
378388
void microbit_hal_accelerometer_get_sample(int axis[3]) {
379389
Sample3D sample = uBit.accelerometer.getSample();
380390
axis[0] = sample.x;

src/codal_app/microbithal.h

+1
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ void microbit_hal_display_enable(int value);
150150
int microbit_hal_display_get_pixel(int x, int y);
151151
void microbit_hal_display_set_pixel(int x, int y, int bright);
152152
int microbit_hal_display_read_light_level(void);
153+
void microbit_hal_display_rotate(unsigned int rotation);
153154

154155
void microbit_hal_accelerometer_get_sample(int axis[3]);
155156
int microbit_hal_accelerometer_get_gesture(void);

0 commit comments

Comments
 (0)