Skip to content

Commit

Permalink
fixed old examples
Browse files Browse the repository at this point in the history
  • Loading branch information
forntoh committed Oct 9, 2021
1 parent 6c28257 commit 4344a6a
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 16 deletions.
6 changes: 3 additions & 3 deletions examples/Callbacks/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,19 @@ Callbacks can be used with menu items of type `ItemCommand`, `ItemInput`, `ItemL

## Code

### 1 Declare the callback function
### 1. Declare the callback function

```cpp
// ../../examples/Callbacks/Callbacks.ino#L36-L36
```

### 1 Add callback to MenuItem
### 2. Add callback to MenuItem

```cpp
// ../../examples/Callbacks/Callbacks.ino#L51-L56
```

### 1 Define the callback function
### 3. Define the callback function

When `enter()` is invoked, the command _(callback)_ bound to the item is invoked.

Expand Down
2 changes: 1 addition & 1 deletion examples/List/List.ino
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ void loop() {
else if (command == BACKSPACE)
menu.backspace();
else
menu.type((String)command);
menu.type(command);
}

// Define the calbacks
Expand Down
10 changes: 5 additions & 5 deletions examples/List/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,34 +13,34 @@ The supported datatype for the list is `String`. This can be used for other prim

## Code

### 1 Declare the array
### 1. Declare the array

```cpp
// ../../examples/List/List.ino#L41-L41
```

### 1 Initialize the array
### 2. Initialize the array

```cpp
// ../../examples/List/List.ino#L43-L44
```

### 1 Add the array to your `MenuItem`
### 3. Add the array to your `MenuItem`

You must add the size of the array in order for the menu to know when to stop or loop when cycling through the items in the list.

```cpp
// ../../examples/List/List.ino#L58-L58
```

### 1 Cycle through list
### 4. Cycle through list

Use `menu.left()` and/or `menu.right()` to cycle through the items

- When `left()` is invoked the view cycles down the list
- When `right()` is invoked the view cycles up the list, you can use only `right()` if you have a single button, because once the menu reaches the end of the list, it automatically goes to the begining.

### 1 Run when item is selected
### 5. Run when item is selected

When `enter()` is invoked, the command _(callback)_ bound to the item is invoked.

Expand Down
2 changes: 1 addition & 1 deletion examples/MenuNotifications/MenuNotifications.ino
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ void loop() {
else if (command == BACKSPACE)
menu.backspace();
else {
menu.type((String)command);
menu.type(command);
menu.displayNotification("Success", 2000);
}
}
2 changes: 1 addition & 1 deletion examples/SubMenu/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ This example will show you how to get started with submenus
// ../../examples/SubMenu/SubMenu.ino#L39-L46
```

### 1 Create the sub menu
### 2 Create the sub menu

```cpp
// ../../examples/SubMenu/SubMenu.ino#L47-L53
Expand Down
8 changes: 3 additions & 5 deletions examples/SubMenu/SubMenu.ino
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,8 @@ MenuItem mainMenu[] = {ItemHeader(),
/**
* Create submenu and precise its parent
*/
MenuItem settingsMenu[] = {ItemHeader(mainMenu),
MenuItem("Backlight"),
MenuItem("Contrast"),
ItemFooter()};
MenuItem settingsMenu[] = {ItemHeader(mainMenu), MenuItem("Backlight"),
MenuItem("Contrast"), ItemFooter()};

LcdMenu menu(LCD_ROWS, LCD_COLS);

Expand Down Expand Up @@ -80,5 +78,5 @@ void loop() {
else if (command == BACKSPACE)
menu.backspace();
else
menu.type((String)command);
menu.type(command);
}

0 comments on commit 4344a6a

Please sign in to comment.