Changeset c30c900 in orbit


Ignore:
Timestamp:
12/05/12 03:49:54 (7 years ago)
Author:
Steve Castellotti <sc@…>
Branches:
master, RawEEG, Raw_EEG_Plot, Servo, Tab_Interface, pyramid
Children:
4634b1d
Parents:
e3d7c4a (diff), cb3655b (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' of ssh://puzzlebox.info/repo/orbit

Files:
38 added
6 edited

Legend:

Unmodified
Added
Removed
  • octave/GenerateAudioCommand/bitGenDirect.m

    ra0b523e rcb3655b  
    44% num: how many certain bit to generate. 
    55% audioFileName: like 'audio.wav'. 
    6  
     6% last four parameter: pass period of sine wave here. 
    77longHIGH=875; 
    88longLOW=729; 
  • octave/GenerateAudioCommand/flyCommand.m

    r655a816 rcb3655b  
    77%sps = 96000;     % sample rate [samples/s] 
    88 
     9% 4 demo codes here for testing. you can either put a matrix as the first parameter, or just use 'demo1' ~ 'demo4' for testing purpose.  
    910if length(code)==5 
    1011if code=='demo1' 
    11         code=[1 0 1 1 0 1 1 1 0 1 0 0 1 1 0 0 1 0 0 1 1 1 1 1 0 1 1 0];%minimum rotating throttle 
     12        code=[1 0 1 1 0 1 1 1 0 1 0 0 1 1 0 0 1 0 0 1 1 1 1 1 0 1 1 0];%minimum  throttle to make propeller rotating 
    1213elseif code=='demo2' 
    1314        code=[1 1 1 1 1 1 1 1 0 1 0 0 0 1 1 0 1 0 0 1 1 1 1 1 0 0 0 0];%maximum throttle 
     
    5051elseif length(AndroidOriOS)==7 %'Android' 
    5152 
     53% number with _s suffix is in samples. Optimized with 44100 sampling rate. 
    5254longHIGH=875;longHIGH_s=floor(longHIGH*sps/1e6)-3;%longHIGH[us]  longHIGH_s[sample] 
    5355longLOW=729;longLOW_s=floor(longLOW*sps/1e6+3)+1; 
     
    5557shortLOW=333;shortLOW_s=floor(shortLOW*sps/1e6)+1+2; 
    5658 
    57  
    5859shortLOW_ss=floor(shortLOW*sps/1e6)+2; 
    5960 
     61 
     62% PAY ATTENTION to the special starting and ending code of command. 
    6063codeWave=[halfSineGenDirect('d',longLOW_s-1,0,1,sps);halfSineGenDirect('u',longHIGH_s-2,0,1,sps);    halfSineGenDirect('d',shortLOW_ss+2,0,1,sps);halfSineGenDirect('u',longHIGH_s-2,0,1,sps); halfSineGenDirect('d',shortLOW_ss+3,0,1,sps)]; %starting 5 half period 
    6164 
    6265% notice that the "code" here should be a 28 bit binary array. 
     66% function bitGenDirect will generate a complete digit in the form of sine wave of either "0" or "1" 
    6367for i=1:size(code,2) 
    6468codeWave = [codeWave; bitGenDirect(code(i),1,sps,longHIGH_s,   longLOW_s,shortHIGH_s,shortLOW_s)]; 
    6569         
    6670endfor 
     71 
    6772 
    6873codeWave=[codeWave; halfSineGenDirect('u',longHIGH_s,0,1,sps)];  %last half period 
  • octave/GenerateAudioCommand/flyOrbit.m

    rf22b7ab rcb3655b  
    33% code: array of 1s and 0s. 1 means bit "1", 0 means bit "0". 
    44% audioFileName: like 'audio.wav'. 
    5 % space: space between codes [us] 
     5% space: space between codes [uS] 
    66bps = 16;       % bits per sample 
    77%sps = 96000;     % sample rate [samples/s] 
    8  
    9 space=floor(space*48000/1e6); 
     8%repeatTime: the number of same commands you want to generate 
     9%AndroidOriOS: 'Android' 'iOS' generates two different style of codes 
     10%flipOrNot: 'flip' 'notF' some android device needs a flipped signal. 
     11space=floor(space*48000/1e6);% turn uS into samples 
    1012 
    1113if length(AndroidOriOS)==3 %iOS 
     
    1416elseif length(AndroidOriOS)==7 %Android 
    1517 
    16         if AndroidOriOS=='Android' 
    17         fullCodeWave=[flyCommand(code,space,'temp1,wav',sps,4,AndroidOriOS,flipOrNot);initCodeGenAndroid('temp2.wav',sps);zeros(1,1);flyCommand(code,space,'temp3.wav',sps,repeatTime,AndroidOriOS,flipOrNot)]; 
    18         elseif AndroidOriOS=='Command' 
     18        if AndroidOriOS=='Android'%generate android style command with init 
     19 
     20%Android style command consists of 4(any number larger than 2) command, init code, and certain repeat of command. 
     21%function initCodeGenAndroid can generate init 
     22%function flyCommand can generate command 
     23        fullCodeWave=[flyCommand(code,space,'temp1.wav',sps,4,AndroidOriOS,flipOrNot);initCodeGenAndroid('temp2.wav',sps);zeros(1,1);flyCommand(code,space,'temp3.wav',sps,repeatTime,AndroidOriOS,flipOrNot)]; 
     24        elseif AndroidOriOS=='Command'%generate command only 
    1925        fullCodeWave=[flyCommand(code,space,'temp3.wav',sps,repeatTime,AndroidOriOS,flipOrNot)]; 
    2026        endif 
  • octave/GenerateAudioCommand/halfSineGenDirect.m

    ra0b523e rcb3655b  
    22 
    33% dir: 'u' means UP, 'd' means down. 
    4 % halfPeriod: half period of cosine signal[us]. 
     4% halfPeriod: half period of sine signal[us]. 
    55% zero: zero level of cosine signal. 
    66% amp: amplitude of cosine signal, in percentage.  
     
    1313freq = floor(sps/(halfPeriod_in_samples*2));       % frequency of the tone [Hz] 
    1414 
    15  
     15%linspace is an octave function that generates a sequence with certain step. 
    1616time = linspace(1/sps, halfPeriod, halfPeriod_in_samples); 
    1717if (dir== 'u')  
    18         wave = sin(time*2*pi*freq)'.*amp+zero; 
     18        wave = sin(time*2*pi*freq)'.*amp+zero;%'u' indicates above zero line 
    1919elseif (dir=='d') 
    20         wave = sin((time+halfPeriod)*2*pi*freq)'.*amp+zero; 
     20        wave = sin((time+halfPeriod)*2*pi*freq)'.*amp+zero;%'d' indicates below zero line 
    2121endif 
    2222 
  • octave/GenerateAudioCommand/initCodeGenAndroid.m

    rf22b7ab rcb3655b  
    66bps = 16;       % bits per sample 
    77 
     8 
     9%all numbers start with '_' is measured in uS with audacity. 
    810_longHIGH=1000; %[us] 
    911_longLOW=2000;  
     
    1416_space=84354; 
    1517 
     18%turn everything into samples based on sps. Modifyer is optimized when sps=44100Hz 
    1619longHIGH=floor(_longHIGH*sps/1e6)-1; 
    1720longLOW=floor(_longLOW*sps/1e6)+1; 
     
    2225space=floor(_space*sps/1e6); 
    2326 
     27%initWave stores the init code we will finnaly generate 
     28%function halfSineGenDirect can generate the upper or lower half of a sine wave based on how many samples are included in a "half-period" sine wave. 
    2429initWave=[halfSineGenDirect('u',longHIGH,0,1,sps);zeros(longLOW,1);halfSineGenDirect('u',longHIGH,0,1,sps);zeros(longLOW,1);halfSineGenDirect('u',longHIGH,0,1,sps);halfSineGenDirect('d',mediumLOW,0,1,sps);halfSineGenDirect('u',shortHIGH,0,1,sps)]; 
    2530 
    26 initWave2=[initWave;halfSineGenDirect('d',shortLOW,0,1,sps)]; 
    27 initWave=[initWave;halfSineGenDirect('d',mediumLOW,0,1,sps)]; 
     31initWave2=[initWave;halfSineGenDirect('d',shortLOW,0,1,sps)];%inits 4,5,6 
     32initWave=[initWave;halfSineGenDirect('d',mediumLOW,0,1,sps)];%inits 1,2,3 
    2833 
    2934 
  • android/src/info/puzzlebox/orbit/MainActivity.java

    r5b7f570 re3d7c4a  
    9595 
    9696        private static final String MAC_ADDRESS = "D0:DF:9A:69:5D:42"; // MindWave Mobile Dev (p1-dev-60-01) 
    97 //      private static final String MAC_ADDRESS = "9C:B7:0D:5E:E5:6A"; // UK So Television 
    98 //      private static final String MAC_ADDRESS = "00:16:53:09:0B:B9"; 
     97        //      private static final String MAC_ADDRESS = "9C:B7:0D:5E:E5:6A"; // UK So Television 
     98        //      private static final String MAC_ADDRESS = "00:16:53:09:0B:B9"; 
    9999 
    100100 
     
    252252                        } 
    253253                }); 
    254                 //              soundID = soundPool.load(this, R.raw.throttle_max_android_common, 1); 
    255                 //              soundID = soundPool.load(this, R.raw.throttle_min_android_common, 1); 
    256                 soundID = soundPool.load(this, R.raw.throttle_max_android_htc_one_x, 1); 
     254                soundID = soundPool.load(this, R.raw.throttle_max_android_common, 1); 
     255//              soundID = soundPool.load(this, R.raw.throttle_min_android_common, 1); 
     256//              soundID = soundPool.load(this, R.raw.throttle_max_android_htc_one_x, 1); 
    257257 
    258258 
     
    317317                 */ 
    318318 
    319                 @SuppressLint({ "HandlerLeak", "HandlerLeak" }) 
     319                //              @SuppressLint({ "HandlerLeak", "HandlerLeak" }) 
    320320                @Override 
    321321                public void handleMessage(Message msg) { 
Note: See TracChangeset for help on using the changeset viewer.