1 00:00:04,960 --> 00:00:19,999 [Music] 2 00:00:20,920 --> 00:00:24,720 I love that little sting thing it's 3 00:00:22,439 --> 00:00:28,119 great hi hi everyone and welcome to 4 00:00:24,720 --> 00:00:29,320 Saturday afternoon um this afternoon 5 00:00:28,119 --> 00:00:32,719 we've got a fellow who needs no 6 00:00:29,320 --> 00:00:35,079 introduction to a lot of you Matt 7 00:00:32,719 --> 00:00:38,280 trentini um Matt's been hosting the 8 00:00:35,079 --> 00:00:40,200 micropython Meetup in Melbourne for uh 9 00:00:38,280 --> 00:00:43,200 several years now and is a prolific 10 00:00:40,200 --> 00:00:45,200 contributor to the micropython ecosystem 11 00:00:43,200 --> 00:00:48,360 and culture um and he's here to talk to 12 00:00:45,200 --> 00:00:50,600 us about micropython the best bits um 13 00:00:48,360 --> 00:00:53,719 please make him very 14 00:00:50,600 --> 00:00:56,640 welcome thanks 15 00:00:53,719 --> 00:00:58,239 ni thanks Nick thanks every R um first 16 00:00:56,640 --> 00:00:59,640 housekeeping if anyone's stickers we've 17 00:00:58,239 --> 00:01:02,199 got a bunch of them uh they're really 18 00:00:59,640 --> 00:01:05,239 cool cute so I highly highly recommend 19 00:01:02,199 --> 00:01:07,280 grabbing a couple um Andrew's waving 20 00:01:05,239 --> 00:01:08,759 them about over his head so go see him 21 00:01:07,280 --> 00:01:10,920 uh and if you don't interrupt come grab 22 00:01:08,759 --> 00:01:12,159 them afterwards no problem uh slides are 23 00:01:10,920 --> 00:01:13,520 available on Discord and the eure 24 00:01:12,159 --> 00:01:15,759 channel so if you want to play along at 25 00:01:13,520 --> 00:01:17,320 home uh they're there uh and really have 26 00:01:15,759 --> 00:01:19,280 changed the title without telling the 27 00:01:17,320 --> 00:01:20,560 Pyon folks um I just couldn't get 28 00:01:19,280 --> 00:01:23,280 through everything so today is just some 29 00:01:20,560 --> 00:01:27,520 of the best bits of micropython um don't 30 00:01:23,280 --> 00:01:30,520 tell anyone so I'm I'm Matt uh hi uh 31 00:01:27,520 --> 00:01:31,680 I've got about 25 years experience which 32 00:01:30,520 --> 00:01:34,640 I'm kind of proud to say that but I'm 33 00:01:31,680 --> 00:01:37,200 also God I feels old um and I've been 34 00:01:34,640 --> 00:01:39,360 lucky enough to play with most parts of 35 00:01:37,200 --> 00:01:42,799 the software stack uh whether it's 36 00:01:39,360 --> 00:01:45,360 desktop software or embedded or um Cloud 37 00:01:42,799 --> 00:01:47,719 stuff uh but a lot of my time in this 38 00:01:45,360 --> 00:01:50,560 domain has been working closer on the 39 00:01:47,719 --> 00:01:51,840 hardware uh and about 10 or 15 years ago 40 00:01:50,560 --> 00:01:53,640 I was getting a bit jaded with a lot of 41 00:01:51,840 --> 00:01:55,600 that that um embedded development 42 00:01:53,640 --> 00:01:57,000 because it was sort of in stuck in its 43 00:01:55,600 --> 00:01:59,159 own little time capsule of building in 44 00:01:57,000 --> 00:02:00,840 SE and quite slow developments when you 45 00:01:59,159 --> 00:02:02,960 look around the rest the software space 46 00:02:00,840 --> 00:02:04,920 and people are um trying to progress 47 00:02:02,960 --> 00:02:06,640 with more agile developments can use 48 00:02:04,920 --> 00:02:08,160 integration better tooling all this kind 49 00:02:06,640 --> 00:02:09,440 of stuff and embedded is kind of 50 00:02:08,160 --> 00:02:12,800 plotting along the way it had been for 51 00:02:09,440 --> 00:02:14,200 many years and so I've been looking for 52 00:02:12,800 --> 00:02:15,519 an improvement or a better way to do 53 00:02:14,200 --> 00:02:18,879 things than embeded when micropython 54 00:02:15,519 --> 00:02:19,959 came along I kind of jumped at it and so 55 00:02:18,879 --> 00:02:22,400 uh I'm a 56 00:02:19,959 --> 00:02:24,400 contributor I've created added some code 57 00:02:22,400 --> 00:02:26,599 and and documentation I as Nick said 58 00:02:24,400 --> 00:02:28,280 I've hosted the M meet up for for a long 59 00:02:26,599 --> 00:02:31,000 time which Nick started just for anyone 60 00:02:28,280 --> 00:02:32,840 that didn't get that inside note there 61 00:02:31,000 --> 00:02:34,760 um I've given a couple of talks that Pon 62 00:02:32,840 --> 00:02:36,480 a used in the past although they're a 63 00:02:34,760 --> 00:02:37,879 little different to today in the past 64 00:02:36,480 --> 00:02:39,280 have kind of gone deep today I'm sort of 65 00:02:37,879 --> 00:02:41,000 going Broad and I want to give you a bit 66 00:02:39,280 --> 00:02:42,560 of a a glimpse into some of the tooling 67 00:02:41,000 --> 00:02:43,920 and the features which is part of the 68 00:02:42,560 --> 00:02:45,879 reason why I think mic Python's a good 69 00:02:43,920 --> 00:02:48,400 environment and worth your 70 00:02:45,879 --> 00:02:50,280 time um I also use micropython 71 00:02:48,400 --> 00:02:52,400 professionally we build medical devices 72 00:02:50,280 --> 00:02:54,280 with micropython so for those that think 73 00:02:52,400 --> 00:02:56,239 it's sort of a hobbyist system I'm happy 74 00:02:54,280 --> 00:02:57,159 to have that argument with you after 75 00:02:56,239 --> 00:02:59,400 this 76 00:02:57,159 --> 00:03:01,720 talk um most of us have sort of already 77 00:02:59,400 --> 00:03:03,519 talked about um I was planning on doing 78 00:03:01,720 --> 00:03:05,440 some demos I'm not I just didn't have 79 00:03:03,519 --> 00:03:06,519 time so uh it's mostly your talk and I 80 00:03:05,440 --> 00:03:08,159 want to get you sort of interested in 81 00:03:06,519 --> 00:03:09,840 some of these topics and I'll given you 82 00:03:08,159 --> 00:03:12,519 link so you can go look look at things 83 00:03:09,840 --> 00:03:13,640 if uh if they Peak your curiosity and 84 00:03:12,519 --> 00:03:16,120 hands up does everyone know what 85 00:03:13,640 --> 00:03:18,000 micropython is at least vaguely that it 86 00:03:16,120 --> 00:03:19,799 runs on microcontrollers and it's python 87 00:03:18,000 --> 00:03:21,720 right that's if not just hang on for the 88 00:03:19,799 --> 00:03:24,680 ride you'll be 89 00:03:21,720 --> 00:03:26,840 fine so starting from the the core guts 90 00:03:24,680 --> 00:03:28,000 of micropython um the repel is the first 91 00:03:26,840 --> 00:03:30,319 thing I wanted to talk about that's a 92 00:03:28,000 --> 00:03:31,760 best bit um micropython gives you a live 93 00:03:30,319 --> 00:03:33,959 reppel and and for those that have used 94 00:03:31,760 --> 00:03:35,599 python you might be thinking well okay 95 00:03:33,959 --> 00:03:37,680 we have a repple that's not that 96 00:03:35,599 --> 00:03:39,519 exciting but having a repple that runs 97 00:03:37,680 --> 00:03:41,680 on your embedded device is a complete 98 00:03:39,519 --> 00:03:44,519 GameChanger because it allows you to 99 00:03:41,680 --> 00:03:46,400 inspect the device you're you're able to 100 00:03:44,519 --> 00:03:48,640 uh manipulate the pins or communicate to 101 00:03:46,400 --> 00:03:51,519 peripherals in a live sort of fashion 102 00:03:48,640 --> 00:03:54,040 and back in the days before um with c 103 00:03:51,519 --> 00:03:57,079 and and C++ this is typically like a 104 00:03:54,040 --> 00:03:58,920 compile deploy test it didn't work so 105 00:03:57,079 --> 00:04:01,200 you try that again and again and again 106 00:03:58,920 --> 00:04:03,360 and so having that live communication to 107 00:04:01,200 --> 00:04:05,400 your device where we can um introspect 108 00:04:03,360 --> 00:04:07,439 what's going on provides just 109 00:04:05,400 --> 00:04:09,079 exploration and investigation you can 110 00:04:07,439 --> 00:04:11,480 really see what's what's happening it's 111 00:04:09,079 --> 00:04:13,120 a it's a really freeing way to develop 112 00:04:11,480 --> 00:04:15,040 um it also gives you tab completion 113 00:04:13,120 --> 00:04:18,000 which is nice although I really want to 114 00:04:15,040 --> 00:04:19,000 get 33s prompt into micro time for 115 00:04:18,000 --> 00:04:22,919 another 116 00:04:19,000 --> 00:04:23,960 day um next one file system so again 117 00:04:22,919 --> 00:04:26,000 everyone's got a file system on the 118 00:04:23,960 --> 00:04:27,560 regular python environment but having a 119 00:04:26,000 --> 00:04:29,440 file system on an embedded device is 120 00:04:27,560 --> 00:04:31,039 actually really cool it lets you store 121 00:04:29,440 --> 00:04:34,160 your code on the device and let you 122 00:04:31,039 --> 00:04:35,800 store logs and sensor information and 123 00:04:34,160 --> 00:04:37,680 configuration files so if you want to 124 00:04:35,800 --> 00:04:40,440 change the way your system behaves just 125 00:04:37,680 --> 00:04:43,039 store a file in your device seems simple 126 00:04:40,440 --> 00:04:45,280 but it's a really useful 127 00:04:43,039 --> 00:04:46,280 thing uh serial connection so we're 128 00:04:45,280 --> 00:04:47,240 talking about the repple there's there's 129 00:04:46,280 --> 00:04:48,800 a number of different ways you can get 130 00:04:47,240 --> 00:04:50,160 to the reppel on the device the most 131 00:04:48,800 --> 00:04:53,360 common way that is provided out of the 132 00:04:50,160 --> 00:04:54,320 box is over a Serial uh connection uh 133 00:04:53,360 --> 00:04:55,919 the other thing I just want to mention 134 00:04:54,320 --> 00:04:57,759 is you also have file transfers over 135 00:04:55,919 --> 00:04:59,199 that serial connection too micropython 136 00:04:57,759 --> 00:05:02,479 has a way of of getting files on and off 137 00:04:59,199 --> 00:05:04,800 the device over that same connection um 138 00:05:02,479 --> 00:05:07,440 and bit of an age test I wonder how many 139 00:05:04,800 --> 00:05:08,720 people actually realize what that is 140 00:05:07,440 --> 00:05:12,000 [Music] 141 00:05:08,720 --> 00:05:14,680 um we are going to skip over this Rabbit 142 00:05:12,000 --> 00:05:16,880 Hole um but if anyone's got uh an 143 00:05:14,680 --> 00:05:18,880 interest in serial factoids ask me about 144 00:05:16,880 --> 00:05:21,720 this later if we have time it's kind of 145 00:05:18,880 --> 00:05:23,720 interesting um Moving Straight on to MP 146 00:05:21,720 --> 00:05:26,160 remote it's the official tool to use 147 00:05:23,720 --> 00:05:27,440 with micropython command line tool uh 148 00:05:26,160 --> 00:05:30,120 it's supported and used by the 149 00:05:27,440 --> 00:05:34,240 micropython core team um half of which 150 00:05:30,120 --> 00:05:35,360 are here today thanks folks um what MP 151 00:05:34,240 --> 00:05:37,120 remote allows you to do is to make that 152 00:05:35,360 --> 00:05:39,600 repple connection uh lets you transfer 153 00:05:37,120 --> 00:05:41,479 files in a very easy sort of natural 154 00:05:39,600 --> 00:05:44,080 kind of way but it also lets you run 155 00:05:41,479 --> 00:05:46,720 files from your PC allows you to exe 156 00:05:44,080 --> 00:05:48,440 execute Snippets of python uh let you 157 00:05:46,720 --> 00:05:50,319 reset all these things here set your set 158 00:05:48,440 --> 00:05:51,600 your clock on your device put your 159 00:05:50,319 --> 00:05:52,720 device to sleep all sorts of things that 160 00:05:51,600 --> 00:05:55,680 you want to do but today I want to 161 00:05:52,720 --> 00:05:57,600 mention the mounting feature which MP 162 00:05:55,680 --> 00:05:59,280 remote Mount is kind of magic and it's a 163 00:05:57,600 --> 00:06:01,280 really interesting way to develop on an 164 00:05:59,280 --> 00:06:03,199 embedded device because what it does is 165 00:06:01,280 --> 00:06:05,560 it lets you mount a folder from your PC 166 00:06:03,199 --> 00:06:07,160 on your device it's just like as I said 167 00:06:05,560 --> 00:06:09,080 here it's just like having the PC as 168 00:06:07,160 --> 00:06:10,199 your hard drive for your device and the 169 00:06:09,080 --> 00:06:12,479 nice thing about this is that you can 170 00:06:10,199 --> 00:06:14,680 develop in your regular use vs code 171 00:06:12,479 --> 00:06:15,960 right we use our git repositories and so 172 00:06:14,680 --> 00:06:18,160 you just develop as you would normally 173 00:06:15,960 --> 00:06:19,800 you would commit as you would um and 174 00:06:18,160 --> 00:06:22,599 when you're ready you just Mount that 175 00:06:19,800 --> 00:06:24,360 that folder on your device and you test 176 00:06:22,599 --> 00:06:25,759 and you edit your files and you test you 177 00:06:24,360 --> 00:06:28,840 edit your files and you test and it's a 178 00:06:25,759 --> 00:06:31,360 really quick way to do turnarounds and 179 00:06:28,840 --> 00:06:33,919 uh to develop your embedded system uh 180 00:06:31,360 --> 00:06:35,800 it's a relatively new feature um had it 181 00:06:33,919 --> 00:06:36,960 for probably a year or so but um I want 182 00:06:35,800 --> 00:06:38,479 to spread that word because we've gotten 183 00:06:36,960 --> 00:06:40,919 a lot of use out of using this feature 184 00:06:38,479 --> 00:06:40,919 it's it's 185 00:06:41,400 --> 00:06:47,440 great uh MIP MIP is to micropython as 186 00:06:44,520 --> 00:06:48,880 pip is to cpython so uh it's our package 187 00:06:47,440 --> 00:06:50,840 manager for for 188 00:06:48,880 --> 00:06:52,599 micropython and the important thing here 189 00:06:50,840 --> 00:06:54,919 is that I like to say that micropython 190 00:06:52,599 --> 00:06:58,400 has small batteries included it doesn't 191 00:06:54,919 --> 00:07:01,199 have the vast um python standard library 192 00:06:58,400 --> 00:07:02,800 that you would be used to uh has a much 193 00:07:01,199 --> 00:07:04,560 smaller con constrained one because the 194 00:07:02,800 --> 00:07:06,759 devices we're operating on have small 195 00:07:04,560 --> 00:07:08,919 amounts of Flash and resources so we 196 00:07:06,759 --> 00:07:10,840 need to be careful about what we deploy 197 00:07:08,919 --> 00:07:12,759 so a bunch of packages are also hosted 198 00:07:10,840 --> 00:07:16,039 on micropython lib which is a separate 199 00:07:12,759 --> 00:07:17,680 repository and you can install those um 200 00:07:16,039 --> 00:07:20,720 after you've got your device up and 201 00:07:17,680 --> 00:07:22,000 running and mlet you do that easily uh 202 00:07:20,720 --> 00:07:24,000 you can also install third party 203 00:07:22,000 --> 00:07:26,120 libraries from GitHub or gitlab and it 204 00:07:24,000 --> 00:07:27,520 makes it easy to do that as well um so 205 00:07:26,120 --> 00:07:30,680 how do you do it you do it with MP 206 00:07:27,520 --> 00:07:32,160 remote uh just MIP install package name 207 00:07:30,680 --> 00:07:33,199 if you're used to Pip this should feel 208 00:07:32,160 --> 00:07:35,000 kind of 209 00:07:33,199 --> 00:07:37,520 familiar um and you can also do it 210 00:07:35,000 --> 00:07:40,479 straight from GitHub if your device has 211 00:07:37,520 --> 00:07:42,840 micropython like Anthony's rby Pi PW you 212 00:07:40,479 --> 00:07:44,479 can also use MIP on a connected device 213 00:07:42,840 --> 00:07:47,039 so you establish a connection to your 214 00:07:44,479 --> 00:07:49,440 Wi-Fi um and yeah MIP install the 215 00:07:47,039 --> 00:07:50,840 package which kind of feels really um 216 00:07:49,440 --> 00:07:52,720 futuristic being able to install 217 00:07:50,840 --> 00:07:56,360 packages on a device with like 30k of 218 00:07:52,720 --> 00:07:56,360 ram um yeah it's pretty 219 00:07:56,840 --> 00:08:02,159 cool H quick example should youtil is 220 00:07:59,560 --> 00:08:05,680 not provided uh by default so I try to 221 00:08:02,159 --> 00:08:08,720 use it doesn't exist uh MIP it's just 222 00:08:05,680 --> 00:08:12,759 you know it's pseudo make me a sandwich 223 00:08:08,720 --> 00:08:16,800 um and there it will work 224 00:08:12,759 --> 00:08:18,280 yay thanks for the little appreciate uh 225 00:08:16,800 --> 00:08:20,800 the Unix port's an important tool that 226 00:08:18,280 --> 00:08:23,159 we have um and I know that Unix and 227 00:08:20,800 --> 00:08:24,720 Linux are different but that's okay Unix 228 00:08:23,159 --> 00:08:26,639 is like an umbrella term for the 229 00:08:24,720 --> 00:08:29,560 micropython that runs on 230 00:08:26,639 --> 00:08:31,000 x86 um super useful thing because it's 231 00:08:29,560 --> 00:08:33,320 the same interpreter it's the same code 232 00:08:31,000 --> 00:08:35,159 that you're running on Unix um so if you 233 00:08:33,320 --> 00:08:36,120 get it running on the Unix Port you're 234 00:08:35,159 --> 00:08:38,399 usually pretty confident it's going to 235 00:08:36,120 --> 00:08:40,959 run in your device um so it's especially 236 00:08:38,399 --> 00:08:44,200 useful for doing unit tests so you can 237 00:08:40,959 --> 00:08:45,959 run your unit tests on x86 on the Unix 238 00:08:44,200 --> 00:08:48,760 Port uh and you know it's going to 239 00:08:45,959 --> 00:08:50,800 behave very similarly to the device it's 240 00:08:48,760 --> 00:08:52,120 very handy to be able to configure the 241 00:08:50,800 --> 00:08:55,000 memory because normally you've got 242 00:08:52,120 --> 00:08:56,519 Oodles of memory on your PC but um the 243 00:08:55,000 --> 00:08:58,560 Unix Port allows you to specify the 244 00:08:56,519 --> 00:09:01,399 maximum amount of memory so you um Can 245 00:08:58,560 --> 00:09:03,399 simulate more closely your your embedded 246 00:09:01,399 --> 00:09:05,680 device and although it's easy to build 247 00:09:03,399 --> 00:09:09,440 the Unix Port we also provide containers 248 00:09:05,680 --> 00:09:11,720 so uh you can just Docker um grab grab a 249 00:09:09,440 --> 00:09:13,760 Docker container of the Unix Port it's 250 00:09:11,720 --> 00:09:15,360 also super useful because the tag uh can 251 00:09:13,760 --> 00:09:16,279 specify the version so you can check for 252 00:09:15,360 --> 00:09:19,240 aggressions between different 253 00:09:16,279 --> 00:09:20,680 micropython versions um so yeah I would 254 00:09:19,240 --> 00:09:23,000 encourage everyone to get familiar with 255 00:09:20,680 --> 00:09:23,000 Unix 256 00:09:23,040 --> 00:09:26,839 Port MP build I look I don't think it's 257 00:09:25,519 --> 00:09:29,680 overstating it that it might be the best 258 00:09:26,839 --> 00:09:32,720 build tool ever created for any platform 259 00:09:29,680 --> 00:09:34,800 in any Universe um I did write it 260 00:09:32,720 --> 00:09:36,920 recently um so I might be a little bit 261 00:09:34,800 --> 00:09:38,360 biased um it does have a cool logo there 262 00:09:36,920 --> 00:09:41,200 right 263 00:09:38,360 --> 00:09:45,360 um so micr can be a bit challenging to 264 00:09:41,200 --> 00:09:46,480 build because uh it uses it works on 265 00:09:45,360 --> 00:09:48,399 number of different microcontrollers and 266 00:09:46,480 --> 00:09:51,240 they all require their own tool chains 267 00:09:48,399 --> 00:09:52,480 and their own um dependencies and so mpu 268 00:09:51,240 --> 00:09:54,200 kind of simplifies a lot of that by 269 00:09:52,480 --> 00:09:56,720 building in containers and knowing which 270 00:09:54,200 --> 00:09:58,720 containers to use for the various um 271 00:09:56,720 --> 00:10:00,120 devices that you're trying to build for 272 00:09:58,720 --> 00:10:01,800 uh it also has completion which is 273 00:10:00,120 --> 00:10:04,120 really nice because it it knows the name 274 00:10:01,800 --> 00:10:06,440 of all of the um all the boards that you 275 00:10:04,120 --> 00:10:09,000 might want to build so how do you do it 276 00:10:06,440 --> 00:10:10,760 this is the shortest most boring um 277 00:10:09,000 --> 00:10:13,120 animated demo ever because it's just MP 278 00:10:10,760 --> 00:10:14,320 build and then the name of your board uh 279 00:10:13,120 --> 00:10:16,079 if you don't have the container it'll go 280 00:10:14,320 --> 00:10:18,600 grab it and it will just build and spit 281 00:10:16,079 --> 00:10:19,519 you out a firmware binary and uh that's 282 00:10:18,600 --> 00:10:23,120 pretty 283 00:10:19,519 --> 00:10:24,440 nice um for those yeah I also use an 284 00:10:23,120 --> 00:10:26,320 alias to make it even shorter because I 285 00:10:24,440 --> 00:10:29,720 don't like 286 00:10:26,320 --> 00:10:32,000 typing uh we're also just stying to add 287 00:10:29,720 --> 00:10:33,760 everyone's used text rle um or if you 288 00:10:32,000 --> 00:10:36,800 haven't go check out textle Library by 289 00:10:33,760 --> 00:10:39,720 will mugan it lets you do um sort of 290 00:10:36,800 --> 00:10:40,880 goys in uh the CLI and this is an 291 00:10:39,720 --> 00:10:42,760 example of what we're doing here with 292 00:10:40,880 --> 00:10:45,279 the um ports and the boards there on the 293 00:10:42,760 --> 00:10:47,000 left and that big stripey section in the 294 00:10:45,279 --> 00:10:49,160 middle or on the right is going to be 295 00:10:47,000 --> 00:10:50,560 where you can choose to build or it'll 296 00:10:49,160 --> 00:10:53,720 give you information about your board 297 00:10:50,560 --> 00:10:56,079 and so on and so forth so um stay tuned 298 00:10:53,720 --> 00:10:59,320 I'll hopefully talk about that another 299 00:10:56,079 --> 00:11:01,320 time uh the memory profile uh just like 300 00:10:59,320 --> 00:11:03,880 big python and yes we call it big python 301 00:11:01,320 --> 00:11:06,120 um micropython uses a GC to to manage 302 00:11:03,880 --> 00:11:07,720 memory but because these devices have 303 00:11:06,120 --> 00:11:08,800 quite limited amounts of memory you 304 00:11:07,720 --> 00:11:10,320 really need to be on top of this and 305 00:11:08,800 --> 00:11:12,079 make sure that you're not using too much 306 00:11:10,320 --> 00:11:14,240 memory and not fragmenting it in 307 00:11:12,079 --> 00:11:16,880 particular and so micropython gives you 308 00:11:14,240 --> 00:11:19,000 a tool M info that will specify how 309 00:11:16,880 --> 00:11:22,320 memory is being used at any given time 310 00:11:19,000 --> 00:11:24,880 it will spit out a whole uh asy uh line 311 00:11:22,320 --> 00:11:26,600 that will show you for each character 312 00:11:24,880 --> 00:11:28,560 how that Block's been 313 00:11:26,600 --> 00:11:31,320 allocated and so we've built a tool 314 00:11:28,560 --> 00:11:35,120 inhouse and thanks to my employer um Pi 315 00:11:31,320 --> 00:11:37,279 for helping release this um we we 316 00:11:35,120 --> 00:11:39,000 collect mem info data and we also 317 00:11:37,279 --> 00:11:41,560 collect log information and we produce 318 00:11:39,000 --> 00:11:44,320 an animation so you can see the logs and 319 00:11:41,560 --> 00:11:46,120 the memory information over time uh and 320 00:11:44,320 --> 00:11:48,480 it makes it easy to identify from the 321 00:11:46,120 --> 00:11:49,839 logs what's allocating memory and you 322 00:11:48,480 --> 00:11:52,560 can go back and Target that and use 323 00:11:49,839 --> 00:11:54,120 techniques to reduce that memory use um 324 00:11:52,560 --> 00:11:57,440 we need this for when you're trying to 325 00:11:54,120 --> 00:11:59,600 run uh uh devices for long periods of 326 00:11:57,440 --> 00:12:00,639 time in particular 327 00:11:59,600 --> 00:12:03,560 so let's just have a quick look at what 328 00:12:00,639 --> 00:12:07,360 the animation looks like 329 00:12:03,560 --> 00:12:08,360 um where's the pause button so just to 330 00:12:07,360 --> 00:12:10,160 explain what's going on on the left 331 00:12:08,360 --> 00:12:11,480 we've got the logs coming out on the 332 00:12:10,160 --> 00:12:13,560 right that's the dump that you get from 333 00:12:11,480 --> 00:12:15,600 me info I won't go into detail but each 334 00:12:13,560 --> 00:12:16,880 of these characters here you can 335 00:12:15,600 --> 00:12:19,560 ascertain how that memory is being 336 00:12:16,880 --> 00:12:20,839 allocated I've just got an async uh task 337 00:12:19,560 --> 00:12:23,120 here that's allocating memory quite 338 00:12:20,839 --> 00:12:25,480 frequently and then periodically we're 339 00:12:23,120 --> 00:12:28,160 I'm deallocating half of the memory so 340 00:12:25,480 --> 00:12:30,160 we expect to see the memory grow um but 341 00:12:28,160 --> 00:12:32,199 you'll see the lines sort of increase 342 00:12:30,160 --> 00:12:35,120 increase increase and then get returned 343 00:12:32,199 --> 00:12:37,399 back to the back to the Heap and so this 344 00:12:35,120 --> 00:12:38,800 allows us to see when we've got memory 345 00:12:37,399 --> 00:12:40,720 problems because what you don't want is 346 00:12:38,800 --> 00:12:41,959 to see that continuously grow when 347 00:12:40,720 --> 00:12:45,880 you're running your application for days 348 00:12:41,959 --> 00:12:48,920 at a time um this helps build reliable 349 00:12:45,880 --> 00:12:50,320 applications so that tool is available 350 00:12:48,920 --> 00:12:52,800 um we'd love to extend it a little 351 00:12:50,320 --> 00:12:55,519 further at the moment like the me info 352 00:12:52,800 --> 00:12:57,120 you know it looks asy and nerdy so we 353 00:12:55,519 --> 00:12:59,279 could actually have like a pictorial 354 00:12:57,120 --> 00:13:00,959 version like have pixels for represent 355 00:12:59,279 --> 00:13:02,279 in the blocks there's a lot lot of room 356 00:13:00,959 --> 00:13:03,720 for improvement there I think but it's 357 00:13:02,279 --> 00:13:05,880 still right now it was a really useful 358 00:13:03,720 --> 00:13:08,320 tool for 359 00:13:05,880 --> 00:13:12,079 us uh other useful tools everyone wants 360 00:13:08,320 --> 00:13:13,199 to play in the browser these days um so 361 00:13:12,079 --> 00:13:16,440 you can do that if you want to with 362 00:13:13,199 --> 00:13:18,320 micropython Viper ID is a is an IDE that 363 00:13:16,440 --> 00:13:20,480 uh runs totally in the browser in any 364 00:13:18,320 --> 00:13:23,160 Chromebase browser because it relies on 365 00:13:20,480 --> 00:13:25,560 web USB web serial to U make make 366 00:13:23,160 --> 00:13:29,120 connections to your device it allows 367 00:13:25,560 --> 00:13:30,800 serial B and Wi-Fi connections has the 368 00:13:29,120 --> 00:13:34,440 file editor file manager you can see 369 00:13:30,800 --> 00:13:36,680 there on the side uh it has uh MIP 370 00:13:34,440 --> 00:13:38,440 Integrations so you can install packages 371 00:13:36,680 --> 00:13:40,360 it has a terminal built in so it has all 372 00:13:38,440 --> 00:13:41,639 the things you'd sort of want and need 373 00:13:40,360 --> 00:13:43,760 really good way to get started with 374 00:13:41,639 --> 00:13:45,760 micropython um I personally prefer vs 375 00:13:43,760 --> 00:13:47,360 code and MP remote because it gives you 376 00:13:45,760 --> 00:13:48,160 a little bit of extra power but 377 00:13:47,360 --> 00:13:49,360 particularly if you're in the 378 00:13:48,160 --> 00:13:51,160 educational sector If you're sort of 379 00:13:49,360 --> 00:13:54,959 dabling with micropython it's a really 380 00:13:51,160 --> 00:13:56,560 great tool to use um yeah and speaking 381 00:13:54,959 --> 00:14:00,000 of browser tools uh for those that 382 00:13:56,560 --> 00:14:01,519 haven't used W it's a um it's a browser 383 00:14:00,000 --> 00:14:05,320 based simulator so it actually simulates 384 00:14:01,519 --> 00:14:07,199 a bunch of Hardware uh again free to use 385 00:14:05,320 --> 00:14:09,480 uh it has a large range of peripherals 386 00:14:07,199 --> 00:14:11,279 so you can see here we've got an esp32 387 00:14:09,480 --> 00:14:13,920 connected to an LED ring but you could 388 00:14:11,279 --> 00:14:15,519 easily put temperature sensors in there 389 00:14:13,920 --> 00:14:16,800 um or whatever sort of stuff you've got 390 00:14:15,519 --> 00:14:18,000 they've got you know quite a large list 391 00:14:16,800 --> 00:14:20,120 of things that you can connect up and 392 00:14:18,000 --> 00:14:22,279 wire in the way you would on your actual 393 00:14:20,120 --> 00:14:24,160 Hardware uh and then you can run your 394 00:14:22,279 --> 00:14:26,880 run your uh software and it will 395 00:14:24,160 --> 00:14:29,440 actually run and uh see if it you can 396 00:14:26,880 --> 00:14:31,800 see if it works which is quite nice it 397 00:14:29,440 --> 00:14:33,959 also uh is available as a vs code 398 00:14:31,800 --> 00:14:36,639 extension as well which is quite 399 00:14:33,959 --> 00:14:37,880 neat I just I justess want to put make a 400 00:14:36,639 --> 00:14:40,000 note there that it's quite a rich 401 00:14:37,880 --> 00:14:42,320 simulation like it even has uh the 402 00:14:40,000 --> 00:14:45,279 ability to reach out of the browser so 403 00:14:42,320 --> 00:14:46,680 like this sp32 has Wi-Fi and this 404 00:14:45,279 --> 00:14:50,199 particular example is actually looking 405 00:14:46,680 --> 00:14:51,920 at a mqtt server that's in the cloud uh 406 00:14:50,199 --> 00:14:53,759 which you can send an mqtt message to 407 00:14:51,920 --> 00:14:57,720 and set the color of those LEDs and this 408 00:14:53,759 --> 00:15:00,560 all happens in the browser it's pretty 409 00:14:57,720 --> 00:15:02,240 awesome uh I'm trying to get the two 410 00:15:00,560 --> 00:15:04,839 developers to talk to integrate Viper 411 00:15:02,240 --> 00:15:06,480 IDE and uh and walk we because it'd be 412 00:15:04,839 --> 00:15:09,639 cool to have that extra those extra 413 00:15:06,480 --> 00:15:12,399 features in the browser but um stay 414 00:15:09,639 --> 00:15:14,880 tuned mellane asy I had to mention this 415 00:15:12,399 --> 00:15:17,560 because it's just a fundamental part of 416 00:15:14,880 --> 00:15:18,920 python but also micropython uh it's so 417 00:15:17,560 --> 00:15:20,120 useful in the embedded space because a 418 00:15:18,920 --> 00:15:23,000 lot of the time we're dealing with 419 00:15:20,120 --> 00:15:25,720 micros that just have a single core and 420 00:15:23,000 --> 00:15:27,480 also a lot of the um operations that we 421 00:15:25,720 --> 00:15:29,000 do are sort of asynchronous in nature we 422 00:15:27,480 --> 00:15:30,040 do something we waiting for a result 423 00:15:29,000 --> 00:15:32,360 we're doing something else and waiting 424 00:15:30,040 --> 00:15:34,440 for a result so ennco is a really good 425 00:15:32,360 --> 00:15:36,199 fit for the embedded space um and it's a 426 00:15:34,440 --> 00:15:38,639 foundational Library a lot of other 427 00:15:36,199 --> 00:15:40,480 libraries are built on it uh like AI 428 00:15:38,639 --> 00:15:44,360 repple which is a library that you can 429 00:15:40,480 --> 00:15:47,240 use to um provide uh async features to 430 00:15:44,360 --> 00:15:50,160 the reppel um and this has been a real 431 00:15:47,240 --> 00:15:52,240 win for us um if you've got an async 432 00:15:50,160 --> 00:15:54,399 capable application you can run it from 433 00:15:52,240 --> 00:15:55,639 your reppel so it's running live but 434 00:15:54,399 --> 00:15:59,000 instead of being blocked until the 435 00:15:55,639 --> 00:16:00,680 application uh finishes you can still uh 436 00:15:59,000 --> 00:16:02,759 interact with that running application 437 00:16:00,680 --> 00:16:05,240 so we can do things like have control 438 00:16:02,759 --> 00:16:07,800 loops and they might be uh generating a 439 00:16:05,240 --> 00:16:10,680 p Loop uh to keep a heater at a certain 440 00:16:07,800 --> 00:16:12,800 temperature right um but while that's 441 00:16:10,680 --> 00:16:14,560 running we can actually inquire as to 442 00:16:12,800 --> 00:16:16,920 how it's performing and even change the 443 00:16:14,560 --> 00:16:18,800 values to to modify it on the fly so 444 00:16:16,920 --> 00:16:20,440 it's a really again we've got a really 445 00:16:18,800 --> 00:16:22,319 tight sort of feedback loop and a really 446 00:16:20,440 --> 00:16:24,399 quick way to iterate with our 447 00:16:22,319 --> 00:16:26,920 applications um we also used it for like 448 00:16:24,399 --> 00:16:28,920 a we had a state machine and the state 449 00:16:26,920 --> 00:16:29,959 machine was getting quite complex and 450 00:16:28,920 --> 00:16:31,279 and we want to test what happens when it 451 00:16:29,959 --> 00:16:33,360 gets into unusual States and you can 452 00:16:31,279 --> 00:16:35,240 just inject the States from from the 453 00:16:33,360 --> 00:16:37,519 reppel it's um it's really useful thing 454 00:16:35,240 --> 00:16:40,360 to have Anthony this would also allow 455 00:16:37,519 --> 00:16:43,160 you to download your uh files while your 456 00:16:40,360 --> 00:16:43,160 application's running 457 00:16:43,319 --> 00:16:48,360 too uh a b just a quick mention but uh 458 00:16:46,880 --> 00:16:49,800 if anyone's used B and they've tried to 459 00:16:48,360 --> 00:16:51,199 get it working on an embedded device I'm 460 00:16:49,800 --> 00:16:53,440 sure they would have shared my pain 461 00:16:51,199 --> 00:16:56,079 doing that uh it's a really quite a 462 00:16:53,440 --> 00:16:57,839 complex uh beast and it's it's often 463 00:16:56,079 --> 00:16:59,199 callback heavy so you get a lot of 464 00:16:57,839 --> 00:17:01,199 interrupts coming back a lot of 465 00:16:59,199 --> 00:17:04,079 callbacks and you need to figure out 466 00:17:01,199 --> 00:17:07,079 what's going on um as these callbacks 467 00:17:04,079 --> 00:17:08,959 are being generated AO simplifies a lot 468 00:17:07,079 --> 00:17:11,679 of that by introducing async functions 469 00:17:08,959 --> 00:17:13,760 to a b Library so you can do things like 470 00:17:11,679 --> 00:17:15,480 await a connection and you don't have to 471 00:17:13,760 --> 00:17:16,839 wait for the Callback so you don't have 472 00:17:15,480 --> 00:17:18,799 to inquire as to what message has been 473 00:17:16,839 --> 00:17:20,240 generated the next line just means that 474 00:17:18,799 --> 00:17:22,959 you've made that connection and so then 475 00:17:20,240 --> 00:17:24,679 you can do the next step so uh you kind 476 00:17:22,959 --> 00:17:27,959 of end up with like quite a linear easy 477 00:17:24,679 --> 00:17:29,360 re chunk of code with a lot less code um 478 00:17:27,959 --> 00:17:31,520 rather than having at Le callbacks being 479 00:17:29,360 --> 00:17:33,880 generated so for me this has been the 480 00:17:31,520 --> 00:17:37,400 best way to do B development on any 481 00:17:33,880 --> 00:17:40,880 platform Library language it's been 482 00:17:37,400 --> 00:17:42,400 great uh see we doing time um so C user 483 00:17:40,880 --> 00:17:44,360 modules I've got like the warning down 484 00:17:42,400 --> 00:17:45,480 the bottom there only if you only 485 00:17:44,360 --> 00:17:48,120 indicate that we're we're actually 486 00:17:45,480 --> 00:17:49,200 delving into the the C World here um 487 00:17:48,120 --> 00:17:51,840 because one of the superpowers of 488 00:17:49,200 --> 00:17:54,120 micropython is that it's written in C 489 00:17:51,840 --> 00:17:56,960 and also makes it very easy to um create 490 00:17:54,120 --> 00:17:58,600 C modules so why you'd want to do that 491 00:17:56,960 --> 00:17:59,720 is for two obvious reasons you want to 492 00:17:58,600 --> 00:18:01,240 integr great to C library because 493 00:17:59,720 --> 00:18:02,480 there's lots of them out there but the 494 00:18:01,240 --> 00:18:06,200 second one is if you want to optimize 495 00:18:02,480 --> 00:18:07,880 your code so um you can if your profiler 496 00:18:06,200 --> 00:18:09,960 shows you of course you should check 497 00:18:07,880 --> 00:18:11,320 your profiler if your profiler shows you 498 00:18:09,960 --> 00:18:13,000 You' got a bit of code that needs to run 499 00:18:11,320 --> 00:18:14,840 faster you've always got the option to 500 00:18:13,000 --> 00:18:16,799 drop into C and create like a small trck 501 00:18:14,840 --> 00:18:17,880 of your code in C that's accessible for 502 00:18:16,799 --> 00:18:20,320 micropython and that's actually 503 00:18:17,880 --> 00:18:23,000 relatively easy to do 504 00:18:20,320 --> 00:18:25,240 um and the disadvantage here is that you 505 00:18:23,000 --> 00:18:27,039 do need to produce your own firmware so 506 00:18:25,240 --> 00:18:29,400 we don't have that rapid iteration cycle 507 00:18:27,039 --> 00:18:31,880 that we like with micropython but um you 508 00:18:29,400 --> 00:18:34,120 do get SE level of performance right so 509 00:18:31,880 --> 00:18:36,360 for me this is really 510 00:18:34,120 --> 00:18:39,000 um nice in the sense that I never have 511 00:18:36,360 --> 00:18:40,600 to be worried or scared that micropython 512 00:18:39,000 --> 00:18:42,120 uh I'm going to run out of performance 513 00:18:40,600 --> 00:18:44,600 right I know that I can always drop into 514 00:18:42,120 --> 00:18:47,520 C and write small chunks of my system in 515 00:18:44,600 --> 00:18:48,919 C and then execute them from micropython 516 00:18:47,520 --> 00:18:50,360 um and so that way I'm sort of doing 517 00:18:48,919 --> 00:18:52,000 surgical Cuts Like wherever there's a 518 00:18:50,360 --> 00:18:54,240 little bit of code that needs to be 519 00:18:52,000 --> 00:18:56,159 improved write that and C if I really 520 00:18:54,240 --> 00:18:57,799 have to um and then just get the 521 00:18:56,159 --> 00:19:00,120 benefits of developing a micropython for 522 00:18:57,799 --> 00:19:02,520 the vast majority of my 523 00:19:00,120 --> 00:19:03,840 code and related to that I have to talk 524 00:19:02,520 --> 00:19:06,880 about Native modules this is another 525 00:19:03,840 --> 00:19:09,520 best bit uh Native modules is similar to 526 00:19:06,880 --> 00:19:11,720 the C user modules we can compile chunks 527 00:19:09,520 --> 00:19:13,640 of native code and we can package them 528 00:19:11,720 --> 00:19:16,440 much like you would a dll or or a shared 529 00:19:13,640 --> 00:19:18,360 Library um uh and they got different 530 00:19:16,440 --> 00:19:19,679 pros and cons here uh similar to 531 00:19:18,360 --> 00:19:21,640 Performance to C so we're still talking 532 00:19:19,679 --> 00:19:23,039 fast performance uh they can be loaded 533 00:19:21,640 --> 00:19:25,679 at runtime which is awesome we don't 534 00:19:23,039 --> 00:19:27,480 need to build our own firmware still um 535 00:19:25,679 --> 00:19:28,720 but the little module has to be built 536 00:19:27,480 --> 00:19:31,080 for the platform that you're Target 537 00:19:28,720 --> 00:19:32,480 tting so if you want to support a 538 00:19:31,080 --> 00:19:34,240 general Library you have to build it for 539 00:19:32,480 --> 00:19:35,360 each of the platforms that are available 540 00:19:34,240 --> 00:19:37,080 and there's a few other technical 541 00:19:35,360 --> 00:19:40,120 constraints but we can leave those 542 00:19:37,080 --> 00:19:41,520 around for this particular Doc it's also 543 00:19:40,120 --> 00:19:44,600 worth mentioning there's been a 544 00:19:41,520 --> 00:19:47,280 development uh of combining like wasm 545 00:19:44,600 --> 00:19:49,400 and Empire and another holy sort of mix 546 00:19:47,280 --> 00:19:52,159 um you can sort of package any library 547 00:19:49,400 --> 00:19:55,080 that emits WM theoretically uh and these 548 00:19:52,159 --> 00:19:57,880 ones have been tested um and so you can 549 00:19:55,080 --> 00:20:00,000 compile these and emit uh rasm and then 550 00:19:57,880 --> 00:20:01,520 take those and compile them down to C 551 00:20:00,000 --> 00:20:03,640 and then automatically compile that c 552 00:20:01,520 --> 00:20:04,960 into a native module and so you get near 553 00:20:03,640 --> 00:20:06,760 native performance running in 554 00:20:04,960 --> 00:20:08,679 micropython in a module that can be 555 00:20:06,760 --> 00:20:10,320 loaded at runtime and I think that's 556 00:20:08,679 --> 00:20:13,280 it's a really exciting development 557 00:20:10,320 --> 00:20:17,640 that's um it's active right 558 00:20:13,280 --> 00:20:19,159 now thank you uh lvgl uh is a really 559 00:20:17,640 --> 00:20:20,760 popular embedded UI tool kit this is 560 00:20:19,159 --> 00:20:24,480 kind of a bit of work that we're doing 561 00:20:20,760 --> 00:20:26,440 uh at the moment in part of my day job 562 00:20:24,480 --> 00:20:28,240 uh and the cor lvgl team they maintain 563 00:20:26,440 --> 00:20:29,440 micropython bindings where they pause 564 00:20:28,240 --> 00:20:31,159 their headed 565 00:20:29,440 --> 00:20:32,520 um which generate all these widgets and 566 00:20:31,159 --> 00:20:34,159 they give you micropython bindings for 567 00:20:32,520 --> 00:20:36,000 them and performance is identical 568 00:20:34,159 --> 00:20:39,000 because you're calling through to the C 569 00:20:36,000 --> 00:20:40,799 code um but it's easier to write because 570 00:20:39,000 --> 00:20:41,960 it's micropython and the UI can be 571 00:20:40,799 --> 00:20:44,280 modified at runtime which you're not 572 00:20:41,960 --> 00:20:46,280 going to do in see um and it's really 573 00:20:44,280 --> 00:20:48,480 helpful uh the part that's been missing 574 00:20:46,280 --> 00:20:50,880 till recently is is packaging this 575 00:20:48,480 --> 00:20:53,039 system right the lvgl core team provides 576 00:20:50,880 --> 00:20:54,559 those bindings but they don't provide uh 577 00:20:53,039 --> 00:20:56,159 a firmware binary for the device you 578 00:20:54,559 --> 00:20:58,000 need so we're working hard to try to fix 579 00:20:56,159 --> 00:21:01,000 that uh and we're going to do things 580 00:20:58,000 --> 00:21:02,799 like package lvgl as a c module and 581 00:21:01,000 --> 00:21:04,840 package drivers as a native module 582 00:21:02,799 --> 00:21:07,280 that's the goal we're trying to get to 583 00:21:04,840 --> 00:21:08,720 uh we also use Asino and a AO reppel 584 00:21:07,280 --> 00:21:13,559 here so this is a convergence of some of 585 00:21:08,720 --> 00:21:15,679 these uh cool features asyo um allows us 586 00:21:13,559 --> 00:21:17,279 to sort of tickle the event Loop in lvgl 587 00:21:15,679 --> 00:21:19,080 and a AO reple means that we can 588 00:21:17,279 --> 00:21:22,760 interact with the application while it's 589 00:21:19,080 --> 00:21:26,240 running uh y so that's 590 00:21:22,760 --> 00:21:28,120 right so I've got 20 seconds this is 591 00:21:26,240 --> 00:21:29,679 Andrew who's uh put your hand up Andrew 592 00:21:28,120 --> 00:21:31,279 it's great 593 00:21:29,679 --> 00:21:34,159 this is a work uh you can see here that 594 00:21:31,279 --> 00:21:36,240 he's introspecting uh what is going on 595 00:21:34,159 --> 00:21:38,120 and moving that label around but then 596 00:21:36,240 --> 00:21:40,559 something that's just a bit difficult to 597 00:21:38,120 --> 00:21:42,120 do in see is just blobbing in say 20 12 598 00:21:40,559 --> 00:21:43,360 lines of text and now you can move that 599 00:21:42,120 --> 00:21:46,039 label around and that feature wasn't 600 00:21:43,360 --> 00:21:47,760 there when we built it so uh you can 601 00:21:46,039 --> 00:21:49,200 imagine being on a call with a customer 602 00:21:47,760 --> 00:21:51,360 and they want to go oh what happens if 603 00:21:49,200 --> 00:21:56,480 we move X wigit over here and we can 604 00:21:51,360 --> 00:21:56,480 just do that on the Fly um really 605 00:21:57,279 --> 00:22:05,360 helpful go to the next I thinkk not 606 00:22:02,279 --> 00:22:07,000 you me a sec okay honorable 607 00:22:05,360 --> 00:22:08,799 mentions said there was too much to 608 00:22:07,000 --> 00:22:10,039 discuss so just one line is if these 609 00:22:08,799 --> 00:22:11,720 things are interesting to you go look 610 00:22:10,039 --> 00:22:13,200 him up we've got links py script I could 611 00:22:11,720 --> 00:22:14,559 give give you a whole talk on py script 612 00:22:13,200 --> 00:22:16,799 but it's basically micropython or 613 00:22:14,559 --> 00:22:18,480 cpython in the browser um if that's 614 00:22:16,799 --> 00:22:20,679 exciting to you and it should be uh go 615 00:22:18,480 --> 00:22:24,840 check it out blay is a tool that allows 616 00:22:20,679 --> 00:22:27,039 you to um uh put it allows you to put 617 00:22:24,840 --> 00:22:29,200 your code on a micropython device from a 618 00:22:27,039 --> 00:22:32,159 python application on your PC so so in 619 00:22:29,200 --> 00:22:34,720 your P PC python application you can 620 00:22:32,159 --> 00:22:36,960 decorate with a header with a decorator 621 00:22:34,720 --> 00:22:39,360 uh and make that run on a device that's 622 00:22:36,960 --> 00:22:41,320 connected kind of cool MP Bridge allows 623 00:22:39,360 --> 00:22:43,120 you like MP remote to run code on your 624 00:22:41,320 --> 00:22:44,880 device but it actually synchronizes 625 00:22:43,120 --> 00:22:46,200 files it doesn't actually just Mount the 626 00:22:44,880 --> 00:22:49,760 device it actually synchronizes the 627 00:22:46,200 --> 00:22:52,000 files on both devices and the PC 628 00:22:49,760 --> 00:22:54,120 micropython P test is an effort to get P 629 00:22:52,000 --> 00:22:56,000 test running on micropython we've got 630 00:22:54,120 --> 00:22:59,440 unit tests running but P test was just 631 00:22:56,000 --> 00:23:01,720 too giant to uh to pull across easily So 632 00:22:59,440 --> 00:23:05,760 based on a talk given that last year's 633 00:23:01,720 --> 00:23:07,000 Pyon Au uh yeah micropython pest came 634 00:23:05,760 --> 00:23:08,919 into 635 00:23:07,000 --> 00:23:10,799 being we've got Viper and Native 636 00:23:08,919 --> 00:23:12,760 emitters which are built-in features of 637 00:23:10,799 --> 00:23:15,080 micropython where you can add decorators 638 00:23:12,760 --> 00:23:16,120 to your code and it goes v uh I'll leave 639 00:23:15,080 --> 00:23:17,760 it at that there's some technical 640 00:23:16,120 --> 00:23:20,760 information there you'll need to go 641 00:23:17,760 --> 00:23:22,000 learn uh hard in loot testing important 642 00:23:20,760 --> 00:23:23,520 thing in the embedded space you want to 643 00:23:22,000 --> 00:23:25,840 test your software running on your 644 00:23:23,520 --> 00:23:27,880 Hardware devices that can be quite 645 00:23:25,840 --> 00:23:29,279 complex and difficult to do because 646 00:23:27,880 --> 00:23:31,320 we've got a seral Communications to our 647 00:23:29,279 --> 00:23:33,520 device it actually makes it a lot easier 648 00:23:31,320 --> 00:23:34,880 and uh Hans is here somewhere Hans is 649 00:23:33,520 --> 00:23:36,840 trying to get this to work with the OCTA 650 00:23:34,880 --> 00:23:39,600 probe project where he's built a generic 651 00:23:36,840 --> 00:23:42,240 device that we can host uh a device 652 00:23:39,600 --> 00:23:45,360 under test on and uh put new firmware on 653 00:23:42,240 --> 00:23:46,880 it and do a lot of tests on it um pdb 654 00:23:45,360 --> 00:23:49,799 support we're trying to get pdb running 655 00:23:46,880 --> 00:23:53,320 on micropython it's uh not there yet but 656 00:23:49,799 --> 00:23:55,480 it's getting pretty close uh USB device 657 00:23:53,320 --> 00:23:57,440 uh we want to like if you want to get a 658 00:23:55,480 --> 00:23:59,320 USB device as a client running on 659 00:23:57,440 --> 00:24:01,320 micropython there's no better solution 660 00:23:59,320 --> 00:24:05,320 than this allows you to specify your 661 00:24:01,320 --> 00:24:07,000 descriptors at runtime and uh um yeah 662 00:24:05,320 --> 00:24:09,880 instantiated USB 663 00:24:07,000 --> 00:24:11,919 device uh I'll might skip over this but 664 00:24:09,880 --> 00:24:14,120 Al well there's too much to talk about 665 00:24:11,919 --> 00:24:17,200 there uh because I'm running it out of 666 00:24:14,120 --> 00:24:18,640 time uh my conclusion is that uh 667 00:24:17,200 --> 00:24:21,480 micropython is still a teenager right 668 00:24:18,640 --> 00:24:23,760 it's 11 years old um but it's already 669 00:24:21,480 --> 00:24:24,919 pretty great and we've got some years 670 00:24:23,760 --> 00:24:26,039 now of experience using this 671 00:24:24,919 --> 00:24:29,240 professionally and it's working out 672 00:24:26,039 --> 00:24:31,399 pretty well um I think it's a great 673 00:24:29,240 --> 00:24:32,559 environment right now but uh it's also 674 00:24:31,399 --> 00:24:34,080 really exciting to see where it's going 675 00:24:32,559 --> 00:24:36,840 and how quickly it's developing so 676 00:24:34,080 --> 00:24:38,159 that's um really cool for me and just 677 00:24:36,840 --> 00:24:40,440 one more best bit especially for the 678 00:24:38,159 --> 00:24:42,960 people in in this conference is that 679 00:24:40,440 --> 00:24:44,880 micropython is python right so we get 680 00:24:42,960 --> 00:24:47,399 all the benefits of knowing Python and 681 00:24:44,880 --> 00:24:49,399 using it on these little devices so uh 682 00:24:47,399 --> 00:24:52,120 for me that's really one of the best 683 00:24:49,399 --> 00:24:53,700 best bits um and I think that's all look 684 00:24:52,120 --> 00:24:59,719 go for 685 00:24:53,700 --> 00:24:59,719 [Applause] 686 00:25:00,559 --> 00:25:06,200 thank you Matt we've got five minutes 687 00:25:02,399 --> 00:25:07,799 for questions luxury yeah um put your 688 00:25:06,200 --> 00:25:10,919 hand up if you've got a 689 00:25:07,799 --> 00:25:13,200 question I'm G to 690 00:25:10,919 --> 00:25:16,120 startop by the way we've got like a good 691 00:25:13,200 --> 00:25:17,120 chunk of micropath and Easter here so if 692 00:25:16,120 --> 00:25:18,919 if we can't get an answer there's 693 00:25:17,120 --> 00:25:22,880 something really wrong yeah um you were 694 00:25:18,919 --> 00:25:26,000 talking about uh being able to test on 695 00:25:22,880 --> 00:25:28,440 proper x86 platforms yep what about 696 00:25:26,000 --> 00:25:30,720 peripheral testing so if you've got 697 00:25:28,440 --> 00:25:32,640 devices that are esoteric I squidy or 698 00:25:30,720 --> 00:25:34,039 whatever um yeah how do you go about 699 00:25:32,640 --> 00:25:35,600 testing those you've got you got two 700 00:25:34,039 --> 00:25:38,080 options and the one we most use is to 701 00:25:35,600 --> 00:25:39,720 mock them out yep and so we usually mock 702 00:25:38,080 --> 00:25:42,440 them out sort of at the communications 703 00:25:39,720 --> 00:25:44,520 layer whether it's i2c or spy um so we 704 00:25:42,440 --> 00:25:46,640 know what i2c is doing we know what Spy 705 00:25:44,520 --> 00:25:47,960 is doing um but the other option is that 706 00:25:46,640 --> 00:25:49,600 you can actually get it running on Unix 707 00:25:47,960 --> 00:25:51,480 as well and it's a bit harder and it's a 708 00:25:49,600 --> 00:25:52,559 bit more Cutting Edge but you can 709 00:25:51,480 --> 00:25:56,720 actually get these things running on 710 00:25:52,559 --> 00:25:56,720 your on your x86 device 711 00:26:02,600 --> 00:26:05,679 yeah so I was just wondering about the 712 00:26:04,159 --> 00:26:09,559 for the memory management stuff because 713 00:26:05,679 --> 00:26:11,080 it's like you have so little space and 714 00:26:09,559 --> 00:26:12,480 with the fragmentation and everything 715 00:26:11,080 --> 00:26:14,480 like 716 00:26:12,480 --> 00:26:15,880 is like are there just patterns that 717 00:26:14,480 --> 00:26:17,559 people are doing in micropython to avoid 718 00:26:15,880 --> 00:26:19,559 things or is it kind of that like 719 00:26:17,559 --> 00:26:21,559 usually you actually don't you know 720 00:26:19,559 --> 00:26:22,919 you're kind of you're kind of not 721 00:26:21,559 --> 00:26:24,080 worrying about memory that much in 722 00:26:22,919 --> 00:26:25,240 practice because of what you're doing 723 00:26:24,080 --> 00:26:27,880 well that's the thing so python gives 724 00:26:25,240 --> 00:26:30,000 you lots of tools to do um programming 725 00:26:27,880 --> 00:26:31,080 tasks really rapidly right um but that 726 00:26:30,000 --> 00:26:32,720 usually means you don't care about 727 00:26:31,080 --> 00:26:35,240 memory allocations you just care about 728 00:26:32,720 --> 00:26:37,000 getting the job done um but particularly 729 00:26:35,240 --> 00:26:38,559 with micropython but also with python 730 00:26:37,000 --> 00:26:40,520 you can do things like preallocate your 731 00:26:38,559 --> 00:26:42,039 bite arrays and reuse them for example 732 00:26:40,520 --> 00:26:44,200 so really common money is we want to 733 00:26:42,039 --> 00:26:46,440 send data to a device over over 734 00:26:44,200 --> 00:26:48,440 Communications Channel and the obvious 735 00:26:46,440 --> 00:26:50,120 way to do that is to generate a blob of 736 00:26:48,440 --> 00:26:52,279 data and and send it across but that 737 00:26:50,120 --> 00:26:54,360 allocates a temporary every time so 738 00:26:52,279 --> 00:26:56,520 micropath provides ways of allocating a 739 00:26:54,360 --> 00:26:58,760 b array once and reusing it and then 740 00:26:56,520 --> 00:27:01,200 passing it in through the through the um 741 00:26:58,760 --> 00:27:04,880 methods so um you don't have 742 00:27:01,200 --> 00:27:08,279 those that's right yeah 743 00:27:04,880 --> 00:27:10,200 y awesome more people up the front come 744 00:27:08,279 --> 00:27:13,600 on people down the back you've got to I 745 00:27:10,200 --> 00:27:15,320 know it's afternoon but you know I it 746 00:27:13,600 --> 00:27:17,840 kind of quite a similar question and 747 00:27:15,320 --> 00:27:21,960 maybe might have been over the uh over 748 00:27:17,840 --> 00:27:24,840 the top of it but um what sort of 749 00:27:21,960 --> 00:27:26,440 guarantees or or understandings that you 750 00:27:24,840 --> 00:27:28,840 can have while you're using micropython 751 00:27:26,440 --> 00:27:30,880 to say know that this is 752 00:27:28,840 --> 00:27:34,720 using like statically using memory as 753 00:27:30,880 --> 00:27:36,159 opposed to just underlying dynamically 754 00:27:34,720 --> 00:27:38,159 access 755 00:27:36,159 --> 00:27:40,640 creating all yeah it's kind of a 756 00:27:38,159 --> 00:27:43,720 learning process and part of it is that 757 00:27:40,640 --> 00:27:45,440 um python isn't that transparent about 758 00:27:43,720 --> 00:27:47,360 how you manage memory and that's it's a 759 00:27:45,440 --> 00:27:48,440 pro and a con right they can see you 760 00:27:47,360 --> 00:27:49,720 have to be very aware of what you're 761 00:27:48,440 --> 00:27:51,320 doing with the memory and that means 762 00:27:49,720 --> 00:27:53,600 that you're very aware of what that 763 00:27:51,320 --> 00:27:55,159 memory is doing so in Python you tend to 764 00:27:53,600 --> 00:27:58,200 learn by using like tools like the 765 00:27:55,159 --> 00:28:00,519 memory profile as to how uh and when 766 00:27:58,200 --> 00:28:01,880 Temporaries get created um but it is a 767 00:28:00,519 --> 00:28:04,039 learning process and that is kind of a 768 00:28:01,880 --> 00:28:05,640 detail that you need to worry about but 769 00:28:04,039 --> 00:28:08,519 uh I guess I'd encourage people just to 770 00:28:05,640 --> 00:28:10,720 not care about that at first just just 771 00:28:08,519 --> 00:28:12,679 get your application done and working 772 00:28:10,720 --> 00:28:14,360 and then analyze it later and figure out 773 00:28:12,679 --> 00:28:17,919 where you need to make the the 774 00:28:14,360 --> 00:28:17,919 improvements um 775 00:28:19,559 --> 00:28:23,279 yeah you're all so close 776 00:28:21,690 --> 00:28:27,000 [Laughter] 777 00:28:23,279 --> 00:28:28,960 together um at the risk of debugging my 778 00:28:27,000 --> 00:28:32,159 own project 779 00:28:28,960 --> 00:28:35,519 um what we offer consultancy service if 780 00:28:32,159 --> 00:28:39,799 that's um what what ideas do you have 781 00:28:35,519 --> 00:28:42,559 for look at like looking at debugging or 782 00:28:39,799 --> 00:28:44,080 um working out why 783 00:28:42,559 --> 00:28:47,120 something 784 00:28:44,080 --> 00:28:50,840 fails after A Time are there sort of 785 00:28:47,120 --> 00:28:53,159 good logging patterns and practices or 786 00:28:50,840 --> 00:28:55,240 debuggers what what sort of tooling is 787 00:28:53,159 --> 00:28:57,320 out there yeah so um we can hook into 788 00:28:55,240 --> 00:28:59,559 the standard python logging system so 789 00:28:57,320 --> 00:29:01,760 that uh for for the most part you've got 790 00:28:59,559 --> 00:29:04,880 very similar features to regular logging 791 00:29:01,760 --> 00:29:07,360 in Python that's the first Port of Call 792 00:29:04,880 --> 00:29:09,440 uh other things kind of depends on the 793 00:29:07,360 --> 00:29:11,399 on the on the the specifics like you 794 00:29:09,440 --> 00:29:13,080 might want to um keep your repple open 795 00:29:11,399 --> 00:29:14,679 so that you can get debug information 796 00:29:13,080 --> 00:29:16,480 when problems occur that's actually 797 00:29:14,679 --> 00:29:20,440 really useful to introspect what the 798 00:29:16,480 --> 00:29:21,480 variables are doing um but yeah press 799 00:29:20,440 --> 00:29:23,600 talk to me afterwards and we'll see if 800 00:29:21,480 --> 00:29:25,159 we can fix your problem yeah all right 801 00:29:23,600 --> 00:29:27,559 we got time for one more question I 802 00:29:25,159 --> 00:29:29,559 think yeah come um how do the realtime 803 00:29:27,559 --> 00:29:32,279 capability compared to like a bare metal 804 00:29:29,559 --> 00:29:33,880 C or like an OS like application yeah 805 00:29:32,279 --> 00:29:35,760 it's not a real time operating system is 806 00:29:33,880 --> 00:29:37,679 the short answer um the best thing you 807 00:29:35,760 --> 00:29:40,039 can do is drop into C and and use 808 00:29:37,679 --> 00:29:41,320 whatever guarantees your Manu your 809 00:29:40,039 --> 00:29:43,840 microcontroller manufacturer gives you 810 00:29:41,320 --> 00:29:45,519 on their API that would be the if you're 811 00:29:43,840 --> 00:29:46,919 looking for tight realtime operating 812 00:29:45,519 --> 00:29:50,159 system stuff probably not the right tool 813 00:29:46,919 --> 00:29:52,279 for the job um but I I would say that a 814 00:29:50,159 --> 00:29:55,080 lot of the C real time operating systems 815 00:29:52,279 --> 00:29:58,480 aren't that real time as well so 816 00:29:55,080 --> 00:30:00,480 um yeah 817 00:29:58,480 --> 00:30:03,440 yeah yeah so micro gives you access to 818 00:30:00,480 --> 00:30:05,000 to regular isrs and to interrupts um so 819 00:30:03,440 --> 00:30:07,880 that that part of the system actually 820 00:30:05,000 --> 00:30:09,960 performs very well um as with anything 821 00:30:07,880 --> 00:30:11,159 that's where timing is critical measure 822 00:30:09,960 --> 00:30:13,519 measure measure like make sure you're 823 00:30:11,159 --> 00:30:16,039 doing it within your timing constraints 824 00:30:13,519 --> 00:30:20,320 yeah all right please U join with me in 825 00:30:16,039 --> 00:30:20,320 thanking Matt TR again