a
Dependencies: mbed
LogUtil/LogUtil.cpp@0:85567bbcebdb, 2014-12-14 (annotated)
- Committer:
- Jagang
- Date:
- Sun Dec 14 17:49:01 2014 +0000
- Revision:
- 0:85567bbcebdb
New
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Jagang | 0:85567bbcebdb | 1 | /** |
Jagang | 0:85567bbcebdb | 2 | * @file LogUtil.cpp |
Jagang | 0:85567bbcebdb | 3 | * @brief Utility to log messages during runtime |
Jagang | 0:85567bbcebdb | 4 | * @author sam grove |
Jagang | 0:85567bbcebdb | 5 | * @version 1.0 |
Jagang | 0:85567bbcebdb | 6 | * @see http://www.drdobbs.com/cpp/a-lightweight-logger-for-c/240147505 |
Jagang | 0:85567bbcebdb | 7 | * |
Jagang | 0:85567bbcebdb | 8 | * Copyright (c) 2013 |
Jagang | 0:85567bbcebdb | 9 | * |
Jagang | 0:85567bbcebdb | 10 | * Licensed under the Apache License, Version 2.0 (the "License"); |
Jagang | 0:85567bbcebdb | 11 | * you may not use this file except in compliance with the License. |
Jagang | 0:85567bbcebdb | 12 | * You may obtain a copy of the License at |
Jagang | 0:85567bbcebdb | 13 | * |
Jagang | 0:85567bbcebdb | 14 | * http://www.apache.org/licenses/LICENSE-2.0 |
Jagang | 0:85567bbcebdb | 15 | * |
Jagang | 0:85567bbcebdb | 16 | * Unless required by applicable law or agreed to in writing, software |
Jagang | 0:85567bbcebdb | 17 | * distributed under the License is distributed on an "AS IS" BASIS, |
Jagang | 0:85567bbcebdb | 18 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
Jagang | 0:85567bbcebdb | 19 | * See the License for the specific language governing permissions and |
Jagang | 0:85567bbcebdb | 20 | * limitations under the License. |
Jagang | 0:85567bbcebdb | 21 | */ |
Jagang | 0:85567bbcebdb | 22 | |
Jagang | 0:85567bbcebdb | 23 | #include "LogUtil.h" |
Jagang | 0:85567bbcebdb | 24 | #include "mbed.h" |
Jagang | 0:85567bbcebdb | 25 | |
Jagang | 0:85567bbcebdb | 26 | LogUtil::LogUtil(Serial &serial, uint32_t baudrate) |
Jagang | 0:85567bbcebdb | 27 | { |
Jagang | 0:85567bbcebdb | 28 | _serial = &serial; |
Jagang | 0:85567bbcebdb | 29 | (baudrate > 0) ? _serial->baud(baudrate) : __nop(); |
Jagang | 0:85567bbcebdb | 30 | _serial->printf("\033[2J"); // clear the terminal |
Jagang | 0:85567bbcebdb | 31 | _serial->printf("\033[1;1H");// and set the cursor to home |
Jagang | 0:85567bbcebdb | 32 | wait(0.5f); |
Jagang | 0:85567bbcebdb | 33 | return; |
Jagang | 0:85567bbcebdb | 34 | } |
Jagang | 0:85567bbcebdb | 35 | |
Jagang | 0:85567bbcebdb | 36 | |
Jagang | 0:85567bbcebdb | 37 |