Skip to content

Commit

Permalink
log interval
Browse files Browse the repository at this point in the history
  • Loading branch information
andysworkshop committed Dec 23, 2016
1 parent fe0fd72 commit 1f8882a
Show file tree
Hide file tree
Showing 4 changed files with 91 additions and 2 deletions.
1 change: 1 addition & 0 deletions Application.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,6 @@
#include "Limit.h"
#include "Calibration.h"
#include "Intensity.h"
#include "Log.h"
#include "Reset.h"
#include "Program.h"
86 changes: 86 additions & 0 deletions Log.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
/*
* Andy's Workshop NXA66 controller ATMega328p firmware
* Copyright (c) 2017 Andy Brown. http://www.andybrown.me.uk
* Please see website for licensing terms.
*/

#pragma once


namespace nxa66 {

class Log : public MenuItem {

protected:
uint16_t _interval;

protected:
void updateDisplay() const;

public:
Log(MenuItem *next);

virtual void start() override;
virtual void finish() override;
virtual void onEncoder(int8_t direction) override;
};


/*
* Constructor
*/

inline Log::Log(MenuItem *next)
: MenuItem(next,"Log") {
}


/*
* Startup: initialise values
*/

inline void Log::start() {

MenuItem::start();

_interval=Eeprom::Reader::loggerInterval();
updateDisplay();
}


/*
* User has confirmed completion with the action button
*/

inline void Log::finish() {
Eeprom::Writer::loggerInterval(_interval);
}


/*
* Encoder (wheel) changed
*/

inline void Log::onEncoder(int8_t direction) {

if(direction>0) {
if(_interval<65500)
_interval+=100;
}
else if(direction<0) {
if(_interval)
_interval-=100;
}

updateDisplay();
}


/*
* Update the display
*/

inline void Log::updateDisplay() const {
Max7221::displayNumber(Max7221::Display::LOWER,_interval);
}
}
2 changes: 1 addition & 1 deletion Max7221.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ namespace nxa66 {
0b00111101,
0b01001111,
0b01000111,
0b00000000,
0b01111011, // g
0b00110111,
0b00000000,
0b00000000,
Expand Down
4 changes: 3 additions & 1 deletion Program.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ namespace nxa66 {

Limit _limit;
Calibration _calibration;
Log _log;
Intensity _intensity;
Reset _reset;
MenuItem *_currentMenuItem;
Expand All @@ -48,7 +49,8 @@ namespace nxa66 {

inline Program::Program()
: _limit(&_calibration),
_calibration(&_intensity),
_calibration(&_log),
_log(&_intensity),
_intensity(&_reset),
_reset(nullptr),
_currentMenuItem(nullptr) {
Expand Down

0 comments on commit 1f8882a

Please sign in to comment.