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.
Dependencies: mbed
Diff: main.cpp
- Revision:
- 1:5b491fa83cb7
- Parent:
- 0:951442bd3f7f
- Child:
- 3:086e556b57f9
--- a/main.cpp Thu Jul 11 09:36:30 2019 +0000 +++ b/main.cpp Mon Jul 22 16:35:45 2019 +0000 @@ -1,28 +1,120 @@ #include "mbed.h" #include "main.hpp" +#include "variables.hpp" +float abstempo = 0; +int clockcountneg; +int storedduration; +int runval; + void fire(void){ + clockout = 1; + wait(0.0001); + clockout = 0; + wait(0.0001); + } +void runonce(void){ + getfaderdata(); + //tempo calculations + gettempodata(); + //note calculations + sumprobabilitynotes(); + randomgeneratenotes(); + determinenotes(); + + //octive calculation + sumprobabilityoctives(); + randomgenerateoctives(); + determineoctives(); + + //duration calculation + sumprobabilityduration(); + randomgenerateduration(); + determineduration(); + outputdecision(); + } +void firetrig(void){ + if(clockcount<32){ + clockcount++; + clockcountneg = clockcount - 1; + } + else + { + clockcount = 0; + clockcount++; + } + if(clockcount == 1){ + storedduration = duration; + } + pc.printf("%i \n\r",clockcount); + fire(); + //getfaderdata + if(clockcount == 1 && storedduration == 1){ + allledoff(); + getfaderdata(); + //tempo calculations + gettempodata(); + //note calculations + sumprobabilitynotes(); + randomgeneratenotes(); + determinenotes(); + //octive calculation + sumprobabilityoctives(); + randomgenerateoctives(); + determineoctives(); + //duration calculation + sumprobabilityduration(); + randomgenerateduration(); + determineduration(); + outputdecision(); + } + if(clockcount == storedduration-1){ + allledoff(); + getfaderdata(); + //tempo calculations + gettempodata(); + //note calculations + sumprobabilitynotes(); + randomgeneratenotes(); + determinenotes(); + //octive calculation + sumprobabilityoctives(); + randomgenerateoctives(); + determineoctives(); + //duration calculation + sumprobabilityduration(); + randomgenerateduration(); + determineduration(); + outputdecision(); + } +// pc.printf("NOTE: %i OCTIVE: %i DURATION: %i \n\r",note,octive,duration); +// pc.printf("abstemmp %f \n\r",abstempo); + if(clockcount == storedduration && sumnotes > 1){ + senddacout(); + trigout = 1; + wait(0.0001); + trigout = 0; + wait(0.0001); + clockcount = 0; + } + if(clockcount == 1 && storedduration == 1){ + updateled(); + } + if(clockcount == storedduration-1){ + updateled(); + } + } int main() { - float meas; - while(1) { - cs = 1; - dac.format(32,1); + clockin.mode(PullUp); + clockin.fall(&firetrig); + dac.format(8,0); dac.frequency(50000000); -wait(0.5); - cs = 0; - dac.write(0x30FFFF); - wait(0.5); - allledon(); - updateled(); - multiplexa = 0; - meas = analog_valuea.read(); // Converts and read the analog input value (value from 0.0 to 1.0) - meas = meas * 3300; // Change the value to be in the 0 to 3300 range - printf("measure = %.0f mV\n", meas); - if (meas > 2000) { // If the value is greater than 2V then switch the LED on - led = 1; - } - else { - led = 0; -// } - } + pc.baud(115200); + allledoff(); + updateled(); + runonce(); + while(1) { + //pc.printf("%i \n\r",targetnumber); + //pc.printf("SO %f \n\r",sumoctives); + } - } +}