Skip to content

Commit

Permalink
Add ability to set notification in mask mode after printing some masks
Browse files Browse the repository at this point in the history
  • Loading branch information
lo1ol committed Jul 8, 2024
1 parent b32f71f commit 67d513d
Show file tree
Hide file tree
Showing 13 changed files with 52 additions and 20 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
1. F Stop test mode: ability to print tones and part tones of prints (decreasing f stop step). After that you can see the log
2. Linear test mode: simple mode for linear testing
3. Print mode: ability to stop printing at any time. Usefull for getting fast masking values
4. Mask mode: for printing with accurate masks
4. Mask mode: for printing with accurate masks. Hold extra btn while set mask to go back to first mask. Click start btn when set mask to play melody after printing this mask -- usefull, when you don't want to forgot to do something. For example, change filter.
5. Split grade test modes: the same as fstop and linear test modes, but allows to set base time. After printing base, the melody is playing to not forget change filter

## Killer features:
Expand Down
2 changes: 1 addition & 1 deletion README_RU.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
1. Тест F стопами: позволяет произвести быстрый тест для подбора тона изображения повышая каждый следующий тест на заданный тон. Размер тона можно уменьшать. После печати вы можете посмотреть лог печати
2. Линейный тест: Задается начальное значение и шаг
3. Режим печати: можете задать время и печатать с ним. Дополнительно есть возможность остановки печати и печати по удержанию кнопки (удобно для маскирования и коротких выдержках).
4. Режим маскирования: задайте количество масок и время, которое нужено для засветки определенной маски
4. Режим маскирования: задайте количество масок и время, которое нужено для засветки определенной маски. Удерживайте кнопку на энкодере, во время установки масок, чтобы вернуться к установке первой маски. Нажмите на кнопку старта, во время установки масок, чтобы поставить напоминание на конкретной маске. После печати маски с уведомлением проиграет милодия, которая напомнит вам сделать что-то, например, сменить фильтр
5. Сплит грейд тесты: аналогичны тестам F стопами и линейным тестам, но с возможностью выставить начальное время экспонирования (время засветки первым фильтром). После печати базового времени играет мелодия, чтобы вы не забыли сменить фильтр

## Killer фичи:
Expand Down
4 changes: 2 additions & 2 deletions src/Display.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ void Display::reset() {
line.reset();
}

void Display::resetBlink() {
void Display::resetBlink(bool state) {
for (auto&& line : m_lines)
line.resetBlink();
line.resetBlink(state);
}
2 changes: 1 addition & 1 deletion src/Display.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class Display {

void tick();
void reset();
void resetBlink();
void resetBlink(bool state = false);

private:
LiquidCrystal m_lcd;
Expand Down
18 changes: 14 additions & 4 deletions src/DisplayLine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ void DisplayLine::concatInt(char* dst, int value) {
concat(dst, str);
}

bool DisplayLine::tryPrint(const char* src, bool blink, uint8_t alignSize) {
bool DisplayLine::tryPrint(const char* src, bool blink, uint8_t alignSize, const char* mark) {
uint8_t srclen = strlen(src);
uint8_t dstlen = strlen(m_fwInfo);

Expand All @@ -37,6 +37,9 @@ bool DisplayLine::tryPrint(const char* src, bool blink, uint8_t alignSize) {
if (blink) {
m_blinkLength = alignSize;
m_blinkPos = dstlen;

if (mark)
m_mark = mark;
}

concat(m_fwInfo, src);
Expand All @@ -47,11 +50,12 @@ void DisplayLine::reset() {
m_fwInfo[0] = 0;
m_bwInfo[0] = 0;
m_blinkLength = 0;
m_mark = 0;
}

void DisplayLine::resetBlink() {
void DisplayLine::resetBlink(bool state) {
m_blinkTimer = millis();
m_blinkState = false;
m_blinkState = state;
}

void DisplayLine::tick() {
Expand All @@ -67,8 +71,14 @@ void DisplayLine::tick() {
m_blinkTimer = millis();
}

if (m_blinkState)
if (m_blinkState) {
memset(m_fwInfo + m_blinkPos, ' ', m_blinkLength);

if (m_mark) {
uint8_t marklen = strlen(m_mark);
memcpy(m_fwInfo + m_blinkPos + m_blinkLength - marklen, m_mark, marklen);
}
}
}

m_lcd.setCursor(0, m_line);
Expand Down
5 changes: 3 additions & 2 deletions src/DisplayLine.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ class DisplayLine {

void tick();
void reset();
void resetBlink();
void resetBlink(bool state = false);

DisplayLine& operator<<(const char* src);
DisplayLine& operator<<(int value);

DisplayLine& operator>>(const char* src);
DisplayLine& operator>>(int value);

bool tryPrint(const char* src, bool blink = false, uint8_t alignSize = 0);
bool tryPrint(const char* src, bool blink = false, uint8_t alignSize = 0, const char* mark = nullptr);

private:
static void concat(char* dst, const char* src);
Expand All @@ -33,6 +33,7 @@ class DisplayLine {
uint8_t m_blinkLength = 0;
uint32_t m_blinkTimer = 0;
bool m_blinkState = 0;
const char* m_mark;

char m_fwInfo[DISPLAY_COLS + 1] = "";
char m_bwInfo[DISPLAY_COLS + 1] = "";
Expand Down
8 changes: 5 additions & 3 deletions src/ModeProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
#include "Config.h"
#include "Tools.h"

uint8_t ModeProcessor::printLogHelper(Time (*timeGetter)(const void* ctx, uint8_t id, bool& current, bool& end),
uint8_t ModeProcessor::printLogHelper(Time (*timeGetter)(const void* ctx, uint8_t id, bool& current, bool& end,
const char*& mark),
const void* ctx) const {
uint8_t id = 0;

Expand All @@ -14,8 +15,9 @@ uint8_t ModeProcessor::printLogHelper(Time (*timeGetter)(const void* ctx, uint8_
bool end = false;
bool printTimer = gTimer.state() == Timer::RUNNING;
uint8_t alignSize = 0;
const char* mark = nullptr;

Time time = timeGetter(ctx, id, current, end);
Time time = timeGetter(ctx, id, current, end, mark);

if (end)
return id;
Expand All @@ -32,7 +34,7 @@ uint8_t ModeProcessor::printLogHelper(Time (*timeGetter)(const void* ctx, uint8_
}
}

if (!gDisplay[row].tryPrint(str, current && !printTimer, alignSize))
if (!gDisplay[row].tryPrint(str, current && !printTimer, alignSize, mark))
break;

gDisplay[row] << " ";
Expand Down
2 changes: 1 addition & 1 deletion src/ModeProcessor.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ class ModeProcessor {
virtual const char* preview() const = 0;

protected:
uint8_t printLogHelper(Time (*timeGetter)(const void* ctx, uint8_t id, bool& current, bool& end),
uint8_t printLogHelper(Time (*timeGetter)(const void* ctx, uint8_t id, bool& current, bool& end, const char*& mark),
const void* ctx) const;
};
2 changes: 1 addition & 1 deletion src/Modes/FStopTestMode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ bool FStopTestMode::canSwitchView() const {

void FStopTestMode::printLog(bool& logOverFlowed) const {
uint8_t id = printLogHelper(
[](const void* this__, uint8_t id, bool& current, bool& end) -> Time {
[](const void* this__, uint8_t id, bool& current, bool& end, const char*& mark) -> Time {
auto this_ = reinterpret_cast<const FStopTestMode*>(this__);
float stopPart = kFStopPartVarinatns[this_->m_FStopPartId];

Expand Down
2 changes: 1 addition & 1 deletion src/Modes/LinearTestMode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ bool LinearTestMode::canSwitchView() const {

void LinearTestMode::printLog(bool& logOverFlowed) const {
uint8_t id = printLogHelper(
[](const void* this__, uint8_t id, bool& current, bool& end) -> Time {
[](const void* this__, uint8_t id, bool& current, bool& end, const char*& mark) -> Time {
auto this_ = reinterpret_cast<const LinearTestMode*>(this__);

if (!this_->kSplit)
Expand Down
22 changes: 20 additions & 2 deletions src/Modes/MaskMode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ MaskMode::MaskMode() {
m_step = Step::setNum;
m_view = gSettings.logViewInMasks ? View::log : View::common;
m_currentMask = 0;
m_notifyMask = 0;

for (uint8_t i = 1; i != kMasksMaxNumber; ++i)
m_masks[i] = -1_ts;
Expand All @@ -22,6 +23,7 @@ void MaskMode::switchMode() {

m_currentMask = 0;

m_notifyMask &= ~((~0) << m_notifyMask);
for (uint8_t i = m_numberOfMasks; i != kMasksMaxNumber; ++i)
m_masks[i] = -1_ts;

Expand Down Expand Up @@ -60,12 +62,19 @@ void MaskMode::process() {
}

void MaskMode::processSetMasks() {
if (gStartBtn.click()) {
m_notifyMask ^= 1 << m_currentMask;
gDisplay.resetBlink(true);
}

bool changed = getTime(m_masks[m_currentMask]);

switch (m_view) {
case View::common:
gDisplay[0] << "Mask set: #" << (m_currentMask + 1);
gDisplay[1] << m_masks[m_currentMask];
if (m_notifyMask & (1 << m_currentMask))
gDisplay[1] >> "Notify";
break;
case View::log: {
if (changed)
Expand All @@ -86,6 +95,9 @@ void MaskMode::processRun() {
case View::common:
gDisplay[0] << "Mask #" << m_currentMask + 1 << " T:" << gTimer.total();

if (m_notifyMask & (1 << m_currentMask))
gDisplay[1] >> "Notify";

if (gTimer.state() == Timer::RUNNING) {
gTimer.printFormatedState();
} else if (m_currentMask == m_numberOfMasks) {
Expand All @@ -112,8 +124,11 @@ void MaskMode::processRun() {
if (gTimer.state() == Timer::STOPPED && gStartBtn.click())
gTimer.start(m_masks[m_currentMask]);

if (gTimer.stopped())
if (gTimer.stopped()) {
if (m_notifyMask & (1 << m_currentMask))
gBeeper.melody();
++m_currentMask;
}
}

void MaskMode::reset() {
Expand All @@ -137,14 +152,17 @@ bool MaskMode::canSwitchView() const {

void MaskMode::printLog(bool& logOverFlowed) const {
uint8_t id = printLogHelper(
[](const void* this__, uint8_t id, bool& current, bool& end) -> Time {
[](const void* this__, uint8_t id, bool& current, bool& end, const char*& mark) -> Time {
auto this_ = reinterpret_cast<const MaskMode*>(this__);

current = this_->m_step != Step::setNum && this_->m_currentMask == id;
end = id == this_->m_numberOfMasks;
if (end)
return {};

if (this_->m_notifyMask & (1 << id))
mark = "ntf";

Time time = this_->m_masks[id];
if (time == -1_ts)
return 0_ts;
Expand Down
1 change: 1 addition & 0 deletions src/Modes/MaskMode.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,5 @@ class MaskMode final : public ModeProcessor {
uint8_t m_currentMask;

Time m_masks[kMasksMaxNumber];
uint16_t m_notifyMask;
};
2 changes: 1 addition & 1 deletion src/Modes/PrintMode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ void PrintMode::printLog() const {
gDisplay[0] << "Log ";

printLogHelper(
[](const void* this__, uint8_t id, bool& current, bool& end) -> Time {
[](const void* this__, uint8_t id, bool& current, bool& end, const char*& mark) -> Time {
auto this_ = reinterpret_cast<const PrintMode*>(this__);

end = id == this_->m_logSize;
Expand Down

0 comments on commit 67d513d

Please sign in to comment.