-
Notifications
You must be signed in to change notification settings - Fork 0
/
m5c_gps_navi_blog.m5f
1 lines (1 loc) · 13.4 KB
/
m5c_gps_navi_blog.m5f
1
{"components":[{"id":"_stickscreen","createTime":1708176875621,"name":"screen","x":0,"y":0,"width":120,"height":240,"backgroundColor":"#111111","backgroundImage":"","size":0,"screenType":"default","type":"screen"},{"id":"5eXoZNdruySo!!^Z","createTime":1708176995403,"isCoreTwo":false,"isPaper":false,"name":"dateT","x":0,"y":139,"color":"#FFFFFF","text":"date","font":"lcd.FONT_DefaultSmall","rotation":0,"screenType":"default","type":"label","layer":5},{"id":"5zPxK6*q_OGKi23D","createTime":1708177003284,"isCoreTwo":false,"isPaper":false,"name":"timeT","x":0,"y":149,"color":"#FFFFFF","text":"time","font":"lcd.FONT_DefaultSmall","rotation":0,"screenType":"default","type":"label","layer":7},{"id":"VEXxAjy6UH3^Gz@z","createTime":1708177008101,"isCoreTwo":false,"isPaper":false,"name":"latT","x":0,"y":116,"color":"#FFFFFF","text":"lat","font":"lcd.FONT_DefaultSmall","rotation":0,"screenType":"default","type":"label","layer":9},{"id":"#YlPMAhDQr4ZK`a&","createTime":1708177012897,"isCoreTwo":false,"isPaper":false,"name":"lgtT","x":0,"y":127,"color":"#FFFFFF","text":"lgt","font":"lcd.FONT_DefaultSmall","rotation":0,"screenType":"default","type":"label","layer":11},{"id":"`E9*07SB+``rr1h@","createTime":1708177029498,"isCoreTwo":false,"isPaper":false,"name":"degT","x":54,"y":138,"color":"#FFFFFF","text":"deg","font":"lcd.FONT_DefaultSmall","rotation":0,"screenType":"default","type":"label","layer":21},{"id":"D9AJU*76PHg0vX8w","createTime":1708792591601,"isCoreTwo":false,"isPaper":false,"name":"drcT","x":54,"y":149,"color":"#FFFFFF","text":"drc","font":"lcd.FONT_DefaultSmall","rotation":0,"screenType":"default","type":"label","layer":33},{"id":"*KkU7pet0DidMnW_","createTime":1708843265667,"isCoreTwo":false,"isPaper":false,"name":"dstT","x":10,"y":77,"color":"#FFFFFF","text":"dst","font":"lcd.FONT_Default","rotation":0,"screenType":"default","type":"label","layer":42,"width":null,"height":null,"radius":null},{"id":"8wZD!*v*rzFF&FAf","createTime":1708843309566,"isCoreTwo":false,"isPaper":false,"name":"deg1T","x":54,"y":124,"color":"#FFFFFF","text":"deg1","font":"lcd.FONT_DefaultSmall","rotation":0,"screenType":"default","type":"label","layer":44,"width":null,"height":null,"radius":null},{"id":"icP`pXrx7ym$GWoy","createTime":1708848561689,"name":"triangle0","x":55,"y":78,"x1":55,"y1":78,"x2":36,"y2":99,"x3":76,"y3":99,"h":30,"borderColor":"#ffaaaa","backgroundColor":"#ffaaaa","screenType":"default","type":"triangle","layer":45,"width":null,"height":null,"radius":null},{"id":"g7%i7yFrrPbMo1cW","createTime":1708848573428,"name":"circle0","x":40,"y":40,"radius":36,"borderColor":"#FFFFFF","backgroundColor":"#aaaaaa","screenType":"default","type":"circle","layer":5,"width":null,"height":null},{"id":"e!0hgJ+ga_NktM$=","createTime":1708868467894,"name":"triangle1","x":55,"y":78,"x1":55,"y1":78,"x2":35,"y2":99,"x3":75,"y3":99,"h":30,"borderColor":"#000000","backgroundColor":"#000000","screenType":"default","type":"triangle","layer":49,"width":null,"height":null,"radius":null}],"type":"stick-C","versions":"Beta","units":[{"id":"3wV#oKE8ul1K1kat","createTime":1708832348946,"type":"gps","name":"gps_0","port":"A","default":["A","Custom"],"user_port":["21","22"],"icon":"unit_gps.png","hasPnP":true,"url":"https://docs.m5stack.com/en/unit/gps"}],"hats":[],"stamps":[],"blockly":"<variables><variable id=\"EV6Nnq4MUHPbxV3xcF+{\">deg</variable><variable id=\"^s9)GqW/kYh_{Ifd+t5a\">lat1</variable><variable id=\"/g4kF]WvG2DN-we4y.jx\">lgt1</variable><variable id=\"k!FNLU_^7Ol^|2Y}#J-,\">lat2</variable><variable id=\"%wf~^SAGNAfF{|2K[^dH\">lgt2</variable></variables><block type=\"basic_on_setup\" id=\"setup_block\" deletable=\"false\" x=\"-390\" y=\"-270\"><next><block type=\"screen_set_brightness\" id=\"#ayEjVa2o!K,)lNTuZyE\"><value name=\"BRIGHTNESS\"><shadow type=\"math_slider\" id=\"#?;8:47k{v~7jZBvCDj%\"><field name=\"NUM\" max=\"100\" step=\"1\">25</field></shadow></value><next><block type=\"unit_gps_uart_init\" id=\"2!kiks8;!hvLr~zhtEyk\"><field name=\"latitude\">gps_0</field><value name=\"ID\"><shadow type=\"unit_gps_pos_option\" id=\"Sy*XY/R(8an^3PF#xX[6\"><field name=\"pos\">1</field></shadow></value><next><block type=\"unit_gps_set_time_zone\" id=\"8I.]*/OFA-ztulzBTK,N\"><field name=\"gps\">gps_0</field><value name=\"ZONE\"><shadow type=\"math_number\" id=\"}.G{#hgS~P,-iv6!p;Bs\"><field name=\"NUM\">9</field></shadow></value><next><block type=\"iic_set_C\" id=\"upSJb89e4!li-t8OTLSM\"><field name=\"i2c\">i2c0</field><field name=\"FREQ\">400000</field><value name=\"sda\"><shadow type=\"math_number\" id=\"pam8HJ$@RIf2`UWtIWqx\"><field name=\"NUM\">0</field></shadow></value><value name=\"scl\"><shadow type=\"math_number\" id=\"a-2z+aLA2ZW#d@5PmXWz\"><field name=\"NUM\">26</field></shadow></value><next><block type=\"execute\" id=\"FQCmzOn8S.=8eo)+KBXz\"><field name=\"CODE\">import sys&#10;sys.path.append('/flash/res')&#10;from lsm9ds1_m5 import LSM9DS1&#10;lsm = LSM9DS1(i2c0, address_gyro=0x6A, address_magnet=0x1C)&#10;import math&#10;R = math.pi / 180</field><next><block type=\"timer_setStart\" id=\"OQlmKm#Cg1-ZG6S6$2:1\"><field name=\"start_name\">timer1</field><field name=\"mode\">0x00</field><value name=\"period\"><shadow type=\"math_number\" id=\"=;5+6}csiO5!`iOAvl_q\"><field name=\"NUM\">250</field></shadow></value><next><block type=\"basic_on_loop\" id=\"?fs0VOX7E4qq-nHcJjzt\"><statement name=\"LOOP\"><block type=\"timer_delay_ms\" id=\"nbzr6zb*eQDgWZ2.^r;W\"><value name=\"DELAY\"><shadow type=\"math_number\" id=\"T}C0_]zBqP7C3KH6gEKC\"><field name=\"NUM\">50</field></shadow></value></block></statement></block></next></block></next></block></next></block></next></block></next></block></next></block></next></block><block type=\"timer_callback\" id=\"U;SK=VBWMF?B=%i55i.]\" x=\"330\" y=\"-270\"><field name=\"name\">timer1</field><statement name=\"FUNC\"><block type=\"variables_set\" id=\"^UX%U6*td?6Ypb|0k%JP\"><field name=\"VAR\" id=\"^s9)GqW/kYh_{Ifd+t5a\">lat1</field><value name=\"VALUE\"><block type=\"unit_gps_get_latitude_decimal\" id=\")ox](siI1`e8RK{=yYr7\"><field name=\"latitude\">gps_0</field></block></value><next><block type=\"variables_set\" id=\"]-t=[I`~k0)|DYSP:S5+\"><field name=\"VAR\" id=\"/g4kF]WvG2DN-we4y.jx\">lgt1</field><value name=\"VALUE\"><block type=\"unit_gps_get_longitude_decimal\" id=\"gNxPf_YW~bNYAh;4%cR^\"><field name=\"longitude\">gps_0</field></block></value><next><block type=\"label_set_text\" id=\"`Qr`QKXzj*=,g%`ON,.U\"><field name=\"COMPONENT\">dateT</field><value name=\"TEXT\"><shadow type=\"text\" id=\"@5VHLbmjATd*n^egPGR6\"><field name=\"TEXT\">Hello M5</field></shadow><block type=\"unit_gps_get_date\" id=\"zf4uiZ8[Yec8m,-*;tnc\"><field name=\"gps\">gps_0</field></block></value><next><block type=\"label_set_text\" id=\"T+j36{xgmk{QN-g+ZnuS\"><field name=\"COMPONENT\">timeT</field><value name=\"TEXT\"><shadow type=\"text\" id=\"%W,f~-L_oU)op4{a{JqT\"><field name=\"TEXT\">Hello M5</field></shadow><block type=\"unit_gps_get_state\" id=\"IKHT1FfJ(cWe`W+?IugS\"><field name=\"gps\">gps_0</field></block></value><next><block type=\"label_set_text\" id=\"_,mSSE2/b5I%`M(j4ds{\"><field name=\"COMPONENT\">latT</field><value name=\"TEXT\"><shadow type=\"text\" id=\"ljxyf%GAt+$/-l@W91WY\"><field name=\"TEXT\">Hello M5</field></shadow><block type=\"variables_get\" id=\"VEb9cm^+Y{Ev~+/ZN?h~\"><field name=\"VAR\" id=\"^s9)GqW/kYh_{Ifd+t5a\">lat1</field></block></value><next><block type=\"label_set_text\" id=\"H=z_t[4[lJ3pKwx@MGLB\"><field name=\"COMPONENT\">lgtT</field><value name=\"TEXT\"><shadow type=\"text\" id=\"Ydsva/Kc(M;y,IcTS=XI\"><field name=\"TEXT\">Hello M5</field></shadow><block type=\"variables_get\" id=\"{C7][7fz_HYlH^vTZ[=R\"><field name=\"VAR\" id=\"/g4kF]WvG2DN-we4y.jx\">lgt1</field></block></value><next><block type=\"execute\" id=\"hwA*Go9wXi`802dN4[UF\"><field name=\"CODE\">## 目的地との距離、方角&#10;lat1 = float(lat1)&#10;lgt1 = float(lgt1)&#10;#lat2, lgt2 = 3333,11111&#10;lat2, lgt2 = 33333,11111&#10;dst = lat2dist(lat1, lgt1, lat2, lgt2)&#10;deg1 = lat2deg(lat1, lgt1, lat2, lgt2)&#10;dstT.setText(\"{:.2f}km\".format(dst))&#10;deg1T.setText(str(int(deg1)))</field><next><block type=\"execute\" id=\"E[A7aP|n2x/uXHcc=[0k\"><field name=\"CODE\">## 現在の方位関係&#10;mx0,my0,mz0 = lsm.read_magnet()&#10;deg = math.atan2(my0-0.25, mx0+0.03)*180/math.pi&#10;# 位相変換&#10;deg = deg if deg >= 0 else 360 + deg&#10;deg = (deg + 180) % 360&#10;degT.setText(str(int(deg)))&#10;drcT.setText(deg2drc(deg))</field><next><block type=\"circle_set_bgcolor_rgb\" id=\"4/q,R^bXI-lJ9@$I{_k!\"><field name=\"COMPONENT\">circle0</field><value name=\"R\"><shadow type=\"math_slider\" id=\"vSzf3a!U1ia(Y]qif8qB\"><field name=\"NUM\" max=\"255\" step=\"1\">160</field></shadow></value><value name=\"G\"><shadow type=\"math_slider\" id=\",}BmbcnJ%`87B@+YTPAE\"><field name=\"NUM\" max=\"255\" step=\"1\">160</field></shadow></value><value name=\"B\"><shadow type=\"math_slider\" id=\"F~z6[5P!Z.IRzK=~9SET\"><field name=\"NUM\" max=\"255\" step=\"1\">160</field></shadow></value><next><block type=\"line_set_position\" id=\"Z$|U#`!aV6deMzc5]W{)\"><field name=\"COMPONENT\">line0</field><value name=\"X1\"><shadow type=\"math_number\" id=\"9lN9w0NdmEkLSB(x%oR0\"><field name=\"NUM\">0</field></shadow></value><value name=\"Y1\"><shadow type=\"math_number\" id=\"eHt}oi65.sx2zAXli/{^\"><field name=\"NUM\">0</field></shadow></value><value name=\"X2\"><shadow type=\"math_number\" id=\"+9B8;*Uu}KspAyy`[cQS\"><field name=\"NUM\">0</field></shadow></value><value name=\"Y2\"><shadow type=\"math_number\" id=\"i;8=6-U}IiWU3#.4wbl8\"><field name=\"NUM\">0</field></shadow></value><next><block type=\"execute\" id=\"A:||E/HYYOC;=94Z/|uZ\"><field name=\"CODE\"># north direction&#10;triangle0.setSize(&#10;int(36*math.cos((deg+90)*R))+40, 40-int(36*math.sin((deg+90)*R)),&#10;int(9*math.cos((deg)*R))+40, 40-int(9*math.sin((deg)*R)),&#10;int(9*math.cos((deg+180)*R))+40, 40-int(9*math.sin((deg+180)*R))&#10;)</field><next><block type=\"execute\" id=\"VS!J-[YFHLs*|KW4`:{V\"><field name=\"CODE\"># destination direction&#10;delt = (deg1 + deg) % 360&#10;triangle1.setSize(&#10;int(36*math.cos((delt+90)*R))+40, 40-int(36*math.sin((delt+90)*R)),&#10;int(9*math.cos((delt)*R))+40, 40-int(9*math.sin((delt)*R)),&#10;int(9*math.cos((delt+180)*R))+40, 40-int(9*math.sin((delt+180)*R)),&#10;)</field></block></next></block></next></block></next></block></next></block></next></block></next></block></next></block></next></block></next></block></next></block></next></block></statement></block><block type=\"procedures_defreturn\" id=\"..XG9lY:|h-6teJb2P7;\" x=\"930\" y=\"-270\"><mutation><arg name=\"deg\" varid=\"EV6Nnq4MUHPbxV3xcF+{\"></arg></mutation><field name=\"NAME\">deg2drc</field><comment pinned=\"false\" h=\"80\" w=\"160\">Describe this function...</comment><statement name=\"STACK\"><block type=\"execute\" id=\"7My3`=D_hbr2M?6u+6A_\"><field name=\"CODE\">d = \"\"&#10;if deg <= 22.5*1:&#10; d = \"N\"&#10;elif deg < 22.5*3:&#10; d = \"NE\"&#10;elif deg <= 22.5*5:&#10; d = \"E\"&#10;elif deg <= 22.5*7:&#10; d = \"SE\"&#10;elif deg < 22.5*9:&#10; d = \"S\"&#10;elif deg <= 22.5*11:&#10; d = \"SW\"&#10;elif deg <= 22.5*13:&#10; d = \"W\"&#10;elif deg <= 22.5*15:&#10; d = \"NW\"&#10;else:&#10; d = \"N\"&#10;return d</field></block></statement></block><block type=\"procedures_defreturn\" id=\"V*1amk+e)%FZghUy?rWm\" x=\"-390\" y=\"270\"><mutation><arg name=\"lat1\" varid=\"^s9)GqW/kYh_{Ifd+t5a\"></arg><arg name=\"lgt1\" varid=\"/g4kF]WvG2DN-we4y.jx\"></arg><arg name=\"lat2\" varid=\"k!FNLU_^7Ol^|2Y}#J-,\"></arg><arg name=\"lgt2\" varid=\"%wf~^SAGNAfF{|2K[^dH\"></arg></mutation><field name=\"NAME\">lat2dist</field><comment pinned=\"false\" h=\"80\" w=\"160\">Describe this function...</comment><statement name=\"STACK\"><block type=\"execute\" id=\"@3~%Mz{{#UmP3HP.zj1P\"><field name=\"CODE\">return 6378*math.acos(&#10; math.cos(lat1*R)*math.cos(lat2*R)*math.cos(lgt2*R - lgt1*R)&#10; + math.sin(lat1*R)*math.sin(lat2*R)&#10;)</field></block></statement></block><block type=\"procedures_defreturn\" id=\"Ce9tZU7Pf^RcIQ3/mFwt\" x=\"-390\" y=\"470\"><mutation><arg name=\"lat1\" varid=\"^s9)GqW/kYh_{Ifd+t5a\"></arg><arg name=\"lgt1\" varid=\"/g4kF]WvG2DN-we4y.jx\"></arg><arg name=\"lat2\" varid=\"k!FNLU_^7Ol^|2Y}#J-,\"></arg><arg name=\"lgt2\" varid=\"%wf~^SAGNAfF{|2K[^dH\"></arg></mutation><field name=\"NAME\">lat2deg</field><comment pinned=\"false\" h=\"80\" w=\"160\">Describe this function...</comment><statement name=\"STACK\"><block type=\"execute\" id=\"7qM6Y-/ICPG11;0%L{,Q\"><field name=\"CODE\">rad = math.atan2(&#10; math.sin(lgt2*R-lgt1*R) * math.cos(lat2*R),&#10; math.cos(lat1*R)*math.sin(lat2*R) -&#10;math.sin(lat1*R)*math.cos(lat2*R)*math.cos(lgt2*R-lgt1*R)&#10;)&#10;deg = rad/R&#10;return (deg + 360) % 360</field></block></statement></block>","Blockly.Remotes":[],"Blockly.RemotePlus":[{"id":"__title","blockId":"","createTime":1708832348946,"name":"M5RemoteTitle","dragAndDrop":false,"resizable":false,"options":{"minWidth":1,"minHeight":1,"maxWidth":6,"maxHeight":10,"defaultWidth":2,"defaultHeight":1},"w":2,"h":1,"bgColor":"#0080FF","color":"#fff","fontsize":"M","label":"M5Remote","interval":3000,"code":"","event":"","dataSource":"none","ezdataToken":"JYlf205iO3qom4vpnNBl20HLC1Qz3GeR","topic":"","needShadow":false,"type":"title","x":0,"y":0}],"modules":[],"cbIdList_":[],"eventCBIdList_":[],"apikey":"CB89EEAD","uuid":"afb4e2d9-3b26-4c69-a7d3-4631f7808916"}