You are here:
< Back

Sensor events 

After connecting a sensor to a device (Android screen) via an M5stack or M5stick, you can send a configuration through the Home menu by right clicking on a screen or screen group, Manage, Set, Set sensor config. Example JSON files will be uploaded to our knowledge base.

In this config file, you can set up exactly which values will be sent to your content when an event happens. For example, you can connect a sensor with two buttons and set their press down values to “prev” and “next”.

There is a two-way communication between contents and sensors. Event handlers can be set for both of them in contents

Create and open a content, add some pages, then select EDIT SENSOR EVENTS in the Page section of the left-hand menu. 

Input actions 

We call everything an input event, when something happens to a sensor (a button is pressed, someone walks in front of a motion sensor, etc), and sends a value to the content. Input actions will be executed when their conditions match an input event

Click Add action to add a new row. Right now, only a couple of options are visible. As condition, we can specify a Sensor value (in our example, “prev” or “next”).  

When a content receives a sensor value, it will check the page wide actions from top to bottom, then the content wide actions from top to bottom. 

If any of them fulfills the condition, the corresponding action will be executed. 

If an executed action was final, any action that comes after this one, will be ignored. If it is not final and more actions’s conditions are fulfilled, more actions can be executed for that event

In this case, on receiving “prev”, the first action won’t match the input, so will be ignored. The second action’s condition is fulfilled, so the content will jump to the previous page. The third action will be ignored, because the second one got executed and is final, even though it would have matched. 

Content wide input action 

After selecting Jump to, or Popup you need to specify the Target page, which is a page of the current content. If a popup action is executed and there is an open popup already, it will be closed. Popups open in full screen and won’t close until something closes them. 

With Previous and Next, the targets aren’t set here. If the current page has a next page set either by hand or through the Playlist editor, the next action will navigate to that. The Previous will work in the Playlist or try to go backwards in page history. In most cases, you want to turn off the Automatic option in the Playlist editor or in the left-hand menu. 

The Ignore option’s purpose is to use in combination with final to stop some values from activating the different types of fallback actions.

Page wide input actions 

The window will open with the current page selected, but you can choose any other page as well. It is possible to modify multiple pages then save only once. 

The Page wide actions have a different set of options compared to Content wide actions

Navigation 

 Jump to, Popup and Ignore work the same way. If you need Previous or Next on a specific page, just use Jump to with the correct target. 

Widget interaction 

After selecting Interact widget, the Target field will show all the eligible widgets from the current page. Some of them also have special options. The displayed widget name can be set both in the left-hand menu or in the Layers menu. 

  • checkbox can be toggled, always checked or always uncheckedIf you have one event (such as a button press) to interact with a checkbox, use toggle. If multiple events can influence the value, check and uncheck for separate actions can come in handy. 
  • A radio button can be checked. Checking and unchecking other radio buttons in the same button group will happen normally; any other radio button in the same group will be checked or unchecked, depending on whether their checked event value and event name equals this one’s. 
  • For user input, you can either choose overwrite or append. Most of the time you want to turn on read only in the widget Properties menu. 
  • Carousels can be flipped through backward or forward
  • Reset button and submit button work as if they were clicked by the user. 

Show/hide widgets

Any type of widget can be choosen as target. Available options are: show, hide and toggle.

You can also read this guide about action types

Output actions 

We call everything an output event when a content sends a value towards a sensor. Output sensors such as relays and printers can react to these. 

Content wide output actions 

Output events can be sent on every page start and every page end. 

If multiple values are set, all of them will be sent out individually. 

Page wide output actions 

Page wide output actions are triggered when the specific page starts or ends. If there are both page wide and content wide output actions, they will all be sent individually, starting with the page wide actions

Widget interaction 

Page wide page end actions can either send out a static text or an interactive widget’s value. 

The available widgets are checkbox, radio button and user input

By choosing any radio button in a button group, the group’s selected checked event value will be sent instead of the individual radio button’s value. For checkboxes, either the checked event value or the unchecked event value will be sent.  

On click 

If your device has touch screen, you can also set the interaction event for textimage and shape widgets to send out sensor events. This will be sent out once per touch event. 

Tip: If you need a bigger area to be touch sensitive but would like to use a small text in the middle, add an image or Shape below it and use the click through option on your small widget. It can usually be found in the More section of the Other tab. 

Submit button 

Submit buttons always log into a database and this data can be downloaded through the Home menu for each content individually. Next to logging, they can do another action: send an e-mail, send an output sensor event or call an API. After collecting the data from all interactive widgets in the entire content, the widgets will be reset to their original values.

If the use button groups option is not set, a ‘flat’ object will be sent as sensor event value or API call request body, interaction event name used as key. If use button groups is set, all of these will be wrapped into individual button groups

It will also work if it is activated through an input sensor action

Datasource event 

Output sensor events can also be sent as an action reacting to a datasource event. More details can be found below in its own section.

Behavior 

Below the input sensor actions, you can find even more options. 

Fallback 

In case none of the page wide or content wide actions matched the sensor event, the fallback action will be executed. 

Tip: For some sensors, it is important to either disable some insignificant actions in the config file or add them up as ignore actions, so they won’t trigger the fallback when they shouldn’t have. For example, some button sensors can send both key down and key up events and we usually only care about one of those.

Sender 

After turning on allow handling senders, not just values, a sender column will appear in the input actions tables. 

If you leave the sender field blank, everything will work the same as before. If both the sender and sensor value are filled out for an action, it will only be executed if the given sensor sent the given value. If only the sender is filled out, any value sent by that sensor will fulfill the condition. 

It can be useful in combination with an RFID sensor. 

Final 

If an action is not final, it won’t stop other actions from getting executed, even if it is a match. For example, it is possible to toggle a checkbox and navigate to another page. However, the fallback will only be triggered in case none of the actions has been executed, regardless of their final status. 

You can change the order of actions with the arrow buttons. 

Wait for page end 

If allow turning on wait for page end option for events is turned on, another column will appear in the content wide input actions table. 

If it is turned on, the navigation actions (jump to, previous, next) won’t always happen instantly. Instead, if the current page has next page, a next page delay and is set to automatic, it will wait for the remaining seconds and will jump to the page selected in the sensor action instead of its original next page. It can be useful if you are displaying videos and don’t want your content to jump before its end.

Send as data row 

Send value as bound data row label can only be turned on if the content has a valid base data binding and change based on data row label… is enabled. The values will be sent out with navigation and popup actions as bound data row. If the value is found in the label position, the corresponding data row will be used instead of the original one. Best used in combination with an action that only specifies the sender and accepts any sensor values. RFID and similar sensors can help build powerful contents with this option. 

Regular expressions Since v1.6

If you turn on use regular expressions for values in the content wide sensor events window, the sensor value field value will be treated as a regular expression for both content wide and page wide events.  

Read more: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions 

Comments are closed.