Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Dashboard
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Service Desk
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
egorguslyan
Dashboard
Commits
80e37f6f
Commit
80e37f6f
authored
3 years ago
by
egorguslyan
Browse files
Options
Downloads
Plain Diff
Merge branch 'untested' into 'master'
Sleep mode, ignore small ppm values See merge request
!2
parents
badd95dd
4d99d43a
Branches
Branches containing commit
Tags
Tags containing commit
2 merge requests
!7
Sync README
,
!2
Sleep mode, ignore small ppm values
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Dashboard/Dashboard.ino
+184
-37
184 additions, 37 deletions
Dashboard/Dashboard.ino
Dashboard/config.h
+8
-2
8 additions, 2 deletions
Dashboard/config.h
with
192 additions
and
39 deletions
Dashboard/Dashboard.ino
+
184
−
37
View file @
80e37f6f
...
...
@@ -55,6 +55,12 @@
/************Mem map*************/
// | 0 | Panel orientation |
// | 1 | Is RTC initialized |
// | 2 | Sleep hour |
// | 3 | Sleep minute |
// | 4 | Wake up hour |
// | 5 | Wake up minute |
// | 6 | Pomodoro work minutes |
// | 7 | Pomodoro break minutes |
/********************************/
/*************Marcos*************/
...
...
@@ -107,20 +113,28 @@ const uint8_t special_key = 0b11011100; // Just a random number (it's actually t
// Structure for all global variables
struct
{
// Matrix
PANEL_ORIENTATION
panelOrientation
:
2
;
// Swipe panel orientation
SCREEN
currentScreen
;
// Current screen's address in the screens table
uint8_t
currentState
;
// Current state of current screen
ANIMATION
animation
:
3
;
// The way to animate
uint8_t
prepare
:
2
;
// 0 — Draw current screen; 1 — Call prepare function; 2 — Animate
// mData leds[NUMLEDS];
mData
leds
[
0
];
// Sorry, but this buffer takes a lot of memory
// Service
uint32_t
timer
;
// Global timer for screens
char
S
[
64
];
// Temp string
uint8_t
unpreparedEEPROM
:
1
;
// True if EEPROM contains special_key in each cell
uint8_t
sleep
:
1
;
// Sleep mode
// Gestures events
uint8_t
tapLeft
:
1
;
// True when tapped left
uint8_t
tapRight
:
1
;
// True when tapped right
uint8_t
swipeLeft
:
1
;
// True when swiped from right to left
uint8_t
swipeRight
:
1
;
// True when swiped from left to right
uint8_t
holdLeft
:
1
;
// True when left holded
uint8_t
holdRight
:
1
;
// True when right holded
// mData leds[NUMLEDS];
mData
leds
[
0
];
// Sorry, but this buffer takes a lot of memory
// CO₂
uint16_t
ppm
[
WIDTH
];
// CO₂ ppm
...
...
@@ -139,14 +153,18 @@ struct
// Pomodoro
uint32_t
pomodoroTimer
;
// Timer milliseconds
uint8_t
pomodoroMinutes
:
5
;
// Current minutes, also used for setting work
uint8_t
pomodoroMinutes
:
6
;
// Current minutes, also used for setting work
uint8_t
pomodoroSeconds
:
6
;
// Current seconds, also used for setting break
uint8_t
pomodoroSavedWork
:
5
;
// Last entered minutes
uint8_t
pomodoroSavedBreak
:
5
;
// Last entered seconds
uint8_t
pomodoroSavedWork
:
6
;
// Last entered minutes
uint8_t
pomodoroSavedBreak
:
6
;
// Last entered seconds
uint8_t
pomodoroRunning
:
1
;
// True when timer is running
uint8_t
pomodoroState
:
1
;
// False for a work, true for a break
char
S
[
64
];
// Sleep mode
uint8_t
sleepHour
:
5
;
uint8_t
sleepMinute
:
6
;
uint8_t
wakeupHour
:
5
;
uint8_t
wakeupMinute
:
6
;
}
globalVars
;
microLED
<
NUMLEDS
,
LEDsPin
,
MLED_NO_CLOCK
,
MODEL
,
CLI_AVER
...
...
@@ -278,37 +296,147 @@ void setup()
PRINTLN_DEBUG
(
F
(
"Hello"
));
// Reading settings from nonvolatile memory
uint8_t
eepromData
;
eepromData
=
EEPROM
.
read
(
0
);
PRINTLN_DEBUG
(
eepromData
&
0b11111100
);
PRINTLN_DEBUG
(
special_key
);
PRINTLN_DEBUG
(
eepromData
&
0b00000011
);
if
(((
eepromData
&
0b11111100
)
==
special_key
)
&&
((
eepromData
&
0b00000011
)
<
3
))
globalVars
.
panelOrientation
=
(
PANEL_ORIENTATION
)(
eepromData
&
0b00000011
);
else
globalVars
.
panelOrientation
=
PANEL_UNKNOWN
;
eepromData
=
EEPROM
.
read
(
1
);
PRINTLN_DEBUG
(
eepromData
);
if
(
!
(
eepromData
==
special_key
))
uint8_t
eepromData
,
i
;
for
(
i
=
0
;
i
<=
7
;
i
++
)
{
PRINTLN_DEBUG
(
F
(
"RTC UPDATED"
));
EEPROM
.
write
(
1
,
special_key
);
rtc
.
setTime
(
COMPILE_TIME
);
eepromData
=
EEPROM
.
read
(
i
);
switch
(
i
)
{
// Panel orientation
case
0
:
{
if
(((
eepromData
&
0b11111100
)
==
(
special_key
&
0b11111100
))
&&
((
eepromData
&
0b00000011
)
<
3
))
globalVars
.
panelOrientation
=
(
PANEL_ORIENTATION
)(
eepromData
&
0b00000011
);
else
{
EEPROM
.
write
(
i
,
special_key
);
globalVars
.
panelOrientation
=
PANEL_UNKNOWN
;
globalVars
.
unpreparedEEPROM
=
true
;
}
}
break
;
// Is RTC ready?
case
1
:
{
if
(
!
(
eepromData
==
special_key
)
||
globalVars
.
unpreparedEEPROM
)
{
EEPROM
.
write
(
i
,
special_key
);
rtc
.
setTime
(
COMPILE_TIME
);
globalVars
.
unpreparedEEPROM
=
true
;
}
}
break
;
// Sleep
case
2
:
{
if
(((
eepromData
&
0b11100000
)
==
(
special_key
&
0b11100000
))
&&
((
eepromData
&
0b00011111
)
<
24
))
globalVars
.
sleepHour
=
eepromData
&
0b00011111
;
else
{
EEPROM
.
write
(
i
,
(
eepromData
&
0b11100000
)
|
SLEEPHOUR
);
globalVars
.
sleepHour
=
SLEEPHOUR
;
globalVars
.
unpreparedEEPROM
=
true
;
}
}
break
;
case
4
:
{
if
(((
eepromData
&
0b11100000
)
==
(
special_key
&
0b11100000
))
&&
((
eepromData
&
0b00011111
)
<
24
))
globalVars
.
wakeupHour
=
eepromData
&
0b00011111
;
else
{
EEPROM
.
write
(
i
,
(
eepromData
&
0b11100000
)
|
WAKEUPHOUR
);
globalVars
.
wakeupHour
=
WAKEUPHOUR
;
globalVars
.
unpreparedEEPROM
=
true
;
}
}
break
;
// Wake up
case
3
:
{
if
(((
eepromData
&
0b11000000
)
==
(
special_key
&
0b11000000
))
&&
((
eepromData
&
0b00111111
)
<
60
))
globalVars
.
sleepMinute
=
eepromData
&
0b00111111
;
else
{
EEPROM
.
write
(
i
,
(
eepromData
&
0b11000000
)
|
SLEEPMINUTE
);
globalVars
.
sleepMinute
=
SLEEPMINUTE
;
globalVars
.
unpreparedEEPROM
=
true
;
}
}
break
;
case
5
:
{
if
(((
eepromData
&
0b11000000
)
==
(
special_key
&
0b11000000
))
&&
((
eepromData
&
0b00111111
)
<
60
))
globalVars
.
wakeupMinute
=
eepromData
&
0b00111111
;
else
{
EEPROM
.
write
(
i
,
(
eepromData
&
0b11000000
)
|
WAKEUPMINUTE
);
globalVars
.
wakeupMinute
=
WAKEUPMINUTE
;
globalVars
.
unpreparedEEPROM
=
true
;
}
}
break
;
// Pomodoro minutes
case
6
:
{
if
(((
eepromData
&
0b11000000
)
==
(
special_key
&
0b11000000
))
&&
((
eepromData
&
0b00111111
)
<
60
))
globalVars
.
pomodoroSavedWork
=
eepromData
&
0b00111111
;
else
{
EEPROM
.
write
(
i
,
(
eepromData
&
0b11000000
)
|
POMODORO_WORK
);
globalVars
.
pomodoroSavedWork
=
POMODORO_WORK
;
globalVars
.
unpreparedEEPROM
=
true
;
}
}
break
;
case
7
:
{
if
(((
eepromData
&
0b11000000
)
==
(
special_key
&
0b11000000
))
&&
((
eepromData
&
0b00111111
)
<
60
))
globalVars
.
pomodoroSavedBreak
=
eepromData
&
0b00111111
;
else
{
EEPROM
.
write
(
i
,
(
eepromData
&
0b11000000
)
|
POMODORO_BREAK
);
globalVars
.
pomodoroSavedBreak
=
POMODORO_BREAK
;
globalVars
.
unpreparedEEPROM
=
true
;
}
}
break
;
}
}
PRINTLN_DEBUG
(
globalVars
.
panelOrientation
);
// Set start screen
globalVars
.
currentScreen
=
startWith
;
// Start without animation
globalVars
.
animation
=
NO_ANIMATION
;
globalVars
.
prepare
=
true
;
// Write default pomodoro times
globalVars
.
pomodoroSavedWork
=
POMODORO_WORK
;
globalVars
.
pomodoroSavedBreak
=
POMODORO_BREAK
;
globalVars
.
minPPM
=
bit
(
13
)
-
1
;
delay
(
500
);
// Measure PPM
globalVars
.
freshPPM
=
0
;
globalVars
.
ppm
[
0
]
=
globalVars
.
minPPM
=
globalVars
.
maxPPM
=
co2
.
getPPM
();
}
void
checkSleep
(
DateTime
*
DT
)
{
if
((
globalVars
.
sleepHour
>
globalVars
.
wakeupHour
)
||
((
globalVars
.
sleepHour
==
globalVars
.
wakeupHour
)
&&
(
globalVars
.
sleepMinute
>=
globalVars
.
wakeupMinute
)))
{
globalVars
.
sleep
=
(((
DT
->
hour
>
globalVars
.
sleepHour
)
||
((
DT
->
hour
==
globalVars
.
sleepHour
)
&&
(
DT
->
minute
>=
globalVars
.
sleepMinute
)))
||
((
DT
->
hour
<
globalVars
.
wakeupHour
)
||
((
DT
->
hour
==
globalVars
.
wakeupHour
)
&&
(
DT
->
minute
<
globalVars
.
wakeupMinute
))));
}
else
{
globalVars
.
sleep
=
(((
DT
->
hour
>
globalVars
.
sleepHour
)
||
((
DT
->
hour
==
globalVars
.
sleepHour
)
&&
(
DT
->
minute
>=
globalVars
.
sleepMinute
)))
&&
((
DT
->
hour
<
globalVars
.
wakeupHour
)
||
((
DT
->
hour
==
globalVars
.
wakeupHour
)
&&
(
DT
->
minute
<
globalVars
.
wakeupMinute
))));
}
}
void
loop
()
...
...
@@ -335,17 +463,23 @@ void loop()
{
timer0
=
millis
();
PRINT_DEBUG
(
F
(
"Measured CO2 "
));
TIMER
(
timer1
,
GRAPH_UPDATE_TIME
)
uint16_t
measuredPPM
=
co2
.
getPPM
();
if
(
measuredPPM
>
100
)
{
timer1
=
millis
();
globalVars
.
freshPPM
++
;
if
(
globalVars
.
freshPPM
==
WIDTH
)
globalVars
.
freshPPM
=
0
;
PRINT_DEBUG
(
F
(
"and shifted array "
));
TIMER
(
timer1
,
GRAPH_UPDATE_TIME
)
{
timer1
=
millis
();
globalVars
.
freshPPM
++
;
if
(
globalVars
.
freshPPM
==
WIDTH
)
globalVars
.
freshPPM
=
0
;
PRINT_DEBUG
(
F
(
"and shifted array "
));
}
globalVars
.
ppm
[
globalVars
.
freshPPM
]
=
measuredPPM
;
if
(
globalVars
.
ppm
[
globalVars
.
freshPPM
]
>
globalVars
.
maxPPM
)
globalVars
.
maxPPM
=
globalVars
.
ppm
[
globalVars
.
freshPPM
];
if
(
globalVars
.
ppm
[
globalVars
.
freshPPM
]
<
globalVars
.
minPPM
)
globalVars
.
minPPM
=
globalVars
.
ppm
[
globalVars
.
freshPPM
];
PRINTLN_DEBUG
(
globalVars
.
ppm
[
globalVars
.
freshPPM
]);
}
globalVars
.
ppm
[
globalVars
.
freshPPM
]
=
co2
.
getPPM
();
if
(
globalVars
.
ppm
[
globalVars
.
freshPPM
]
>
globalVars
.
maxPPM
)
globalVars
.
maxPPM
=
globalVars
.
ppm
[
globalVars
.
freshPPM
];
if
(
globalVars
.
ppm
[
globalVars
.
freshPPM
]
<
globalVars
.
minPPM
)
globalVars
.
minPPM
=
globalVars
.
ppm
[
globalVars
.
freshPPM
];
PRINTLN_DEBUG
(
globalVars
.
ppm
[
globalVars
.
freshPPM
]);
}
// Notify when ppm is high
...
...
@@ -372,7 +506,10 @@ void loop()
#endif
globalVars
.
minutes
=
DTtmp
.
minute
;
if
(
globalVars
.
seconds
!=
DTtmp
.
second
)
{
timer3
=
millis
();
checkSleep
(
&
DTtmp
);
}
globalVars
.
seconds
=
DTtmp
.
second
;
PRINTLN_DEBUG
(
F
(
"succesfuly"
));
}
...
...
@@ -417,6 +554,9 @@ void loop()
}
// Display
static
uint32_t
timer5
=
0
;
TIMER
(
timer5
,
10000
){}
else
globalVars
.
sleep
=
false
;
switch
(
globalVars
.
prepare
)
{
case
1
:
...
...
@@ -431,7 +571,13 @@ void loop()
PRINT_DEBUG
(
globalVars
.
currentScreen
);
PRINT_DEBUG
(
F
(
" state "
));
PRINT_DEBUG
(
globalVars
.
currentState
);
screens
[
globalVars
.
currentScreen
].
func
(
&
screens
[
globalVars
.
currentScreen
].
arg
);
if
(
globalVars
.
tapLeft
||
globalVars
.
tapRight
||
globalVars
.
holdLeft
||
globalVars
.
holdRight
||
globalVars
.
swipeLeft
||
globalVars
.
swipeRight
)
timer5
=
millis
();
if
(
globalVars
.
sleep
)
matrix
.
clear
();
else
screens
[
globalVars
.
currentScreen
].
func
(
&
screens
[
globalVars
.
currentScreen
].
arg
);
break
;
}
matrix
.
show
();
...
...
@@ -453,6 +599,7 @@ void loop()
timer2
=
0
;
timer3
=
0
;
timer4
=
0
;
timer5
=
0
;
buttons
(
1
);
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Dashboard/config.h
+
8
−
2
View file @
80e37f6f
#pragma once
// Native Language
#define LANG_RU_RU
//
#define LANG_RU_RU
// Time format (24, 12 and also every number)
#define TIME_FORMAT 24
// If true, it will display 24:00 instead of 00:00
...
...
@@ -56,4 +56,10 @@
// Pomodoro defaults
#define POMODORO_WORK 25
#define POMODORO_BREAK 5
\ No newline at end of file
#define POMODORO_BREAK 5
// Sleep/wake up hours
#define SLEEPHOUR 22
#define SLEEPMINUTE 0
#define WAKEUPHOUR 7
#define WAKEUPMINUTE 30
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment