Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
U
UFCFVK-15-2 - Internet of things - Challenge 1
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
ja3-saxby
UFCFVK-15-2 - Internet of things - Challenge 1
Commits
703c8079
Commit
703c8079
authored
5 years ago
by
ja3-saxby
Browse files
Options
Downloads
Patches
Plain Diff
Amend mistakes
parent
faecddd8
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
source/main.cpp
+11
-5
11 additions, 5 deletions
source/main.cpp
with
11 additions
and
5 deletions
source/main.cpp
+
11
−
5
View file @
703c8079
...
...
@@ -143,7 +143,7 @@ private:
Block
::
Block
()
:
shape
((
Shape
)
UBIT
.
random
(
SHAPE_TYPES_COUNT
))
// choose a random shape
,
facing
(
NORTH
)
// for now, all shapes face North
,
facing
(
RotationDirection
::
NORTH
)
// for now, all shapes face North
{}
MicroBitImage
Block
::
image
()
const
{
...
...
@@ -167,24 +167,30 @@ int main() {
// Initialise the micro:bit runtime.
UBIT
.
init
();
// draw first dot to indicate runtime system is initialised
UBIT
.
display
.
setPixelValue
(
0
,
2
,
255
);
UBIT
.
display
.
image
.
setPixelValue
(
0
,
2
,
255
);
// seed the PRNG with the HRNG
UBIT
.
seedRandom
();
// draw second dot to indicate PRNG has been seeded
UBIT
.
display
.
setPixelValue
(
2
,
2
,
255
);
UBIT
.
display
.
image
.
setPixelValue
(
2
,
2
,
255
);
// ensure display is set to black and white mode
UBIT
.
display
.
setDisplayMode
(
DISPLAY_MODE_BLACK_AND_WHITE
);
// draw third and final dot to indicate screen has been set up
UBIT
.
display
.
setPixelValue
(
4
,
2
,
1
);
UBIT
.
display
.
image
.
setPixelValue
(
4
,
2
,
1
);
UBIT
.
display
.
scroll
(
"BLOCKS!"
);
// XXX: simple debug test to check my FLASH images were stored correctly
// a simple clocker to check frame rate
bool
strober
=
false
;
while
(
true
)
{
// display new random blocks each second
Block
block
;
UBIT
.
display
.
print
(
block
.
image
(),
1
,
1
);
UBIT
.
display
.
print
(
block
.
image
(),
2
,
2
);
// display clocker
UBIT
.
display
.
image
.
setPixelValue
(
0
,
0
,
strober
);
UBIT
.
sleep
(
1000
);
// 1000ms or 1s sleep
// invert the clocker
strober
=
!
strober
;
}
// TODO: potentially remove this call, if clarified that it is not required.
...
...
This diff is collapsed.
Click to expand it.
ja3-saxby
@ja3-saxby
mentioned in issue
#1 (closed)
·
5 years ago
mentioned in issue
#1 (closed)
mentioned in issue #1
Toggle commit list
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment