Junxiao Shi
Published © CC BY

Fridge Door Alarm with NXP Rapid IoT

I made a fridge door alarm that sounds a buzzer if I leave my fridge door open for more than 10 seconds.

EasyFull instructions provided1 hour144

Things used in this project

Hardware components

Rapid IoT Prototyping Kit
NXP Rapid IoT Prototyping Kit
×1

Software apps and online services

NXP Rapid IOT Studio

Story

Read more

Schematics

Rapid IOT project

Image 2 06hackfmgg

Code

fridge.atmo

JSON
Import this file to Rapid IOT Studio https://rapid-iot-studio.nxp.com/
{
  "name": "fridge",
  "createVersion": "2017-08-12",
  "description": "New Project",
  "lastModified": "2018-12-16T23:04:56.902Z",
  "created": "2018-12-16T23:04:56.902Z",
  "meta": {
    "projectTypeName": "NXP Rapid IoT",
    "projectTypeId": "NxpRpk"
  },
  "planes": {
    "NXP Rapid IoT": {
      "type": "mcuxpresso",
      "compilerVersion": "latest",
      "variants": [
        "NxpRpk"
      ],
      "meta": {},
      "elements": [
        {
          "name": "TSL2572",
          "type": "EmbeddedTSL2572",
          "variants": [
            "embedded",
            "triggers",
            "abilities",
            "properties",
            "variables"
          ],
          "properties": {
            "errorData": {},
            "code": {
              "trigger": "\treturn ATMO_Status_Success;",
              "setup": "\tATMO_TSL2572_Config_t config;\n\tconfig.address = ATMO_PROPERTY(TSL2572, i2cAddress);\n\tconfig.i2cDriverInstance = ATMO_PROPERTY(TSL2572, i2cInstance);\n\n\treturn ( ATMO_TSL2572_Init(&config) == ATMO_TSL2572_Status_Success ) ? ATMO_Status_Success : ATMO_Status_Fail;\n",
              "setEnabled": "ATMO_TSL2572_SetEnabled(true);\nreturn ATMO_Status_Success;",
              "setDisabled": "ATMO_TSL2572_SetEnabled(false);\nreturn ATMO_Status_Success;",
              "setEnabledDisabled": "bool enabled = false;\nATMO_GetBool(in, &enabled);\nATMO_TSL2572_SetEnabled(enabled);\nreturn ATMO_Status_Success;",
              "readAmbientLight": "    float lightLux;\n    if(ATMO_TSL2572_GetAmbientLight(&lightLux) != ATMO_TSL2572_Status_Success)\n    {\n        ATMO_CreateValueVoid(out);\n        return ATMO_Status_Fail;\n    }\n    ATMO_CreateValueInt(out, (int)lightLux);\n    return ATMO_Status_Success;"
            },
            "variables": {},
            "embeddedPropertyConversions": {},
            "codeUserChanged": {
              "setup": false,
              "setEnabled": false,
              "setDisabled": false,
              "setEnabledDisabled": false,
              "readAmbientLight": false
            },
            "i2cInstance": 1,
            "i2cAddress": "0x39"
          },
          "meta": {
            "editorX": 171,
            "editorY": 64,
            "lastTrigger": "ambientLightRead"
          },
          "triggers": {
            "triggered": [],
            "ambientLightRead": [
              {
                "mapping": {},
                "targetOrder": [],
                "targetElement": "light_cmp",
                "targetAbility": "evaluate"
              },
              {
                "mapping": {},
                "targetOrder": [],
                "targetElement": "display",
                "targetAbility": "setLine1Text"
              }
            ]
          },
          "interruptAbilities": {
            "trigger": false,
            "setup": false,
            "setEnabled": false,
            "setDisabled": false,
            "setEnabledDisabled": false,
            "readAmbientLight": false
          },
          "abilities": [
            {
              "name": "trigger",
              "triggers": [
                "triggered"
              ]
            },
            {
              "name": "setup",
              "triggers": []
            },
            {
              "name": "setEnabled",
              "triggers": []
            },
            {
              "name": "setDisabled",
              "triggers": []
            },
            {
              "name": "setEnabledDisabled",
              "triggers": []
            },
            {
              "name": "readAmbientLight",
              "triggers": [
                "ambientLightRead"
              ]
            }
          ]
        },
        {
          "name": "Interval",
          "type": "EmbeddedInterval",
          "variants": [
            "embedded",
            "triggers",
            "abilities",
            "properties",
            "variables"
          ],
          "properties": {
            "errorData": {},
            "code": {
              "trigger": "\treturn ATMO_Status_Success;",
              "setup": "\n\tATMO_INTERVAL_Handle_t intervalHandle;\n    ATMO_INTERVAL_AddAbilityInterval(\n\t\tATMO_PROPERTY(Interval, instance), \n\t\tATMO_ABILITY(Interval, interval), \n\t\tATMO_PROPERTY(Interval, time), \n\t\t&intervalHandle\n\t);\n\t\n\treturn ATMO_Status_Success;\n\t",
              "interval": "\treturn ATMO_Status_Success;"
            },
            "variables": {},
            "embeddedPropertyConversions": {},
            "codeUserChanged": {
              "setup": false,
              "interval": false
            },
            "instance": 0,
            "time": 1000
          },
          "meta": {
            "editorX": 44,
            "editorY": 64,
            "lastTrigger": "interval"
          },
          "triggers": {
            "triggered": [],
            "interval": [
              {
                "mapping": {},
                "targetOrder": [],
                "targetElement": "TSL2572",
                "targetAbility": "readAmbientLight"
              },
              {
                "mapping": {},
                "targetOrder": [],
                "targetElement": "ENS210",
                "targetAbility": "readTemperature"
              },
              {
                "mapping": {},
                "targetOrder": [],
                "targetElement": "ENS210",
                "targetAbility": "readHumidity"
              }
            ]
          },
          "interruptAbilities": {
            "trigger": false,
            "setup": false,
            "interval": true
          },
          "abilities": [
            {
              "name": "trigger",
              "triggers": [
                "triggered"
              ]
            },
            {
              "name": "setup",
              "triggers": []
            },
            {
              "name": "interval",
              "triggers": [
                "interval"
              ]
            }
          ]
        },
        {
          "name": "light_cmp",
          "type": "EmbeddedComparison",
          "variants": [
            "embedded",
            "triggers",
            "abilities",
            "properties",
            "variables"
          ],
          "properties": {
            "errorData": {},
            "code": {
              "trigger": "\treturn ATMO_Status_Success;",
              "setup": "\n\treturn ATMO_Status_Success;\n\t",
              "evaluate": "\n\tbool conditionTrue = false;\n\n\t// Convert property to same type as input\n\tATMO_Value_t targetStr;\n\tATMO_Value_t targetNum;\n\t\n\tATMO_InitValue(&targetStr);\n\tATMO_InitValue(&targetNum);\n\tATMO_CreateValueString(&targetStr, ATMO_PROPERTY(light_cmp, target));\n\tATMO_CreateValueConverted(&targetNum, in->type, &targetStr);\n\t\n\tif(ATMO_CompareValues(in, &targetNum, ATMO_PROPERTY(light_cmp, condition), &conditionTrue) != ATMO_Status_Success)\n\t{\n\t\tATMO_Value_t value;\n\t\tATMO_InitValue(&value);\n\t\tATMO_TriggerHandler(ATMO_TRIGGER(light_cmp, invalidType), NULL);\n\t\tATMO_FreeValue(&value);\n\t\tATMO_FreeValue(&targetStr);\n\t\tATMO_FreeValue(&targetNum);\n\t\treturn ATMO_Status_Fail;\n\t}\n\n\tATMO_FreeValue(&targetStr);\n\tATMO_FreeValue(&targetNum);\n\n\tif(conditionTrue)\n\t{\n\t\tATMO_Value_t value;\n\t\tATMO_InitValue(&value);\n\t\tATMO_TriggerHandler(ATMO_TRIGGER(light_cmp, conditionTrue), NULL);\n\t\tATMO_FreeValue(&value);\t\t\n\t}\n\telse\n\t{\n\t\tATMO_Value_t value;\n\t\tATMO_InitValue(&value);\n\t\tATMO_TriggerHandler(ATMO_TRIGGER(light_cmp, conditionFalse), NULL);\n\t\tATMO_FreeValue(&value);\t\t\t\n\t}\n\n\treturn ATMO_Status_Success;\n\t"
            },
            "variables": {},
            "embeddedPropertyConversions": {
              "target": "string"
            },
            "codeUserChanged": {
              "setup": false,
              "evaluate": false
            },
            "condition": "ATMO_GREATER_THAN",
            "target": "100"
          },
          "meta": {
            "editorX": 404,
            "editorY": 0,
            "lastTrigger": "conditionTrue"
          },
          "triggers": {
            "triggered": [],
            "conditionTrue": [
              {
                "mapping": {},
                "targetOrder": [],
                "targetElement": "RGB",
                "targetAbility": "setRedOn"
              },
              {
                "mapping": {},
                "targetOrder": [],
                "targetElement": "time",
                "targetAbility": "getValue"
              }
            ],
            "conditionFalse": [
              {
                "mapping": {},
                "targetOrder": [],
                "targetElement": "RGB",
                "targetAbility": "setOff"
              },
              {
                "mapping": {},
                "targetOrder": [],
                "targetElement": "zero",
                "targetAbility": "convert"
              }
            ],
            "invalidType": []
          },
          "interruptAbilities": {
            "trigger": false,
            "setup": false,
            "evaluate": false
          },
          "abilities": [
            {
              "name": "trigger",
              "triggers": [
                "triggered"
              ]
            },
            {
              "name": "setup",
              "triggers": []
            },
            {
              "name": "evaluate",
              "triggers": []
            }
          ]
        },
        {
          "name": "display",
          "type": "EmbeddedIconLinesDisplay",
          "variants": [
            "embedded",
            "triggers",
            "abilities",
            "properties",
            "variables",
            "rpk"
          ],
          "properties": {
            "errorData": {},
            "code": {
              "trigger": "\treturn ATMO_Status_Success;",
              "displayPage": "\n\tATMO_UI_Page_DisplayPageByCoord(ATMO_PROPERTY(display, x), ATMO_PROPERTY(display, y), false);\n\treturn ATMO_Status_Success;\n\t",
              "onDisplayed": "\n\treturn ATMO_Status_Success;\n    ",
              "onLeave": "\n\treturn ATMO_Status_Success;\n\t",
              "setIconLabelAndColor": "\n    struct {\n        char str[32];\n        GUI_COLOR color;\n    } icon_data;\n \n    ATMO_GetBinary(in, &icon_data, sizeof(icon_data));\n    ATMO_UI_ICONLINES_SetIconLabelColor(ATMO_VARIABLE(display, pageHandle), icon_data.str, icon_data.color);\n    return ATMO_Status_Success;\n    ",
              "setIconLabel": "\n    char str[32];\n    ATMO_GetString(in, str, 32);\n    ATMO_UI_ICONLINES_SetIconLabel(ATMO_VARIABLE(display, pageHandle), str);\n    return ATMO_Status_Success;\n    ",
              "setup": "\n    ATMO_UI_PAGE_Config_t config;\n    config.hidden = ATMO_PROPERTY(display, pageHidden);\n    config.textColor = ATMO_PROPERTY(display, textColor);\n    config.activeButtons = ATMO_UI_Page_GetButtonMask(ATMO_PROPERTY(display, topRightButtonEnabled),\n    ATMO_PROPERTY(display,bottomRightButtonEnabled), ATMO_PROPERTY(display, topLeftButtonEnabled), ATMO_PROPERTY(display, bottomLeftButtonEnabled));\n\tconfig.x = ATMO_PROPERTY(display, x);\n    config.y = ATMO_PROPERTY(display, y);\n\tstrncpy(config.topLeftButtonLabel, ATMO_PROPERTY(display, topLeftButtonLabel), ATMO_BUTTON_LABEL_MAXLEN);\n\tstrncpy(config.topRightButtonLabel, ATMO_PROPERTY(display, topRightButtonLabel), ATMO_BUTTON_LABEL_MAXLEN);\n\tstrncpy(config.bottomLeftButtonLabel, ATMO_PROPERTY(display, bottomLeftButtonLabel), ATMO_BUTTON_LABEL_MAXLEN);\n\tstrncpy(config.bottomRightButtonLabel, ATMO_PROPERTY(display, bottomRightButtonLabel), ATMO_BUTTON_LABEL_MAXLEN);\n    config.spanX = ATMO_PROPERTY(display, spanX);\n\tconfig.spanY = ATMO_PROPERTY(display, spanY);\n    config.title = ATMO_PROPERTY(display, pageTitle);\n    config.titleHidden = ATMO_PROPERTY(display, titleHidden);\n\tATMO_UI_ICONLINES_Init(&config, ATMO_PROPERTY(display, numLines), false);\n\tATMO_VARIABLE(display, pageHandle) = config.templateInstance;\n    ATMO_UI_ICONLINES_SetMainText(config.templateInstance, 0, ATMO_PROPERTY(display, line1Text));\n    ATMO_UI_ICONLINES_SetMainText(config.templateInstance, 1, ATMO_PROPERTY(display, line2Text));\n    ATMO_UI_ICONLINES_SetMainText(config.templateInstance, 2, ATMO_PROPERTY(display, line3Text));\n    ATMO_UI_ICONLINES_SetMainText(config.templateInstance, 3, ATMO_PROPERTY(display, line4Text));\n    ATMO_UI_ICONLINES_SetIconLabel(config.templateInstance, ATMO_PROPERTY(display, iconLabel));\n    ATMO_UI_ICONLINES_RegisterButtonAbilityHandle(ATMO_VARIABLE(display,pageHandle), 1, ATMO_ABILITY(display, topRightButtonPressed));\n\tATMO_UI_ICONLINES_RegisterButtonAbilityHandle(ATMO_VARIABLE(display,pageHandle), 2, ATMO_ABILITY(display, bottomRightButtonPressed));\n\tATMO_UI_ICONLINES_RegisterButtonAbilityHandle(ATMO_VARIABLE(display,pageHandle), 3, ATMO_ABILITY(display, topLeftButtonPressed));\n    ATMO_UI_ICONLINES_RegisterButtonAbilityHandle(ATMO_VARIABLE(display,pageHandle), 4, ATMO_ABILITY(display, bottomLeftButtonPressed));\n    ATMO_UI_ICONLINES_SetIcon(config.templateInstance, ATMO_PROPERTY(display, icon));\n    ATMO_UI_ICONLINES_RegisterOnDisplayedAbilityHandle(ATMO_VARIABLE(display,pageHandle), ATMO_ABILITY(display, onDisplayed));\n    ATMO_UI_ICONLINES_RegisterOnLeaveAbilityHandle(config.templateInstance, ATMO_ABILITY(display, onLeave));\n    return ATMO_Status_Success;\n    ",
              "setLine1Text": "\n    char label[32];\n    if(ATMO_GetString(in, label, 32) == ATMO_Status_Success)\n    {\n        ATMO_UI_ICONLINES_SetMainText(ATMO_VARIABLE(display,pageHandle), 0, label);\n    }\n    else\n    {\n        return ATMO_Status_Fail;\n    }\n\n    return ATMO_Status_Success;\n    ",
              "setLine2Text": "\n    char label[32];\n    if(ATMO_GetString(in, label, 32) == ATMO_Status_Success)\n    {\n        ATMO_UI_ICONLINES_SetMainText(ATMO_VARIABLE(display,pageHandle), 1, label);\n    }\n    else\n    {\n        return ATMO_Status_Fail;\n    }\n\n    return ATMO_Status_Success;\n    ",
              "setLine3Text": "\n    char label[32];\n    if(ATMO_GetString(in, label, 32) == ATMO_Status_Success)\n    {\n        ATMO_UI_ICONLINES_SetMainText(ATMO_VARIABLE(display,pageHandle), 2, label);\n    }\n    else\n    {\n        return ATMO_Status_Fail;\n    }\n\n    return ATMO_Status_Success;\n    ",
              "setLine4Text": "\n    char label[32];\n    if(ATMO_GetString(in, label, 32) == ATMO_Status_Success)\n    {\n        ATMO_UI_ICONLINES_SetMainText(ATMO_VARIABLE(display,pageHandle), 3, label);\n    }\n    else\n    {\n        return ATMO_Status_Fail;\n    }\n\n    return ATMO_Status_Success;\n    ",
              "topRightButtonPressed": "\n\treturn ATMO_Status_Success;\n\t",
              "bottomRightButtonPressed": "\n\treturn ATMO_Status_Success;\n\t",
              "topLeftButtonPressed": "\n\treturn ATMO_Status_Success;\n\t",
              "bottomLeftButtonPressed": "\n\treturn ATMO_Status_Success;\n\t"
            },
            "variables": {
              "pageHandle": {
                "type": "ATMO_DriverInstanceHandle_t"
              }
            },
            "embeddedPropertyConversions": {
              "pageTitle": "string",
              "topRightButtonLabel": "string",
              "bottomRightButtonLabel": "string",
              "topLeftButtonLabel": "string",
              "bottomLeftButtonLabel": "string",
              "iconLabel": "string",
              "line1Text": "string",
              "line2Text": "string",
              "line3Text": "string",
              "line4Text": "string"
            },
            "codeUserChanged": {
              "displayPage": false,
              "onDisplayed": false,
              "onLeave": false,
              "setIconLabelAndColor": false,
              "setIconLabel": false,
              "setup": false,
              "setLine1Text": false,
              "setLine2Text": false,
              "setLine3Text": false,
              "setLine4Text": false,
              "topRightButtonPressed": false,
              "bottomRightButtonPressed": false,
              "topLeftButtonPressed": false,
              "bottomLeftButtonPressed": false
            },
            "textColor": "GUI_BLACK",
            "pageTitle": "",
            "titleHidden": false,
            "pageHidden": false,
            "topRightButtonLabel": "",
            "topRightButtonEnabled": false,
            "bottomRightButtonLabel": "",
            "bottomRightButtonEnabled": false,
            "topLeftButtonLabel": "",
            "topLeftButtonEnabled": false,
            "bottomLeftButtonLabel": "",
            "bottomLeftButtonEnabled": false,
            "x": 0,
            "y": 0,
            "spanX": 1,
            "spanY": 1,
            "icon": "icon_applications_thermostat",
            "iconLabel": "",
            "numLines": 4,
            "line1Text": "",
            "line2Text": "",
            "line3Text": "",
            "line4Text": ""
          },
          "meta": {
            "editorX": 418,
            "editorY": 201,
            "lastTrigger": "onDisplayed"
          },
          "triggers": {
            "triggered": [],
            "onDisplayed": [],
            "onLeave": [],
            "topRightButtonPressed": [],
            "bottomRightButtonPressed": [],
            "topLeftButtonPressed": [],
            "bottomLeftButtonPressed": []
          },
          "interruptAbilities": {
            "trigger": false,
            "displayPage": false,
            "onDisplayed": false,
            "onLeave": false,
            "setIconLabelAndColor": false,
            "setIconLabel": false,
            "setup": false,
            "setLine1Text": false,
            "setLine2Text": false,
            "setLine3Text": false,
            "setLine4Text": false,
            "topRightButtonPressed": false,
            "bottomRightButtonPressed": false,
            "topLeftButtonPressed": false,
            "bottomLeftButtonPressed": false
          },
          "abilities": [
            {
              "name": "trigger",
              "triggers": [
                "triggered"
              ]
            },
            {
              "name": "displayPage",
              "triggers": []
            },
            {
              "name": "onDisplayed",
              "triggers": [
                "onDisplayed"
              ]
            },
            {
              "name": "onLeave",
              "triggers": [
                "onLeave"
              ]
            },
            {
              "name": "setIconLabelAndColor",
              "triggers": []
            },
            {
              "name": "setIconLabel",
              "triggers": []
            },
            {
              "name": "setup",
              "triggers": []
            },
            {
              "name": "setLine1Text",
              "triggers": []
            },
            {
              "name": "setLine2Text",
              "triggers": []
            },
            {
              "name": "setLine3Text",
              "triggers": []
            },
            {
              "name": "setLine4Text",
              "triggers": []
            },
            {
              "name": "topRightButtonPressed",
              "triggers": [
                "topRightButtonPressed"
              ]
            },
            {
              "name": "bottomRightButtonPressed",
              "triggers": [
                "bottomRightButtonPressed"
              ]
            },
            {
              "name": "topLeftButtonPressed",
              "triggers": [
                "topLeftButtonPressed"
              ]
            },
            {
              "name": "bottomLeftButtonPressed",
              "triggers": [
                "bottomLeftButtonPressed"
              ]
            }
          ]
        },
        {
          "name": "RGB",
          "type": "EmbeddedNxpRpkRgbLed",
          "variants": [
            "embedded",
            "triggers",
            "abilities",
            "properties",
            "variables",
            "rpk"
          ],
          "properties": {
            "errorData": {},
            "code": {
              "trigger": "\treturn ATMO_Status_Success;",
              "setup": "\n    RGB_Led_Set_State(RGB_LED_BRIGHT_HIGH, RGB_LED_COLOR_BLACK);\n\treturn ATMO_Status_Success;\n\t",
              "setColorPreset": "\n    unsigned int desiredColor = 0;\n    ATMO_GetUnsignedInt(in, &desiredColor);\n\n    uint8_t brightness = 0;\n    uint8_t color = 0;\n    RGB_Led_Get_State(&brightness, &color);\n    RGB_Led_Set_State(brightness, desiredColor);\n    return ATMO_Status_Success;\n    ",
              "setBrightnessLow": "\n    uint8_t brightness = 0;\n    uint8_t color = 0;\n    RGB_Led_Get_State(&brightness, &color);\n    RGB_Led_Set_State(RGB_LED_BRIGHT_LOW, color);\n    return ATMO_Status_Success;\n    ",
              "setBrightnessOff": "\n    uint8_t brightness = 0;\n    uint8_t color = 0;\n    RGB_Led_Get_State(&brightness, &color);\n    RGB_Led_Set_State(RGB_LED_BRIGHT_OFF, color);\n    return ATMO_Status_Success;\n    ",
              "setBrightnessMedium": "\n    uint8_t brightness = 0;\n    uint8_t color = 0;\n    RGB_Led_Get_State(&brightness, &color);\n    RGB_Led_Set_State(RGB_LED_BRIGHT_MEDIUM, color);\n    return ATMO_Status_Success;\n    ",
              "setBrightnessHigh": "\treturn ATMO_Status_Success;",
              "setRedOn": "\n    RGB_Led_Set_State(RGB_LED_BRIGHT_HIGH, RGB_LED_COLOR_RED);\n\treturn ATMO_Status_Success;\n    ",
              "setGreenOn": "\n    RGB_Led_Set_State(RGB_LED_BRIGHT_HIGH, RGB_LED_COLOR_GREEN);\n\treturn ATMO_Status_Success;\n    ",
              "setBlueOn": "\n    RGB_Led_Set_State(RGB_LED_BRIGHT_HIGH, RGB_LED_COLOR_BLUE);\n\treturn ATMO_Status_Success;\n    ",
              "setWhiteOn": "\treturn ATMO_Status_Success;",
              "toggleRed": "\n\tuint8_t color, brightness;\n    RGB_Led_Get_State(&brightness, &color);\n    if(brightness == RGB_LED_BRIGHT_OFF || color == RGB_LED_COLOR_BLACK)\n    {\n        brightness = RGB_LED_BRIGHT_HIGH;\n    }\n    else\n    {\n        brightness = RGB_LED_BRIGHT_OFF;\n    }\n\n    RGB_Led_Set_State(brightness, RGB_LED_COLOR_RED);\n    return ATMO_Status_Success;\n\t",
              "toggleGreen": "\n\tuint8_t color, brightness;\n    RGB_Led_Get_State(&brightness, &color);\n    if(brightness == RGB_LED_BRIGHT_OFF || color == RGB_LED_COLOR_BLACK)\n    {\n        brightness = RGB_LED_BRIGHT_HIGH;\n    }\n    else\n    {\n        brightness = RGB_LED_BRIGHT_OFF;\n    }\n\n    RGB_Led_Set_State(brightness, RGB_LED_COLOR_GREEN);\n    return ATMO_Status_Success;\n\t",
              "toggleBlue": "\n\tuint8_t color, brightness;\n    RGB_Led_Get_State(&brightness, &color);\n    if(brightness == RGB_LED_BRIGHT_OFF || color == RGB_LED_COLOR_BLACK)\n    {\n        brightness = RGB_LED_BRIGHT_HIGH;\n    }\n    else\n    {\n        brightness = RGB_LED_BRIGHT_OFF;\n    }\n\n    RGB_Led_Set_State(brightness, RGB_LED_COLOR_BLUE);\n    return ATMO_Status_Success;\n\t",
              "setOff": "\n    uint8_t color, brightness;\n    RGB_Led_Get_State(&brightness, &color);\n    RGB_Led_Set_State(brightness, RGB_LED_COLOR_BLACK);\n\treturn ATMO_Status_Success;\n    ",
              "setColorHex": "\n    unsigned int color = 0;\n    ATMO_GetUnsignedInt(in, &color);\n    uint8_t red = (color >> 16) & 0xFF;\n    uint8_t green = (color >> 8) & 0xFF;\n    uint8_t blue = color & 0xFF;\n    Rgb_Led_Set_Colors(red, green, blue);  \n    ATMO_CreateValueUnsignedInt(out, color);\n\treturn ATMO_Status_Success;\n    "
            },
            "variables": {},
            "embeddedPropertyConversions": {},
            "codeUserChanged": {
              "setup": false,
              "setColorPreset": false,
              "setBrightnessLow": false,
              "setBrightnessOff": false,
              "setBrightnessMedium": false,
              "setBrightnessHigh": false,
              "setRedOn": false,
              "setGreenOn": false,
              "setBlueOn": false,
              "setWhiteOn": false,
              "toggleRed": false,
              "toggleGreen": false,
              "toggleBlue": false,
              "setOff": false,
              "setColorHex": false
            }
          },
          "meta": {
            "editorX": 930,
            "editorY": 3,
            "lastTrigger": "colorSet"
          },
          "triggers": {
            "triggered": [],
            "brightnessSet": [],
            "colorSet": []
          },
          "interruptAbilities": {
            "trigger": false,
            "setup": false,
            "setColorPreset": false,
            "setBrightnessLow": false,
            "setBrightnessOff": false,
            "setBrightnessMedium": false,
            "setBrightnessHigh": false,
            "setRedOn": false,
            "setGreenOn": false,
            "setBlueOn": false,
            "setWhiteOn": false,
            "toggleRed": false,
            "toggleGreen": false,
            "toggleBlue": false,
            "setOff": false,
            "setColorHex": false
          },
          "abilities": [
            {
              "name": "trigger",
              "triggers": [
                "triggered"
              ]
            },
            {
              "name": "setup",
              "triggers": []
            },
            {
              "name": "setColorPreset",
              "triggers": []
            },
            {
              "name": "setBrightnessLow",
              "triggers": [
                "brightnessSet"
              ]
            },
            {
              "name": "setBrightnessOff",
              "triggers": [
                "brightnessSet"
              ]
            },
            {
              "name": "setBrightnessMedium",
              "triggers": [
                "brightnessSet"
              ]
            },
            {
              "name": "setBrightnessHigh",
              "triggers": [
                "brightnessSet"
              ]
            },
            {
              "name": "setRedOn",
              "triggers": []
            },
            {
              "name": "setGreenOn",
              "triggers": []
            },
            {
              "name": "setBlueOn",
              "triggers": []
            },
            {
              "name": "setWhiteOn",
              "triggers": []
            },
            {
              "name": "toggleRed",
              "triggers": []
            },
            {
              "name": "toggleGreen",
              "triggers": []
            },
            {
              "name": "toggleBlue",
              "triggers": []
            },
            {
              "name": "setOff",
              "triggers": []
            },
            {
              "name": "setColorHex",
              "triggers": [
                "colorSet"
              ]
            }
          ]
        },
        {
          "name": "time",
          "type": "EmbeddedVariable",
          "variants": [
            "embedded",
            "triggers",
            "abilities",
            "properties",
            "variables"
          ],
          "properties": {
            "errorData": {},
            "code": {
              "trigger": "\treturn ATMO_Status_Success;",
              "setup": "\n    ATMO_InitValue(&ATMO_VARIABLE(time, value));\n\treturn ATMO_Status_Success;\n\t",
              "setValue": "\n    ATMO_CreateValueCopy(&ATMO_VARIABLE(time, value), in);\n    ATMO_CreateValueCopy(out, in);\n    return ATMO_Status_Success;\n    ",
              "getValue": "\n    ATMO_CreateValueCopy(out, &ATMO_VARIABLE(time, value));\n    return ATMO_Status_Success;\n    "
            },
            "variables": {
              "value": {
                "type": "ATMO_Value_t"
              }
            },
            "embeddedPropertyConversions": {},
            "codeUserChanged": {
              "setup": false,
              "setValue": false,
              "getValue": false
            }
          },
          "meta": {
            "editorX": 653,
            "editorY": 67,
            "lastTrigger": "valueSet"
          },
          "triggers": {
            "triggered": [],
            "valueSet": [
              {
                "mapping": {},
                "targetOrder": [],
                "targetElement": "display",
                "targetAbility": "setLine2Text"
              },
              {
                "mapping": {},
                "targetOrder": [],
                "targetElement": "time_cmp",
                "targetAbility": "evaluate"
              }
            ],
            "valueRetrieved": [
              {
                "mapping": {},
                "targetOrder": [],
                "targetElement": "time_increment",
                "targetAbility": "performOperation"
              }
            ]
          },
          "interruptAbilities": {
            "trigger": false,
            "setup": false,
            "setValue": false,
            "getValue": false
          },
          "abilities": [
            {
              "name": "trigger",
              "triggers": [
                "triggered"
              ]
            },
            {
              "name": "setup",
              "triggers": []
            },
            {
              "name": "setValue",
              "triggers": [
                "valueSet"
              ]
            },
            {
              "name": "getValue",
              "triggers": [
                "valueRetrieved"
              ]
            }
          ]
        },
        {
          "name": "time_increment",
          "type": "EmbeddedOperation",
          "variants": [
            "embedded",
            "triggers",
            "abilities",
            "properties",
            "variables"
          ],
          "properties": {
            "errorData": {},
            "code": {
              "trigger": "\treturn ATMO_Status_Success;",
              "setup": "\n\treturn ATMO_Status_Success;\n\t",
              "performOperation": "\n    return ATMO_PerformOperation(out, ATMO_PROPERTY(time_increment, operation), ATMO_PROPERTY(time_increment, operand), in);\n    "
            },
            "variables": {},
            "embeddedPropertyConversions": {},
            "codeUserChanged": {
              "setup": false,
              "performOperation": false
            },
            "operation": "ATMO_OPERATOR_ADD",
            "operand": "1"
          },
          "meta": {
            "editorX": 826,
            "editorY": 138,
            "lastTrigger": "operationPerformed"
          },
          "triggers": {
            "triggered": [],
            "operationPerformed": [
              {
                "mapping": {},
                "targetOrder": [],
                "targetElement": "time",
                "targetAbility": "setValue"
              }
            ]
          },
          "interruptAbilities": {
            "trigger": false,
            "setup": false,
            "performOperation": false
          },
          "abilities": [
            {
              "name": "trigger",
              "triggers": [
                "triggered"
              ]
            },
            {
              "name": "setup",
              "triggers": []
            },
            {
              "name": "performOperation",
              "triggers": [
                "operationPerformed"
              ]
            }
          ]
        },
        {
          "name": "time_cmp",
          "type": "EmbeddedComparison",
          "variants": [
            "embedded",
            "triggers",
            "abilities",
            "properties",
            "variables"
          ],
          "properties": {
            "errorData": {},
            "code": {
              "trigger": "\treturn ATMO_Status_Success;",
              "setup": "\n\treturn ATMO_Status_Success;\n\t",
              "evaluate": "\n\tbool conditionTrue = false;\n\n\t// Convert property to same type as input\n\tATMO_Value_t targetStr;\n\tATMO_Value_t targetNum;\n\t\n\tATMO_InitValue(&targetStr);\n\tATMO_InitValue(&targetNum);\n\tATMO_CreateValueString(&targetStr, ATMO_PROPERTY(time_cmp, target));\n\tATMO_CreateValueConverted(&targetNum, in->type, &targetStr);\n\t\n\tif(ATMO_CompareValues(in, &targetNum, ATMO_PROPERTY(time_cmp, condition), &conditionTrue) != ATMO_Status_Success)\n\t{\n\t\tATMO_Value_t value;\n\t\tATMO_InitValue(&value);\n\t\tATMO_TriggerHandler(ATMO_TRIGGER(time_cmp, invalidType), NULL);\n\t\tATMO_FreeValue(&value);\n\t\tATMO_FreeValue(&targetStr);\n\t\tATMO_FreeValue(&targetNum);\n\t\treturn ATMO_Status_Fail;\n\t}\n\n\tATMO_FreeValue(&targetStr);\n\tATMO_FreeValue(&targetNum);\n\n\tif(conditionTrue)\n\t{\n\t\tATMO_Value_t value;\n\t\tATMO_InitValue(&value);\n\t\tATMO_TriggerHandler(ATMO_TRIGGER(time_cmp, conditionTrue), NULL);\n\t\tATMO_FreeValue(&value);\t\t\n\t}\n\telse\n\t{\n\t\tATMO_Value_t value;\n\t\tATMO_InitValue(&value);\n\t\tATMO_TriggerHandler(ATMO_TRIGGER(time_cmp, conditionFalse), NULL);\n\t\tATMO_FreeValue(&value);\t\t\t\n\t}\n\n\treturn ATMO_Status_Success;\n\t"
            },
            "variables": {},
            "embeddedPropertyConversions": {
              "target": "string"
            },
            "codeUserChanged": {
              "setup": false,
              "evaluate": false
            },
            "condition": "ATMO_GREATER_THAN_EQUAL",
            "target": "10"
          },
          "meta": {
            "editorX": 752,
            "editorY": 210,
            "lastTrigger": "conditionFalse"
          },
          "triggers": {
            "triggered": [],
            "conditionTrue": [
              {
                "mapping": {},
                "targetOrder": [],
                "targetElement": "buzzer",
                "targetAbility": "turnOn"
              }
            ],
            "conditionFalse": [
              {
                "mapping": {},
                "targetOrder": [],
                "targetElement": "buzzer",
                "targetAbility": "turnOff"
              }
            ],
            "invalidType": []
          },
          "interruptAbilities": {
            "trigger": false,
            "setup": false,
            "evaluate": false
          },
          "abilities": [
            {
              "name": "trigger",
              "triggers": [
                "triggered"
              ]
            },
            {
              "name": "setup",
              "triggers": []
            },
            {
              "name": "evaluate",
              "triggers": []
            }
          ]
        },
        {
          "name": "zero",
          "type": "EmbeddedDataTypeConversion",
          "variants": [
            "embedded",
            "triggers",
            "abilities",
            "properties",
            "variables"
          ],
          "properties": {
            "errorData": {},
            "code": {
              "trigger": "\treturn ATMO_Status_Success;",
              "setup": "\n\treturn ATMO_Status_Success;\n\t",
              "convert": "\n    return ATMO_CreateValueConverted(out, ATMO_PROPERTY(zero, type), in);\n    "
            },
            "variables": {},
            "embeddedPropertyConversions": {},
            "codeUserChanged": {
              "setup": false,
              "convert": false
            },
            "type": "ATMO_DATATYPE_INT"
          },
          "meta": {
            "editorX": 476,
            "editorY": 76,
            "lastTrigger": "converted"
          },
          "triggers": {
            "triggered": [],
            "converted": [
              {
                "mapping": {},
                "targetOrder": [],
                "targetElement": "time",
                "targetAbility": "setValue"
              }
            ]
          },
          "interruptAbilities": {
            "trigger": false,
            "setup": false,
            "convert": false
          },
          "abilities": [
            {
              "name": "trigger",
              "triggers": [
                "triggered"
              ]
            },
            {
              "name": "setup",
              "triggers": []
            },
            {
              "name": "convert",
              "triggers": [
                "converted"
              ]
            }
          ]
        },
        {
          "name": "buzzer",
          "type": "EmbeddedNxpRpkBuzzer",
          "variants": [
            "embedded",
            "triggers",
            "abilities",
            "properties",
            "variables",
            "rpk"
          ],
          "properties": {
            "errorData": {},
            "code": {
              "trigger": "\treturn ATMO_Status_Success;",
              "setup": "\n\treturn ATMO_Status_Success;\n    ",
              "beep": "\n    ATMO_MK64F_Buzzer_On();\n    ATMO_PLATFORM_DelayMilliseconds(200);\n    ATMO_MK64F_Buzzer_Off();\n\treturn ATMO_Status_Success;\n    ",
              "turnOn": "\n    ATMO_MK64F_Buzzer_On();\n    ATMO_CreateValueBool(out, true);\n\treturn ATMO_Status_Success;\n    ",
              "turnOff": "\n    ATMO_MK64F_Buzzer_Off();\n    ATMO_CreateValueBool(out, false);\n\treturn ATMO_Status_Success;\n    ",
              "toggle": "\n    bool newState = false;\n    ATMO_MK64F_Buzzer_Toggle(&newState);\n    ATMO_CreateValueBool(out, newState);\n\treturn ATMO_Status_Success;\n    ",
              "setState": "\n    bool on = false;\n    ATMO_GetBool(in, &on);\n\n    if( on )\n    {\n        ATMO_MK64F_Buzzer_On();\n    }\n    else\n    {\n        ATMO_MK64F_Buzzer_Off();\n    }\n    ATMO_CreateValueBool(out, on);\n    \n\treturn ATMO_Status_Success;\n    "
            },
            "variables": {},
            "embeddedPropertyConversions": {},
            "codeUserChanged": {
              "setup": false,
              "beep": false,
              "turnOn": false,
              "turnOff": false,
              "toggle": false,
              "setState": false
            }
          },
          "meta": {
            "editorX": 945,
            "editorY": 210,
            "lastTrigger": "buzzerStateChange"
          },
          "triggers": {
            "triggered": [],
            "buzzerStateChange": []
          },
          "interruptAbilities": {
            "trigger": false,
            "setup": false,
            "beep": false,
            "turnOn": false,
            "turnOff": false,
            "toggle": false,
            "setState": false
          },
          "abilities": [
            {
              "name": "trigger",
              "triggers": [
                "triggered"
              ]
            },
            {
              "name": "setup",
              "triggers": []
            },
            {
              "name": "beep",
              "triggers": []
            },
            {
              "name": "turnOn",
              "triggers": [
                "buzzerStateChange"
              ]
            },
            {
...

This file has been truncated, please download it to see its full contents.

Credits

Junxiao Shi

Junxiao Shi

1 project • 0 followers

Comments