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 xbee_lib ADXL345_I2C IMUfilter ITG3200 Motor RangeFinder Servo mbos PID
Fork of Labo_TRSE_Drone by
Revision 23:7f5681d8d5b5, committed 2013-04-03
- Comitter:
- IngesupMbed01
- Date:
- Wed Apr 03 10:36:21 2013 +0000
- Parent:
- 22:d2adbcc3580d
- Child:
- 24:3462a304f9a0
- Commit message:
- Buffer Trame fini
Changed in this revision
| Service/Buffer_Trame.cpp | Show annotated file Show diff for this revision Revisions of this file |
| Service/Buffer_Trame.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/Service/Buffer_Trame.cpp Wed Apr 03 09:11:38 2013 +0000
+++ b/Service/Buffer_Trame.cpp Wed Apr 03 10:36:21 2013 +0000
@@ -22,11 +22,80 @@
/* CONSRTRUCTEUR(S) */
C_FrameBuffer::C_FrameBuffer()
{
+ m_frameBuffer = new frame [default_size];
+ m_maxSize = default_size;
+ m_currentReadIndex = 0;
+ m_currentWriteIndex = 0;
+ }
+ C_FrameBuffer::C_FrameBuffer(unsigned int size)
+ {
+ m_maxSize = size;
+ m_frameBuffer = new frame [m_maxSize];
+ m_currentReadIndex = 0;
+ m_currentWriteIndex = 0;
}
/* DESTRUCTEUR */
C_FrameBuffer::~C_FrameBuffer()
{
+ delete [] m_frameBuffer;
+ m_maxSize = 0;
+ m_currentReadIndex = 0;
+ m_currentWriteIndex = 0;
+ }
+ /* Propriétés */
+ void C_FrameBuffer::frameBuffer(frame newFrame)
+ {
+ m_frameBuffer[m_currentWriteIndex] = newFrame;
+ m_currentWriteIndex++;
+
+ if(m_currentWriteIndex >= m_maxSize) m_currentWriteIndex = 0;
+ }
+
+ frame C_FrameBuffer::frameBuffer(void)
+ {
+ frame newFrame = m_frameBuffer[m_currentReadIndex];
+ m_currentReadIndex++;
+
+ if(m_currentReadIndex >= m_maxSize) m_currentReadIndex = 0;
+
+ return newFrame;
+ }
+
+ frame C_FrameBuffer::frameBuffer(unsigned int index)
+ {
+ if(index >= m_maxSize) index = m_maxSize;
+
+ return m_frameBuffer[index];
+ }
+
+ unsigned int C_FrameBuffer::maxSize(void)
+ {
+ return m_maxSize;
+ }
+
+ unsigned int C_FrameBuffer::currentReadIndex(void)
+ {
+ return m_currentReadIndex;
+ }
+
+ void C_FrameBuffer::currentReadIndex(unsigned int newIndex)
+ {
+ if(newIndex >= m_maxSize) newIndex = m_maxSize;
+
+ m_currentReadIndex = newIndex;
+ }
+
+ unsigned int C_FrameBuffer::currentWriteIndex(void)
+ {
+ return m_currentWriteIndex;
+ }
+
+ void C_FrameBuffer::currentWriteIndex(unsigned int newIndex)
+ {
+ if(newIndex >= m_maxSize) newIndex = m_maxSize;
+
+ m_currentWriteIndex = newIndex;
}
\ No newline at end of file
--- a/Service/Buffer_Trame.h Wed Apr 03 09:11:38 2013 +0000
+++ b/Service/Buffer_Trame.h Wed Apr 03 10:36:21 2013 +0000
@@ -23,6 +23,8 @@
#include "mbos.h"
+ #define default_size 50
+
typedef struct {
char identifier;
char data [8];
@@ -32,16 +34,28 @@
private :
/* ATTRIBUTS */
-
+ frame * m_frameBuffer;
+ unsigned int m_currentReadIndex;
+ unsigned int m_currentWriteIndex;
+ unsigned int m_maxSize;
+
public :
/* CONSTRUCTEUR(S) */
C_FrameBuffer();
+ C_FrameBuffer(unsigned int size);
/* DESTRUCTEUR */
~C_FrameBuffer();
- /* METHODES */
-
+ /* Propriétés */
+ void frameBuffer(frame newFrame);
+ frame frameBuffer(void);
+ frame frameBuffer(unsigned int index);
+ unsigned int maxSize(void);
+ unsigned int currentReadIndex(void);
+ void currentReadIndex(unsigned int newIndex);
+ unsigned int currentWriteIndex(void);
+ void currentWriteIndex(unsigned int newIndex);
};
#endif
\ No newline at end of file
