Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Sergey Remizov
BluetoothHeater
Commits
480bd1b1
Commit
480bd1b1
authored
6 years ago
by
rljonesau
Browse files
Options
Download
Email Patches
Plain Diff
Adding OnStart, OnStop and OnTimeout home screen actions
parent
c1b1036e
master
DS18B20_trials
MQTTstore
V3.1.3
V3.1.2
V3.1.1
V3.1.0
V3.0.3
V3.0.3a
V3.0.2
V3.0.1
V2.3.6n
V2.3.6c
V2.3.5
V2.3.4
V2.3.3
V2.3.2
V2.3.1
V2.3.0
V2.2.3
V2.2.2
V2.2
JustinMods
No related merge requests found
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
Arduino/BTCDieselHeater/src/OLED/BasicScreen.cpp
+2
-2
Arduino/BTCDieselHeater/src/OLED/BasicScreen.cpp
Arduino/BTCDieselHeater/src/OLED/ClockScreen.cpp
+17
-0
Arduino/BTCDieselHeater/src/OLED/ClockScreen.cpp
Arduino/BTCDieselHeater/src/OLED/HomeMenuSelScreen.cpp
+173
-0
Arduino/BTCDieselHeater/src/OLED/HomeMenuSelScreen.cpp
Arduino/BTCDieselHeater/src/OLED/HomeMenuSelScreen.h
+46
-0
Arduino/BTCDieselHeater/src/OLED/HomeMenuSelScreen.h
Arduino/BTCDieselHeater/src/OLED/OtherOptionsScreen.cpp
+11
-9
Arduino/BTCDieselHeater/src/OLED/OtherOptionsScreen.cpp
Arduino/BTCDieselHeater/src/OLED/OtherOptionsScreen.h
+1
-1
Arduino/BTCDieselHeater/src/OLED/OtherOptionsScreen.h
Arduino/BTCDieselHeater/src/OLED/ScreenManager.cpp
+7
-3
Arduino/BTCDieselHeater/src/OLED/ScreenManager.cpp
Arduino/BTCDieselHeater/src/Utility/NVStorage.cpp
+9
-5
Arduino/BTCDieselHeater/src/Utility/NVStorage.cpp
Arduino/BTCDieselHeater/src/Utility/NVStorage.h
+23
-5
Arduino/BTCDieselHeater/src/Utility/NVStorage.h
with
289 additions
and
25 deletions
+289
-25
Arduino/BTCDieselHeater/src/OLED/BasicScreen.cpp
View file @
480bd1b1
...
...
@@ -69,8 +69,8 @@ CBasicScreen::show()
{
CTransientFont
AF
(
_display
,
&
MAXIFONT
);
// temporarily use a large font
//
_printMenuText(_display.xCentre(), 23, msg, false, eCentreJustify);
_printMenuText
(
_display
.
xCentre
(),
25
,
msg
,
false
,
eCentreJustify
);
_printMenuText
(
_display
.
xCentre
(),
23
,
msg
,
false
,
eCentreJustify
);
//
_printMenuText(_display.xCentre(), 25, msg, false, eCentreJustify);
}
}
else
{
...
...
This diff is collapsed.
Click to expand it.
Arduino/BTCDieselHeater/src/OLED/ClockScreen.cpp
View file @
480bd1b1
...
...
@@ -107,6 +107,23 @@ CClockScreen::keyHandler(uint8_t event)
setGPIO
(
1
,
!
getGPIO
(
1
));
// toggle GPIO output #2
}
}
// hold CENTRE to toggle On/Off state
if
(
event
&
key_Centre
)
{
int
runstate
=
getHeaterInfo
().
getRunStateEx
();
if
(
runstate
)
{
// running, including cyclic mode idle
if
(
_keyRepeatCount
>
5
)
{
_keyRepeatCount
=
-
1
;
requestOff
();
}
}
else
{
// standard idle state
// standby, request ON
if
(
_keyRepeatCount
>
3
)
{
_keyRepeatCount
=
-
1
;
requestOn
();
}
}
}
}
}
// release event
...
...
This diff is collapsed.
Click to expand it.
Arduino/BTCDieselHeater/src/OLED/HomeMenuSelScreen.cpp
0 → 100644
View file @
480bd1b1
/*
* This file is part of the "bluetoothheater" distribution
* (https://gitlab.com/mrjones.id.au/bluetoothheater)
*
* Copyright (C) 2018 Ray Jones <ray@mrjones.id.au>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
#include "128x64OLED.h"
#include "HomeMenuSelScreen.h"
#include "KeyPad.h"
#include "../Protocol/helpers.h"
#include "../Utility/UtilClasses.h"
#include "../Utility/NVStorage.h"
#include "../Utility/GPIO.h"
#include "fonts/Icons.h"
CHomeMenuSelScreen
::
CHomeMenuSelScreen
(
C128x64_OLED
&
display
,
CScreenManager
&
mgr
)
:
CPasswordScreen
(
display
,
mgr
)
{
}
void
CHomeMenuSelScreen
::
onSelect
()
{
CScreenHeader
::
onSelect
();
_rowSel
=
0
;
_action
=
NVstore
.
getHomeMenu
();
}
void
CHomeMenuSelScreen
::
_initUI
()
{
}
bool
CHomeMenuSelScreen
::
show
()
{
char
msg
[
16
];
_display
.
clearDisplay
();
if
(
!
CPasswordScreen
::
show
())
{
// for showing "saving settings"
if
(
_rowSel
==
4
)
{
_printInverted
(
_display
.
xCentre
(),
0
,
" Saving Settings "
,
true
,
eCentreJustify
);
_printMenuText
(
_display
.
xCentre
(),
35
,
"Press UP to"
,
false
,
eCentreJustify
);
_printMenuText
(
_display
.
xCentre
(),
43
,
"confirm save"
,
false
,
eCentreJustify
);
}
else
{
_printInverted
(
_display
.
xCentre
(),
0
,
" Home Menu Actions "
,
true
,
eCentreJustify
);
_printMenuText
(
66
,
14
,
"On timeout:"
,
false
,
eRightJustify
);
switch
(
_action
.
onTimeout
)
{
case
0
:
strcpy
(
msg
,
"Default"
);
break
;
case
1
:
strcpy
(
msg
,
"Detailed"
);
break
;
case
2
:
strcpy
(
msg
,
"Basic"
);
break
;
case
3
:
strcpy
(
msg
,
"Clock"
);
break
;
}
_printMenuText
(
70
,
14
,
msg
,
_rowSel
==
3
);
_printMenuText
(
66
,
26
,
"On Start:"
,
false
,
eRightJustify
);
switch
(
_action
.
onStart
)
{
case
0
:
strcpy
(
msg
,
"Default"
);
break
;
case
1
:
strcpy
(
msg
,
"Detailed"
);
break
;
case
2
:
strcpy
(
msg
,
"Basic"
);
break
;
case
3
:
strcpy
(
msg
,
"Clock"
);
break
;
}
_printMenuText
(
70
,
26
,
msg
,
_rowSel
==
2
);
_printMenuText
(
66
,
38
,
"On Stop:"
,
false
,
eRightJustify
);
switch
(
_action
.
onStop
)
{
case
0
:
strcpy
(
msg
,
"Default"
);
break
;
case
1
:
strcpy
(
msg
,
"Detailed"
);
break
;
case
2
:
strcpy
(
msg
,
"Basic"
);
break
;
case
3
:
strcpy
(
msg
,
"Clock"
);
break
;
}
_printMenuText
(
70
,
38
,
msg
,
_rowSel
==
1
);
_printMenuText
(
_display
.
xCentre
(),
53
,
"
\021
Exit
\020
"
,
_rowSel
==
0
,
eCentreJustify
);
}
}
return
true
;
}
bool
CHomeMenuSelScreen
::
keyHandler
(
uint8_t
event
)
{
if
(
event
&
keyPressed
)
{
// UP press
if
(
event
&
key_Up
)
{
if
(
_rowSel
==
4
)
{
_showStoringMessage
();
NVstore
.
setHomeMenu
(
_action
);
saveNV
();
_rowSel
=
0
;
}
else
{
_rowSel
++
;
UPPERLIMIT
(
_rowSel
,
3
);
}
}
// UP press
if
(
event
&
key_Down
)
{
_rowSel
--
;
LOWERLIMIT
(
_rowSel
,
0
);
}
// CENTRE press
if
(
event
&
key_Centre
)
{
if
(
_rowSel
==
0
)
{
_ScreenManager
.
selectMenu
(
CScreenManager
::
RootMenuLoop
);
// force return to main menu
}
else
{
_rowSel
=
4
;
}
}
// LEFT press
if
(
event
&
key_Left
)
{
if
(
_rowSel
==
0
)
_ScreenManager
.
prevMenu
();
else
adjust
(
-
1
);
}
// RIGHT press
if
(
event
&
key_Right
)
{
if
(
_rowSel
==
0
)
_ScreenManager
.
nextMenu
();
else
adjust
(
+
1
);
}
}
_ScreenManager
.
reqUpdate
();
return
true
;
}
void
CHomeMenuSelScreen
::
adjust
(
int
dir
)
{
switch
(
_rowSel
)
{
case
1
:
_action
.
onStop
+=
dir
;
ROLLLOWERLIMIT
(
_action
.
onStop
,
0
,
3
);
ROLLUPPERLIMIT
(
_action
.
onStop
,
3
,
0
);
break
;
case
2
:
_action
.
onStart
+=
dir
;
ROLLLOWERLIMIT
(
_action
.
onStart
,
0
,
3
);
ROLLUPPERLIMIT
(
_action
.
onStart
,
3
,
0
);
break
;
case
3
:
_action
.
onTimeout
+=
dir
;
ROLLLOWERLIMIT
(
_action
.
onTimeout
,
0
,
3
);
ROLLUPPERLIMIT
(
_action
.
onTimeout
,
3
,
0
);
break
;
}
}
This diff is collapsed.
Click to expand it.
Arduino/BTCDieselHeater/src/OLED/HomeMenuSelScreen.h
0 → 100644
View file @
480bd1b1
/*
* This file is part of the "bluetoothheater" distribution
* (https://gitlab.com/mrjones.id.au/bluetoothheater)
*
* Copyright (C) 2018 Ray Jones <ray@mrjones.id.au>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
#ifndef __HOMEMENUSELSCREEN_H__
#define __HOMEMENUSELSCREEN_H__
#include <stdint.h>
#include "PasswordScreen.h"
#include "../Utility/NVStorage.h"
class
C128x64_OLED
;
class
CScreenManager
;
class
CHomeMenuSelScreen
:
public
CPasswordScreen
{
int
_rowSel
;
sHomeMenuActions
_action
;
void
_initUI
();
public:
CHomeMenuSelScreen
(
C128x64_OLED
&
display
,
CScreenManager
&
mgr
);
bool
show
();
bool
keyHandler
(
uint8_t
event
);
void
onSelect
();
void
adjust
(
int
dir
);
};
#endif
This diff is collapsed.
Click to expand it.
Arduino/BTCDieselHeater/src/OLED/OtherOptionsScreen.cpp
View file @
480bd1b1
...
...
@@ -40,7 +40,7 @@ COtherOptionsScreen::onSelect()
CScreenHeader
::
onSelect
();
_rowSel
=
0
;
_frameRate
=
NVstore
.
getFrameRate
();
_homeMenu
=
NVstore
.
getHomeMenu
();
//
_homeMenu = NVstore.getHomeMenu();
}
void
...
...
@@ -69,14 +69,14 @@ COtherOptionsScreen::show()
sprintf
(
msg
,
"%dms"
,
_frameRate
);
_printMenuText
(
70
,
14
,
msg
,
_rowSel
==
2
);
_printMenuText
(
66
,
25
,
"Home menu:"
,
false
,
eRightJustify
);
/*
_printMenuText(66, 25, "Home menu:", false, eRightJustify);
switch(_homeMenu) {
case 0: strcpy(msg, "Default"); break;
case 1: strcpy(msg, "Detailed"); break;
case 2: strcpy(msg, "Basic"); break;
case 3: strcpy(msg, "Clock"); break;
}
_printMenuText
(
70
,
25
,
msg
,
_rowSel
==
1
);
_printMenuText(70, 25, msg, _rowSel == 1);
*/
_printMenuText
(
_display
.
xCentre
(),
53
,
"
\021
Exit
\020
"
,
_rowSel
==
0
,
eCentreJustify
);
}
...
...
@@ -94,18 +94,20 @@ COtherOptionsScreen::keyHandler(uint8_t event)
if
(
_rowSel
==
4
)
{
_showStoringMessage
();
NVstore
.
setFrameRate
(
_frameRate
);
NVstore
.
setHomeMenu
(
_homeMenu
);
//
NVstore.setHomeMenu(_homeMenu);
saveNV
();
_rowSel
=
0
;
}
else
{
_rowSel
++
;
// _rowSel++;
_rowSel
=
2
;
UPPERLIMIT
(
_rowSel
,
2
);
}
}
// UP press
if
(
event
&
key_Down
)
{
_rowSel
--
;
// _rowSel--;
_rowSel
=
0
;
LOWERLIMIT
(
_rowSel
,
0
);
}
// CENTRE press
...
...
@@ -143,9 +145,9 @@ COtherOptionsScreen::adjust(int dir)
{
switch
(
_rowSel
)
{
case
1
:
_homeMenu
+=
dir
;
ROLLLOWERLIMIT
(
_homeMenu
,
0
,
3
);
ROLLUPPERLIMIT
(
_homeMenu
,
3
,
0
);
//
_homeMenu += dir;
//
ROLLLOWERLIMIT(_homeMenu, 0, 3);
//
ROLLUPPERLIMIT(_homeMenu, 3, 0);
break
;
case
2
:
_frameRate
+=
dir
*
50
;
...
...
This diff is collapsed.
Click to expand it.
Arduino/BTCDieselHeater/src/OLED/OtherOptionsScreen.h
View file @
480bd1b1
...
...
@@ -33,7 +33,7 @@ class COtherOptionsScreen : public CPasswordScreen
{
int
_rowSel
;
uint16_t
_frameRate
;
uint8_t
_homeMenu
;
//
uint8_t _homeMenu;
void
_initUI
();
public:
COtherOptionsScreen
(
C128x64_OLED
&
display
,
CScreenManager
&
mgr
);
...
...
This diff is collapsed.
Click to expand it.
Arduino/BTCDieselHeater/src/OLED/ScreenManager.cpp
View file @
480bd1b1
...
...
@@ -37,6 +37,7 @@
#include "InheritSettingsScreen.h"
#include "GPIOScreen.h"
#include "VersionInfoScreen.h"
#include "HomeMenuSelScreen.h"
#include "OtherOptionsScreen.h"
#include <Wire.h>
#include "../cfg/pins.h"
...
...
@@ -216,6 +217,7 @@ CScreenManager::begin(bool bNoClock)
menuloop
.
push_back
(
new
CThermostatModeScreen
(
*
_pDisplay
,
*
this
));
// experimental settings screen
menuloop
.
push_back
(
new
CGPIOScreen
(
*
_pDisplay
,
*
this
));
// GPIO settings screen
menuloop
.
push_back
(
new
CVersionInfoScreen
(
*
_pDisplay
,
*
this
));
// GPIO settings screen
menuloop
.
push_back
(
new
CHomeMenuSelScreen
(
*
_pDisplay
,
*
this
));
// Home menu settings screen
menuloop
.
push_back
(
new
COtherOptionsScreen
(
*
_pDisplay
,
*
this
));
// Other options screen
_Screens
.
push_back
(
menuloop
);
...
...
@@ -259,9 +261,11 @@ CScreenManager::checkUpdate()
// return to those upon timeout, otherwise return to Basic Control screen
if
(
_rootMenu
>
2
)
{
_rootMenu
=
_subMenu
=
1
;
if
(
NVstore
.
getHomeMenu
())
{
// allow user to override defualt screen
DebugPort
.
print
(
"Falling back to user home screen #"
);
DebugPort
.
println
(
NVstore
.
getHomeMenu
()
-
1
);
_rootMenu
=
_subMenu
=
NVstore
.
getHomeMenu
()
-
1
;
uint8_t
userHomeMenu
=
NVstore
.
getHomeMenu
().
onTimeout
;
if
(
userHomeMenu
)
{
// allow user to override defualt screen
userHomeMenu
--
;
DebugPort
.
print
(
"Falling back to user home screen #"
);
DebugPort
.
println
(
userHomeMenu
);
_rootMenu
=
_subMenu
=
userHomeMenu
;
}
}
_enterScreen
();
...
...
This diff is collapsed.
Click to expand it.
Arduino/BTCDieselHeater/src/Utility/NVStorage.cpp
View file @
480bd1b1
...
...
@@ -351,14 +351,14 @@ CHeaterStorage::setFrameRate(uint16_t val)
_calValues
.
Options
.
FrameRate
=
val
;
}
uint8_t
CHeaterStorage
::
getHomeMenu
()
const
sHomeMenuActions
&
CHeaterStorage
::
getHomeMenu
()
const
{
return
_calValues
.
Options
.
HomeMenu
;
}
void
CHeaterStorage
::
setHomeMenu
(
uint8_t
val
)
CHeaterStorage
::
setHomeMenu
(
sHomeMenuActions
val
)
{
_calValues
.
Options
.
HomeMenu
=
val
;
}
...
...
@@ -485,7 +485,9 @@ CESP32HeaterStorage::loadUI()
validatedLoad
(
"GPIOinMode"
,
_calValues
.
Options
.
GPIOinMode
,
0
,
u8inBounds
,
0
,
3
);
validatedLoad
(
"GPIOoutMode"
,
_calValues
.
Options
.
GPIOoutMode
,
0
,
u8inBounds
,
0
,
2
);
validatedLoad
(
"GPIOalgMode"
,
_calValues
.
Options
.
GPIOalgMode
,
0
,
u8inBounds
,
0
,
2
);
validatedLoad
(
"HomeMenu"
,
_calValues
.
Options
.
HomeMenu
,
0
,
u8inBounds
,
0
,
3
);
validatedLoad
(
"HomeMenuonTimeout"
,
_calValues
.
Options
.
HomeMenu
.
onTimeout
,
0
,
u8inBounds
,
0
,
3
);
validatedLoad
(
"HomeMenuonStart"
,
_calValues
.
Options
.
HomeMenu
.
onStart
,
0
,
u8inBounds
,
0
,
3
);
validatedLoad
(
"HomeMenuonStop"
,
_calValues
.
Options
.
HomeMenu
.
onStop
,
0
,
u8inBounds
,
0
,
3
);
validatedLoad
(
"FrameRate"
,
_calValues
.
Options
.
FrameRate
,
1000
,
u16inBounds
,
300
,
1500
);
preferences
.
end
();
}
...
...
@@ -503,7 +505,9 @@ CESP32HeaterStorage::saveUI()
preferences
.
putUChar
(
"GPIOinMode"
,
_calValues
.
Options
.
GPIOinMode
);
preferences
.
putUChar
(
"GPIOoutMode"
,
_calValues
.
Options
.
GPIOoutMode
);
preferences
.
putUChar
(
"GPIOalgMode"
,
_calValues
.
Options
.
GPIOalgMode
);
preferences
.
putUChar
(
"HomeMenu"
,
_calValues
.
Options
.
HomeMenu
);
preferences
.
putUChar
(
"HomeMenuonTimeout"
,
_calValues
.
Options
.
HomeMenu
.
onTimeout
);
preferences
.
putUChar
(
"HomeMenuonStart"
,
_calValues
.
Options
.
HomeMenu
.
onStart
);
preferences
.
putUChar
(
"HomeMenuonStop"
,
_calValues
.
Options
.
HomeMenu
.
onStop
);
preferences
.
putUShort
(
"FrameRate"
,
_calValues
.
Options
.
FrameRate
);
preferences
.
end
();
}
...
...
This diff is collapsed.
Click to expand it.
Arduino/BTCDieselHeater/src/Utility/NVStorage.h
View file @
480bd1b1
...
...
@@ -62,6 +62,24 @@ struct sHeater {
};
};
struct
sHomeMenuActions
{
uint8_t
onTimeout
;
uint8_t
onStart
;
uint8_t
onStop
;
bool
valid
()
{
bool
retval
=
true
;
retval
&=
onTimeout
<
4
;
retval
&=
onStart
<
4
;
retval
&=
onStop
<
4
;
return
retval
;
}
void
init
()
{
onTimeout
=
0
;
onStart
=
0
;
onStop
=
0
;
}
};
struct
sBTCoptions
{
long
DimTime
;
uint8_t
degF
;
...
...
@@ -73,7 +91,7 @@ struct sBTCoptions {
uint8_t
GPIOoutMode
;
uint8_t
GPIOalgMode
;
uint16_t
FrameRate
;
uint8_t
HomeMenu
;
sHomeMenuActions
HomeMenu
;
bool
valid
()
{
bool
retval
=
true
;
...
...
@@ -86,7 +104,7 @@ struct sBTCoptions {
retval
&=
GPIOinMode
<
4
;
retval
&=
GPIOoutMode
<
3
;
retval
&=
(
FrameRate
>=
300
)
&&
(
FrameRate
<=
1500
);
retval
&=
HomeMenu
<
4
;
retval
&=
HomeMenu
.
valid
()
;
return
retval
;
}
void
init
()
{
...
...
@@ -100,7 +118,7 @@ struct sBTCoptions {
GPIOoutMode
=
0
;
GPIOalgMode
=
0
;
FrameRate
=
1000
;
HomeMenu
=
0
;
HomeMenu
.
init
()
;
};
};
...
...
@@ -159,7 +177,7 @@ public:
GPIOoutModes
getGPIOoutMode
();
GPIOalgModes
getGPIOalgMode
();
uint16_t
getFrameRate
();
uint8_t
getHomeMenu
();
const
sHomeMenuActions
&
getHomeMenu
()
const
;
void
setPmin
(
float
);
void
setPmax
(
float
);
...
...
@@ -181,7 +199,7 @@ public:
void
setGPIOoutMode
(
unsigned
char
val
);
void
setGPIOalgMode
(
unsigned
char
val
);
void
setFrameRate
(
uint16_t
val
);
void
setHomeMenu
(
uint8_t
val
);
void
setHomeMenu
(
sHomeMenuActions
val
);
void
getTimerInfo
(
int
idx
,
sTimer
&
timerInfo
);
void
setTimerInfo
(
int
idx
,
const
sTimer
&
timerInfo
);
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Projects
Groups
Snippets
Help