I've built a library for you to use that does all the tedious stuff! But this library is not yet complete (Feb 2021) and will probably change around for a while. I recommend you fork and include the source project in your application, not a compiled library
Contribute however you like. No rules. just use common sense if available
- Scale Get/Set
- Sampling Frequency Get/Set
- Bias Get/Set
- Angular Velocity Bias Get/Set
- Scaled/Raw X, Y, Z
- Scaled/Raw Angular Velocity X, Y, Z
- Scale Get/Set
- Integration Time Get/Set
- Scaled/Raw Luminance
- Status
- Health
- Online
- Presence
- Type
- Charge Percentage
- Min/Max Voltage (Get/Set)
- Current Voltage
- Voltage Calibration (Last Full Voltage?)
- Constant Charging (Max)Current (Get/Set)
- Current Flow
- Enabled (Get/Set)
- Enabled (Get/Set)
- Governor (Get/Set)
- (Critical)Temperature
- Frequency (Get/Set)
- Min/Max (Governor)Frequency
- Frequency Stats
- Brightness (Get/Set)
- Backlight Power (Get/Set)
- Event based KeyUp/Down
- Event based plug detection
- Headphone Kind (Headset, Headphones)
- Sampling Frequency (Get/Set)
- Scale (Get/Set)
- Raw/Scaled X, Y, Z
- [WIP] Enabled
- [WIP] Event based Call detection
- [TBD] Event based Text detection
- [TBD] Event based MMS detection
- Status
- Health
- Online
- Presence
- BC Enabled
- Type
- Min Voltage
- Input Current Limit (Get/Set)
- Input Current Limit DCP (Get/Set)
- Charging Protocol
- Scale Get/Set
- Integration Time Get/Set
- Scaled/Raw Proximity
- GPU Temp
- CPU Temp
- Event Based
- Finger Up/Down detection events (10 fingers)
- Touch detection events (When something touches, when nothing touches)
- Gestures: Directional Swipes (8 directions), Screen Edge Zones with 'zoned' gestures (Eg.: SwipeLeft becomes BottomEdgeSwipeLeft)
- Position, X, Y for each finger
- Tap detection
- [WIP] On/Off
- Enabled (RFKILL, NMCLI, IFCONFIG, IP) (Get/Set)
- Connected (NMCLI, IP, IFCONFIG)
- MAC (IFCONFIG, IP) (Get/Set)
- SSID (NMCLI, IWGETID)
- Local IP (IFCONFIG, IP) (Get/Set)
- Signal/Noise Level (IWCONFIG)
- Link Quality (IWCONFIG)
- Scan (IW, IWLIST, NMCLI)
- Connect (NMCLI)
dotnet add package PinePhoneCore
// All in one
HardwareButtons.OnKeyStateChanged += (button,state)=> Console.WriteLine($"{button}: {(state ? "Pressed!" : "Released!")}");
// Both Volume Buttons
HardwareButtons.OnVolumeKeyStateChanged += (button,state)=> Console.WriteLine($"{button}: {(state ? "Pressed!" : "Released!")}");
// Individual events for each button
HardwareButtons.OnVolumeDownKeyStateChanged += (down)=> Console.WriteLine($"VolumeDown: {(down ? "Pressed!" : "Released!")}");
HardwareButtons.OnVolumeUpKeyStateChanged += (down)=> Console.WriteLine($"VolumeUp: {(down ? "Pressed!" : "Released!")}");
HardwareButtons.OnPowerKeyStateChanged += (down)=> Console.WriteLine($"PowerButon: {(down ? "Pressed!" : "Released!")}");
class Program
{
public static string DotConfigPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
static void Main(string[] args)
{
if (Environment.UserName == "root")
{
Console.WriteLine("ExitCode 1: Don't run me as root!");
Environment.Exit(1);
}
//HeadphoneJack.OnPluggedIn = Plugged;
//HeadphoneJack.OnPluggedOut = Plugged;
HeadphoneJack.OnPlugged = Plugged;
while (true)
Thread.Sleep(int.MaxValue);
}
private static void Plugged(HeadphoneKind kind)
{
Shell.Execute($"sh", $"-c \"{DotConfigPath}/sxmo/hooks/headphonejack {HeadphoneJack.Connected}\"");
}
}
class Program
{
static void Main(string[] args)
{
while (true)
{
var state = PinePhoneBattery.GetState();
var flow = PinePhoneBattery.GetChargeFlowMilliAmps();
switch (state)
{
case BatteryState.Unknown:
break;
case BatteryState.Charging:
var untilFull = PinePhoneBattery.GetTimeUntilFull()ToStri("hh'h 'mm'min'");
Console.WriteLine($"Battery full in {untilFull} (delivering {flow}mAh)");
break;
case BatteryState.Discharging:
var untilEmpty = PinePhoneBattery.GetTimeUntilEmpty()ToStri("hh'h 'mm'min'");
Console.WriteLine($"Battery empty in {untilEmpty} (drawing {flow}mAh)");
break;
}
Thread.Sleep(1000);
}
}
}