From 73b03cfc1c2e4fc5ca26e35a4938971ad290b2c0 Mon Sep 17 00:00:00 2001 From: Sam Hos Date: Mon, 17 Feb 2025 10:46:14 +0100 Subject: [PATCH] Compiler flags docs --- .../week_4_programming/programming.md | 40 ++++++++++++++++++- 1 file changed, 38 insertions(+), 2 deletions(-) diff --git a/docs/Assignments/week_4_programming/programming.md b/docs/Assignments/week_4_programming/programming.md index 3e8c2c6..ae4a658 100644 --- a/docs/Assignments/week_4_programming/programming.md +++ b/docs/Assignments/week_4_programming/programming.md @@ -183,9 +183,45 @@ board = seeed_xiao_esp32c6 To get the correct configuration if it isn't listed on PlatformIO, is to go to the Board manufactors website and hope there is a PlatformIO example configuration. For example this example was listed on the Xiao website. [Link](https://wiki.seeedstudio.com/xiao_esp32c6_with_platform_io/). -#### Using PlaformIO +#### Installing libraries in platformIO +To install a library click the platformIO icon. In there click the libraries button. Then you can search a library and click add to project. Now you have added a library to your project! + +![alt text](image.png) + +After that it will edit platformio.ini and there you will see the library added to the project. It's also in `.pio/libdeps` + + +### Programming and compiling and uploading Using platformIO is really straight forward. The only folder you should look at in your platformIO project is the `src` folder. ![alt text](image-5.png) -In the main.cpp file you can write your program. \ No newline at end of file +In the main.cpp file you can write your program to run on a microcontroller. + +On the bottom of your screen you see that there are a few new buttons. + +![alt text](image-6.png) + +The Compile and Upload and Serial console buttons are going to be the most used. Compile compiles the code and checks if it's correct. If it has incorrect syntax you need to correct it. The upload button compiles the code first and then sends it to the Microcontroller. The Serial console is a really nice debug tool to see what the microcontroller is doing if you added print statements in your code. + +## Editing the new driver +Adding in support for the BNO085. The original driver doesn't support the BNO085. +I first started off searching for every instance of an existing sensor. +![alt text](image-7.png) +From there I started out changing everything to BNO085 and also importing the correct library. As I have found the correct library earlier in the code. + +![alt text](image-8.png) + +### The purple text (Compiler flags) +The purple text are compiler flags. They tell the compiler what to do with certain pieces of code or variables. + +| Flag | What does it do | +| :-------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| #define | What define does is it replaces a variable with a value at compilation. This can save some memory by using less variables | +| # if | Everything between #if and #endif or #elif is compiled if the #if is true. So if the variable isn't defined the code will not get included while compiling. So it also won't get run when uploading it to the microcontroller | +| #elif | Same as #if except using this you can have multiple cases | +| #include | Include a library into the code | +| #else | If none of the cases are met this is used | +| #error | Throws an error during compiling when it is compiled | +| #endif | end of a #if, #elif or #else | +