Skip to content

Commit

Permalink
fix: wasd in gridui
Browse files Browse the repository at this point in the history
  • Loading branch information
Tasssadar committed Jul 10, 2024
1 parent 45b4980 commit b49bd85
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions docs/robot/lekce1/example-gridui/src/layout.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// AUTOGENERATED FILE, DO NOT EDIT
// Generated by https://gridui.robotikabrno.cz/
// Layout: {"cols":12,"rows":18,"enableSplitting":true,"widgets":[{"uuid":43594,"type":"Button","state":{"id":"ButtonBlink","x":1,"y":1.5,"w":10,"h":2,"tab":0,"css":{},"text":"Blikni","fontSize":18,"color":"#fb0404","background":"","align":"center","valign":"center","disabled":false}},{"uuid":11866,"type":"Joystick","state":{"id":"Joystick","x":3,"y":10,"w":6,"h":5.5,"tab":0,"css":{},"color":"#FF0000","keys":"","text":""}},{"uuid":4862,"type":"Slider","state":{"id":"SetSpeed","x":1,"y":4,"w":10,"h":2.5,"tab":0,"css":{},"color":"#008000","fontSize":16,"min":0,"max":1,"value":0.5,"precision":0.05,"showValue":true}},{"uuid":47586,"type":"Text","state":{"id":"TextSpeed","x":1,"y":6.5,"w":10,"h":1,"tab":0,"css":{},"text":"Nastavení maximální rychlosti","fontSize":17,"color":"#000000","background":"","align":"center","valign":"center","prefix":"","suffix":""}},{"uuid":26977,"type":"Text","state":{"id":"TextInfo","x":1,"y":0,"w":10,"h":1,"tab":0,"css":{},"text":"Řízení Robůtka","fontSize":19,"color":"#000000","background":"","align":"center","valign":"center","prefix":"","suffix":""}}]}
// Layout: {"cols":12,"rows":18,"enableSplitting":true,"widgets":[{"uuid":11866,"type":"Joystick","state":{"id":"Joystick","x":3,"y":10,"w":6,"h":5.5,"tab":0,"css":{},"color":"#FF0000","keys":"wasd","text":""}},{"uuid":4862,"type":"Slider","state":{"id":"SetSpeed","x":1,"y":4,"w":10,"h":2.5,"tab":0,"css":{},"color":"#008000","fontSize":16,"min":0,"max":1,"value":0.5,"precision":0.05,"showValue":true}},{"uuid":47586,"type":"Text","state":{"id":"TextSpeed","x":1,"y":6.5,"w":10,"h":1,"tab":0,"css":{},"text":"Maximální rychlosti","fontSize":17,"color":"#000000","background":"","align":"center","valign":"center","prefix":"","suffix":""}}]}

// Add this as a file layout.ts to your project.
//
Expand All @@ -25,7 +25,7 @@

import * as gridui from "gridui"

if (gridui.version() < 0x040000) {
if(gridui.version() < 0x040000) {
throw new Error("Your RBGridUi library version is too low for this layout, please update to 040000.")
}

Expand All @@ -50,21 +50,22 @@ const layout = {
begin(ownerName: string, deviceName: string, builderCallback?: (layoutBuilder: LayoutBuilder) => void) {
gridui.begin(ownerName, deviceName, (builder) => {
const layoutBuilder: LayoutBuilder = {
Joystick: builder.joystick(3, 10, 6, 5.5, 11866),
Joystick: builder.joystick(3, 10, 6, 5.5, 11866)
.keys("wasd"),
SetSpeed: builder.slider(1, 4, 10, 2.5, 4862)
.max(1)
.value(0.5)
.precision(0.05),
TextSpeed: builder.text(1, 6.5, 10, 1, 47586)
.text("Nastavení maximální rychlosti")
.fontSize(17),
.text("Maximální rychlosti")
.fontSize(17)
}

if (builderCallback !== undefined) {
if(builderCallback !== undefined) {
builderCallback(layoutBuilder)
}

for (const key in layoutBuilder) {
for(const key in layoutBuilder) {
layout[key] = layoutBuilder[key].finish()
layoutBuilder[key] = undefined
}
Expand All @@ -74,4 +75,4 @@ const layout = {
log: gridui.log,
} as Layout

export default layout
export default layout

0 comments on commit b49bd85

Please sign in to comment.