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.
Fork of 00_LAB_matrix8x8_SPI by
Revision 2:414129d953dd, committed 2017-03-16
- Comitter:
- fabeltranm
- Date:
- Thu Mar 16 22:53:10 2017 +0000
- Parent:
- 1:b732136485e0
- Child:
- 3:4a8de2f71ed0
- Commit message:
- new snake
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Wed Mar 15 21:47:38 2017 +0000
+++ b/main.cpp Thu Mar 16 22:53:10 2017 +0000
@@ -9,7 +9,7 @@
DigitalOut ssel (PB_12);
#define uint8_t unsigned char
-
+uint8_t vcol2[8]={0,0,0,0,0,0,0,0};
void sendSPI(uint8_t d1, uint8_t d2)
@@ -32,17 +32,56 @@
}
};
+
+void reset_vcol()
+ {
+ for (i=0; i<8;i++){
+ vcol2[i]=0;
+ }
+}
+
+void print_Snake2()
+{
+
+ int j, i;
+ //reset
+ reset_vcol();
+ for (j=0; j<8;j++){
+ for (i=0; i<8;i++){
+ if(j % 2 == 0){
+ if (vcol2[j]==0)
+ vcol2[j]= 1;
+ vcol2[j]=3>>i;
+ }
+ else{
+ if (vcol2[j]==0x80)
+ vcol2[j]= 1;
+ vcol2[j]=3>>i;
+ }
+ printMatrix(vcol2);
+ wait_ms(5);
+ }
+ }
+}
+
void print_Snake()
{
- //reset
- uint8_t vcol2[8]={0,0,0,0,0,0,0,0};
- uint8_t vcol[8]={0,1,3,7,0xf,0x1f,0x3f,};
+
+ uint8_t vt1[8]={1,3,7,0xf,0x1f,0x3f, 0x7f,0xff};
+ uint8_t vt2[8]={0b10000000,0b11000000,0b11100000,0b11110000,0b11111000,0b11111100,0b11111110,0b11111111};
+
int j, i;
+ //reset
+ reset_vcol();
for (j=0; j<8;j++){
for (i=0; i<8;i++){
- vcol2[j]=i;
+ if(j % 2 == 0){
+ vcol2[j]=vt1[i];
+ }else{
+ vcol2[j]=vt2[i];
+ }
printMatrix(vcol2);
wait_ms(5);
}
