Skip to content

Commit

Permalink
Set display orientation when running XCSoar
Browse files Browse the repository at this point in the history
  • Loading branch information
kedder committed Apr 15, 2020
1 parent ddd6f27 commit 6e24bbe
Show file tree
Hide file tree
Showing 8 changed files with 375 additions and 38 deletions.
256 changes: 256 additions & 0 deletions rootfs-ref/home/root/.xcsoar/openvario.prf
Original file line number Diff line number Diff line change
@@ -0,0 +1,256 @@
AdditionalWPFile=""
AircraftReg="D-KHBC"
AircraftRego=""
AircraftSymbol="2"
AircraftType="ASW24 TOP "
AirspaceFile=""
AltitudeUnit="9"
AppAveNeedle="0"
AppGaugeVarioAvgText="1"
AppGaugeVarioBugs="1"
AppGaugeVarioGross="1"
AppGaugeVarioMc="1"
AppIndLandable="2"
AppInverseInfoBox="1"
AppLandableRenderingScale="130"
AppTextInputStyle="0"
AudioVario2="0"
AutoCloseFlarmDialog="1"
AutoWind="2"
BallastSecsToEmpty="120"
ClimbMapScale="248"
CruiseMapScale="61"
DeviceA="OpenVario"
DeviceB="ILEC SN10"
DeviceC="FLARM"
DeviceD="Generic"
DeviceE="Generic"
DeviceF="Generic"
DisplayOrientation="0"
DisplayText="6"
DistanceUnit="1"
DrawTerrain="1"
DryMass="410.000000"
EnableFLARMGauge="1"
EnableFlightLogger="1"
EnableNMEALogger="1"
EnableThermalProfile="0"
ExternalWind="0"
FlarmLocation="3"
FlarmRadarAutoZoom="1"
FlarmRadarNorthUp="0"
FriendsBlue=""
FriendsGreen=""
FriendsMagenta=""
FriendsYellow=""
Handicap="107"
HomeLocation="14.964167 47.379717"
HomeWaypoint="-1"
InfoBoxGeometry="6"
InfoBoxPanel0Box0="39"
InfoBoxPanel0Box1="98"
InfoBoxPanel0Box10="35"
InfoBoxPanel0Box11="11"
InfoBoxPanel0Box12="0"
InfoBoxPanel0Box13="0"
InfoBoxPanel0Box14="0"
InfoBoxPanel0Box15="0"
InfoBoxPanel0Box16="0"
InfoBoxPanel0Box17="0"
InfoBoxPanel0Box18="0"
InfoBoxPanel0Box19="0"
InfoBoxPanel0Box2="2"
InfoBoxPanel0Box20="0"
InfoBoxPanel0Box21="0"
InfoBoxPanel0Box22="0"
InfoBoxPanel0Box23="0"
InfoBoxPanel0Box3="78"
InfoBoxPanel0Box4="73"
InfoBoxPanel0Box5="14"
InfoBoxPanel0Box6="36"
InfoBoxPanel0Box7="75"
InfoBoxPanel0Box8="21"
InfoBoxPanel0Box9="33"
InfoBoxPanel1Box0="39"
InfoBoxPanel1Box1="77"
InfoBoxPanel1Box10="35"
InfoBoxPanel1Box11="11"
InfoBoxPanel1Box12="0"
InfoBoxPanel1Box13="0"
InfoBoxPanel1Box14="0"
InfoBoxPanel1Box15="0"
InfoBoxPanel1Box16="0"
InfoBoxPanel1Box17="0"
InfoBoxPanel1Box18="0"
InfoBoxPanel1Box19="0"
InfoBoxPanel1Box2="24"
InfoBoxPanel1Box20="0"
InfoBoxPanel1Box21="0"
InfoBoxPanel1Box22="0"
InfoBoxPanel1Box23="0"
InfoBoxPanel1Box3="65"
InfoBoxPanel1Box4="32"
InfoBoxPanel1Box5="33"
InfoBoxPanel1Box6="78"
InfoBoxPanel1Box7="75"
InfoBoxPanel1Box8="61"
InfoBoxPanel1Box9="33"
InputFile="%LOCAL_PATH%\openvario.xci"
LiftUnit="7"
MapFile="%LOCAL_PATH%\openvario_default.xcm"
MapShiftBias="1"
OLCRules="2"
Page1Bottom="0"
Page1InfoBoxMode="1"
Page1InfoBoxPanel="0"
Page1Layout="2"
Page1Main="1"
Page2Bottom="0"
Page2InfoBoxMode="1"
Page2InfoBoxPanel="0"
Page2Layout="1"
Page2Main="0"
PagesDistinctZoom="1"
PilotName="OPENVARIO"
PlanePath=""
PolarDegradation="0.900000"
PolarInformation="350,0,108.820,-0.730,142.250,-1.210,167.410,-1.800,10.000,56.944"
PolarName="Custom"
Port2BaudRate="19200"
Port2BluetoothMAC=""
Port2BulkBaudRate="19200"
Port2Enabled="1"
Port2I2C_Addr="0"
Port2I2C_Bus="2"
Port2IOIOUartID="0"
Port2IPAddress=""
Port2IgnoreChecksum="0"
Port2K6Bt="0"
Port2Path="/dev/ttyS1"
Port2PressureUse="2"
Port2SecondDevice=""
Port2SensorFactor="0.000000"
Port2SensorOffset="0.000000"
Port2SyncFromDevice="1"
Port2SyncToDevice="1"
Port2TCPPort="4353"
Port2Type="disabled"
Port2UseSecondDevice="0"
Port3BaudRate="19200"
Port3BluetoothMAC=""
Port3BulkBaudRate="0"
Port3Enabled="1"
Port3I2C_Addr="0"
Port3I2C_Bus="2"
Port3IOIOUartID="0"
Port3IPAddress=""
Port3IgnoreChecksum="0"
Port3K6Bt="0"
Port3Path="/dev/ttyS3"
Port3PressureUse="2"
Port3SecondDevice=""
Port3SensorFactor="0.000000"
Port3SensorOffset="0.000000"
Port3SyncFromDevice="1"
Port3SyncToDevice="1"
Port3TCPPort="4353"
Port3Type="serial"
Port3UseSecondDevice="0"
Port4BaudRate="4800"
Port4BluetoothMAC=""
Port4BulkBaudRate="0"
Port4I2C_Addr="0"
Port4I2C_Bus="2"
Port4IOIOUartID="0"
Port4IgnoreChecksum="0"
Port4K6Bt="0"
Port4Path="/dev/ttyS3"
Port4PressureUse="2"
Port4SensorFactor="0.000000"
Port4SensorOffset="0.000000"
Port4SyncFromDevice="1"
Port4SyncToDevice="1"
Port4TCPPort="4353"
Port4Type="disabled"
Port5BaudRate="4800"
Port5BluetoothMAC=""
Port5BulkBaudRate="0"
Port5I2C_Addr="0"
Port5I2C_Bus="2"
Port5IOIOUartID="0"
Port5IgnoreChecksum="0"
Port5K6Bt="0"
Port5Path="/dev/ttyS4"
Port5PressureUse="2"
Port5SensorFactor="0.000000"
Port5SensorOffset="0.000000"
Port5SyncFromDevice="1"
Port5SyncToDevice="1"
Port5TCPPort="4353"
Port5Type="disabled"
Port6BaudRate="4800"
Port6BluetoothMAC=""
Port6BulkBaudRate="0"
Port6I2C_Addr="0"
Port6I2C_Bus="2"
Port6IOIOUartID="0"
Port6IgnoreChecksum="0"
Port6K6Bt="0"
Port6Path="/dev/ttyS7"
Port6PressureUse="2"
Port6SensorFactor="0.000000"
Port6SensorOffset="0.000000"
Port6SyncFromDevice="1"
Port6SyncToDevice="1"
Port6TCPPort="4353"
Port6Type="disabled"
PortBaudRate="19200"
PortBluetoothMAC=""
PortBulkBaudRate="0"
PortDumpPort="0"
PortEnabled="1"
PortI2C_Addr="0"
PortI2C_Bus="2"
PortIOIOUartID="0"
PortIPAddress=""
PortIgnoreChecksum="0"
PortK6Bt="0"
PortPath=""
PortPressureUse="2"
PortSensorFactor="0.000000"
PortSensorOffset="0.000000"
PortSyncFromDevice="1"
PortSyncToDevice="1"
PortTCPPort="4352"
PortType="tcp_listener"
PredictContest="0"
Pressure="15"
RoutePlannerMode="1"
SafetyAltitudeArrival="200.000000"
SetSystemTimeFromGPS="1"
SkyLinesTrackingEnabled="1"
SkyLinesTrackingKey=""
SkyLinesTrafficEnabled="1"
SlopeShadingType="3"
SnailTrail="3"
SnailType="1"
SnailWidthScale="0"
SpeedUnit="4"
TaskSpeedUnit="4"
TeamcodeRefWaypoint="-1"
TemperatureUnit="13"
TerrainBrightness="36"
TerrainContours="0"
TerrainContrast="151"
TerrainRamp="0"
TitleWindowFont="24,0,0,0,500,0,0,0,0,0,0,0,2,Tahoma"
TrailDrift="0"
UIScale="200"
UTCOffsetSigned="0"
UseCustomFonts="1"
UseFinalGlideDisplayMode="0"
UserLevel="1"
WPFile=""
WatchedWPFile=""
WayPointLabelStyle="3"
WindArrowStyle="2"
2 changes: 2 additions & 0 deletions rootfs-ref/opt/XCSoar/bin/xcsoar
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/sh
notify-send -t 1000 "Openvario shell started XCSoar"
10 changes: 5 additions & 5 deletions src/ovshell/ovos.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@ def unmount_boot(self) -> None:
subprocess.run(["umount", "/boot"], check=True)

def read_file(self, filename: str) -> bytes:
fpath = self._normalize_path(filename)
fpath = self.norm_path(filename)
with open(fpath, "rb") as f:
return f.read()

def write_file(self, filename: str, content: bytes) -> None:
fpath = self._normalize_path(filename)
fpath = self.norm_path(filename)
with open(fpath, "wb") as f:
f.write(content)

def _normalize_path(self, fname: str) -> str:
def norm_path(self, fname: str) -> str:
assert fname.startswith("/"), "Absolute path is required"
return fname

Expand All @@ -40,6 +40,6 @@ def unmount_boot(self) -> None:
mountpath = os.path.join(self._rootfs, "boot")
os.unlink(mountpath)

def _normalize_path(self, fname: str) -> str:
fname = super()._normalize_path(fname)
def norm_path(self, fname: str) -> str:
fname = super().norm_path(fname)
return os.path.join(self._rootfs, fname[1:])
12 changes: 12 additions & 0 deletions src/ovshell/protocol/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,23 @@


class StoredSettings(Protocol):
@abstractmethod
def setdefault(self, key: str, value: JsonType) -> None:
pass

@abstractmethod
def set(self, key: str, value: Optional[JsonType], save: bool = False):
pass

@abstractmethod
def get(self, key: str, type: Type[JT], default: JT = None) -> Optional[JT]:
pass

@abstractmethod
def getstrict(self, key: str, type: Type[JT]) -> JT:
pass

@abstractmethod
def save(self) -> None:
pass

Expand Down Expand Up @@ -122,6 +130,10 @@ def read_file(self, filename: str) -> bytes:
def write_file(self, filename: str, content: bytes) -> None:
pass

@abstractmethod
def norm_path(self, path: str) -> str:
pass


class Extension(Protocol):
id: str
Expand Down
5 changes: 5 additions & 0 deletions src/ovshell/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,8 @@ def set(self, key: str, value: Optional[protocol.JsonType], save: bool = False):
def get(self, key: str, type: Type[JT], default: JT = None) -> Optional[JT]:
v = self._settings.get(key, default)
return v if isinstance(v, type) else None

def getstrict(self, key: str, type: Type[JT]) -> JT:
v = self.get(key, type)
assert v is not None
return v
13 changes: 9 additions & 4 deletions src/ovshell_core/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ def store(self, value: Optional[str]) -> None:
def get_choices(self) -> Sequence[Tuple[str, str]]:
return [
("0", "Landscape"),
("1", "Portrait (90)"),
("2", "Landscape (180)"),
("3", "Portrait (270)"),
("1", "Portrait (90°)"),
("2", "Landscape (180°)"),
("3", "Portrait (270°)"),
]

def _apply_rotation(self, rotation: str) -> None:
Expand All @@ -40,7 +40,12 @@ def _apply_rotation(self, rotation: str) -> None:
os.unmount_boot()

# For some weird reason 90 degree rotation is inverted for fbcon
fbcon_rotmap = {"0": b"0", "1": b"3", "2": b"2", "3": b"1"}
fbcon_rotmap = {
"0": b"0", # normal
"1": b"3", # portrait (90)
"2": b"2", # landscape (180)
"3": b"1", # portrait (270)
}
os.write_file("/sys/class/graphics/fbcon/rotate_all", fbcon_rotmap[rotation])


Expand Down
4 changes: 2 additions & 2 deletions src/ovshell_xcsoar/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
from ovshell_xcsoar import ext


def extension(id: str, app: protocol.OpenVarioShell) -> protocol.Extension:
return ext.XCSoarExtension(id, app)
def extension(id: str, shell: protocol.OpenVarioShell) -> protocol.Extension:
return ext.XCSoarExtension(id, shell)
Loading

0 comments on commit 6e24bbe

Please sign in to comment.