-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #232 from brilliantlabsAR/dev
Dev
- Loading branch information
Showing
10 changed files
with
170 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule micropython
updated
83 files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import os, device | ||
|
||
class RAMBlockDev: | ||
def __init__(self, block_size, num_blocks): | ||
self.block_size = block_size | ||
self.data = bytearray(block_size * num_blocks) | ||
|
||
def readblocks(self, block_num, buf, offset=0): | ||
addr = block_num * self.block_size + offset | ||
for i in range(len(buf)): | ||
buf[i] = self.data[addr + i] | ||
|
||
def writeblocks(self, block_num, buf, offset=None): | ||
if offset is None: | ||
# do erase, then write | ||
for i in range(len(buf) // self.block_size): | ||
self.ioctl(6, block_num + i) | ||
offset = 0 | ||
addr = block_num * self.block_size + offset | ||
for i in range(len(buf)): | ||
self.data[addr + i] = buf[i] | ||
|
||
def ioctl(self, op, arg): | ||
if op == 4: # block count | ||
return len(self.data) // self.block_size | ||
if op == 5: # block size | ||
return self.block_size | ||
if op == 6: # block erase | ||
return 0 | ||
|
||
bdev = RAMBlockDev(512, 32) | ||
os.VfsLfs2.mkfs(bdev) | ||
os.mount(bdev, "/") | ||
|
||
del os | ||
del device | ||
del bdev |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* | ||
* This file is part of the MicroPython for Monocle project: | ||
* https://github.com/brilliantlabsAR/monocle-micropython | ||
* | ||
* Authored by: Josuah Demangeon ([email protected]) | ||
* Raj Nakarja / Brilliant Labs Ltd. ([email protected]) | ||
* | ||
* ISC Licence | ||
* | ||
* Copyright © 2023 Brilliant Labs Ltd. | ||
* | ||
* Permission to use, copy, modify, and/or distribute this software for any | ||
* purpose with or without fee is hereby granted, provided that the above | ||
* copyright notice and this permission notice appear in all copies. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH | ||
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY | ||
* AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, | ||
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM | ||
* LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR | ||
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR | ||
* PERFORMANCE OF THIS SOFTWARE. | ||
*/ | ||
|
||
#include "monocle.h" | ||
#include "nrf_gpio.h" | ||
#include "nrfx_log.h" | ||
#include "py/runtime.h" | ||
#include "py/objstr.h" | ||
|
||
STATIC mp_obj_t rtt_print(mp_obj_t arg1) | ||
{ | ||
const char *str = mp_obj_str_get_data(arg1, NULL); | ||
|
||
NRFX_LOG("%s", str); | ||
return mp_const_none; | ||
} | ||
STATIC MP_DEFINE_CONST_FUN_OBJ_1(rtt_print_obj, rtt_print); | ||
|
||
STATIC const mp_rom_map_elem_t rtt_module_globals_table[] = { | ||
{MP_ROM_QSTR(MP_QSTR_print), MP_ROM_PTR(&rtt_print_obj)}, | ||
}; | ||
STATIC MP_DEFINE_CONST_DICT(rtt_module_globals, rtt_module_globals_table); | ||
|
||
const mp_obj_module_t rtt_module = { | ||
.base = {&mp_type_module}, | ||
.globals = (mp_obj_dict_t *)&rtt_module_globals, | ||
}; | ||
MP_REGISTER_MODULE(MP_QSTR__rtt, rtt_module); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters