Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
example_flag.cpp
00001 #include "MicroBit.h" 00002 00003 #include "Display.h" 00004 #include "common.h" 00005 00006 00007 00008 int8_t pixels[] = 00009 {4,8,10,12,16,0,4,9,14,19,24,2,7,8,25,0,6,7,8,9,10,12,14,18,-1}; 00010 00011 00012 int8_t yield() { 00013 static int8_t column=0; 00014 int8_t retval = pixels[column++]; 00015 if (retval == -1) { 00016 column=0; 00017 return -1; 00018 } 00019 return retval-1; 00020 } 00021 00022 00023 void flag1(int8_t(*yieldF)()) { 00024 for (int8_t i=0; i < 5; i++) { 00025 display.setFlag(6*i); 00026 display.setFlag(4+4*i); 00027 } 00028 } 00029 00030 void flag2(int8_t(*yieldF)()) { 00031 int8_t p; 00032 while ((p = (yieldF)())!=-1) { 00033 display.setFlag(p); 00034 } 00035 } 00036 00037 void (*flg[])(int8_t(*yieldF)()) = {flag1,flag2}; 00038 00039 void example_flag() { 00040 int8_t i=0; 00041 while (true) { 00042 display.clear(); 00043 (flg[i>0 ? 1 : 0])(yield); 00044 i=(i+1) & 3; 00045 uBit.sleep(2000); 00046 } 00047 }
Generated on Mon Jul 18 2022 21:57:34 by
1.7.2