Skip to content

Instantly share code, notes, and snippets.

View microbit-carlos's full-sized avatar

Carlos Pereira Atencio microbit-carlos

View GitHub Profile
@microbit-carlos
microbit-carlos / Dockerfile
Created February 10, 2023 15:48
Docker image for pext/yotta:latest
View Dockerfile
FROM pext/yotta:latest
# We need to update Yotta by manually downloading required packages and installing it
# This is because Ubuntu 14.04 ships with Python 2.7.6 and there are TLS issues only resolvable by upgrading to 2.7.9
# https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
RUN apt-get -y update && \
apt-get install -y wget && \
wget https://files.pythonhosted.org/packages/65/bd/2908a99239bfe3131ceff479c6fd0388dd53ffaca3543c5216b44618dc44/yotta-0.20.5.tar.gz && \
wget https://files.pythonhosted.org/packages/e2/67/4597fc5d5de01bb44887844647ab8e73239079dd478c35c52d58a9eb3d45/cryptography-2.8-cp27-cp27mu-manylinux1_x86_64.whl && \
@microbit-carlos
microbit-carlos / button_outputs.py
Created August 8, 2022 17:17
micro:bit V2 MicroPython configure buttons as outputs
View button_outputs.py
from microbit import *
from micropython import const
from machine import mem32
REG_GPIO_P0 = const(0x50000000) # Base address for the GPIO 0 peripheal
REG_GPIO_OUTSET = const(REG_GPIO_P0 + 0x508) # When a 32bit value is written to this address, each bit set to 1 sets the output pin high
REG_GPIO_OUTCLR = const(REG_GPIO_P0 + 0x50C) # When a 32bit value is written to this address, each bit set to 1 sets the output pin low
REG_GPIO_DIRSET = const(REG_GPIO_P0 + 0x518) # When a 32bit value is written to this address, each bit set to 1 sets the pin to output
REG_GPIO_DIRCLR = const(REG_GPIO_P0 + 0x51C) # When a 32bit value is written to this address, each bit set to 1 sets the pin to input
@microbit-carlos
microbit-carlos / adc_config_test.py
Last active July 19, 2017 14:17
micro:bit MicroPython ADC config test
View adc_config_test.py
from microbit import pin0, pin1
NRF_ADC_BASE = 0x40007000
NRF_ADC_CONFIG = NRF_ADC_BASE + 0x504
@micropython.asm_thumb
def reg_read(r0):
ldr(r0, [r0, 0])
@micropython.asm_thumb
@microbit-carlos
microbit-carlos / adc_ref_volt.py
Last active June 28, 2022 18:43
micro:bit MicroPython change ADC reference voltage
View adc_ref_volt.py
from microbit import pin0
NRF_ADC_BASE = 0x40007000
NRF_ADC_CONFIG = NRF_ADC_BASE + 0x504
@micropython.asm_thumb
def reg_read(r0):
ldr(r0, [r0, 0])
@micropython.asm_thumb