Kai Lauterbach
/
MBedToBrainMachine
mbed to brain machine firmware. See http://klautesblog.blogspot.com for further information.
Revision 1:90922bda2b17, committed 2011-04-13
- Comitter:
- klaute
- Date:
- Wed Apr 13 15:44:28 2011 +0000
- Parent:
- 0:cf8c942ef95b
- Commit message:
- v0.1
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
main.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Sat Apr 09 12:35:35 2011 +0000 +++ b/main.cpp Wed Apr 13 15:44:28 2011 +0000 @@ -11,6 +11,11 @@ void initBrainwaves() { + // A example brain wave sequence. + // The sequence starts from a state of being awake. + // Then is goes into deep meditation. + // Hangs out there awhile, and then is will be going + // into awake again. brainwaves[1-1].type = 1; brainwaves[1-1].duration = 60; brainwaves[2-1].type = 0; @@ -142,10 +147,12 @@ bw_duration = brainwaves[bw_pos].duration; - int type = brainwaves[bw_pos].type; + int type = brainwaves[bw_pos].type; float pwmPeriod = 0.0; float ledPulseWidth = 0.0; float audioFreq = 0.0; + // Set the audioTimer and PWM signals to the new brain + // wave frequency. switch (type) { case ALFA : audioFreq = HZ_411_1;
--- a/main.h Sat Apr 09 12:35:35 2011 +0000 +++ b/main.h Wed Apr 13 15:44:28 2011 +0000 @@ -10,25 +10,37 @@ #include "mbed.h" /*************************************************************************************************/ +// Defining 4 of the 5 (atm) figured out brain wave frequencies as +// the period duration of the LED PWM signals. +// The ***_HALF definitions equals to the PWM pulsewidth, which is +// the half of the brainwave frequency. +// Beta wave frequency (13-30Hz) #define HZ_14_4 0.06940000 #define HZ_14_4_HALF 0.03470000 +// Alpha wave frequency (8-13Hz) #define HZ_11_1 0.09009009 #define HZ_11_1_HALF 0.04504504 +// Theta wave frequency (4-8Hz) #define HZ_6 0.16666666 #define HZ_6_HALF 0.08333333 +// Delta waves frequency (0.5-4Hz) #define HZ_2_2 0.45454545 #define HZ_2_2_HALF 0.22727272 +// Brain frequencies with a offset of 400Hz +// for audio output. #define HZ_414_4 0.00241312 #define HZ_411_1 0.00243249 #define HZ_406 0.00246305 #define HZ_402_2 0.00248632 +// Base Frequency #define HZ_400 0.00250000 +// Brainwave types #define ALFA 0 #define BETA 1 #define DELTA 2