2014-09-29 17:10:41 -04:00
|
|
|
# test ptr8 type
|
|
|
|
|
2020-03-22 22:26:08 -04:00
|
|
|
|
2014-09-29 17:10:41 -04:00
|
|
|
@micropython.viper
|
2020-03-22 22:26:08 -04:00
|
|
|
def set(dest: ptr8, val: int):
|
2014-09-29 17:10:41 -04:00
|
|
|
dest[0] = val
|
|
|
|
|
2020-03-22 22:26:08 -04:00
|
|
|
|
2015-04-22 18:18:28 -04:00
|
|
|
@micropython.viper
|
2020-03-22 22:26:08 -04:00
|
|
|
def set1(dest: ptr8, val: int):
|
2015-04-22 18:18:28 -04:00
|
|
|
dest[1] = val
|
|
|
|
|
2020-03-22 22:26:08 -04:00
|
|
|
|
2014-09-29 17:10:41 -04:00
|
|
|
@micropython.viper
|
2020-03-22 22:26:08 -04:00
|
|
|
def memset(dest: ptr8, val: int, n: int):
|
2014-09-29 17:10:41 -04:00
|
|
|
for i in range(n):
|
|
|
|
dest[i] = val
|
|
|
|
|
2020-03-22 22:26:08 -04:00
|
|
|
|
2014-09-29 17:10:41 -04:00
|
|
|
@micropython.viper
|
2020-03-22 22:26:08 -04:00
|
|
|
def memset2(dest_in, val: int):
|
2014-09-29 17:10:41 -04:00
|
|
|
dest = ptr8(dest_in)
|
|
|
|
n = int(len(dest_in))
|
|
|
|
for i in range(n):
|
|
|
|
dest[i] = val
|
|
|
|
|
2020-03-22 22:26:08 -04:00
|
|
|
|
2014-09-29 17:10:41 -04:00
|
|
|
b = bytearray(4)
|
|
|
|
print(b)
|
|
|
|
|
2015-04-22 18:18:28 -04:00
|
|
|
set(b, 41)
|
|
|
|
print(b)
|
|
|
|
|
|
|
|
set1(b, 42)
|
2014-09-29 17:10:41 -04:00
|
|
|
print(b)
|
|
|
|
|
|
|
|
memset(b, 43, len(b))
|
|
|
|
print(b)
|
|
|
|
|
|
|
|
memset2(b, 44)
|
|
|
|
print(b)
|