Skip to content

Commit 76e696f

Browse files
committed
Bug fixing / UI improvements
1 parent bdb8cbf commit 76e696f

32 files changed

Lines changed: 645 additions & 273 deletions

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,4 +63,4 @@ It comes with the hardware schematics, production files and the Megahub firmware
6363

6464
## Getting Started
6565

66-
Documentation coming soon...
66+
Documentation coming soon...

examples/Gamepad Test/model.xml

Lines changed: 0 additions & 1 deletion
This file was deleted.

examples/Gamepad Test/program.lua

Lines changed: 0 additions & 26 deletions
This file was deleted.

examples/IMU Test/model.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<xml xmlns="https://developers.google.com/blockly/xml"><block type="mh_init" id="c8I^HrdZHuVx;,@L]XLc" x="330" y="46"><statement name="DO"><block type="ui_show_value" id="a9{w}qIHn,d}XEO=[cFd"><field name="LABEL">Status</field><field name="STYLE">FORMAT_SIMPLE</field><value name="VALUE"><block type="text" id=".CbMk1m~q/(6TvYhS}ZX"><field name="TEXT">Initialized</field></block></value></block></statement></block><block type="mh_main_control_loop" id="=sB8)q9E??Z[Bn!7tTe8" x="326" y="226"><statement name="DO"><block type="ui_show_value" id="^ofK$7;l2VJ7WOnIz;$-"><field name="LABEL">Roll</field><field name="STYLE">FORMAT_SIMPLE</field><value name="VALUE"><block type="mh_imu_value" id="(;j~p_L,u_pYm]GjX^lc"><field name="VALUE">ROLL</field></block></value><next><block type="ui_show_value" id="fXH!Ss2HUbl4yf4eyRSb"><field name="LABEL">Pitch</field><field name="STYLE">FORMAT_SIMPLE</field><value name="VALUE"><block type="mh_imu_value" id="fx]L_Ar2KO^=S1d?S55H"><field name="VALUE">PITCH</field></block></value><next><block type="ui_show_value" id="Pz4O?,]@uOQJ+Ua@,[GP"><field name="LABEL">Yaw</field><field name="STYLE">FORMAT_SIMPLE</field><value name="VALUE"><block type="mh_imu_value" id="!ao-z6F}h_~TkUDwz-34"><field name="VALUE">YAW</field></block></value><next><block type="mh_wait" id="d1}7@!JF_YKLPF77)smY"><value name="VALUE"><block type="math_number" id="?fhByUF?S{_fJ;$h{{rq"><field name="NUM">1000</field></block></value></block></next></block></next></block></next></block></statement></block></xml>
1+
<xml xmlns="https://developers.google.com/blockly/xml"><block type="mh_init" id="c8I^HrdZHuVx;,@L]XLc" x="551" y="236"><statement name="DO"><block type="ui_show_value" id="a9{w}qIHn,d}XEO=[cFd"><field name="LABEL">Status</field><field name="STYLE">FORMAT_SIMPLE</field><value name="VALUE"><block type="text" id=".CbMk1m~q/(6TvYhS}ZX"><field name="TEXT">Initialized</field></block></value><next><block type="mh_startthread" id="Xglk!gmtk^`19=hRQa_r"><field name="NAME">Main control loop</field><value name="STACKSIZE"><shadow type="math_number" id="Q1+BoaY.iE9x1@]NI~g+"><field name="NUM">4096</field></shadow></value><statement name="DO"><block type="ui_show_value" id="oj-qf,|7[8k0RtesT]5H"><field name="LABEL">IMU Yaw</field><field name="STYLE">FORMAT_SIMPLE</field><value name="VALUE"><block type="mh_imu_value" id=".9=X.uP:=g+YS_ekx,~@"><field name="VALUE">YAW</field></block></value><next><block type="ui_show_value" id="5[6zLb+Oq.z..EmM0p]f"><field name="LABEL">IMU Pitch</field><field name="STYLE">FORMAT_SIMPLE</field><value name="VALUE"><block type="mh_imu_value" id="Fi-gRyeX+iy2a?Xk%ZjR"><field name="VALUE">PITCH</field></block></value><next><block type="ui_show_value" id="{bbo|cV$`;Ko:Dsca}]g"><field name="LABEL">IMU Roll</field><field name="STYLE">FORMAT_SIMPLE</field><value name="VALUE"><block type="mh_imu_value" id="B5GjEaD^w@yNhom7FM[:"><field name="VALUE">ROLL</field></block></value><next><block type="mh_wait" id="?i!cdD`g;:EV_iK}7`1^"><value name="VALUE"><shadow type="math_number" id="blfgA@-=N??rD{oUw{Lv"><field name="NUM">1000</field></shadow></value></block></next></block></next></block></next></block></statement></block></next></block></statement></block></xml>

examples/IMU Test/program.lua

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
hub.init(function()
22
ui.showvalue("Status", FORMAT_SIMPLE, 'Initialized')
3+
hub.startthread('Main control loop', 4096, function()
4+
ui.showvalue("IMU Yaw", FORMAT_SIMPLE, imu.value(YAW))
5+
ui.showvalue("IMU Pitch", FORMAT_SIMPLE, imu.value(PITCH))
6+
ui.showvalue("IMU Roll", FORMAT_SIMPLE, imu.value(ROLL))
7+
wait(1000)
8+
end)
39
end)
4-
5-
hub.main_control_loop(function()
6-
ui.showvalue("Roll", FORMAT_SIMPLE, imu.value(ROLL))
7-
ui.showvalue("Pitch", FORMAT_SIMPLE, imu.value(PITCH))
8-
ui.showvalue("Yaw", FORMAT_SIMPLE, imu.value(YAW))
9-
wait(1000)
10-
end)

examples/LEGO Test/model.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<xml xmlns="https://developers.google.com/blockly/xml"><block type="mh_init" id="LVYi^]j(RXkMfwEi@4ti" x="411" y="202"><statement name="DO"><block type="lego_select_mode" id="_mYuXtPiPl,ZdCo}Uy(O"><field name="PORT">PORT1</field><value name="MODE"><block type="math_number" id=":7Ji].B]YSRYfQLlVW1I"><field name="NUM">1</field></block></value></block></statement></block><block type="mh_main_control_loop" id="_CYUbq$se,CPfvu!d7c|" x="409" y="362"><statement name="DO"><block type="ui_show_value" id="kLfQu11}+6-DFd|d7|-6"><field name="LABEL">Dataset #0</field><field name="STYLE">FORMAT_SIMPLE</field><value name="VALUE"><block type="lego_get_mode_dataset" id="B!*R1*9X,S73w^6~q#Xk"><field name="PORT">PORT1</field><value name="DATASET"><block type="math_number" id="H,4vo%1ulo]3/,e3@HXM"><field name="NUM">0</field></block></value></block></value><next><block type="mh_wait" id="+;`M*Yg!#f^(MT.`*1:q"><value name="VALUE"><block type="math_number" id="ruX]3CEV}SjP[PeGK@{%"><field name="NUM">1000</field></block></value></block></next></block></statement></block></xml>
1+
<xml xmlns="https://developers.google.com/blockly/xml"><variables><variable id="aOvk#j.!7`bXx%@yc6w4">MOTOR_DIRECTION</variable></variables><block type="mh_init" id="P1;=b)_RTm{~mHF@*rUC" x="133" y="-9"><statement name="DO"><block type="ui_show_value" id="d%pX_X18X6V=bvRB=|,x"><field name="LABEL">Status</field><field name="STYLE">FORMAT_SIMPLE</field><value name="VALUE"><shadow type="text" id="OF~RckSNI_Yo}%|`XCR)"><field name="TEXT">Replace me</field></shadow><block type="text" id="n*YJw{j04CSNIsRy-}$:"><field name="TEXT">Initialized</field></block></value><next><block type="variables_set" id="g_6rk=,1bzHvv|e;u4KT"><field name="VAR" id="aOvk#j.!7`bXx%@yc6w4">MOTOR_DIRECTION</field><value name="VALUE"><block type="math_number" id="5(tA_}rZ2EiP,-;N2ztI"><field name="NUM">0</field></block></value><next><block type="mh_set_motor_speed" id="v`jy$6Grd?e6%s6V!N4f"><value name="PORT"><shadow type="mh_port" id="!qy#ao^6L6,f3Q;5ecTB"><field name="PORT">PORT1</field></shadow></value><value name="VALUE"><block type="math_number" id="?h]t~WRW9Vh`:__$*2tb"><field name="NUM">0</field></block></value><next><block type="mh_startthread" id="yCUFhTJyuPV?SXqB(Dw."><field name="NAME">Main control loop</field><value name="STACKSIZE"><shadow type="math_number" id="xL=sx8GS5%@x~-.iJ=#r"><field name="NUM">4096</field></shadow></value><statement name="DO"><block type="controls_if" id="JlZRVGFT}fNOaI7G4aZN"><mutation elseif="1" else="1"></mutation><value name="IF0"><block type="logic_compare" id=";P97Jxt4w3R,C$p`ObmZ"><field name="OP">LT</field><value name="A"><block type="mh_gamepad_value" id="tKhJYUJ0iEmE0]{5e$qn"><field name="VALUE">GAMEPAD_LEFT_X</field><value name="GAMEPAD"><shadow type="mh_gamepad_gamepad" id="#cZ+=9C,V}.C@EIiU1U6"><field name="GAMEPAD">GAMEPAD1</field></shadow></value></block></value><value name="B"><block type="math_number" id="!Q#md;DOT4%nl#,UhCbO"><field name="NUM">0</field></block></value></block></value><statement name="DO0"><block type="controls_if" id=":CO-vs?XM245U*1r%Fbd"><value name="IF0"><block type="logic_compare" id="u73m^_x$vT!z+7(V@yt$"><field name="OP">GTE</field><value name="A"><block type="variables_get" id="*)bHiKXHq5C0GgINz7LP"><field name="VAR" id="aOvk#j.!7`bXx%@yc6w4">MOTOR_DIRECTION</field></block></value><value name="B"><block type="math_number" id="TE*p^+aVSO*tsMbQDZ}!"><field name="NUM">0</field></block></value></block></value><statement name="DO0"><block type="ui_show_value" id="AKx]teP9b#LSi0qiC[4q"><field name="LABEL">Direction</field><field name="STYLE">FORMAT_SIMPLE</field><value name="VALUE"><shadow type="text" id="OF~RckSNI_Yo}%|`XCR)"><field name="TEXT">Replace me</field></shadow><block type="text" id="=aKt94u)(^R2:RLM`fXQ"><field name="TEXT">Left</field></block></value><next><block type="mh_set_motor_speed" id="WZ%4=^ZFFY#kO+SRq(WX"><value name="PORT"><shadow type="mh_port" id="?/iLagn|#=00%IX*j@WI"><field name="PORT">PORT1</field></shadow></value><value name="VALUE"><block type="math_number" id="ebt,p/i!6nL6fmmsv)HX"><field name="NUM">-127</field></block></value><next><block type="variables_set" id="Qd0{}q/#:NgS0c}JB2Tz"><field name="VAR" id="aOvk#j.!7`bXx%@yc6w4">MOTOR_DIRECTION</field><value name="VALUE"><block type="math_number" id="EQj-_5?}T,tVm%v%[eQW"><field name="NUM">-1</field></block></value></block></next></block></next></block></statement></block></statement><value name="IF1"><block type="logic_compare" id="BUU(rSGTixPJ2Z%n5(UX"><field name="OP">GT</field><value name="A"><block type="mh_gamepad_value" id="8_Bueyfz_7-=5dxe+M`C"><field name="VALUE">GAMEPAD_LEFT_X</field><value name="GAMEPAD"><shadow type="mh_gamepad_gamepad" id="S1LgUQ6AQ9JLIob-M_!D"><field name="GAMEPAD">GAMEPAD1</field></shadow></value></block></value><value name="B"><block type="math_number" id="zdq`-{-q^fBKc5V(#BKG"><field name="NUM">0</field></block></value></block></value><statement name="DO1"><block type="controls_if" id="uk?MzOah@}ayLI,P[FZf"><value name="IF0"><block type="logic_compare" id="m/).oHE.BF{?b8s?KJsq"><field name="OP">LTE</field><value name="A"><block type="variables_get" id="b.^B(Ixw=2M7_F+unNKq"><field name="VAR" id="aOvk#j.!7`bXx%@yc6w4">MOTOR_DIRECTION</field></block></value><value name="B"><block type="math_number" id="S%,G0m.^ccFENmvs.iN%"><field name="NUM">0</field></block></value></block></value><statement name="DO0"><block type="ui_show_value" id="F/YUPKk_#LU;i|IcT%Xa"><field name="LABEL">Direction</field><field name="STYLE">FORMAT_SIMPLE</field><value name="VALUE"><shadow type="text" id="OF~RckSNI_Yo}%|`XCR)"><field name="TEXT">Replace me</field></shadow><block type="text" id="/l%DKQQ=OBz1:@K!9EQG"><field name="TEXT">Right</field></block></value><next><block type="mh_set_motor_speed" id="X0TDuJc#m#ZAabn1_u}!"><value name="PORT"><shadow type="mh_port" id=";x4-oT_UDVdVaDCWT3@)"><field name="PORT">PORT1</field></shadow></value><value name="VALUE"><block type="math_number" id="ib}Y7{.++;QJ3US:SknG"><field name="NUM">127</field></block></value><next><block type="variables_set" id="X=~:Z6RUTS8qiZ5?{#v#"><field name="VAR" id="aOvk#j.!7`bXx%@yc6w4">MOTOR_DIRECTION</field><value name="VALUE"><block type="math_number" id="@1t`w*-KEBd+_H00.T+="><field name="NUM">1</field></block></value></block></next></block></next></block></statement></block></statement><statement name="ELSE"><block type="controls_if" id="T{oKnSx~K+JV`(@$PdpK"><value name="IF0"><block type="logic_compare" id="*m|]yr6qsn9cH|kB4Gdc"><field name="OP">NEQ</field><value name="A"><block type="variables_get" id="{;n639a665T=EbFl27vu"><field name="VAR" id="aOvk#j.!7`bXx%@yc6w4">MOTOR_DIRECTION</field></block></value><value name="B"><block type="math_number" id="_:VOh!OO^4-acud@-[:5"><field name="NUM">0</field></block></value></block></value><statement name="DO0"><block type="ui_show_value" id="2^qL5x`D}q*8{P=U$E5P"><field name="LABEL">Direction</field><field name="STYLE">FORMAT_SIMPLE</field><value name="VALUE"><shadow type="text" id="OF~RckSNI_Yo}%|`XCR)"><field name="TEXT">Replace me</field></shadow><block type="text" id="z;WBP5aHx/zY`~W%6vXH"><field name="TEXT">Stopped</field></block></value><next><block type="mh_set_motor_speed" id="clvQl;rv|(?G`!c$#t9Z"><value name="PORT"><shadow type="mh_port" id="`#w[N@Q[FMDIsNNRQDl$"><field name="PORT">PORT1</field></shadow></value><value name="VALUE"><block type="math_number" id="VIQJK/U,-fOEz3+Pj:P8"><field name="NUM">0</field></block></value><next><block type="variables_set" id="7tez.uFv7ePy;c%?B}[K"><field name="VAR" id="aOvk#j.!7`bXx%@yc6w4">MOTOR_DIRECTION</field><value name="VALUE"><block type="math_number" id="P,aV.%PwGhP`PKAm%KR`"><field name="NUM">0</field></block></value></block></next></block></next></block></statement></block></statement><next><block type="mh_wait" id="G@?T/Mc}hK^s~kV{$930"><value name="VALUE"><shadow type="math_number" id="wvhykxbVbDhQyu79by}o"><field name="NUM">1000</field></shadow><block type="math_number" id="Pn9}6^sVFW65r^Vdy`yM"><field name="NUM">20</field></block></value></block></next></block></statement></block></next></block></next></block></next></block></statement></block></xml>

examples/LEGO Test/program.lua

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,27 @@
11
hub.init(function()
2-
lego.selectmode(PORT1, 1)
2+
ui.showvalue("Status", FORMAT_SIMPLE, 'Initialized')
3+
MOTOR_DIRECTION = 0
4+
hub.setmotorspeed(PORT1,0)
5+
hub.startthread('Main control loop', 4096, function()
6+
if gamepad.value(GAMEPAD1,GAMEPAD_LEFT_X) < 0 then
7+
if MOTOR_DIRECTION >= 0 then
8+
ui.showvalue("Direction", FORMAT_SIMPLE, 'Left')
9+
hub.setmotorspeed(PORT1,(-127))
10+
MOTOR_DIRECTION = -1
11+
end
12+
elseif gamepad.value(GAMEPAD1,GAMEPAD_LEFT_X) > 0 then
13+
if MOTOR_DIRECTION <= 0 then
14+
ui.showvalue("Direction", FORMAT_SIMPLE, 'Right')
15+
hub.setmotorspeed(PORT1,127)
16+
MOTOR_DIRECTION = 1
17+
end
18+
else
19+
if MOTOR_DIRECTION ~= 0 then
20+
ui.showvalue("Direction", FORMAT_SIMPLE, 'Stopped')
21+
hub.setmotorspeed(PORT1,0)
22+
MOTOR_DIRECTION = 0
23+
end
24+
end
25+
wait(20)
26+
end)
327
end)
4-
5-
hub.main_control_loop(function()
6-
ui.showvalue("Dataset #0", FORMAT_SIMPLE, lego.getmodedataset(PORT1,0))
7-
wait(1000)
8-
end)

0 commit comments

Comments
 (0)