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