Skip to content

Commit

Permalink
New Features!
Browse files Browse the repository at this point in the history
Added Submenu and Tile menu support and updated Documentation.
  • Loading branch information
The-Young-Maker committed Feb 28, 2024
1 parent 61d07c1 commit e291919
Show file tree
Hide file tree
Showing 7 changed files with 455 additions and 120 deletions.
153 changes: 132 additions & 21 deletions README.MD
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# OpenMenuOS Documentation

#### This library is continuously evolving, with numerous features and bug fixes in the pipeline. Stay tuned for exciting updates!

#### If you have any suggestions to enhance the library or encounter any bugs, please don't hesitate to create a new issue. Your contributions play a vital role in shaping the future of this library.

## Introduction

OpenMenuOS is a versatile open-source menu system for ESP32, designed to simplify the implementation of user interfaces in various applications. This documentation provides an overview of the OpenMenuOS library, including its features, usage, and customization options.
Expand Down Expand Up @@ -39,55 +43,162 @@ OpenMenuOS menu(
TFT Backlight Pin,
Display CS Pin,
Display DC Pin,
Display RST Pin,
Name of the item separated by a comma (You can go up to 20),
NULL
Display RST Pin
)
```

Example Use: `OpenMenuOS menu(10, 5, 12, 4, 21, 22, "Flashlight", "Profile", "Heat", "Reflow", "Settings", "Wifi", "Package", "Survival", "Other", NULL);`
Example Use:

`OpenMenuOS menu(10, 5, 12, 4, 21, 22, "Flashlight", "Profile", "Heat", "Reflow", "Settings", "Wifi", "Package", "Survival", "Other", NULL);`

### begin()

`menu.begin()`

Initializes the OpenMenuOS library. Call this function in the setup() function of your sketch.

### loop()

`menu.loop()`

The main loop function of the OpenMenuOS library. Call this function in the loop() function of your sketch. This function checks for button presses and handle the OTA.
## Function

#### Display Functions
void drawMenu(): Draws the menu on the display.
void drawSettingMenu(const char* items...): Draws the settings menu on the display.
void drawCanvasOnTFT(): Draws the canvas on the TFT display.
#### Button Handling
void checkForButtonPress(): Checks for button presses and handles navigation.
void checkSerial(): Checks for input from the serial monitor for configuring Wi-Fi settings.
#### Settings Management
void saveToEEPROM(): Saves settings to EEPROM memory.
void readFromEEPROM(): Reads settings from EEPROM memory.
#### Utility Functions
void printMenuToSerial(): Prints the menu items to the serial monitor.
int getCurrentScreen() const: Returns the current screen (0 for menu, 1 for settings).
int getSelectedItem() const: Returns the index of the selected menu item.
### Display Functions

#### drawMenu()

Draws the menu on the display.

Example:
```
menu.drawMenu(
Name of the item separated by a comma (You can go up to 20),
NULL
)
```

Example Use:

`menu.drawMenu("Flashlight", "Profile", "Heat", "Reflow", "Settings", "Wifi", "Package", "Survival", "Other", NULL);`

#### drawSubmenu()

Draws the menu on the display.

Example:
```
menu.drawSubmenu(
Name of the item separated by a comma (You can go up to 20),
NULL
)
```

Example Use:

`menu.drawMenu("Submenu_1", "Submenu_2", "Submenu_3", "Submenu_4", NULL);`

#### drawSettingMenu()

Draws the settings menu on the display.

Example:
```
menu.drawSettingMenu(
Name of the item separated by a comma (You can go up to 5),
NULL
)
```

Example Use:

`menu.drawSettingMenu("Light", "Sound", "Deep-Sleep", NULL);`

#### drawTileMenu()

Draws a tile menu on the display.

Example:
```
menu.drawSettingMenu(
Number of rows,
Number of columns,
Color of the tiles
)
```

Example Use:

`menu.drawTileMenu(2, 4, ST7735_GREEN);`

#### void drawCanvasOnTFT()

Draws the canvas on the TFT display.

### Button Handling

#### checkForButtonPress()

Checks for button presses and handles navigation.

#### checkSerial()

Checks for input from the serial monitor for configuring Wi-Fi settings.

### Settings Management

#### saveToEEPROM()

Saves settings to EEPROM memory.

#### readFromEEPROM()

Reads settings from EEPROM memory.

### Utility Functions

#### printMenuToSerial()

Prints the menu items to the serial monitor.

#### getCurrentScreen()

Returns the current screen (0 for menu, 1 for submenu).

#### getSelectedItem()

Returns the index of the selected menu item.

#### getCurrentScreenTileMenu()

Returns the current screen (0 for tile menu, 1 for tile submenu).

#### getSelectedItemTileMenu()

Returns the index of the selected tile menu item.

## Menu Navigation

#### Moving Through Menu Items:
Utilize the UP button to navigate through the menu items.

#### Selecting an Item:
Press the SELECT button to select a menu item.

#### Returning to Previous Menu:
Perform a long press on the SELECT button to return to the previous menu level.

## Customization

### Menu Icons

OpenMenuOS supports menu icons to enhance the visual presentation of menu items. Icons should be provided as 16x16 pixel bitmaps and stored in an `images.h` file. Define each icon as a constant array of bytes.

For the images, you can use [LVGL Image Converter](https://lvgl.io/tools/imageconverter) and in the "Color Format" section, choose "CF_RGB565A8".

### Additional Images

In addition to menu icons, OpenMenuOS allows for the integration of custom images or icons beyond menu items. These images can be used for boot screens, splash screens, or other graphical elements. Store additional images in the `images.h` file as constant arrays of bytes.


## Additional Notes
The library is still in beta. If you encounter any bugs or if you have suggestion, please create an issue on the [OpenMenuOS GitHub repository](https://github.com/The-Young-Maker/OpenMenuOS).
The library is still in beta. If you encounter any bugs or if you have any suggestion, please create an issue on the [OpenMenuOS GitHub repository](https://github.com/The-Young-Maker/OpenMenuOS).
Ensure that you have the necessary dependencies installed and configured in your Arduino IDE.
64 changes: 0 additions & 64 deletions examples/OpenMenuOS_Simple/OpenMenuOS.ino

This file was deleted.

64 changes: 64 additions & 0 deletions examples/OpenMenuOS_Simple/OpenMenuOS_Simple.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#include <OpenMenuOS.h> // Include the OpenMenuOS library
#include <Fonts/FreeMonoBold9pt7b.h> // Include the required fonts
#include <Fonts/FreeMono9pt7b.h>

// Create an instance of the OpenMenuOS class with button and display pins, along with menu item names
OpenMenuOS menu(10, 5, 12, 4, 21, 22); //btn_up, btn_sel, tft_bl, cs, dc, rst

void setup() {
Serial.begin(921600); // Initialize serial communication
menu.begin(); // Initialize the menu
}

void loop() {
menu.loop(); // Handle menu logic
menu.checkSerial(); // Check for serial input
menu.connectToWiFi(); // Attempt to connect to WiFi if enabled

// Display the menu if the current screen is the main menu (screen 0)
if (menu.getCurrentScreen() == 0) {
delay(100); // Small delay for stability
menu.drawMenu(true, "Tile Menu", "Submenu", "Settings", NULL); // Draw the main menu on the screen. Set to "true" to display the 16x16 images for the items, else, set to "false"
}
// If the current screen is a submenu (screen 1)
else if (menu.getCurrentScreen() == 1) {
// Handle actions based on the selected menu item
switch (menu.getSelectedItem()) {
case 0: // Tile Menu
menu.drawTileMenu(2, 2, ST7735_GREEN);
break;
case 1: // Submenu
if (menu.getCurrentScreen() == 1) {
delay(100); // Small delay for stability
menu.drawSubmenu(true, "1", "2", "3", "4", NULL); // Draw the submenu on the screen. Set to "true" to display the 16x16 images for the items, else, set to "false"
} else if (menu.getCurrentScreen() == 2) {
// Handle actions based on the selected submenu item
switch (menu.getSelectedItem()) {
case 0:
menu.canvas.fillScreen(ST7735_BLACK);
break;
case 1:
menu.canvas.fillScreen(ST7735_BLACK);
break;
case 2:
menu.canvas.fillScreen(ST7735_BLACK);
break;
case 3:
menu.canvas.fillScreen(ST7735_BLACK);
break;
}
}
break;
case 2: // Settings
// Draw the setting menu on the screen
menu.drawSettingMenu("Setting_6", "Setting_7", "Setting_8", NULL); // 5 items are by default in the settings. The one defined in this function are added after the one there by default
break;
}
}
// Additional functionality based on menu settings
if (menu.menu_items_settings_bool[5]) {
// Execute code if a specific menu item setting is enabled
Serial.println("Menu item bool 5 is true");
}
menu.drawCanvasOnTFT(); // Draw the updated canvas on the screen. You need to call it at the END of your code (in the "loop()")
}
2 changes: 1 addition & 1 deletion examples/OpenMenuOS_Simple/images.h
Original file line number Diff line number Diff line change
Expand Up @@ -511,4 +511,4 @@ const uint8_t Boot_img[] = {
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
};
};
6 changes: 3 additions & 3 deletions library.properties
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
name=OpenMenuOS
version=1.0.2-beta
version=1.1.0
author=Loic Daigle <loicdaigle31@gmail.com>
maintainer=Loic Daigle <loicdaigle31@gmail.com>
sentence=ESP32 library to easily build menu on ST7735 0.96" display
paragraph=This library was made to easily draw menu on ST7735R 0.96" 160x80 display with ESP32.
category=Display
url=https://github.com/The-Young-Maker/OpenMenuOS
architectures=esp32
architectures=*
includes=OpenMenuOS.h
depends=ArduinoOTA, Preferences, WiFi
depends=ArduinoOTA, Preferences, WiFi

0 comments on commit e291919

Please sign in to comment.