types

Common data types and constants.

class freewili.types.AccelData(g: float, x: float, y: float, z: float, temp_c: float, temp_f: float)

Bases: EventData

Accelerometer event data from Free-Wili Display.

classmethod from_string(data: str) Self

Convert a string to an AccelData object.

Arguments:

data: str

The string to convert, typically from an accel event.

Returns:

AccelData:

The converted AccelData object.

g: float
temp_c: float
temp_f: float
x: float
y: float
z: float
class freewili.types.AudioData(data: list[int])

Bases: EventData

Audio event data from Free-Wili Display.

data: list[int]
classmethod from_string(data: str) Self

Convert a string to an IRData object.

Arguments:

data: str

The string to convert, typically from an audio event.

Returns:

AudioData:

The converted AudioData object.

class freewili.types.BatteryData(vbus: float, vsys: float, vbatt: float, ichg: int, charging: bool, charge_complete: bool)

Bases: EventData

Battery event data from Free-Wili Display.

charge_complete: bool
charging: bool

True if the battery is charging, False otherwise.

classmethod from_string(data: str) Self

Convert a string to an BatteryData object.

Arguments:

data: str

The string to convert, typically from a battery event.

Returns:

BatteryData:

The converted BatteryData object.

ichg: int

Indicates if the battery is currently charging.

vbatt: float
vbus: float
vsys: float
class freewili.types.ButtonColor(value)

Bases: Enum

Free-Wili Physical Button Color.

Blue = 5
Green = 4
Red = 6
Unknown = 1
White = 2
Yellow = 3
class freewili.types.ButtonData(gray: bool, yellow: bool, green: bool, blue: bool, red: bool)

Bases: EventData

Button event data from Free-Wili Display.

blue: bool
classmethod from_string(data: str) Self

Convert a string to an ButtonData object.

Arguments:

data: str

The string to convert, typically from a button event.

Returns:

ButtonData:

The converted ButtonData object.

gray: bool
green: bool
red: bool
yellow: bool
class freewili.types.EventData

Bases: object

Base class for Free-Wili event data types.

classmethod from_string(data: str) Self

Convert a string to an instance of the subclass.

Arguments:

datastr

The string to convert.

Returns:

Self

An instance of the subclass.

Raises:

NotImplementedError

If the method is not implemented in the subclass.

class freewili.types.EventType(value)

Bases: Enum

Free-Wili Event Type.

Accel = 4
Audio = 11
Battery = 6
Button = 5
File = 3
GPIO = 2
IR = 7
Radio1 = 8
Radio2 = 9
UART1 = 10
Unknown = 1
classmethod from_frame(frame: ResponseFrame) Self

Convert a ResponseFrame to an EventType.

Arguments:

frame: ResponseFrame

The ResponseFrame to convert.

Returns:

EventType:

The corresponding EventType.

Raises:
ValueError:

When the frame does not contain a valid event type.

classmethod from_string(value: str) Self

Convert a string value to an EventType.

Arguments:

value: str

string value to convert to an enum. Case Insensitive. This is typically the rf_type_data field in a FreeWili Event ResponseFrame.

Returns:

EventType:

FreeWili event type.

Raises:
ValueError:

When invalid enum isn’t matched against provided string value.

get_data_type() EventData

Get the EventDataType class from this EventType.

Arguments:

None

Returns:

EventDataType:

The corresponding EventDataType class.

Raises:
ValueError:

When the string does not match any known event type.

class freewili.types.FileSystemContents(cwd: str, contents: list[FileSystemItem])

Bases: object

File system representation for Free-Wili.

contents: list[FileSystemItem]
cwd: str
class freewili.types.FileSystemItem(name: str, file_type: FileType, size: int = 0)

Bases: object

File system item representation for Free-Wili.

file_type: FileType

Size of the file in bytes, 0 for directories.

name: str

Type of the file system item, either File or Directory.

size: int = 0
class freewili.types.FileType(value)

Bases: Enum

Free-Wili File Type.

Directory = 2
File = 3
Unknown = 1
classmethod from_string(value: str) Self

Convert a string value to a FileType.

Arguments:

value: str

string value to convert to an enum. Case Insensitive.

Returns:

FileType:

FreeWili file type.

class freewili.types.FreeWiliProcessorType(value)

Bases: Enum

Processor type of the Free-Wili.

Display = 2
ESP32 = 4
FTDI = 3
Main = 1
Unknown = 5
class freewili.types.GPIOData(raw: list[int], pin: dict[str, int])

Bases: EventData

GPIO event data from Free-Wili Display.

classmethod from_string(data: str) Self

Convert a string to a GPIOData object.

Arguments:

data: str

The string to convert, typically from a GPIO event.

Returns:

GPIOData:

The converted GPIOData object.

pin: dict[str, int]
raw: list[int]
class freewili.types.IOMenuCommand(value)

Bases: Enum

Free-Wili IO menu representation.

Get = 6
High = 1
Low = 2
Pwm = 4
Stream = 5
Toggle = 3
classmethod from_string(value: str) Self

Convert a string value to an IOMenuCommand.

Arguments:

value: str

string value to convert to an enum. Case Insensitive.

Returns:

str:

FreeWili menu command character.

Raises:
ValueError:

When invalid enum isn’t matched against provided string value.

property menu_character: str

Convert IOMenuCommand to a FreeWili menu command character.

Arguments:

None

Returns:

str:

FreeWili menu command character.

Raises:
ValueError:

When invalid enum isn’t found.

class freewili.types.IRData(value: bytes)

Bases: EventData

IR event data from Free-Wili Display.

classmethod from_string(data: str) Self

Convert a string to an IRData object.

Arguments:

data: str

The string to convert, typically from an IR event.

Returns:

IRData:

The converted IRData object.

value: bytes
class freewili.types.Radio1Data(data: bytes, raw: str)

Bases: EventData

Radio1 event data from Free-Wili Display.

data: bytes
classmethod from_string(data: str) Self

Convert a string to a Radio1Data object.

Arguments:

data: str

The string to convert, typically from a Radio1 event.

Returns:

Radio1Data:

The converted Radio1Data object.

raw: str
class freewili.types.Radio2Data(data: bytes, raw: str)

Bases: Radio1Data

Radio2 event data from Free-Wili Display.

class freewili.types.RawData(value: str)

Bases: EventData

Raw event data from Free-Wili Display.

classmethod from_string(data: str) Self

Convert a string to a RawData object.

Arguments:

data: str

The string to convert, typically from an Unknown event.

Returns:

RawData:

The converted RawData object.

value: str
class freewili.types.UART1Data(data: bytes, raw: str)

Bases: Radio1Data

UART1 event data from Free-Wili Display.