Hannan Satopay
Published © LGPL

Smart Life: A Modular Approach

Smart Life is all about making the most out of our lives!

IntermediateFull instructions provided10 hours765

Things used in this project

Hardware components

Rapid IoT Prototyping Kit
NXP Rapid IoT Prototyping Kit
×1
Android device
Android device
×1

Software apps and online services

NXP Rapid IoT Studio

Story

Read more

Code

Smart Bottle

JSON
Remember to change the extension to .atmo before importing the project.
{
  "name": "Smart Bottle",
  "createVersion": "2017-08-12",
  "description": "",
  "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": "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": "ATMO_DRIVERINSTANCE_INTERVAL_INTERVAL1",
            "time": "100"
          },
          "meta": {
            "editorX": 44,
            "editorY": 64,
            "lastTrigger": "interval"
          },
          "triggers": {
            "triggered": [],
            "interval": [
              {
                "mapping": {},
                "targetOrder": [],
                "targetElement": "GetY",
                "targetAbility": "getAccelY"
              },
              {
                "mapping": {},
                "targetOrder": [],
                "targetElement": "DisplayTime",
                "targetAbility": "trigger"
              },
              {
                "mapping": {},
                "targetOrder": [],
                "targetElement": "TotConsUpdate",
                "targetAbility": "trigger"
              }
            ]
          },
          "interruptAbilities": {
            "trigger": false,
            "setup": false,
            "interval": true
          },
          "abilities": [
            {
              "name": "trigger",
              "triggers": [
                "triggered"
              ]
            },
            {
              "name": "setup",
              "triggers": []
            },
            {
              "name": "interval",
              "triggers": [
                "interval"
              ]
            }
          ]
        },
        {
          "name": "accl_cmp_greater",
          "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(accl_cmp_greater, target));\n\tATMO_CreateValueConverted(&targetNum, in->type, &targetStr);\n\t\n\tif(ATMO_CompareValues(in, &targetNum, ATMO_PROPERTY(accl_cmp_greater, condition), &conditionTrue) != ATMO_Status_Success)\n\t{\n\t\tATMO_Value_t value;\n\t\tATMO_InitValue(&value);\n\t\tATMO_TriggerHandler(ATMO_TRIGGER(accl_cmp_greater, 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(accl_cmp_greater, 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(accl_cmp_greater, 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": "0.25"
          },
          "meta": {
            "editorX": 404,
            "editorY": 0,
            "lastTrigger": "conditionTrue"
          },
          "triggers": {
            "triggered": [],
            "conditionTrue": [
              {
                "mapping": {},
                "targetOrder": [],
                "targetElement": "RGB",
                "targetAbility": "setRedOn"
              },
              {
                "mapping": {},
                "targetOrder": [],
                "targetElement": "increment_counter",
                "targetAbility": "trigger"
              }
            ],
            "conditionFalse": [
              {
                "mapping": {},
                "targetOrder": [],
                "targetElement": "RGB",
                "targetAbility": "setOff"
              }
            ],
            "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": "Smart Bottle",
            "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_humidity",
            "iconLabel": "",
            "numLines": "3",
            "line1Text": "",
            "line2Text": "",
            "line3Text": "ml",
            "line4Text": ""
          },
          "meta": {
            "editorX": 513,
            "editorY": 302,
            "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": "\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_HIGH, color);\n    return ATMO_Status_Success;\n    ",
              "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": 852,
            "editorY": 0,
            "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_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": "conditionTrue"
          },
          "triggers": {
            "triggered": [],
            "conditionTrue": [
              {
                "mapping": {},
                "targetOrder": [],
                "targetElement": "EmbeddedNxpRpkBuzzer",
                "targetAbility": "beep"
              },
              {
                "mapping": {},
                "targetOrder": [],
                "targetElement": "Consumption",
                "targetAbility": "trigger"
              }
            ],
            "conditionFalse": [],
            "invalidType": []
          },
          "interruptAbilities": {
            "trigger": false,
            "setup": false,
            "evaluate": false
          },
          "abilities": [
            {
              "name": "trigger",
              "triggers": [
                "triggered"
              ]
            },
            {
              "name": "setup",
              "triggers": []
            },
            {
              "name": "evaluate",
              "triggers": []
            }
          ]
        },
        {
          "name": "GetY",
          "type": "EmbeddedFXOS8700",
          "variants": [
            "embedded",
            "triggers",
            "abilities",
            "properties",
            "variables"
          ],
          "properties": {
            "errorData": {},
            "code": {
              "trigger": "\treturn ATMO_Status_Success;",
              "setup": "\tATMO_FXOS8700_Config_t config;\n\tconfig.address = ATMO_PROPERTY(GetY, i2cAddress);\n\tconfig.i2cDriverInstance = ATMO_PROPERTY(GetY, i2cInstance);\n\tconfig.gpioDriverInstance = ATMO_PROPERTY(GetY, gpioInstance);\n\tconfig.int1En = ATMO_PROPERTY(GetY, interrupt1Enabled);\n    config.int2En = ATMO_PROPERTY(GetY, interrupt2Enabled);\n    config.int1Pin = ATMO_PROPERTY(GetY, interrupt1Gpio);\n    config.int2Pin = ATMO_PROPERTY(GetY, interrupt2Gpio);\n\n    switch(ATMO_PROPERTY(GetY, motionDetectType))\n    {\n        case FXOS8700_NoDetect:\n        {\n            config.freefallEnabled = false;\n            config.motionEnabled = false;\n            config.tapDetectionEnabled = false;\n            break;\n        }\n        case FXOS8700_FreefallDetect:\n        {\n            config.freefallEnabled = true;\n            config.motionEnabled = false;\n            config.tapDetectionEnabled = false;\n            break;\n        }\n        case FXOS8700_MotionDetect:\n        {\n            config.freefallEnabled = false;\n            config.motionEnabled = true;\n            config.tapDetectionEnabled = false;\n            break;\n        }\n        case FXOS8700_TapDetect:\n        {\n            config.freefallEnabled = false;\n            config.motionEnabled = false;\n            config.tapDetectionEnabled = true;\n            break; \n        }\n        default:\n        {\n            config.freefallEnabled = false;\n            config.motionEnabled = false;  \n            config.tapDetectionEnabled = false;\n            break;\n        }\n    }\n\n    ATMO_FXOS8700_SetMotionDetectedAbilityHandle(ATMO_ABILITY(GetY, detectMotion));\n    ATMO_FXOS8700_SetFreefallDetectedAbilityHandle(ATMO_ABILITY(GetY, detectFreefall));\n    ATMO_FXOS8700_SetTapDetectedAbilityHandle(ATMO_ABILITY(GetY, detectTap));\n\tATMO_FXOS8700_Init(&config);\n\n    return ATMO_Status_Success;\n\t",
              "setEnabled": "ATMO_FXOS8700_SetEnabled(true);\nreturn ATMO_Status_Success;",
              "setDisabled": "ATMO_FXOS8700_SetEnabled(false);\nreturn ATMO_Status_Success;",
              "setEnabledDisabled": "bool enabled = false;\nATMO_GetBool(in, &enabled);\nATMO_FXOS8700_SetEnabled(enabled);\nreturn ATMO_Status_Success;",
              "getAccelData": "    ATMO_3dFloatVector_t data;\r\n\r\n    if( ATMO_FXOS8700_GetAccelData(&data) != ATMO_FXOS8700_Status_Success )\r\n    {\r\n        ATMO_CreateValueVoid(out);\r\n        return ATMO_Status_Fail;\r\n    }\r\n\r\n    ATMO_CreateValue3dVectorFloat(out, &data);\r\n\r\n    return ATMO_Status_Success;",
              "getAccelX": "\tATMO_3dFloatVector_t data;\n\n\tif(ATMO_FXOS8700_GetAccelData(&data) != ATMO_FXOS8700_Status_Success)\n\t{\n\t\tATMO_CreateValueVoid(out);\n\t\treturn ATMO_Status_Fail;\n\t}\n\n\tATMO_CreateValueFloat(out, data.x);\n\treturn ATMO_Status_Success;\n",
              "getAccelY": "\tATMO_3dFloatVector_t data;\n\n\tif(ATMO_FXOS8700_GetAccelData(&data) != ATMO_FXOS8700_Status_Success)\n\t{\n\t\tATMO_CreateValueVoid(out);\n\t\treturn ATMO_Status_Fail;\n\t}\n\n\tATMO_CreateValueFloat(out, data.y);\n\treturn ATMO_Status_Success;\n",
              "getAccelZ": "\tATMO_3dFloatVector_t data;\n\n\tif(ATMO_FXOS8700_GetAccelData(&data) != ATMO_FXOS8700_Status_Success)\n\t{\n\t\tATMO_CreateValueVoid(out);\n\t\treturn ATMO_Status_Fail;\n\t}\n\n\tATMO_CreateValueFloat(out, data.z);\n\treturn ATMO_Status_Success;\n",
              "getMagData": "    ATMO_3dFloatVector_t data;\r\n\r\n    if( ATMO_FXOS8700_GetMagData(&data) != ATMO_FXOS8700_Status_Success )\r\n    {\r\n        ATMO_CreateValueVoid(out);\r\n        return ATMO_Status_Fail;\r\n    }\r\n\r\n    ATMO_CreateValue3dVectorFloat(out, &data);\r\n\r\n    return ATMO_Status_Success;",
              "getMagX": "\tATMO_3dFloatVector_t data;\n\n\tif(ATMO_FXOS8700_GetMagData(&data) != ATMO_FXOS8700_Status_Success)\n\t{\n\t\tATMO_CreateValueVoid(out);\n\t\treturn ATMO_Status_Fail;\n\t}\n\n\tATMO_CreateValueFloat(out, data.x);\n\treturn ATMO_Status_Success;\n",
              "getMagY": "\tATMO_3dFloatVector_t data;\n\n\tif(ATMO_FXOS8700_GetMagData(&data) != ATMO_FXOS8700_Status_Success)\n\t{\n\t\tATMO_CreateValueVoid(out);\n\t\treturn ATMO_Status_Fail;\n\t}\n\n\tATMO_CreateValueFloat(out, data.y);\n\treturn ATMO_Status_Success;\n",
              "getMagZ": "\tATMO_3dFloatVector_t data;\n\n\tif(ATMO_FXOS8700_GetMagData(&data) != ATMO_FXOS8700_Status_Success)\n\t{\n\t\tATMO_CreateValueVoid(out);\n\t\treturn ATMO_Status_Fail;\n\t}\n\n\tATMO_CreateValueFloat(out, data.z);\n\treturn ATMO_Status_Success;\n",
              "detectTap": "\treturn ATMO_Status_Success;\n",
              "detectMotion": "\treturn ATMO_Status_Success;\n",
              "detectFreefall": "\treturn ATMO_Status_Success;\n",
              "enableFreefallDetection": "if(ATMO_FXOS8700_EnableFreefallDetection() == ATMO_FXOS8700_Status_Success)\n{\n    return ATMO_Status_Success;\n}\n\nreturn ATMO_Status_Fail;",
              "enableMotionDetection": "if(ATMO_FXOS8700_EnableMotionDetection() == ATMO_FXOS8700_Status_Success)\n{\n    return ATMO_Status_Success;\n}\n\nreturn ATMO_Status_Fail;",
              "enableTapDetection": "if(ATMO_FXOS8700_EnableTapDetection() == ATMO_FXOS8700_Status_Success)\n{\n    return ATMO_Status_Success;\n}\n\nreturn ATMO_Status_Fail;",
              "disableDetection": "if(ATMO_FXOS8700_DisableAllDetection() == ATMO_FXOS8700_Status_Success)\n{\n    return ATMO_Status_Success;\n}\n\nreturn ATMO_Status_Fail;"
            },
            "variables": {},
            "embeddedPropertyConversions": {},
            "codeUserChanged": {
              "setup": false,
              "setEnabled": false,
              "setDisabled": false,
              "setEnabledDisabled": false,
              "getAccelData": false,
              "getAccelX": false,
              "getAccelY": false,
              "getAccelZ": false,
              "getMagData": false,
              "getMagX": false,
              "getMagY": false,
              "getMagZ": false,
              "detectTap": false,
              "detectMotion": false,
              "detectFreefall": false,
              "enableFreefallDetection": false,
              "enableMotionDetection": false,
              "enableTapDetection": false,
              "disableDetection": false
            },
            "i2cInstance": 1,
            "gpioInstance": 0,
            "interrupt1Enabled": false,
            "interrupt2Enabled": true,
            "interrupt1Gpio": "ATMO_DEFAULT_GPIO",
            "interrupt2Gpio": "PTD13",
            "motionDetectType": "FXOS8700_NoDetect",
            "i2cAddress": "0x1E"
          },
          "meta": {
            "editorX": 173,
            "editorY": 0,
            "lastTrigger": "accelYRead"
          },
          "triggers": {
            "triggered": [],
            "accelDataRead": [
              {
                "mapping": {},
                "targetOrder": [],
                "targetElement": "accl_cmp_greater",
                "targetAbility": "evaluate"
              },
              {
                "mapping": {},
                "targetOrder": [],
                "targetElement": "accl_cmp_less",
                "targetAbility": "evaluate"
              }
            ],
            "accelXRead": [],
            "accelYRead": [
              {
                "mapping": {},
                "targetOrder": [],
                "targetElement": "accl_cmp_greater",
                "targetAbility": "evaluate"
              },
              {
                "mapping": {},
                "targetOrder": [],
                "targetElement": "accl_cmp_less",
                "targetAbility": "evaluate"
              }
            ],
            "accelZRead": [],
            "magDataRead": [],
            "magXRead": [],
            "magYRead": [],
            "magZRead": [],
            "tapDetected": [],
            "motionDetected": [],
            "freefallDetected": []
          },
          "interruptAbilities": {
            "trigger": false,
            "setup": false,
            "setEnabled": false,
            "setDisabled": false,
            "setEnabledDisabled": false,
            "getAccelData": false,
            "getAccelX": false,
            "getAccelY": false,
            "getAccelZ": false,
            "getMagData": false,
            "getMagX": false,
            "getMagY": false,
            "getMagZ": false,
            "detectTap": false,
            "detectMotion": false,
            "detectFreefall": false,
            "enableFreefallDetection": false,
            "enableMotionDetection": false,
            "enableTapDetection": false,
            "disableDetection": false
          },
          "abilities": [
            {
              "name": "trigger",
              "triggers": [
                "triggered"
              ]
            },
            {
              "name": "setup",
              "triggers": []
            },
            {
              "name": "setEnabled",
              "triggers": []
            },
            {
              "name": "setDisabled",
              "triggers": []
            },
            {
              "name": "setEnabledDisabled",
              "triggers": []
            },
            {
              "name": "getAccelData",
              "triggers": [
                "accelDataRead"
              ]
            },
            {
              "name": "getAccelX",
              "triggers": [
                "accelXRead"
              ]
            },
            {
              "name": "getAccelY",
              "triggers": [
                "accelYRead"
              ]
            },
            {
              "name": "getAccelZ",
              "triggers": [
                "accelZRead"
              ]
            },
            {
              "name": "getMagData",
              "triggers": [
                "magDataRead"
              ]
            },
            {
              "name": "getMagX",
              "triggers": [
                "magXRead"
              ]
            },
            {
              "name": "getMagY",
              "triggers": [
                "magYRead"
              ]
            },
            {
              "name": "getMagZ",
              "triggers": [
                "magZRead"
              ]
            },
            {
              "name": "detectTap",
              "triggers": [
                "tapDetected"
              ]
            },
            {
              "name": "detectMotion",
              "triggers": [
                "motionDetected"
              ]
            },
            {
              "name": "detectFreefall",
              "triggers": [
                "freefallDetected"
              ]
            },
            {
              "name": "enableFreefallDetection",
              "triggers": []
            },
            {
              "name": "enableMotionDetection",
              "triggers": []
            },
            {
              "name": "enableTapDetection",
              "triggers": []
            },
            {
              "name": "disableDetection",
              "triggers": []
            }
          ]
        },
        {
          "name": "EmbeddedNxpRpkBuzzer",
          "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": 874,
            "editorY": 211,
            "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"
              ]
            },
            {
              "name": "turnOff",
              "triggers": [
                "buzzerStateChange"
              ]
            },
            {
              "name": "toggle",
              "triggers": [
                "buzzerStateChange"
              ]
            },
            {
              "name": "setState",
              "triggers": [
                "buzzerStateChange"
              ]
            }
          ]
        },
        {
          "name": "increment_counter",
          "type": "EmbeddedFunction",
          "variants": [
            "embedded",
            "triggers",
            "abilities",
            "properties",
            "variables"
          ],
          "properties": {
            "errorData": {},
            "code": {
              "trigger": "\tcounter=counter+1;\n\tATMO_CreateValueInt(out,counter);\n\treturn ATMO_Status_Success;"
            },
            "variables": {},
            "embeddedPropertyConversions": {},
            "codeUserChanged": {
              "trigger": true
            }
          },
          "meta": {
            "editorX": 625,
            "editorY": 102,
            "lastTrigger": "triggered"
          },
          "triggers": {
            "triggered": [
              {
                "mapping": {},
                "targetOrder": [],
                "targetElement": "time_cmp",
                "targetAbility": "evaluate"
              }
            ]
          },
          "interruptAbilities": {
            "trigger": false
          },
          "abilities": [
            {
              "name": "trigger",
              "triggers": [
                "triggered"
              ]
            }
          ]
        },
        {
          "name": "accl_cmp_less",
          "type": "EmbeddedComparison",
          "variants": [
            "embedded",
            "triggers",
            "abilities",
            "properties",
            "variables"
          ],
          "properties": {
            "errorData": {},
            "code": {
              "trigger": "\treturn ATMO_Status_Success;",
              "setup": "\n\treturn ATMO_Status_Success;\n\t",
...

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

Credits

Hannan Satopay

Hannan Satopay

3 projects • 7 followers
I am doing electronics engineering and I am interested in both hardware and software development.

Comments