Skip to main content

imp.environment()

Returns information about the imp’s type

Availability

Device + Agent

Returns

Integer — A constant indicating the current environment

Description

This method returns information about what type of imp (card or module) the Squirrel code is executing on. It will also signal that the imp is a virtual one, ie. an agent. This is useful when writing portable code that might need to run in different places and know where it is being run.

The return value is one of the constants below:

Constant Value Type imps
ENVIRONMENT_CARD 0 Card imp001
ENVIRONMENT_MODULE 1 Module imp002, imp003, imp004m, imp005, imp006, impC001
ENVIRONMENT_AGENT 2 Agent N/A

The values assigned to the constants may change in a future impOS™ release.

You can call imp.info() to determine exactly specific imp type your code is running on and thus the availability of certain peripheral buses and GPIO pin names.