Chris Hatfield / Mbed 2 deprecated WatchAndTrace

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers DBug.cpp Source File

DBug.cpp

00001 #include "VT100.h"
00002 #include "DBug.h"
00003 
00004 CDBug::CDBug()
00005     : m_nWatches(0)
00006     , m_nScrollLimit(CVT100::Rows)
00007     , m_nNextWatch(0)
00008 {
00009 }
00010 
00011 CDBug::~CDBug(void)
00012 {
00013 }
00014 
00015 void CDBug::Init(unsigned char nWatches)
00016 {
00017   m_nWatches = nWatches > CVT100::Rows * 2 ? CVT100::Rows * 2 : nWatches;
00018   m_nScrollLimit = CVT100::Rows - ((m_nWatches + 1) / 2) - 1;
00019   m_VT100.ClearScreen();
00020   m_VT100.CursorOff();
00021   m_VT100.printf(0, 0, "^_^RTRACE OUTPUT...^r");
00022   m_VT100.printf(0, m_nScrollLimit + 1, "^RWATCHES...^r");
00023   m_VT100.SetScroll(2, m_nScrollLimit);
00024   m_VT100.MoveXY(0, 2);
00025 }
00026                                                                                                                                                                                                                                                              //
00027 void CDBug::Trace(char *lpszFormat, ...)
00028 {
00029     va_list args;
00030     va_start(args, lpszFormat);
00031     m_VT100.vprintf(lpszFormat, args);
00032     va_end(args);
00033 }
00034 
00035 void CDBug::Watch(unsigned char &hHandle, const char *lpszFormat, ...)
00036 {
00037   if (!hHandle && (m_nNextWatch <= m_nWatches))
00038   {
00039     hHandle = ++m_nNextWatch;
00040   }
00041   if (hHandle)
00042   {
00043     va_list args;
00044     va_start(args, lpszFormat);
00045     m_VT100.vprintf(hHandle & 1 ?  0 : CVT100::Columns / 2, m_nScrollLimit + 2 + ((hHandle - 1) / 2), lpszFormat, args);
00046     va_end(args);
00047   }
00048 }