Viking Skull Lamp
V1.0.1
Loading...
Searching...
No Matches
menu.hpp
Go to the documentation of this file.
1
/*
2
* Created on May 28 2022
3
*
4
* Copyright (c) 2022 - Daniel Hajnal
5
* hajnal.daniel96@gmail.com
6
* This file is part of the Viking Skull Lamp project.
7
* Modified 2022.06.27
8
*/
9
10
/*
11
MIT License
12
Copyright (c) 2022 Daniel Hajnal
13
Permission is hereby granted, free of charge, to any person obtaining a copy
14
of this software and associated documentation files (the "Software"), to deal
15
in the Software without restriction, including without limitation the rights
16
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
17
copies of the Software, and to permit persons to whom the Software is
18
furnished to do so, subject to the following conditions:
19
The above copyright notice and this permission notice shall be included in all
20
copies or substantial portions of the Software.
21
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
27
SOFTWARE.
28
*/
29
30
#ifndef MENU_HPP__
31
#define MENU_HPP__
32
33
#include "Arduino.h"
34
#include "
oled.hpp
"
35
#include <avr/pgmspace.h>
36
50
class
menuItem
{
51
52
public
:
53
56
enum
encoderState_t
{
57
NEXT
,
58
UP
,
59
DOWN
60
};
61
63
enum
menuStyle_t
{
64
NORMAL
,
65
INVERTED
66
};
67
71
menuItem
(
const
char
* name_p );
72
74
menuItem
*
up
= NULL;
75
77
menuItem
*
down
= NULL;
78
80
menuItem
*
next
= NULL;
81
85
bool
selectable
=
true
;
86
90
bool
selected
=
false
;
91
93
enum
menuStyle_t
style
=
NORMAL
;
94
100
void(*
actionFunc
)(
enum
encoderState_t
state ) = NULL;
101
107
void(*
drawFunc
)(
ssd1306
* oled ) = NULL;
108
111
const
char
*
name
= NULL;
112
113
private
:
114
115
};
116
121
class
menu
{
122
123
public
:
124
128
menu
(
ssd1306
* oled_p,
menuItem
* selectedItem_p );
129
132
void
draw
();
133
135
void
up
();
136
138
void
down
();
139
141
void
next
();
142
143
private
:
144
146
menuItem
*
selectedItem
= NULL;
147
149
ssd1306
*
oled
= NULL;
150
152
bool
changed
=
true
;
153
154
};
155
157
enum
lightMode_t
{
158
LIGHT_MODE_RAINBOW
,
159
LIGHT_MODE_CANDLE
,
160
LIGHT_MODE_PULSE
,
161
LIGHT_MODE_MUSIC
,
162
LIGHT_MODE_KOMODO
,
163
LIGHT_MODE_COLOR
,
164
};
165
167
extern
enum
lightMode_t
lightMode
;
168
170
extern
uint8_t
selectedColor
;
171
173
extern
uint8_t
lightBrightness
;
174
176
extern
bool
buzzerEnabled
;
177
179
extern
bool
clapSwitchEnabled
;
180
182
extern
bool
fogMachineEnabled
;
183
197
extern
uint8_t
fogTimer
;
198
201
void
menuInit
();
202
203
/*
204
____ __ _ _ __
205
/ __ )___ / /_ ____ __ __(_)___ __ _______ ____ _ _____ __________(_)___/ /__ _____
206
/ __ / _ \/ __ \/ __ `/ | / / / __ \/ / / / ___/ / __ \ | / / _ \/ ___/ ___/ / __ / _ \/ ___/
207
/ /_/ / __/ / / / /_/ /| |/ / / /_/ / /_/ / / / /_/ / |/ / __/ / / / / / /_/ / __(__ )
208
/_____/\___/_/ /_/\__,_/ |___/_/\____/\__,_/_/ \____/|___/\___/_/ /_/ /_/\__,_/\___/____/
209
210
*/
211
217
void
brightnessSelectFunction
(
enum
menuItem::encoderState_t
state );
218
224
void
brightnessSelectDrawFunction
(
ssd1306
* oled );
225
231
void
buzzerMenuSelectedFunction
(
enum
menuItem::encoderState_t
state );
232
238
void
clapMenuSelectedFunction
(
enum
menuItem::encoderState_t
state );
239
245
void
fogTimerSelectFunction
(
enum
menuItem::encoderState_t
state );
246
252
void
fogTimerSelectDrawFunction
(
ssd1306
* oled );
253
259
void
rainbowMenuSelectFunction
(
enum
menuItem::encoderState_t
state );
260
266
void
candleMenuSelectFunction
(
enum
menuItem::encoderState_t
state );
267
273
void
pulseMenuSelectFunction
(
enum
menuItem::encoderState_t
state );
274
280
void
musicMenuSelectFunction
(
enum
menuItem::encoderState_t
state );
281
287
void
komodoMenuSelectFunction
(
enum
menuItem::encoderState_t
state );
288
294
void
colorMenuSelectFunction
(
enum
menuItem::encoderState_t
state );
295
301
void
colorSelectFunction
(
enum
menuItem::encoderState_t
state );
302
308
void
colorSelectDrawFunction
(
ssd1306
* oled );
309
310
311
/*
312
__ ___ _ __ ___
313
/ |/ /___ _(_)___ / |/ /__ ____ __ __
314
/ /|_/ / __ `/ / __ \ / /|_/ / _ \/ __ \/ / / /
315
/ / / / /_/ / / / / / / / / / __/ / / / /_/ /
316
/_/ /_/\__,_/_/_/ /_/ /_/ /_/\___/_/ /_/\__,_/
317
318
*/
319
//---- Main menu content ----//
320
322
extern
menuItem
mainMenuItem
;
323
325
extern
menuItem
lightMenuItem
;
326
328
extern
menuItem
brightnessMenuItem
;
329
331
extern
menuItem
brightnessSelectItem
;
332
334
extern
menuItem
buzzerMenuItem
;
335
337
extern
menuItem
clapMenuItem
;
338
340
extern
menuItem
fogEnableMenuItem
;
341
343
extern
menuItem
fogTimerMenuItem
;
344
346
extern
menuItem
fogTimerSelectMenuItem
;
347
348
/*
349
__ _ __ __ __ ___ __
350
/ / (_)___ _/ /_ / /_ / |/ /___ ____/ /__
351
/ / / / __ `/ __ \/ __/ / /|_/ / __ \/ __ / _ \
352
/ /___/ / /_/ / / / / /_ / / / / /_/ / /_/ / __/
353
/_____/_/\__, /_/ /_/\__/ /_/ /_/\____/\__,_/\___/
354
/____/
355
*/
356
//---- Light mode menu content ----//
357
359
extern
menuItem
lightModeMenuItem
;
360
362
extern
menuItem
rainbowModeMenuItem
;
363
365
extern
menuItem
candleModeMenuItem
;
366
368
extern
menuItem
pulseModeMenuItem
;
369
371
extern
menuItem
musicModeMenuItem
;
372
374
extern
menuItem
komodoModeMenuItem
;
375
377
extern
menuItem
colorModeMenuItem
;
378
380
extern
menuItem
colorSelectMenuItem
;
381
382
#endif
menu
Menu Controller Class.
Definition:
menu.hpp:121
menu::selectedItem
menuItem * selectedItem
Pointer to the selected menu item.
Definition:
menu.hpp:146
menu::draw
void draw()
Redraw the menu to the display.
Definition:
menu.cpp:114
menu::up
void up()
Step te menu upwards if possible.
Definition:
menu.cpp:271
menu::down
void down()
Step te menu downwards if possible.
Definition:
menu.cpp:304
menu::next
void next()
Enter to the next menu if possible.
Definition:
menu.cpp:337
menu::changed
bool changed
Flag that shows if the content of the display is changed.
Definition:
menu.hpp:152
menu::oled
ssd1306 * oled
Pointer to the display controller object.
Definition:
menu.hpp:149
menuItem
Menu Item Class.
Definition:
menu.hpp:50
menuItem::menuStyle_t
menuStyle_t
Describes the style of the item drawing.
Definition:
menu.hpp:63
menuItem::INVERTED
@ INVERTED
The active pixel is black, the inactive is lit.
Definition:
menu.hpp:65
menuItem::NORMAL
@ NORMAL
The active pixel is lit, the inactive is black.
Definition:
menu.hpp:64
menuItem::next
menuItem * next
Pointer to the next neighbor.
Definition:
menu.hpp:80
menuItem::name
const char * name
It is a pointer to a string.
Definition:
menu.hpp:111
menuItem::style
enum menuStyle_t style
Menu style variable. By default it is set to NORMAL.
Definition:
menu.hpp:93
menuItem::actionFunc
void(* actionFunc)(enum encoderState_t state)
Function pointer to override the button action behaviour.
Definition:
menu.hpp:100
menuItem::drawFunc
void(* drawFunc)(ssd1306 *oled)
Function pointer to override the drawing behaviour.
Definition:
menu.hpp:107
menuItem::selected
bool selected
If set, a filled circle will appear on the right side, next to the item name.
Definition:
menu.hpp:90
menuItem::down
menuItem * down
Pointer to the lower neighbor.
Definition:
menu.hpp:77
menuItem::encoderState_t
encoderState_t
Used for actionFunc to pass the event as an argument.
Definition:
menu.hpp:56
menuItem::NEXT
@ NEXT
Encoder button pressed.
Definition:
menu.hpp:57
menuItem::DOWN
@ DOWN
Encoder rotated down.
Definition:
menu.hpp:59
menuItem::UP
@ UP
Encoder rotated up.
Definition:
menu.hpp:58
menuItem::up
menuItem * up
Pointer to the upper neighbor.
Definition:
menu.hpp:74
menuItem::selectable
bool selectable
If set, the item won't be selectable.
Definition:
menu.hpp:85
ssd1306
Display driver object.
Definition:
oled.hpp:156
lightModeMenuItem
menuItem lightModeMenuItem
Light Mode Menu item.
brightnessSelectDrawFunction
void brightnessSelectDrawFunction(ssd1306 *oled)
Draw override for brightness selection.
Definition:
menu.cpp:405
komodoMenuSelectFunction
void komodoMenuSelectFunction(enum menuItem::encoderState_t state)
Behaviour override for komodo menu select.
Definition:
menu.cpp:520
lightMenuItem
menuItem lightMenuItem
Light Menu item.
clapMenuItem
menuItem clapMenuItem
Clap Menu item.
brightnessSelectFunction
void brightnessSelectFunction(enum menuItem::encoderState_t state)
Behaviour override for brightness selection.
Definition:
menu.cpp:375
komodoModeMenuItem
menuItem komodoModeMenuItem
Komodo Mode Menu item.
lightMode
enum lightMode_t lightMode
It will store the user selected light mode.
Definition:
menu.cpp:44
clapMenuSelectedFunction
void clapMenuSelectedFunction(enum menuItem::encoderState_t state)
Behaviour override for clap menu.
Definition:
menu.cpp:640
colorSelectFunction
void colorSelectFunction(enum menuItem::encoderState_t state)
Behaviour override for color select menu.
Definition:
menu.cpp:560
lightBrightness
uint8_t lightBrightness
It will store the user selected brightness.
Definition:
menu.cpp:48
colorModeMenuItem
menuItem colorModeMenuItem
Color Mode Menu item.
colorSelectMenuItem
menuItem colorSelectMenuItem
Color Select item.
fogMachineEnabled
bool fogMachineEnabled
It will store the user selected state of the fog machine.
Definition:
menu.cpp:54
musicModeMenuItem
menuItem musicModeMenuItem
Music Mode Menu item.
fogTimerSelectMenuItem
menuItem fogTimerSelectMenuItem
Brightness Timer Select item.
brightnessMenuItem
menuItem brightnessMenuItem
Brightness Menu item.
rainbowModeMenuItem
menuItem rainbowModeMenuItem
Rainbow Mode Menu item.
candleMenuSelectFunction
void candleMenuSelectFunction(enum menuItem::encoderState_t state)
Behaviour override for candle menu select.
Definition:
menu.cpp:460
buzzerMenuSelectedFunction
void buzzerMenuSelectedFunction(enum menuItem::encoderState_t state)
Behaviour override for buzzer menu.
Definition:
menu.cpp:615
selectedColor
uint8_t selectedColor
It will store the user selected color.
Definition:
menu.cpp:46
menuInit
void menuInit()
Initialize the menu system.
Definition:
menu.cpp:807
fogTimerSelectDrawFunction
void fogTimerSelectDrawFunction(ssd1306 *oled)
Draw override for fog timer setting.
Definition:
menu.cpp:721
pulseMenuSelectFunction
void pulseMenuSelectFunction(enum menuItem::encoderState_t state)
Behaviour override for pulse menu select.
Definition:
menu.cpp:480
brightnessSelectItem
menuItem brightnessSelectItem
Brightness Select item.
fogTimerSelectFunction
void fogTimerSelectFunction(enum menuItem::encoderState_t state)
Behaviour override for fog timer setting menu.
Definition:
menu.cpp:691
buzzerEnabled
bool buzzerEnabled
It will store the user selected state of the buzzer.
Definition:
menu.cpp:50
colorSelectDrawFunction
void colorSelectDrawFunction(ssd1306 *oled)
Draw override for color select menu.
Definition:
menu.cpp:590
lightMode_t
lightMode_t
Lost of the different lighting effects.
Definition:
menu.hpp:157
LIGHT_MODE_MUSIC
@ LIGHT_MODE_MUSIC
Definition:
menu.hpp:161
LIGHT_MODE_RAINBOW
@ LIGHT_MODE_RAINBOW
Definition:
menu.hpp:158
LIGHT_MODE_KOMODO
@ LIGHT_MODE_KOMODO
Definition:
menu.hpp:162
LIGHT_MODE_COLOR
@ LIGHT_MODE_COLOR
Definition:
menu.hpp:163
LIGHT_MODE_PULSE
@ LIGHT_MODE_PULSE
Definition:
menu.hpp:160
LIGHT_MODE_CANDLE
@ LIGHT_MODE_CANDLE
Definition:
menu.hpp:159
clapSwitchEnabled
bool clapSwitchEnabled
It will store the user selected state of the clap switch.
Definition:
menu.cpp:52
colorMenuSelectFunction
void colorMenuSelectFunction(enum menuItem::encoderState_t state)
Behaviour override for color mode menu.
Definition:
menu.cpp:540
mainMenuItem
menuItem mainMenuItem
Main Menu text item.
buzzerMenuItem
menuItem buzzerMenuItem
Buzzer Menu item.
candleModeMenuItem
menuItem candleModeMenuItem
Candle Mode Menu item.
rainbowMenuSelectFunction
void rainbowMenuSelectFunction(enum menuItem::encoderState_t state)
Behaviour override for rainbow menu select.
Definition:
menu.cpp:440
fogEnableMenuItem
menuItem fogEnableMenuItem
Fog Enable Menu item.
fogTimer
uint8_t fogTimer
It will store the user selected humidification period.
Definition:
menu.cpp:56
pulseModeMenuItem
menuItem pulseModeMenuItem
Pulse Mode Menu item.
musicMenuSelectFunction
void musicMenuSelectFunction(enum menuItem::encoderState_t state)
Behaviour override for music menu select.
Definition:
menu.cpp:500
fogTimerMenuItem
menuItem fogTimerMenuItem
Fog Timer Menu item.
oled.hpp
Software
include
menu.hpp
|
|
|
© 2021-2022 Daniel Hajnal
|
Viking Skull Lamp V1.0.1
| Generated by:
on Sun Oct 16 2022
|
|
|
© 2021-2022 Daniel Hajnal
|
Viking Skull Lamp V1.0.1
| Generated by:
on Sun Oct 16 2022