diff --git a/software/contrib/cvecorder.py b/software/contrib/cvecorder.py index b85afbb7b..7f648f844 100644 --- a/software/contrib/cvecorder.py +++ b/software/contrib/cvecorder.py @@ -6,7 +6,8 @@ import json import gc import os -#import framebuf +import micropython +import framebuf ''' CVecorder @@ -86,7 +87,7 @@ def __init__(self): # Test routine, pick a random bank n times and save, then load the state if self.initTest: - #print(micropython.mem_info("level")) + print(micropython.mem_info("level")) for n in range(3000): # Clear vars #self.CvRecording = [] @@ -271,7 +272,7 @@ def saveState(self): print(f'[{attempts}] Error: Memory allocation failed, retrying: {e}') if self.debugLogging: self.writeToDebugLog(f"[saveState] Error: Memory allocation failed, retrying: {e}") - #print(micropython.mem_info("level")) + print(micropython.mem_info("level")) else: pass @@ -430,9 +431,8 @@ def writeToDebugLog(self, msg): def showLoadingScreen(self): # push the bytearray of the Rpi logo into a 32 x 32 framebuffer, then show on the screen - # framebuf stuff commented out until we have framebuf testing built - # buffer = bytearray(b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00|?\x00\x01\x86@\x80\x01\x01\x80\x80\x01\x11\x88\x80\x01\x05\xa0\x80\x00\x83\xc1\x00\x00C\xe3\x00\x00~\xfc\x00\x00L'\x00\x00\x9c\x11\x00\x00\xbf\xfd\x00\x00\xe1\x87\x00\x01\xc1\x83\x80\x02A\x82@\x02A\x82@\x02\xc1\xc2@\x02\xf6>\xc0\x01\xfc=\x80\x01\x18\x18\x80\x01\x88\x10\x80\x00\x8c!\x00\x00\x87\xf1\x00\x00\x7f\xf6\x00\x008\x1c\x00\x00\x0c \x00\x00\x03\xc0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00") - # fb = framebuf.FrameBuffer(buffer, 32, 32, framebuf.MONO_HLSB) + buffer = bytearray(b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00|?\x00\x01\x86@\x80\x01\x01\x80\x80\x01\x11\x88\x80\x01\x05\xa0\x80\x00\x83\xc1\x00\x00C\xe3\x00\x00~\xfc\x00\x00L'\x00\x00\x9c\x11\x00\x00\xbf\xfd\x00\x00\xe1\x87\x00\x01\xc1\x83\x80\x02A\x82@\x02A\x82@\x02\xc1\xc2@\x02\xf6>\xc0\x01\xfc=\x80\x01\x18\x18\x80\x01\x88\x10\x80\x00\x8c!\x00\x00\x87\xf1\x00\x00\x7f\xf6\x00\x008\x1c\x00\x00\x0c \x00\x00\x03\xc0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00") + fb = framebuf.FrameBuffer(buffer, 32, 32, framebuf.MONO_HLSB) oled.fill(0) #oled.blit(fb, 0,0) oled.text('Loading...', 40, 12, 1) diff --git a/software/firmware/europi.py b/software/firmware/europi.py index c38af7127..fe2ff2dae 100644 --- a/software/firmware/europi.py +++ b/software/firmware/europi.py @@ -13,6 +13,7 @@ Will set the CV output 3 to a voltage of 4.5V. """ +import sys import time from machine import ADC @@ -22,10 +23,9 @@ from ssd1306 import SSD1306_I2C -try: - import micropython +if sys.implementation.name == "micropython": TEST_ENV = False # We're in micropython, so we can assume access to real hardware -except ModuleNotFoundError: +else: TEST_ENV = True # This var is set when we don't have any real hardware, for example in a test or doc generation setting try: diff --git a/software/tests/mocks/framebuf.py b/software/tests/mocks/framebuf.py new file mode 100644 index 000000000..a25437a71 --- /dev/null +++ b/software/tests/mocks/framebuf.py @@ -0,0 +1,3 @@ + +class FrameBuffer: + pass \ No newline at end of file diff --git a/software/tests/mocks/micropython.py b/software/tests/mocks/micropython.py new file mode 100644 index 000000000..e69de29bb diff --git a/software/tests/mocks/rp2.py b/software/tests/mocks/rp2.py new file mode 100644 index 000000000..c5be4606d --- /dev/null +++ b/software/tests/mocks/rp2.py @@ -0,0 +1,16 @@ +import functools + +class PIO: + OUT_LOW = 0 + +class StateMachine: + pass + + +def asm_pio(**kwargs): + def decorator(func): + @functools.wraps(func) + def wrapper(*args, **kwargs): + pass + return wrapper + return decorator \ No newline at end of file