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.
Revision 0:a50960b2f6bd, committed 2015-12-08
- Comitter:
- kevinrhyne
- Date:
- Tue Dec 08 12:23:46 2015 +0000
- Commit message:
- solenoc
Changed in this revision
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/HardwareControl.cpp	Tue Dec 08 12:23:46 2015 +0000
@@ -0,0 +1,92 @@
+#include "HardwareControl.h"
+
+HardwareControl::HardwareControl(){
+        /*
+        SOL1(p25);
+        SOL2(p26);
+        SOL3(p27);
+        SOL4(p28);
+        SOL5(p23);
+        SOL6(p22);
+        SOL7(p21);   
+        
+        */
+        
+}
+
+
+
+void HardwareControl::playNote(int binaryNote, int length){
+        
+        
+        // Solenoc note controls
+        // =====================
+        //   
+        // C arpeggio : 1 - 193 - 241 - 254 
+        // 
+        // C:  NONE ASSERTEDS, AIR 
+        //     Binary represent-------------ation:  00000001
+        //     Integer representation: 1
+        
+        // D:  SOL1, AIR          
+        //     Binary representation:  10000001
+        //     Integer representation: 129
+        
+        // E:  SOL1, SOL2, AIR 
+        //     Binary representation:  11000001
+        //     Integer representation: 193
+        
+        // F:  SOL1, SOL2, AIR
+        //     Binary representation:  11100001
+        //     Integer representation: 225
+        
+        // Fs: SOL1, SOL3, SOL4, AIR
+        //     Binary representation:  10110001
+        //     Integer representation: 177
+        
+        // G:  SOL1, SOL2, SOL3, SOL4, AIR
+        //     Binary representation:  11110001
+        //     Integer representation: 241
+        
+        // Gs: SOL1, SOL3, SOL4, SOL5, AIR
+        //     Binary representation:  10111001
+        //     Integer representation: 185
+        
+        // A:  SOL1, SOL2, SOL3, SOL4, SOL5, AIR
+        //     Binary representation:  11111001
+        //     Integer representation: 249
+        
+        // As: SOL1, SOL3, SOL4, SOL5, SOL6, AIR
+        //     Binary representation:  10111101
+        //     Integer representation: 189
+        
+        // B:  SOL1 - SOL6, AIR
+        //     Binary representation:  11111101
+        //     Integer representation: 254
+        
+        // R:  ALL ASSERTED // REST
+        //     Binary representation:  11111110
+        //     Integer representation: 254
+        
+        
+        DigitalOut SOL1(p25);
+        DigitalOut SOL2(p26);
+        DigitalOut SOL3(p27);
+        DigitalOut SOL4(p28);
+        DigitalOut SOL5(p23);
+        DigitalOut SOL6(p22);
+        DigitalOut SOL7(p21);
+        DigitalOut AIR(p24); //Air
+
+        SOL1 = binaryNote & 128;
+        SOL2 = binaryNote & 64;
+        SOL3 = binaryNote & 32;
+        SOL4 = binaryNote & 16;
+        SOL5 = binaryNote & 8;
+        SOL6 = binaryNote & 4;
+        SOL7 = binaryNote & 2;
+        AIR = binaryNote & 1;
+        
+        wait_ms(length);
+        
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/HardwareControl.h	Tue Dec 08 12:23:46 2015 +0000
@@ -0,0 +1,17 @@
+#ifndef HARDWARECONTROL_H
+#define HARDWARECONTROL_H
+
+#include "mbed.h"
+#include "Song.h"
+
+class HardwareControl{
+    public:
+
+        HardwareControl();
+        void playNote(int, int);
+        void releaseNote();
+    
+    
+};
+
+#endif
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Solenoc.cpp	Tue Dec 08 12:23:46 2015 +0000
@@ -0,0 +1,24 @@
+#include "Solenoc.h"
+
+DigitalOut myled(LED1);
+DigitalOut SOL1(p25);
+
+int LENGTH_OF_SONG = 19;
+
+void playSong(Song thissong){
+
+    for(int i = 0; i < LENGTH_OF_SONG; i++){
+        thissong.getNote(i);
+        thissong.getLength(i);
+    }
+}
+
+int main() {
+
+    Song newSong("./dummyFile.txt");
+    
+    HardwareControl controller;
+    
+    playSong(newSong);
+    
+}
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Solenoc.h Tue Dec 08 12:23:46 2015 +0000 @@ -0,0 +1,8 @@ +#ifndef SOLENOC_H +#define SOLENOC_H + +#include "mbed.h" +#include "Interpreter.h" +#include "Song.h" + +#endif \ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Song.cpp	Tue Dec 08 12:23:46 2015 +0000
@@ -0,0 +1,60 @@
+#include "Song.h"
+
+Song::Song(string filepath){
+    
+    Serial pc(USBTX, USBRX);
+    pc.baud(115200);
+
+    
+}
+
+using namespace std;
+
+int Song::getBinaryNote(string currentNote){
+        if (currentNote == "A") return 1;
+        if (currentNote == "D") return 129;
+        if (currentNote == "E") return 193;
+        if (currentNote == "F") return 225;
+        if (currentNote == "Fs") return 177;
+        if (currentNote == "G") return 241;
+        if (currentNote == "Gs") return 185;
+        if (currentNote == "A") return 249;
+        if (currentNote == "As") return 289;
+        if (currentNote == "B") return 254;
+        
+        return 1;
+}
+
+void Song::buildSong(){
+        
+    //Example Song
+    
+    noteChart.push_back(make_pair(string("A"), 75));
+    noteChart.push_back(make_pair(string("A"), 75));
+    noteChart.push_back(make_pair(string("B"), 75));
+    noteChart.push_back(make_pair(string("C"), 75));
+    noteChart.push_back(make_pair(string("D"), 75));
+    noteChart.push_back(make_pair(string("E"), 75));
+    noteChart.push_back(make_pair(string("F"), 75));
+    noteChart.push_back(make_pair(string("Fs"), 75));
+    noteChart.push_back(make_pair(string("G"), 75));
+    noteChart.push_back(make_pair(string("Gs"), 75));
+    noteChart.push_back(make_pair(string("Gs"), 75));
+    noteChart.push_back(make_pair(string("G"), 75));
+    noteChart.push_back(make_pair(string("Fs"), 75));
+    noteChart.push_back(make_pair(string("G"), 75));
+    noteChart.push_back(make_pair(string("E"), 75));
+    noteChart.push_back(make_pair(string("F"), 75));
+    noteChart.push_back(make_pair(string("D"), 75));
+    noteChart.push_back(make_pair(string("C"), 75));
+    noteChart.push_back(make_pair(string("A"), 75));
+    
+}
+
+string Song::getNote(int index){
+    return noteChart[index].first;    
+}
+    
+int Song::getLength(int index) {
+    return noteChart[index].second;        
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Song.h	Tue Dec 08 12:23:46 2015 +0000
@@ -0,0 +1,26 @@
+#ifndef SONG_H
+#define SONG_H
+
+#include <vector>
+#include <utility>
+#include <string>
+#include <iostream>
+#include <fstream>
+#include "mbed.h"
+
+using namespace std;
+
+class Song{
+    private:
+        vector< pair<string, int> > noteChart; //Vector of (note, length)
+    public:
+        Song(string);
+        int getBinaryNote(string);
+        void buildSong();
+        int size();
+        string getNote(int);
+        int getLength(int);
+        
+};
+
+#endif
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Tue Dec 08 12:23:46 2015 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/165afa46840b \ No newline at end of file