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.
PatternWinLose.cpp
00001 #include "mbed.h" 00002 //************************ Complete to Interface *************************** 00003 // configure library with this code **************************************** 00004 SPI dot_matrix(D11,NC,D13); //mosi miso sclk 00005 DigitalOut lat(PA_12); //6 00006 DigitalOut sb(PA_11); //7 00007 DigitalOut rst(D10); 00008 BusOut open_line(D2,D3,D4,D5,D6,D7,D8,D9); 00009 //c0 c1 c2 c3 c4 c5 c6 c7 dont foget d7 00010 Serial pc(D1, D0); 00011 Timer t; 00012 int check_win = 0; 00013 int main(){ 00014 00015 dot_matrix.frequency(1000000); 00016 // dot_matrix.format(6,0); 00017 uint8_t wb[3] = {255,255,255}; 00018 uint8_t rgb2[3] = {3,3,60}; 00019 uint8_t rgb[3] = {3,60,3}; 00020 uint8_t pic[8] = {0x3c,0x42,0xa5,0x81,0xa5,0x99,0x42,0x3c}; 00021 uint8_t pic2[8] = {0x3c,0x42,0xa5,0x81,0x99,0xa5,0x42,0x3c}; 00022 00023 uint8_t temp; 00024 int line[8] = {1,2,4,8,16,32,64,128}; 00025 00026 rst = 1; 00027 wait(0.5); 00028 rst = 0; 00029 wait(0.5); 00030 rst = 1; 00031 wait(0.5); 00032 00033 //dot_matrix.format(6,0); 00034 sb = 0; // 6 bit 00035 for(int i = 0; i<8; i++){ 00036 dot_matrix.write(wb[0]); 00037 dot_matrix.write(wb[1]); 00038 dot_matrix.write(wb[2]); 00039 } 00040 open_line = 0; 00041 // dot_matrix.format(8,0); 00042 sb = 1; // 8 bit 00043 t.start(); 00044 while (1) { 00045 if(check_win == 1){ 00046 for(int j = 0;j<8;j++){ 00047 temp = pic[j]; 00048 for(int i = 0; i<8; i++){ 00049 if(temp & 0x80){ 00050 dot_matrix.write(rgb[0]); 00051 dot_matrix.write(rgb[1]); 00052 dot_matrix.write(rgb[2]); 00053 } 00054 else{ 00055 dot_matrix.write(0); 00056 dot_matrix.write(0); 00057 dot_matrix.write(0); 00058 } 00059 temp = temp << 1; 00060 } 00061 lat = 1; 00062 lat = 0; 00063 open_line = line[j]; 00064 wait(0.001); 00065 open_line = 0; 00066 } 00067 } 00068 else if(check_win == 0){ 00069 for(int j = 0;j<8;j++){ 00070 temp = pic2[j]; 00071 for(int i = 0; i<8; i++){ 00072 if(temp & 0x80){ 00073 dot_matrix.write(rgb2[0]); 00074 dot_matrix.write(rgb2[1]); 00075 dot_matrix.write(rgb2[2]); 00076 } 00077 else{ 00078 dot_matrix.write(0); 00079 dot_matrix.write(0); 00080 dot_matrix.write(0); 00081 } 00082 temp = temp << 1; 00083 } 00084 lat = 1; 00085 lat = 0; 00086 open_line = line[j]; 00087 wait(0.001); 00088 open_line = 0; 00089 } 00090 } 00091 else{ 00092 t.reset(); 00093 } 00094 } 00095 00096 00097 }
Generated on Thu Jul 14 2022 05:16:54 by
1.7.2