|
1 | 1 | <script lang="ts"> |
2 | 2 | import Article from '$lib/components/blog/Article.svelte'; |
3 | 3 | import { NUMWORKS_PROGRAMMING } from '$lib/constants/articles'; |
| 4 | + import Code from '@/components/shared/Code.svelte'; |
4 | 5 | import Collapsible from '@/components/shared/Collapsible.svelte'; |
5 | 6 | import Linkable from '@/components/shared/Linkable.svelte'; |
6 | 7 | import TableOfContents from '@/components/shared/TableOfContents.svelte'; |
|
57 | 58 | the methods provided by the some modules below. |
58 | 59 | </p> |
59 | 60 | <Collapsible title="Kandinsky"> |
60 | | - <pre><code class="nohighlight" |
61 | | - >get_pixel(x, y) - returns the color of the pixel at (x,y) |
62 | | -set_pixel(x, y, color) - colors the pixel at (x,y) |
63 | | -color(r, g, b) - defines an RGB color |
64 | | -draw_string(text, x, y, fg, bg) - displays a string at (x, y), and if specified, with a foreground and background color |
65 | | -fill_rect(x, y, w, h, col) - fills a rectangle spanning from (x, y) to (x + w, y + h) with a color</code |
66 | | - ></pre> |
| 61 | + <Code nohl |
| 62 | + >get_pixel(x, y) - returns the color of the pixel at (x,y) set_pixel(x, y, color) - colors the |
| 63 | + pixel at (x,y) color(r, g, b) - defines an RGB color draw_string(text, x, y, fg, bg) - |
| 64 | + displays a string at (x, y), and if specified, with a foreground and background color |
| 65 | + fill_rect(x, y, w, h, col) - fills a rectangle spanning from (x, y) to (x + w, y + h) with a |
| 66 | + color</Code |
| 67 | + > |
67 | 68 | </Collapsible> |
68 | 69 | <Collapsible title="Ion"> |
69 | | - <pre><code class="nohighlight">keydown(k) - returns true if the key k is down</code></pre> |
| 70 | + <Code nohl>keydown(k) - returns true if the key k is down</Code> |
70 | 71 | </Collapsible><Collapsible title="Time" |
71 | | - ><pre><code class="nohighlight" |
72 | | - >monotonic() - returns the clock's time (not to be confused with the actual time) |
73 | | -sleep(t) - suspend execution for t seconds</code |
74 | | - ></pre> |
| 72 | + ><Code nohl |
| 73 | + >monotonic() - returns the clock's time (not to be confused with the actual time) sleep(t) - |
| 74 | + suspend execution for t seconds</Code |
| 75 | + > |
75 | 76 | </Collapsible> |
76 | 77 | <Linkable id="limits"> |
77 | 78 | <p class="text-foreground text-xl font-bold">Limitations</p> |
@@ -116,13 +117,13 @@ sleep(t) - suspend execution for t seconds</code |
116 | 117 | and also uses a special implementation of python called MicroPython. Digging into the |
117 | 118 | MicroPython source code, we can find a base definition of an object in C: |
118 | 119 | </p> |
119 | | - <pre><code class="language-c" |
120 | | - >{`// Anything that wants to be a concrete MicroPython object must have mp_obj_base_t |
| 120 | + <Code language="c" |
| 121 | + >{`// Anything that wants to be a concrete MicroPython object must have mp_obj_base_t |
121 | 122 | // as its first member (small ints, qstr objs and inline floats are not concrete). |
122 | 123 | struct _mp_obj_base_t { |
123 | 124 | const mp_obj_type_t *type MICROPY_OBJ_BASE_ALIGNMENT; |
124 | | -};`}</code |
125 | | - ></pre> |
| 125 | +};`}</Code |
| 126 | + > |
126 | 127 | <p> |
127 | 128 | Thus we can conclude that in MicroPython, an object takes up atleast 4 bytes (the size of a |
128 | 129 | pointer). Of course, each object has a value associated to it, and with padding that brings us |
@@ -163,8 +164,8 @@ struct _mp_obj_base_t { |
163 | 164 | code for the header file, pulled from my latest app at the time of writing, below. |
164 | 165 | </p> |
165 | 166 | <Collapsible title="eadk.h"> |
166 | | - <pre class="h-96"><code class="language-c" |
167 | | - >{`#ifndef EADK_H |
| 167 | + <Code language="c" class="h-96" |
| 168 | + >{`#ifndef EADK_H |
168 | 169 | #define EADK_H |
169 | 170 |
|
170 | 171 | #include <stdbool.h> |
@@ -453,8 +454,8 @@ extern size_t eadk_external_data_size; |
453 | 454 | bool eadk_usb_is_plugged(); |
454 | 455 | uint32_t eadk_random(); |
455 | 456 |
|
456 | | -#endif`}</code |
457 | | - ></pre> |
| 457 | +#endif`}</Code |
| 458 | + > |
458 | 459 | </Collapsible> |
459 | 460 | <p> |
460 | 461 | This time, a lot more functions are provided. I have yet to explore all the different functions |
|
0 commit comments