-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
implemented a primitive log, fixed a bug in lcd clearArea method
- Loading branch information
Showing
17 changed files
with
292 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
#include "log/Log.h" | ||
|
||
namespace log | ||
{ | ||
|
||
Log::Log( LogThreadInterface* logThread ): | ||
logThread_( *logThread ), | ||
mode_( DisplayMode::UNTIMED ), | ||
timeout_( 0 ) | ||
{ | ||
} | ||
|
||
Log::~Log() = default; | ||
|
||
void Log::operator<<( const etl::string_view& message ) const | ||
{ | ||
logThread_.append( message ); | ||
display(); | ||
} | ||
|
||
void Log::operator<<( const char* message ) const | ||
{ | ||
logThread_.append( message ); | ||
display(); | ||
} | ||
|
||
void Log::setDisplayTimeout( uint32_t timeoutMs ) | ||
{ | ||
|
||
} | ||
|
||
void Log::disableDisplayTimeout() | ||
{ | ||
|
||
} | ||
|
||
void Log::disableDisplay() | ||
{ | ||
|
||
} | ||
|
||
void Log::display() const | ||
{ | ||
switch (mode_) | ||
{ | ||
case DisplayMode::TIMED: | ||
logThread_.displayFor( timeout_ ); | ||
break; | ||
case DisplayMode::UNTIMED: | ||
logThread_.display(); | ||
break; | ||
case DisplayMode::OFF: | ||
default: | ||
break; | ||
} | ||
} | ||
|
||
} // namespace log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#pragma once | ||
|
||
#include "log/LogInterface.h" | ||
#include "log/LogThreadInterface.h" | ||
|
||
#include <etl/string_view.h> | ||
|
||
namespace log | ||
{ | ||
|
||
class Log : public LogInterface | ||
{ | ||
public: | ||
explicit Log( LogThreadInterface* log ); | ||
~Log() override; | ||
|
||
void operator<<( const etl::string_view& message ) const override; | ||
void operator<<( const char* message ) const override; | ||
|
||
void setDisplayTimeout( uint32_t timeoutMs ) override; | ||
void disableDisplayTimeout() override; | ||
void disableDisplay() override; | ||
|
||
private: | ||
void display() const; | ||
|
||
LogThreadInterface& logThread_; | ||
|
||
enum class DisplayMode | ||
{ | ||
OFF, | ||
TIMED, | ||
UNTIMED | ||
}; | ||
|
||
DisplayMode mode_; | ||
uint32_t timeout_; | ||
}; | ||
|
||
} // namespace log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#include "log/LogThread.h" | ||
#include "log/info.h" | ||
|
||
#include "main.hpp" | ||
|
||
namespace log | ||
{ | ||
|
||
LogInterface& info = Main::getInstance().getLogContainer().getInfo(); | ||
|
||
LogContainer::LogContainer( lcd::LcdInterface* lcdInterface ): | ||
logThread_( lcdInterface ), | ||
info_( &logThread_ ), | ||
error_( &logThread_ ) | ||
{ | ||
} | ||
|
||
LogInterface& LogContainer::getInfo() | ||
{ | ||
return info_; | ||
} | ||
|
||
LogInterface& LogContainer::getError() | ||
{ | ||
return error_; | ||
} | ||
|
||
} // namespace log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#pragma once | ||
|
||
#include "lcd/LcdInterface.h" | ||
#include "log/Log.h" | ||
#include "log/LogThread.h" | ||
|
||
namespace log | ||
{ | ||
|
||
class LogContainer | ||
{ | ||
public: | ||
explicit LogContainer( lcd::LcdInterface* lcdInterface ); | ||
|
||
LogInterface& getInfo(); | ||
LogInterface& getError(); | ||
|
||
private: | ||
LogThread logThread_; | ||
|
||
Log info_; | ||
Log error_; | ||
}; | ||
|
||
} // namespace log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#pragma once | ||
|
||
#include <cstdint> | ||
#include <etl/string_view.h> | ||
|
||
namespace log | ||
{ | ||
|
||
class LogInterface | ||
{ | ||
public: | ||
virtual ~LogInterface() = default; | ||
|
||
virtual void operator<<( const etl::string_view& message ) const = 0; | ||
virtual void operator<<( const char* message ) const = 0; | ||
|
||
virtual void setDisplayTimeout( uint32_t timeoutMs ) = 0; | ||
virtual void disableDisplayTimeout() = 0; | ||
virtual void disableDisplay() = 0; | ||
}; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#include "log/LogThread.h" | ||
|
||
namespace log | ||
{ | ||
|
||
LogThread::LogThread( lcd::LcdInterface* lcd ): | ||
Thread( "Log", 256, 3 ), | ||
lcd_( *lcd ), | ||
lineNumber_( 0 ) | ||
{ | ||
} | ||
|
||
LogThread::~LogThread() = default; | ||
|
||
void LogThread::append( const etl::string_view& message ) | ||
{ | ||
lcd_.clearArea( 0, lineNumber_ * 8, 83, lineNumber_ * 8 + 7 ); | ||
lcd_.print( message.begin(), 0, lineNumber_ * 8 ); | ||
|
||
lineNumber_ = (lineNumber_ + 1) % 6; | ||
} | ||
|
||
void LogThread::display() | ||
{ | ||
} | ||
|
||
void LogThread::displayFor( const uint32_t timeMs ) | ||
{ | ||
} | ||
|
||
void LogThread::Run() | ||
{ | ||
} | ||
|
||
|
||
} // namespace log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#pragma once | ||
|
||
#include "log/LogThreadInterface.h" | ||
|
||
#include "lcd/LcdInterface.h" | ||
#include <freertos/thread.hpp> | ||
#include <freertos/semaphore.hpp> | ||
|
||
namespace log | ||
{ | ||
|
||
class LogThread : public LogThreadInterface, private freertos::Thread | ||
{ | ||
public: | ||
explicit LogThread( lcd::LcdInterface* lcd ); | ||
~LogThread() override; | ||
|
||
void append( const etl::string_view& message ) override; | ||
void display() override; | ||
void displayFor( uint32_t timeMs ) override; | ||
|
||
void Run() override; | ||
|
||
private: | ||
lcd::LcdInterface& lcd_; | ||
|
||
uint8_t lineNumber_; | ||
}; | ||
|
||
} // namespace log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#pragma once | ||
|
||
#include <cstdint> | ||
#include <etl/string_view.h> | ||
|
||
namespace log | ||
{ | ||
|
||
class LogThreadInterface | ||
{ | ||
public: | ||
~LogThreadInterface() = default; | ||
|
||
virtual void append( const etl::string_view& message ) = 0; | ||
virtual void display() = 0; | ||
virtual void displayFor( uint32_t timeMs ) = 0; | ||
|
||
}; | ||
|
||
} // namespace log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#pragma once | ||
#include "log/LogInterface.h" | ||
|
||
namespace log | ||
{ | ||
|
||
extern LogInterface& info; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters