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 assignment5slave by
Slave.cpp
00001 #include "mbed.h" 00002 #include "music.h" 00003 #include "C12832.h" 00004 DigitalIn play(p14); 00005 00006 I2CSlave slave(p9, p10); 00007 PwmOut speaker(p26); 00008 DigitalOut led1(LED1); 00009 DigitalOut led2(LED2); 00010 C12832 lcd(p5, p7, p6, p8, p11); 00011 00012 Serial term(USBTX, USBRX); 00013 00014 float fu = 2; 00015 float ha = fu/2; 00016 float qu = fu/4; 00017 float tq = fu*3/4; 00018 float ei = fu/8; 00019 float si = fu / 16; 00020 00021 //static char cake[] = { 00022 //0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 00023 //1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 00024 //0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 00025 //1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 00026 //0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,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,0,0,0,0,0,0,0,0,0,0,0}; 00081 static char cake[] = { 00082 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 00083 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 00084 0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00, 00085 0x00,0x00,0x00,0x0e,0x00,0x00,0x00,0x00, 00086 0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00, 00087 0x00,0x00,0x00,0x0e,0x00,0x00,0x00,0x00, 00088 0x00,0x00,0x00,0x0a,0x00,0x00,0x00,0x00, 00089 0x00,0x00,0x7f,0xea,0xff,0xf0,0x00,0x00, 00090 0x00,0x03,0x00,0x0a,0x00,0x0c,0x00,0x00, 00091 0x00,0x0c,0x00,0x0a,0x00,0x03,0x00,0x00, 00092 0x00,0x08,0x00,0x0a,0x00,0x00,0x80,0x00, 00093 0x00,0x18,0x00,0x0a,0x00,0x01,0x80,0x00, 00094 0x00,0x14,0x00,0x0a,0x00,0x02,0x80,0x00, 00095 0x00,0x12,0x00,0x00,0x00,0x04,0x80,0x00, 00096 0x00,0x11,0x00,0x00,0x00,0x08,0x80,0x00, 00097 0x00,0x10,0xff,0xff,0xff,0xf0,0x80,0x00, 00098 0x00,0x10,0x00,0x00,0x00,0x00,0x80,0x00, 00099 0x00,0x18,0x00,0x00,0x00,0x01,0x80,0x00, 00100 0x00,0x14,0x00,0x00,0x00,0x02,0x80,0x00, 00101 0x00,0x12,0x00,0x00,0x00,0x04,0x80,0x00, 00102 0x00,0x11,0x00,0x00,0x00,0x08,0x80,0x00, 00103 0x00,0x10,0xff,0xff,0xff,0xf0,0x80,0x00, 00104 0x00,0x10,0x00,0x00,0x00,0x00,0x80,0x00, 00105 0x00,0x08,0x00,0x00,0x00,0x01,0x00,0x00, 00106 0x00,0x04,0x00,0x00,0x00,0x02,0x00,0x00, 00107 0x00,0x02,0x00,0x00,0x00,0x04,0x00,0x00, 00108 0x00,0x01,0x00,0x00,0x00,0x08,0x00,0x00, 00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B4,Fs4,Gs4,B4,B4,Cs5,Eb5,B4,Fs4,Gs4,Fs4, 00132 B4,B4,Bb4,B4,Fs4,Gs4,B4,E5,Eb5,E5,Fs5,Eb5,Cs5,B4,Fs4,Gs4,B4,Fs4,Gs4,B4,Cs5,Eb5,Cs5,E5,Eb5,E5,Fs5, 00133 B4,B4,Fs4,Gs4,B4,Fs4,E5,Eb5,Cs5,B4,E4,Eb4,E4,Fs4,B4,Fs4,Gs4,B4,Fs4,Gs4,B4,B4,Cs5,Eb5,B4,Fs4,Gs4,Fs4, 00134 B4,B4,Bb4,B4,Fs4,Gs4,B4,E5,Eb5,E5,Fs5,B4,B4 00135 }; 00136 float nyanBeat[]= {si,si,ei,si,si,si,si,si,si,si,si,si,si,ei,ei,si,si,ei,si,si,si,si,si,si,si,si,ei, 00137 ei,ei,si,ei,si,si,si,ei,ei,ei,ei,si,si,si,si,si,si,si,si,si,si,si,si,si,si, 00138 ei,ei,si,si,si,si,si,si,si,si,si,si,si,si,ei,si,si,si,si,si,si,si,si,ei,ei,ei,ei,ei,si,ei,si,si,si,ei,ei,ei, 00139 ei,si,si,si,si,si,si,si,si,si,si,si,si,si,si,ei,ei,si,si,si,si,si,si,si,si,si,si,si,si, 00140 ei,si,si,si,si,si,si,si,si,ei,ei,ei,ei,si,si,ei,si,si,si,si,si,si,si,si,si,si, 00141 ei,ei,si,si,si,si,si,si,si,si,si,si,si,si,ei,si,si,ei,si,si,si,si,si,si,si,si,si,si, 00142 ei,si,si,si,si,si,si,si,si,si,si,ei,ei,ei,si,si,ei,si,si,si,si,si,si,si,si,si,si, 00143 ei,ei,si,si,si,si,si,si,si,si,si,si,si,si,ei,si,si,ei,si,si,si,si,si,si,si,si,si,si, 00144 ei,si,si,si,si,si,si,si,si,si,si,si,si 00145 };//beat array 00146 00147 int main() { 00148 slave.address(0x42); 00149 lcd.print_bm(bitmCake,0,0); // print cake 00150 lcd.copy_to_lcd(); 00151 while(1) { 00152 int foo = slave.receive(); 00153 term.printf("foo = %d\n\r", foo); 00154 unsigned char noteNum = slave.read(); 00155 switch (foo) { 00156 case I2CSlave::WriteAddressed: 00157 if (noteNum == 0xFF) speaker = 0; 00158 speaker.period(1 / (2 * notes[noteNum])); 00159 term.printf("noteNum = %d\n\r", noteNum); 00160 speaker = .5; 00161 break; 00162 case I2CSlave::ReadAddressed: 00163 for (int i = 0; i < sizeof(nyanNotes)/sizeof(nyanNotes[0]); i++) { 00164 slave.write(nyanNotes[i]); 00165 speaker = 0.5; 00166 unsigned char note = nyanNotes[i]; 00167 speaker.period(1/notes[note]); 00168 wait(nyanBeat[i]/20.0f); 00169 } 00170 speaker = 0; 00171 break; 00172 00173 } 00174 } 00175 } 00176
Generated on Thu Jul 14 2022 22:40:06 by
