Wafer.Guards (wafer v1.1.4)

Copy Markdown View Source

Handy guards which you can use in your code to assert correct values.

Summary

Functions

Byte sizes are non negative integers

An integer between 0 and 0x7F

One of :none, :rising, :falling or :both

Either :in or :out

Pin numbers are non negative integers

One of :not_set, :none, :pull_up or :pull_down

Either 0 or 1

Register addresses are non negative integers usually only one byte, but we don't enforce that here

Functions

is_byte_size(bytes)

(macro)

Byte sizes are non negative integers

is_i2c_address(address)

(macro)

An integer between 0 and 0x7F

is_pin_condition(condition)

(macro)

One of :none, :rising, :falling or :both

is_pin_direction(direction)

(macro)

Either :in or :out

is_pin_number(pin)

(macro)

Pin numbers are non negative integers

is_pin_pull_mode(mode)

(macro)

One of :not_set, :none, :pull_up or :pull_down

is_pin_value(value)

(macro)

Either 0 or 1

is_register_address(address)

(macro)

Register addresses are non negative integers usually only one byte, but we don't enforce that here