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.
Fork of Task617Solution-mbedos54 by
Diff: main.cpp
- Revision:
- 3:423191a375dc
- Parent:
- 2:70084af839d3
- Child:
- 4:dae8898e55fe
--- a/main.cpp Tue Mar 08 20:51:13 2016 +0000
+++ b/main.cpp Wed Mar 09 10:12:51 2016 +0000
@@ -16,7 +16,7 @@
#define TWORD (7*TUNIT)
//Size of the morse character buffer
-#define BUFFERSIZE 240
+#define BUFFERSIZE 100
/*
@@ -105,7 +105,7 @@
void addCharacterToQueue(const char c)
{
//Is there space?
- spaceAvailable->wait();
+ int32_t Nspaces = spaceAvailable->wait();
//Ok, there is space - take the lock
bufferLock->lock();
@@ -114,7 +114,8 @@
//Update buffer
newestIndex = (newestIndex+1) % BUFFERSIZE;
buffer[newestIndex] = c;
-
+ pc.printf("\tAdded ASCII Character: %2Xh (%c) to buffer, %d spaces available\n", c, c, Nspaces-1);
+
//Release lock
bufferLock->unlock();
redLED = 0;
@@ -127,7 +128,7 @@
char takeCharacterFromQueue()
{
//Are thre any samples in the buffer
- samplesInBuffer->wait();
+ int32_t Nsamples = samplesInBuffer->wait();
//Ok, there are samples - take the lock
bufferLock->lock();
@@ -136,6 +137,7 @@
//Update buffer - remove oldest
oldestIndex = (oldestIndex+1) % BUFFERSIZE;
char cc = buffer[oldestIndex];
+ pc.printf("\t\tTaking ASCII Character: %2Xh (%c) from buffer, %d bytes remaining\n", cc, cc, Nsamples-1);
//Release lock
bufferLock->unlock();
@@ -203,17 +205,6 @@
}
}
-void convertToMorseAsync(const char* pString)
-{
- //Copy each character into the buffer
- int L = strlen(pString);
- for (int n=0; n<L; n++) {
- char c = pString[n];
- addCharacterToQueue(c);
- }
-}
-
-
//Main thread
int main() {
redLED = 0;
@@ -237,7 +228,6 @@
while (true) {
//Read keyboard (serial port)
char c = pc.getc();
- pc.printf("\n");
addCharacterToQueue(c);
}