diff --git a/Alarms.cpp b/Alarms.cpp index 8ef353b..ccef3b1 100644 --- a/Alarms.cpp +++ b/Alarms.cpp @@ -179,7 +179,9 @@ void AlarmManager::begin() { } void AlarmManager::update() { - displ_->setAlarmText(getHeaderText(), getFooterText(), beeper_.getRemainingSnoozeTime()); + displ_->setAlarmText(getGeneralAlarmText()); + displ_->setUnconfirmedKnobAlarmText(getUnconfirmedKnobText()); + displ_->setSnoozeText(beeper_.getRemainingSnoozeTime()); AlarmLevel highest_level = getHighestLevel(); beeper_.update(highest_level); if (highest_level > NO_ALARM) { @@ -210,7 +212,9 @@ int AlarmManager::numON_Confirm() const { for (int i = 0; i < NUM_ALARMS; i++) { aConfirmAlarm = (i==NOT_CONFIRM_TV || i==NOT_CONFIRM_RR || i==NOT_CONFIRM_IE || i==NOT_CONFIRM_AC); - num += (int)alarms_[i].isON(); + if(aConfirmAlarm) { + num += (int)alarms_[i].isON(); + } } return num; } @@ -221,12 +225,14 @@ int AlarmManager::numON_NonConfirm() const { for (int i = 0; i < NUM_ALARMS; i++) { aConfirmAlarm = (i==NOT_CONFIRM_TV || i==NOT_CONFIRM_RR || i==NOT_CONFIRM_IE || i==NOT_CONFIRM_AC); - num += (int)alarms_[i].isON(); + if(!aConfirmAlarm) { + num += (int)alarms_[i].isON(); + } } return num; } -String AlarmManager::getHeaderText() const { +String AlarmManager::getGeneralAlarmText() const { const int num_on = numON_NonConfirm(); String text = ""; if (num_on > 0) { @@ -247,7 +253,7 @@ String AlarmManager::getHeaderText() const { return text; } -String AlarmManager::getFooterText() const { +String AlarmManager::getUnconfirmedKnobText() const { const int num_on = numON_Confirm(); String text = ""; if (num_on > 0) { diff --git a/Alarms.h b/Alarms.h index 1b3c6b4..c8ded03 100644 --- a/Alarms.h +++ b/Alarms.h @@ -235,6 +235,9 @@ class AlarmManager { NUM_ALARMS }; + // Number of NOT_CONFIRM_XX alarms + static const int numConfirmKnob = 4; + public: AlarmManager(const int& beeper_pin, const int& snooze_pin, const int& led_pin, Display* displ, unsigned long const* cycle_count): @@ -335,8 +338,8 @@ class AlarmManager { int led_pin_; utils::Pulse led_pulse_; Alarm alarms_[NUM_ALARMS]; - Alarm alarmsHeader_[NUM_ALARMS-4]; - Alarm alarmsFooter_[4]; + Alarm alarmsHeader_[NUM_ALARMS-numConfirmKnob]; + Alarm alarmsFooter_[numConfirmKnob]; unsigned long const* cycle_count_; // Get number of alarms that are ON @@ -348,11 +351,11 @@ class AlarmManager { // Get number of nonconfirm alarms that are ON int numON_NonConfirm() const; - // Get header text to display - String getHeaderText() const; + // Get general alarm text to display + String getGeneralAlarmText() const; - // Get footer text to display - String getFooterText() const; + // Get unconfirmed knob alarm text to display + String getUnconfirmedKnobText() const; // Get highest priority level of the alarms that are ON AlarmLevel getHighestLevel() const; diff --git a/Display.cpp b/Display.cpp index 11e1122..98a3c87 100644 --- a/Display.cpp +++ b/Display.cpp @@ -45,7 +45,7 @@ void Display::begin() { void Display::addCustomCharacters() { lcd_->createChar(0, patientIcon); lcd_->createChar(1, timeIcon); - lcd_->createChar(2, peekIcon); + lcd_->createChar(2, peakIcon); lcd_->createChar(3, plateauIcon); lcd_->createChar(4, peepIcon); lcd_->createChar(5, ieiIcon); @@ -58,13 +58,19 @@ void Display::update() { writeFooter(); } -void Display::setAlarmText(const String& alarmH, const String& alarmF, const int& countdown) { - if (animation_.text() != alarmH) { - animation_.reset(alarmH); +void Display::setAlarmText(const String& alarm) { + if (animation_.text() != alarm) { + animation_.reset(alarm); } - if (animationfooter_.text() != alarmF) { - animationfooter_.reset(alarmF); +} + +void Display::setUnconfirmedKnobAlarmText(const String& alarm) { + if (animationfooter_.text() != alarm) { + animationfooter_.reset(alarm); } +} + +void Display::setSnoozeText(const int& countdown) { snoozecountdown_ = countdown; } @@ -128,10 +134,10 @@ void Display::writeHeader() { void Display::writeFooter() { if (!alarmsON()) { writeBlank(FOOTER); - hideIcon(3,0); + hideBellIcon(); } else { - showBellIcon(3, 0); + showBellIcon(); const String line = animationfooter_.getLine(); if (line.length() > 0) { write(elements_[FOOTER].row, elements_[FOOTER].col, line); @@ -195,7 +201,7 @@ void Display::writeACTrigger(const float& ac_trigger) { void Display::writePeakP(const int& peak) { const int peak_c = constrain(peak, -9, 99); - showPeekIcon(elements_[PEAK_PRES].row, elements_[PEAK_PRES].col); + showPeakIcon(elements_[PEAK_PRES].row, elements_[PEAK_PRES].col); char buff[3]; sprintf(buff, "%2s", toString(PEAK_PRES, peak_c).c_str()); write(elements_[PEAK_PRES].row, elements_[PEAK_PRES].col+1, buff); @@ -243,30 +249,35 @@ String Display::toString(const DisplayKey& key, const T& value) const { } // This displays a patient icon -void Display::showPatientIcon(const int& row, const int& col) { - lcd_->setCursor(col, row); +void Display::showPatientIcon() { + lcd_->setCursor(elements_[BREATHING].col, elements_[BREATHING].row); lcd_->write(byte(0)); } // This displays a time icon -void Display::showTimeIcon(const int& row, const int& col) { - lcd_->setCursor(col, row); +void Display::showTimeIcon() { + lcd_->setCursor(elements_[BREATHING].col, elements_[BREATHING].row); lcd_->write(byte(1)); } +// This hides a time-patient icon +void Display::hideTimePatientIcon() { + hideIcon(elements_[BREATHING].row, elements_[BREATHING].col); +} + // Hides icon void Display::hideIcon(const int& row, const int& col) { lcd_->setCursor(col, row); lcd_->write(byte(32)); } -// This displays the peek icon -void Display::showPeekIcon(const int& row, const int& col) { +// This displays the PIP icon +void Display::showPeakIcon(const int& row, const int& col) { lcd_->setCursor(col, row); lcd_->write(byte(2)); } -// This displays a plateau icon +// This displays a plateau pressure icon void Display::showPlateauIcon(const int& row, const int& col) { lcd_->setCursor(col, row); lcd_->write(byte(3)); @@ -291,11 +302,16 @@ void Display::showIE1Icon(const int& row, const int& col) { } // This displays a bell icon -void Display::showBellIcon(const int& row, const int& col) { - lcd_->setCursor(col, row); +void Display::showBellIcon() { + lcd_->setCursor(elements_[BELL].col, elements_[BELL].row); lcd_->write(byte(7)); } +// This hides the bell icon +void Display::hideBellIcon() { + hideIcon(elements_[BELL].row, elements_[BELL].col); +} + template void Display::write(const int& row, const int& col, const T& printable) { lcd_->setCursor(col, row); diff --git a/Display.h b/Display.h index 8112773..9117cbf 100644 --- a/Display.h +++ b/Display.h @@ -76,6 +76,7 @@ class TextAnimation { enum DisplayKey { HEADER, + BREATHING, VOLUME, BPM, IE_RATIO, @@ -85,6 +86,7 @@ enum DisplayKey { PLATEAU_PRES, PEEP_PRES, SNOOZE, + BELL, FOOTER, NUM_KEYS }; @@ -129,6 +131,7 @@ class Display { animationfooter_(1000, 0.5), snoozecountdown_(0) { elements_[HEADER] = Element{0, 0, kHeaderLength}; + elements_[BREATHING] = Element{0, 19, 1}; elements_[VOLUME] = Element{1, 0, 4, "TV"}; elements_[BPM] = Element{1, 4, 3, "RR"}; elements_[IE_RATIO] = Element{1, 7, 5, "IE"}; @@ -137,6 +140,7 @@ class Display { elements_[PLATEAU_PRES] = Element{2, 17, 3, "plat"}; elements_[PEEP_PRES] = Element{3, 17, 3, "PEEP"}; elements_[SNOOZE] = Element{3, 1, 3}; + elements_[BELL] = Element{3, 0, 1}; elements_[FOOTER] = Element{3, 7, kFooterLength}; } @@ -149,8 +153,14 @@ class Display { // Update during arduino loop() void update(); - // Write arbitrary alarm in the header and footer - void setAlarmText(const String& alarmH, const String& alarmF, const int& countdown); + // Set arbitrary alarm text + void setAlarmText(const String& alarm); + + // Set unconfirmed knob alarm text + void setUnconfirmedKnobAlarmText(const String& alarm); + + // Set snooze time text + void setSnoozeText(const int& countdown); // Write value corresponding to key'ed element template @@ -190,16 +200,19 @@ class Display { void writePEEP(const int& peep); // This displays a patient icon - void showPatientIcon(const int& row, const int& col); + void showPatientIcon(); // This displays a time icon - void showTimeIcon(const int& row, const int& col); + void showTimeIcon(); + + // Hide time-patient icon + void hideTimePatientIcon(); // Hides icon void hideIcon(const int& row, const int& col); - // This displays the peek icon - void showPeekIcon(const int& row, const int& col); + // This displays the PIP icon + void showPeakIcon(const int& row, const int& col); // This displays a plateau icon void showPlateauIcon(const int& row, const int& col); @@ -214,7 +227,10 @@ class Display { void showIE1Icon(const int& row, const int& col); // This displays a bell icon - void showBellIcon(const int& row, const int& col); + void showBellIcon(); + + // Hide bell icon + void hideBellIcon(); // Convert value e.g. RR from numeric to string for displaying. template diff --git a/Indicators.h b/Indicators.h index 9582d43..9ff82ad 100644 --- a/Indicators.h +++ b/Indicators.h @@ -54,7 +54,7 @@ static const byte timeIcon[8] = { B11111, B11111}; -static const byte peekIcon[8] = { +static const byte peakIcon[8] = { B01111, B10000, B10000, @@ -114,4 +114,4 @@ static const byte bellIcon[8] = { B00100, B00000}; - #endif \ No newline at end of file + #endif diff --git a/e-vent.ino b/e-vent.ino index 894dcdb..3ee17af 100644 --- a/e-vent.ino +++ b/e-vent.ino @@ -232,7 +232,7 @@ void loop() { if (enteringState) { enteringState = false; goToPositionByDur(roboclaw, BAG_CLEAR_POS, motorPosition, tEx - (now() - tCycleTimer)); - displ.hideIcon(0,19); + displ.hideTimePatientIcon(); } if (abs(motorPosition - BAG_CLEAR_POS) < BAG_CLEAR_TOL) { @@ -271,9 +271,9 @@ void loop() { // An indicator that shows patient-triggered or time-triggered cycles if(patientTriggered) { - displ.showPatientIcon(0,19); + displ.showPatientIcon(); } else { - displ.showTimeIcon(0,19); + displ.showTimeIcon(); } } break;