RobotUI Scroll Layout Tutorial

This guide assumes you have already performed the setup and the development guide

Create a new Arduino example project

Within the Arduino IDE start a new project by using the menu File->New. Start with the following simple code that creates a UI with one button. Make sure to change the BT_BAUDRATE value if you are no longer using the default baudrate for your HC-06 module.
#include <RobotUI.h> #define BT_BAUDRATE 9600 RobotUI robotUI; RobotUIButton button1; void LayoutDef() { robotUI.StartLayout(); robotUI.Add(button1); robotUI.EndLayout(); } void RecoverStatus() { } void setup() { robotUI.Init(ROBOTUI_PIN_RX, ROBOTUI_PIN_TX, BT_BAUDRATE, DEFAULT_COMMAND_BUFFER_SIZE, LayoutDef, RecoverStatus); } void loop() { unsigned long ms = robotUI.Update(); }


Add horizontal and vertical scroll areas

The below code changes add 8 more buttons, h2, h3, h4, h5 are four buttons to be placed in a horizontal scroll area, and v6, v7, v8, v9 are four buttons to be placed in a vertical scroll area. The parameter 2 that is passed along to StartHorizontalScroll means the height of the scroll area will be 2 buttons high. All of the next four buttons have a width of 5 so they will exceed the width of the screen to show off the horizontal scroll effect. The parameter 2.5 that is passed along to StartVerticalScroll function means the height of the scroll area will be 2.5 buttons high. As the next four buttons have a height of 1, that means only 2.5 buttons will be able to be displayed in the vertical scroll area at any time.
RobotUI robotUI; RobotUIButton button1;
RobotUIButton h2; RobotUIButton h3; RobotUIButton h4; RobotUIButton h5; RobotUIButton v6; RobotUIButton v7; RobotUIButton v8; RobotUIButton v9;
void LayoutDef() { robotUI.StartLayout(); robotUI.Add(button1);
robotUI.StartHorizontalScroll(2); robotUI.Add(h2, 5); robotUI.Add(h3, 5); robotUI.Add(h4, 5); robotUI.Add(h5, 5); robotUI.EndHorizontalScroll(); robotUI.StartVerticalScroll(2.5); robotUI.Add(v6, 1); robotUI.Add(v7, 1); robotUI.Add(v8, 1); robotUI.Add(v9, 1); robotUI.EndVerticalScroll();
robotUI.EndLayout(); }