Yeongsoo Kim / Mbed 2 deprecated Mecha_Speed_control

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers Plotting.cpp Source File

Plotting.cpp

00001 #include "Plotting.h"
00002 
00003 Plotting::Plotting()
00004 {
00005     for(int i=0; i<32; i++) {
00006         m_rgfData[i]=0;
00007     }
00008     m_uiDataCount=0;
00009 }
00010 
00011 void Plotting::reset()
00012 {
00013     for(int i = 0; i < 32; i++) {
00014         m_rgfData[i] = 0;
00015     }
00016     m_uiDataCount = 0;
00017 }
00018 
00019 void Plotting::put(float data, int index)
00020 {
00021     m_rgfData[index] = data;
00022     m_uiDataCount++;
00023 }
00024 
00025 void Plotting::put (int data, int index)
00026 {
00027     m_rgfData[index] = (float)data;
00028     m_uiDataCount++;
00029 }
00030 
00031 void Plotting::put (unsigned int data, int index)
00032 {
00033     m_rgfData[index] = (float)data;
00034     m_uiDataCount++;
00035 }
00036 
00037 void Plotting::send(Serial *port)
00038 {
00039     port->putc (0xAA);
00040     port->putc (0xBB);
00041     port->putc (0xCC);
00042     port->putc ((char)(m_uiDataCount*4));
00043     for(int i=0; i < m_uiDataCount; i++) {
00044         char *bytePtr = (char *)&(m_rgfData[i]);
00045         // reverse the order of these 
00046         // lines if you have endian issues
00047         port->putc(*bytePtr);      
00048         port->putc(*(bytePtr+1));
00049         port->putc(*(bytePtr+2));
00050         port->putc(*(bytePtr+3));
00051     }
00052 }