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.hpp
- Revision:
- 4:e56a755aeaf1
- Parent:
- 3:086e556b57f9
- Child:
- 5:cf9d933e278a
--- a/main.hpp Wed Jul 24 12:24:05 2019 +0000
+++ b/main.hpp Wed Jul 24 15:06:20 2019 +0000
@@ -2,9 +2,14 @@
#define __main__
#include "variables.hpp"
#include "math.hpp"
+#include "dataStore.h"
+#include "DebounceIn.h"
+
+
+dataStore loopBuffer[MAX_SAMPLES];
InterruptIn clockin(PB_0);
DigitalIn runsw(PC_0);
-DigitalIn loopsw(PC_1);
+DebounceIn loopsw(PC_1);
AnalogIn analog_valuea(PA_0);
AnalogIn analog_valueb(PA_4);
AnalogIn analog_valuec(PB_2);
@@ -55,6 +60,26 @@
bool lplusone;
bool lplustwo;
+void pointerHandler(void){
+ //Set seperate FIFO head and tail for printing data
+ dataHeader = bufferHeader;
+ dataTail = bufferTail;
+
+ //Move sample FIFO buffer head to next row in buffer
+ bufferHeader++;
+ //Check sample FIFO buffer head
+ if(bufferHeader >= MAX_SAMPLES) {
+ bufferHeader = 0;
+ }
+ //Check sample FIFO buffer tail
+ if(bufferTail == bufferHeader) {
+ bufferTail++;
+ if(bufferTail >= (MAX_SAMPLES)) {
+ bufferTail = 0;
+ }
+ }
+ }
+
void updateled(void){
ledlatch = 1;
ledlatch = 0;
@@ -708,7 +733,8 @@
lhalf = 0;
lone = 0;
ltwo = 0;
- }
+ }
+
}
void senddacout(void){
//octive 0
@@ -1479,6 +1505,9 @@
dac.write(0xFF);
dac.write(0xE5);
cs = 1;
- }
+ }
+ //save to loop buffer
+ loopBuffer[bufferHeader].update(note, octive, duration);
+ pointerHandler();
}
#endif
\ No newline at end of file