rims-arduino-library  v3.1.1
Recirculation infusion mash system library for Arduino
UIRims.h
Go to the documentation of this file.
1 
6 #ifndef UIRims_h
7 #define UIRims_h
8 
10 #define KEYNONE 0
11 #define KEYUP 1
13 #define KEYDOWN 2
15 #define KEYLEFT 3
17 #define KEYRIGHT 4
19 #define KEYSELECT 5
21 
23 #define SCREENTEMP 0
24 #define SCREENTIMEFLOW 1
26 #define SCREENIDENT 2
28 #define SCREENPIDCOEF 3
30 
31 
33 #define LCDCOLUMNS 16
34 #define LCDROWS 2
36 
38 #define POWERFREQ 500
39 #define RINGFREQ 1000
41 #define FLOWFREQ 1500
43 #define NCTHERMFREQ 2000
45 #define ALARMLENGTH 50
47 
49 #define KEYDEBOUNCETIME 15
50 
51 #include "Arduino.h"
52 #include "LiquidCrystal.h"
53 
54 
68 class UIRims
69 {
70 
71 public:
72 
73  UIRims(LiquidCrystal* lcd, byte pinKeysAnalog,
74  byte pinLight = LED_BUILTIN, char pinSpeaker = -1);
75 
76  // === STD DIALOGS METHOD ===
77  void showSerialWarning();
78  void showPumpWarning(float flow = 0.0);
79  void showHeaterWarning(bool state = false);
80  void showTempScreen();
81  void showTimeFlowScreen();
82  void switchScreen();
83  void showIdentScreen();
84  void showPIDTuningScreen(float Kp, float Ki, float Kd, float tauFilter);
85  void showMemAccessScreen();
86 
87  // === VARIABLE SETTER ===
88  void setTempSP(float tempCelcius);
89  void setTempPV(float tempCelcius, bool buzz = true);
90  void setCV(float controlValue);
91  void setTime(unsigned int timeSec);
92  void setFlow(float flow, bool buzz = true); //liter/min
93  void setFlowBounds(float lowBound, float upBound);
94  void setHeaterVoltState(bool state, bool buzz = true);
95 
96  // === KEYS READER ===
97  byte readKeysADC(bool waitNone = true);
98 
99  // === ALARM METHODS ===
100  void timerRunningChar(bool state);
101  void ring(bool state = true);
102  void lcdLight(bool state = true);
103 
104  // === SETUP DIALOGS ===
105  float askSetPoint(float defaultVal); // Celsius
106  unsigned int askTime(unsigned int defaultVal); // seconds
107  byte askMashWater(int mashWaterValues[],byte defaultVal);
108 
109 protected:
110 
111  byte _waitForKeyChange();
112  void _waitTime(unsigned long timeInMilliSec);
113 
114  void _printStrLCD(String mess, byte col, byte row);
115  void _printFloatLCD(float val, int width, int prec, byte col, byte row);
116  void _setCursorPosition(byte col, byte row);
117  float _celciusToFahrenheit(float celcius);
118  void _moveCursorLR(byte begin, byte end, byte dotPosition,
119  byte row,bool left);
120  float _incDecValue(float value,byte dotPosition, bool increase,
121  float lowerBound, float upperBound, bool timeFormat);
122  float _askValue(byte begin, byte end, byte dotPosition, byte row,
123  float defaultVal, float lowerBound, float upperBound,
124  bool timeFormat);
125 
126 private:
127 
128  LiquidCrystal* _lcd;
129  byte _cursorCol;
130  byte _cursorRow;
131  byte _pinKeysAnalog;
132  byte _pinLight;
133  char _pinSpeaker;
134 
135  byte _screenShown;
136 
137  bool _waitNone;
138 
139  float _tempSP;
140  float _tempPV;
141  float _cv;
142  unsigned int _time;
143  float _flow;
144 
145  float _flowLowBound;
146  float _flowUpBound;
147 
148 };
149 
150 #endif
void showHeaterWarning(bool state=false)
Show the heater switching warning.
Definition: UIRims.cpp:671
void _printStrLCD(String mess, byte col, byte row)
Show mess at column col and row row on _lcd.
Definition: UIRims.cpp:248
void showMemAccessScreen()
Show the memory access mode screen.
Definition: UIRims.cpp:683
void setTime(unsigned int timeSec)
Set a new remaining time.
Definition: UIRims.cpp:376
void _setCursorPosition(byte col, byte row)
Set _lcd cursor at given column col and given row row.
Definition: UIRims.cpp:284
void showIdentScreen()
Show system identification screen on _lcd.
Definition: UIRims.cpp:101
void _moveCursorLR(byte begin, byte end, byte dotPosition, byte row, bool left)
Move the cursor left or right on _lcd.
Definition: UIRims.cpp:486
void _waitTime(unsigned long timeInMilliSec)
Pause the Arduino for the given timeInMilliSec.
Definition: UIRims.cpp:236
byte readKeysADC(bool waitNone=true)
Read keys without software debouce.
Definition: UIRims.cpp:136
void switchScreen()
Toggle between SCREENTEMP and SCREENTIMEFLOW on _lcd.
Definition: UIRims.cpp:92
byte _waitForKeyChange()
Read keys with software debounce.
Definition: UIRims.cpp:163
unsigned int askTime(unsigned int defaultVal)
Ask timer time on the UI.
Definition: UIRims.cpp:583
void timerRunningChar(bool state)
Show blinking char next to remaining time.
Definition: UIRims.cpp:191
void showTimeFlowScreen()
Show remaining time and flow screen on _lcd.
Definition: UIRims.cpp:77
void lcdLight(bool state=true)
Turn on/off the LCD backlighting.
Definition: UIRims.cpp:225
void showPumpWarning(float flow=0.0)
Show the pump switching warning.
Definition: UIRims.cpp:658
void showTempScreen()
Show temperature (set point and process value) screen on _lcd.
Definition: UIRims.cpp:63
float _incDecValue(float value, byte dotPosition, bool increase, float lowerBound, float upperBound, bool timeFormat)
Increse or decrease a floating point value on _lcd-> dotPosition give the position (column) of the po...
Definition: UIRims.cpp:440
float askSetPoint(float defaultVal)
Ask set point temperature with the UI.
Definition: UIRims.cpp:569
void showPIDTuningScreen(float Kp, float Ki, float Kd, float tauFilter)
Show PID coefficients screen on _lcd.
Definition: UIRims.cpp:116
void setTempPV(float tempCelcius, bool buzz=true)
Set a new process value temperature.
Definition: UIRims.cpp:333
void _printFloatLCD(float val, int width, int prec, byte col, byte row)
Show a floating number at column col and row row on _lcd.
Definition: UIRims.cpp:264
UIRims(LiquidCrystal *lcd, byte pinKeysAnalog, byte pinLight=LED_BUILTIN, char pinSpeaker=-1)
Constructor.
Definition: UIRims.cpp:12
void setCV(float controlValue)
Set ident CV on identScreen.
Definition: UIRims.cpp:358
void setHeaterVoltState(bool state, bool buzz=true)
Set voltage detection on heater under the heater warning.
Definition: UIRims.cpp:696
void setFlowBounds(float lowBound, float upBound)
Set bounds for accepted flow rate.
Definition: UIRims.cpp:423
float _askValue(byte begin, byte end, byte dotPosition, byte row, float defaultVal, float lowerBound, float upperBound, bool timeFormat)
Ask a value on _lcd.
Definition: UIRims.cpp:519
void setTempSP(float tempCelcius)
Set a new set point temperature.
Definition: UIRims.cpp:310
byte askMashWater(int mashWaterValues[], byte defaultVal)
Ask mash water quantity (4 choices max).
Definition: UIRims.cpp:603
Library to manage LCD and keypad for Rims library.
Definition: UIRims.h:68
void setFlow(float flow, bool buzz=true)
Set a new flow value.
Definition: UIRims.cpp:399
void showSerialWarning()
Show warning about Arduino IDE Serial Monitor.
Definition: UIRims.cpp:645
float _celciusToFahrenheit(float celcius)
Convert celcius temp to fahrenheit temp.
Definition: UIRims.cpp:296
void ring(bool state=true)
Ring with given speaker setted with the Constructor.
Definition: UIRims.cpp:213