Skip to content

Commit

Permalink
experimental support for Radxa Zero with libmraa
Browse files Browse the repository at this point in the history
  • Loading branch information
hishizuka committed Jan 24, 2024
1 parent 090a6d1 commit e6448a1
Show file tree
Hide file tree
Showing 4 changed files with 336 additions and 15 deletions.
26 changes: 13 additions & 13 deletions modules/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,6 @@
)
from modules.utils.timer import Timer

_IS_RASPI = False
try:
import RPi.GPIO as GPIO

GPIO.setmode(GPIO.BCM)
_IS_RASPI = True
except ImportError:
pass


class Config:
#######################
Expand Down Expand Up @@ -75,7 +66,7 @@ class Config:
G_VERSION_MAJOR = 0 # need to be initialized
G_VERSION_MINOR = 1 # need to be initialized
G_UNIT_ID = "0000000000000000" # initialized in get_serial
G_UNIT_ID_HEX = 0x1A2B3C4D # initialized in get_serial
G_UNIT_ID_HEX = 0x00000000 # initialized in get_serial
G_UNIT_MODEL = ""
G_UNIT_HARDWARE = ""

Expand Down Expand Up @@ -224,7 +215,9 @@ class Config:
G_FULLSCREEN = False

# display type (overwritten with setting.conf)
G_DISPLAY = "None" # PiTFT, MIP, MIP_640, Papirus, MIP_Sharp, MIP_Sharp_320, DFRobot_RPi_Display
# PiTFT, MIP, MIP_640, MIP_Mraa, MIP_Mraa_640, MIP_Sharp, MIP_Sharp_320,
# Papirus, DFRobot_RPi_Display, Pirate_Audio, Pirate_Audio_old(Y button is GPIO 20), Display_HAT_Mini
G_DISPLAY = "None"

G_DISPLAY_PARAM = {
"SPI_CLOCK": 2000000,
Expand Down Expand Up @@ -400,8 +393,15 @@ class Config:

def __init__(self):
# Raspbian OS detection
if _IS_RASPI:
self.G_IS_RASPI = True
proc_model = "/proc/device-tree/model"
if os.path.exists(proc_model) and os.path.exists(proc_model):
with open(proc_model) as f:
p = f.read()
if p.find("Raspberry Pi") == 0:
self.G_IS_RASPI = True
elif p.find("Radxa Zero") == 0:
self.G_IS_RASPI = True
self.G_DISPLAY_PARAM["SPI_CLOCK"] = 10000000

# get options
parser = argparse.ArgumentParser()
Expand Down
20 changes: 19 additions & 1 deletion modules/display/display_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,15 @@
"PiTFT": None,
"MIP": None, # LPM027M128C, LPM027M128B
"MIP_640": (640, 480), # LPM044M141A
"MIP_Mraa": None, # LPM027M128C, LPM027M128B
"MIP_Mraa_640": (640, 480), # LPM044M141A
"MIP_Sharp": None,
"MIP_Sharp_320": (320, 240),
"Papirus": None,
"DFRobot_RPi_Display": None,
"Pirate_Audio": None,
"Pirate_Audio_old": None,
"Display_HAT_Mini": (320, 240),
}


Expand Down Expand Up @@ -130,11 +135,16 @@ def init_display(config):

if _SENSOR_DISPLAY:
display = MipDisplay(config, SUPPORTED_DISPLAYS[config.G_DISPLAY])
elif config.G_DISPLAY in ("MIP_Sharp", "MIP_Sharp_320"):
elif config.G_DISPLAY.startswith("MIP_Sharp"):
from .mip_sharp_display import _SENSOR_DISPLAY, MipSharpDisplay

if _SENSOR_DISPLAY:
display = MipSharpDisplay(config, SUPPORTED_DISPLAYS[config.G_DISPLAY])
elif config.G_DISPLAY.startswith("MIP_Mraa"):
from .mip_mraa_display import _SENSOR_DISPLAY, MipMraaDisplay

if _SENSOR_DISPLAY:
display = MipMraaDisplay(config, SUPPORTED_DISPLAYS[config.G_DISPLAY])
elif config.G_DISPLAY == "Papirus":
from .papirus_display import _SENSOR_DISPLAY, PapirusDisplay

Expand All @@ -145,5 +155,13 @@ def init_display(config):

if _SENSOR_DISPLAY:
display = DFRobotRPiDisplay(config)
elif config.G_DISPLAY.startswith("Pirate_Audio") or config.G_DISPLAY == "Display_HAT_Mini":
from .st7789_display import _SENSOR_DISPLAY, ST7789Display

if _SENSOR_DISPLAY:
if config.G_DISPLAY.startswith("Pirate_Audio"):
display = ST7789Display(config)
elif config.G_DISPLAY == "Display_HAT_Mini":
display = ST7789Display(config, SUPPORTED_DISPLAYS[config.G_DISPLAY])

return display
Loading

0 comments on commit e6448a1

Please sign in to comment.