-
Dependencies: CommandHandler HygroClip2 InterruptBasedEncoder SPI_TFT_ILI9341 mbed-src-no-hal
Revision 4:47fd4584df95, committed 2016-04-05
- Comitter:
- wolfsberger
- Date:
- Tue Apr 05 14:00:51 2016 +0000
- Parent:
- 3:3ef8c2d7b1bf
- Commit message:
- -
Changed in this revision
diff -r 3ef8c2d7b1bf -r 47fd4584df95 CommandHandler.h --- a/CommandHandler.h Tue Mar 15 07:46:06 2016 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,117 +0,0 @@ -#ifndef COMMANDHANDLER_H_INCLUDED -#define COMMANDHANDLER_H_INCLUDED - -class CommandBase -{ -public: - // Type definitions - typedef uint8_t IDType; - typedef uint32_t ParameterType; - typedef bool(*CallbackType)(ParameterType); - - CommandBase(IDType id) - : id_(id), nextCommand_(NULL) - {} - - CommandBase * next() - { - return nextCommand_; - } - void setNext(CommandBase * command) - { - nextCommand_ = command; - } - IDType id() - { - return id_; - } - void operator()(ParameterType param) - { - exec(param); - } - virtual bool exec(ParameterType param) = 0; -private: - - IDType id_; - CommandBase * nextCommand_; -}; - -/** Class to create a command that points to a class member. - * - */ -template <typename T> -class MemberCommand : public CommandBase -{ -public: - MemberCommand(CommandBase::IDType id, T* target, bool (T::*func)(CommandBase::ParameterType)) - : CommandBase(id), target_(target), function_(func) - {} - - bool exec(ParameterType param) - { - return (target_->*function_)(param); - } - -private: - T * target_; - bool (T::*function_)(CommandBase::ParameterType); -}; - -/** Class to create a command that points to function. - * - */ -class FunctionCommand : public CommandBase -{ -public: - FunctionCommand(CommandBase::IDType id, CommandBase::CallbackType func) - : CommandBase(id), function_(func) - {} - - bool exec(ParameterType param) - { - return function_(param); - } - -private: - CommandBase::CallbackType function_; -}; - - -class CommandHandler -{ -public: - CommandHandler() - : firstCommand_(NULL), lastCommand_(NULL) - {} - void addCommand(CommandBase * command) - { - if (firstCommand_ == NULL) - { - firstCommand_ = command; - lastCommand_ = command; - } - else - { - lastCommand_->setNext(command); - lastCommand_ = command; - } - } - void handleCommand(CommandBase::IDType id, CommandBase::ParameterType param) - { - CommandBase * cmd = firstCommand_; - while (cmd != 0) - { - if (cmd->id() == id && cmd->exec(param)) - { - return; - } - cmd = cmd->next(); - } - } -private: - CommandBase * nextCommand(); - CommandBase * firstCommand_; - CommandBase * lastCommand_; -}; - -#endif /* COMMANDHANDLER_H_INCLUDED */
diff -r 3ef8c2d7b1bf -r 47fd4584df95 CommandHandler.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/CommandHandler.lib Tue Apr 05 14:00:51 2016 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/wolfsberger/code/CommandHandler/#647c98c63475
diff -r 3ef8c2d7b1bf -r 47fd4584df95 Encoder.h --- a/Encoder.h Tue Mar 15 07:46:06 2016 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,67 +0,0 @@ -#ifndef ENCODER_H_INCLUDED -#define ENCODER_H_INCLUDED - -class RotaryEncoder { -public: - RotaryEncoder(PinName outa, PinName outb) - : position_(0), delta_(0), - inta_(outa), intb_(outb), outa_(outa), outb_(outb) { - outa_.mode(PullUp); - outb_.mode(PullUp); - inta_.rise(this, &RotaryEncoder::handleIntA); - inta_.fall(this, &RotaryEncoder::handleIntA); - intb_.rise(this, &RotaryEncoder::handleIntB); - intb_.fall(this, &RotaryEncoder::handleIntB); - } - - /** Returns the overall position of the encoder - */ - int position() { - return position_; - } - - /** Returns the encoders change since the last call to this function - */ - int delta() { - int d = delta_; - delta_ = 0; - return d; - } - -private: - - // A = B --> Clockwise - // A /= B --> Counter clockwise - void handleIntA() { - if (outa_ == outb_) { - increment(1); - } else { - increment(-1); - } - } - - // A = B --> Counter clockwise - // A /= B --> Clockwise - void handleIntB() { - if (outa_ == outb_) { - increment(-1); - } else { - increment(1); - } - } - - void increment(int i) { - position_ += i; - delta_ += i; - } - - int position_; - int delta_; - - InterruptIn inta_; - InterruptIn intb_; - DigitalIn outa_; - DigitalIn outb_; -}; - -#endif /* ENCODER_H_INCLUDED */
diff -r 3ef8c2d7b1bf -r 47fd4584df95 GraphScale.cpp --- a/GraphScale.cpp Tue Mar 15 07:46:06 2016 +0000 +++ b/GraphScale.cpp Tue Apr 05 14:00:51 2016 +0000 @@ -14,7 +14,7 @@ tft_->rect(x1, y1, x2, y2, color); - int stepsize = height_ / ((max_-min_) / scaleSteps_); + //int stepsize = height_ / ((max_-min_) / scaleSteps_); int stepposition = min_; while (stepposition <= max_)
diff -r 3ef8c2d7b1bf -r 47fd4584df95 HygroClip2.lib --- a/HygroClip2.lib Tue Mar 15 07:46:06 2016 +0000 +++ b/HygroClip2.lib Tue Apr 05 14:00:51 2016 +0000 @@ -1,1 +1,1 @@ -HygroClip2#810b9b0dd9a4 +https://developer.mbed.org/users/wolfsberger/code/HygroClip2/#810b9b0dd9a4
diff -r 3ef8c2d7b1bf -r 47fd4584df95 InterruptBasedEncoder.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/InterruptBasedEncoder.lib Tue Apr 05 14:00:51 2016 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/wolfsberger/code/InterruptBasedEncoder/#d510e8063ad1
diff -r 3ef8c2d7b1bf -r 47fd4584df95 SPI_TFT_ILI9341.lib --- a/SPI_TFT_ILI9341.lib Tue Mar 15 07:46:06 2016 +0000 +++ b/SPI_TFT_ILI9341.lib Tue Apr 05 14:00:51 2016 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/dreschpe/code/SPI_TFT_ILI9341/#ed96a5cc23b5 +https://developer.mbed.org/users/wolfsberger/code/SPI_TFT_ILI9341/#77f9f262e449
diff -r 3ef8c2d7b1bf -r 47fd4584df95 main.cpp --- a/main.cpp Tue Mar 15 07:46:06 2016 +0000 +++ b/main.cpp Tue Apr 05 14:00:51 2016 +0000 @@ -31,7 +31,7 @@ void drawChangingValues() { - TFT.set_font((unsigned char*)Arial28x28); + //TFT.set_font((unsigned char*)Arial28x28); TFT.locate(10,25); TFT.foreground(ColorTemperature); TFT.printf("%.1f*C ",sensor.getTemperature()); // * will be displayed as °
diff -r 3ef8c2d7b1bf -r 47fd4584df95 mbed-src.lib --- a/mbed-src.lib Tue Mar 15 07:46:06 2016 +0000 +++ b/mbed-src.lib Tue Apr 05 14:00:51 2016 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/rs27/code/mbed-src/#8a0b45cd594f +https://developer.mbed.org/users/wolfsberger/code/mbed-src-no-hal/#8a0b45cd594f