B9X Screen Designer

B9X Basic Screen Designer — Complete User Guide

Visual screen design, B9X Basic code generation, and a beginner tutorial for the supplied B9X Basic Screen Designer project.
B9X Electronics Documentation
Public user documentation. This guide describes how to use the Screen Designer and the B9X Basic it generates. It intentionally does not document the application source code, private implementation, licensing internals, or proprietary algorithms.

On this page

Introduction

The B9X Basic Screen Designer is a visual editor for laying out screens for the B9X display system. Instead of calculating every coordinate and writing every displayAdd... call by hand, you place elements visually, edit their properties, save the design, and copy the generated B9X Basic function to the Windows clipboard.

The supplied project supports both 320 × 480 portrait and 480 × 320 landscape layouts. Coordinates and sizes are stored in real display pixels; preview scaling is only a Windows editing convenience.

The normal Screen Designer workflow: choose orientation, add elements, set properties, save, then copy B9X Basic.
The normal Screen Designer workflow: choose orientation, add elements, set properties, save, then copy B9X Basic.

Beginner Quick Start

1. Choose the orientation. Use the Portrait/Landscape button. Portrait uses 320 × 480 pixels; landscape uses 480 × 320.
2. Set Screen / function. Enter a useful name such as mainScreen. The same value becomes the generated B9X Basic function name and the default project filename.
3. Set Start number. Use 0 for a single screen. For multiple screens, use a different range for each screen, such as 0, 100, 200.
4. Add elements. Click a toolbar button such as Button, Label, TextBox, Slider, List Box, Lamp, Icon or Rounded Btn.
5. Position and edit. Drag an element, use the resize handle, or click a property row to enter an exact value.
6. Save. Save the editable design as a .b9xscreen project.
7. Copy B9X BASIC. Click Copy B9X BASIC. Paste the generated screen function into your B9X Basic program.
Best beginner habit: Build and test one screen with only a few elements first. Once the event handling works, add the remaining controls.

Screen Designer Interface

Illustrated guide to the Screen Designer interface, based on the controls and property rows in the supplied project.
Illustrated guide to the Screen Designer interface, based on the controls and property rows in the supplied project.

The top toolbar adds common elements and provides Duplicate, Delete, Copy B9X BASIC, Load, Save, Screen color, About, and the Portrait/Landscape control. A second toolbar row contains the newer sizeable controls. The third row provides Background BMP and Sample Color.

The left panel lists elements. The center is the hardware-screen preview. The right panel is the property inspector. Selecting an element makes its editable properties available.

Portrait & Landscape

Portrait and landscape use real hardware pixel coordinates.
Portrait and landscape use real hardware pixel coordinates.

Portrait is 320 × 480. Landscape is 480 × 320. Changing orientation also causes existing elements to be clamped inside the new screen boundaries. The generated function begins by calling displaySetOrientation(0) for portrait or displaySetOrientation(1) for landscape.

Background BMP note: changing orientation clears the currently loaded background preview, so select an orientation before choosing the final background image.

Complete Element Reference

All element types exposed by the supplied Screen Designer.
All element types exposed by the supplied Screen Designer.
ElementPurposeGenerated B9X Basic
ButtonTouchable rectangular push button.displayAddButton
TextBoxEditable text field.displayAddTextBox
PasswordEditable text field whose preview masks a filled caption with * characters.displayAddPasswordTextBox
LabelNon-editable display text.displayAddLabel
CheckBoxCheckable on/off option.displayAddCheckBox
SliderNumeric value control with minimum, maximum and current value.displayAddSlider
IconBuilt-in icon. Fixed 96 × 80 footprint.displayAddIcon
SD BMPBitmap chosen on Windows for preview and loaded at runtime from SD or SPIFFS.displayAddBmpFromFile
KeyboardOn-screen keyboard associated with an editable text element.displayAddKeyboard
List BoxSelectable list. Items are separated with |; selected index is zero based.displayAddListBox
Analog MeterMoving-needle numeric meter.displayAddAnalogMeter
V BarVertical bar meter.displayAddVerticalBarMeter
LampProgram-controlled on/off indicator.displayAddLamp
SwitchProgram-controlled switch-style element.displayAddSwitch
ToggleUser-toggleable switch.displayAddFlipSwitch
Rounded BtnPush button with configurable corner radius.displayAddRoundedButton

Properties Reference

PropertyMeaning
Screen RGB565Screen background color, decimal 0–65535.
Screen / functionScreen name, generated function name, and default save filename. Spaces become underscores.
Start numberOffset added to every generated element number.
TypeElement type.
NumberDesigner element number, limited to 1–48.
NameGenerated symbolic B9X Basic name. New names are automatically assigned by type and generated in uppercase.
X / YTop-left location in real display pixels.
Width / HeightElement size. Icons and BMPs are not resized by the normal resize handle.
Caption / symbolDisplayed text, list items, or selected BMP filename depending on element type.
Font 1/2/3/4/5/6Font selection. The project documents font heights 15, 22, 29, 39, 48 and 64 pixels respectively.
ValueCurrent numeric value or selected list index as appropriate.
Minimum / MaximumRange used by sliders and meters.
Max text lengthMaximum editable text length.
Icon numberBuilt-in b9x_icons number.
Keyboard targetElement number of the editable text field controlled by the keyboard.
Text color / BackgroundRGB565 decimal colors.
CheckedInitial on/off state where applicable.
Corner radiusRounded-button corner radius in pixels.

Moving, Resizing & Editing

Drag an element to move it. Drag the blue lower-right handle to resize sizeable elements. Icons and BMP images do not use the resize handle because their image dimensions are fixed by the asset itself. Arrow keys move the selected element by one display pixel; Shift + Arrow resizes by one display pixel.

For exact values, click the desired property row and type the value. The designer keeps elements inside the current screen dimensions.

Duplicate creates another element based on the selected item. Delete removes the selected item.

RGB565 Colors

Screen, text and background colors are stored as decimal RGB565 values from 0 through 65535. You can type a value directly or use the visual color picker. The Sample Color tool samples the rendered screen preview and displays the corresponding RGB565 decimal value so it can be copied.

Practical method: design the basic layout first, then choose a small palette of background, text, accent, warning and status colors. Reusing a consistent palette produces a cleaner interface.

BMP Images & Backgrounds

BMP files are selected locally for preview, then assigned an SD-card or SPIFFS runtime path.
BMP files are selected locally for preview, then assigned an SD-card or SPIFFS runtime path.

When adding an SD BMP or Background BMP, first choose the BMP file on Windows. The designer uses that file for preview. You then choose where the same filename will exist on the target: S for /sdcard/filename.bmp or P for /spiffs/filename.bmp.

Generated code uses displayAddBmpFromFile(number, x, y, path$, touchable). Normal BMP elements are generated touchable. A screen background is generated as reserved element 0 and is not touchable.

result = displayAddBmpFromFile(0, 0, 0, "/spiffs/background.bmp", 0);
result = displayAddBmpFromFile(PHOTO1, 20, 50, "/sdcard/photo.bmp", 1);

The selected BMP retains its real pixel dimensions. The local Windows path is stored in the project so the preview can be restored when the project is reopened.

Text, Passwords & Keyboard

A TextBox stores normal editable text. A Password TextBox uses the same basic idea but masks a filled caption in the designer preview. It generates displayAddPasswordTextBox(...).

Only one Keyboard is allowed on a screen. The designer always generates the keyboard after every other displayAdd call, regardless of its position in the element list. This keeps the keyboard above the other elements. Set Keyboard target to the element number of the text field it should edit.

result = displayAddTextBox(USERNAME1, 20, 60, 280, 42, "", 32, 2);
result = displayAddPasswordTextBox(PASSWORD1, 20, 120, 280, 42, "", 32, 2);
result = displayAddKeyboard(KEYBOARD1, PASSWORD1);

Element Numbers, Names & Start Number

Start Number makes separately designed screens use different element-number ranges.
Start Number makes separately designed screens use different element-number ranges.

Each element has both a designer number and a generated symbolic name. For example, a button may be named BUTTON1. The generated function declares that name before creating the screen.

The Start number is especially useful when an application contains several screens. The generated code declares START_NUM and then adds the designer number to it.

let START_NUM = 100;
let BUTTON1 = START_NUM + 1;
let LABEL1 = START_NUM + 2;

This lets screen designs remain simple while keeping their runtime element numbers unique.

Saving & Loading Designs

Save writes a .b9xscreen project. Load reopens it for editing. The project stores screen color, orientation, start number, element order, types, names, numbers, coordinates, sizes, captions, fonts, colors, values, ranges, checkbox state, icon number, keyboard target, BMP information and other applicable element properties.

Older projects without a Start number load with Start number 0. Unsupported element types are ignored, coordinates are clamped to the active screen, and the design is limited to 48 elements. If an older or manually edited project contains multiple keyboards, only the first is loaded.

Generated B9X Basic

Click Copy B9X BASIC to generate the screen function and copy it to the Windows clipboard. The generator sets orientation, removes existing elements, clears the screen, optionally draws a background BMP, creates each element, applies colors, creates the keyboard last, refreshes the display and returns 1.

// Typical generated structure
function mainScreen()
    let START_NUM = 100;
    let BUTTON1 = START_NUM + 1;
    let LABEL1 = START_NUM + 2;

    let result = displaySetOrientation(0);
    result = displayRemoveAllElements();
    result = displayClear(2089);
    result = displayAddButton(BUTTON1, 20, 184, 289, 49, "START", 3);
    result = displaySetColors(BUTTON1, 65535, 2089);
    result = displayAddLabel(LABEL1, 40, 5, 244, 29, "B9X Basic", 3, 65535);
    result = displaySetColors(LABEL1, 65535, 2089);
    result = displayRefresh();
    return 1;
end function
Important: the exact output depends on your design. The example above demonstrates the generated structure; it is not a substitute for clicking Copy B9X BASIC for your actual screen.

Complete Beginner Tutorial

Project: a simple control screen

This tutorial creates a screen with a title, status lamp, slider, rounded START button, editable name field and keyboard.

Step 1 — Start with portrait. Confirm the orientation button says Portrait. Set Screen / function to controlScreen.
Step 2 — Set Start number. Enter 100. Runtime element 1 will therefore become 101.
Step 3 — Choose the screen color. Click Screen color and choose a dark background, or type the RGB565 decimal value into Screen RGB565.
Step 4 — Add a Label. Set its caption to Machine Control, choose a readable font, then position it near the top.
Step 5 — Add a Lamp. Set the caption to RUN and Checked to 0 so it begins off.
Step 6 — Add a Slider. Set Minimum 0, Maximum 100 and Value 50.
Step 7 — Add a Rounded Btn. Set Caption to START, select a font, and set Corner radius to a value that looks appropriate for the button size.
Step 8 — Add a TextBox. Set Max text length to the maximum name length you want to accept.
Step 9 — Add Keyboard. Set Keyboard target to the TextBox designer element number. Remember: only one keyboard is allowed.
Step 10 — Save. Save the project as controlScreen.b9xscreen.
Step 11 — Generate. Click Copy B9X BASIC and paste the generated controlScreen() function into your B9X Basic application.
Step 12 — Call the function. Call the generated screen function when the application should display this screen, then process display messages in your program.

Controlling the Screen from B9X Basic

The designer creates the initial screen. Your running B9X Basic program can then change supported elements using the normal display API. The supplied project reference specifically shows these patterns for the newer controls:

// Move an analog meter needle or vertical bar
result = displaySetValue(METER1, 75);
result = displaySetValue(BAR1, 80);

// Select a list row (zero based)
result = displaySetValue(LISTBOX1, 2);

// Replace list choices
result = displaySetText(LISTBOX1, "Heat|Cool|Fan|Off");

// Turn a lamp or program-controlled switch on
result = displaySetChecked(LAMP1, 1);
result = displaySetChecked(SWITCH1, 1);

// Read a user-toggleable switch
state = displayGetChecked(TOGGLE1);

The project notes that a toggle switch queues checked/unchecked activity and a list box queues value-changed activity. Other touchable new elements can generate normal pressed, released and clicked messages.

Rules & Limits

ItemRule
Active design elementsMaximum 48.
Element numbersDesigner number 1–48; Start number is added in generated BASIC.
Portrait320 × 480 hardware pixels.
Landscape480 × 320 hardware pixels.
KeyboardOne per screen; generated last.
Built-in icon footprint96 × 80 pixels; not resized by the designer.
BMP elementUses original image dimensions; runtime path may be SD or SPIFFS.
ColorsRGB565 decimal 0–65535.
Fonts1 through 6. Project documentation gives heights of 15, 22, 29, 39, 48 and 64 pixels.
List Box itemsSeparated with |; selected index is zero based.

Troubleshooting

ProblemCheck
Element is partly off screenCheck X, Y, Width and Height. Changing orientation can require repositioning elements even though the designer clamps them inside the screen.
Text does not fitUse a smaller font, enlarge the element, or shorten the caption.
Password preview shows normal textUse the Password element, not a normal TextBox. The supplied project includes the password-preview masking fix.
Keyboard edits the wrong fieldSet Keyboard target to the correct editable element number.
Cannot add another keyboardOnly one keyboard is supported per screen.
BMP preview works but target cannot load itVerify the generated /sdcard/ or /spiffs/ path and make sure the same file exists there on the target.
Generated element numbers collide with another screenGive each screen a different Start number range.
Wrong colorConfirm the value is decimal RGB565 from 0–65535; use the built-in picker or Sample Color tool.
Copy B9X BASIC produces no usable resultSave your work, confirm the Screen/function name is valid, and verify the installed application is properly licensed.

Quick Reference

TaskHow
Add an elementClick its + toolbar button.
SelectClick the element or its list entry.
MoveDrag, or Arrow key = 1 hardware pixel.
ResizeDrag blue lower-right handle, or Shift+Arrow = 1 pixel.
Exact propertyClick the property row and enter the value.
Set colorType RGB565 decimal or use Pick.
Sample rendered colorUse Sample Color.
Change orientationPortrait/Landscape toolbar button.
Save editable designSave → .b9xscreen.
Open designLoad.
Generate codeCopy B9X BASIC.

B9X Basic Screen Designer — Complete User Guide. Prepared from the supplied B9X_Basic_Screen_Designer_v2_25 project. Public user-facing behavior only.