Tramontana-for-Javascript icon indicating copy to clipboard operation
Tramontana-for-Javascript copied to clipboard

A prototyping kit for interactive spaces. Javascript library.

Tramontana web library

Introduction

A prototyping kit for iOS.

Tramonatana is a platform intended as a tool for designers and creatives to use iPhones and iPads as sensors or actuators and create quick prototypes of interactive apps, spaces and objects.

With this web library you can control from a desktop sketch your phone and you can use it as a sensor or actuator with little effort. You can download the app for iOS, Android, macOS following the links listed on www.tramontana.xyz.

Getting started

HTML

<html>
	<head>
	<!-- import jquery-->
		<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
	<!-- import tramontana-->
		<script src="https://rawgit.com/pierdr/tramontana/master/lib/tramontana_min.js"></script>
	<!-- create a tramontana instance -->
		<script>
			var iphone=new tramontana();
		</script>
	</head>
	<body>
		<button onclick="iphone.start('192.168.1.2')">start</button><br/>

		<!-- MAKE VIBRATE -->
		<button onclick="iphone.makeVibrate()">vibrate</button>
	</body>

</html>

You can find the IP Address to give as argument in the landing view on your Tramontana App:

Device as actuator

Your device can act as an actuator with:

  • vibration;
  • screen color and brightness;
  • flash light;
  • displaying a picture or playing audio and video;

To trigger your device you can invoke any of the following methods:

	setFlashLight(intensity);
    pulseFlashLight(numberOfPulses, duration , intensity);
    
    makeVibrate();
    setColor(r,g,b,a);//where a is not alpha but screen intensity
    transitionColors(color1, color2, duration);
    showImage(url);

Device as sensor

It's possible to access the device sensors like:

  • orientation;
  • magnetometer;
  • accelerometer;
  • distance sensor;
  • audio jack;
  • changes in power source;
  • touch events;

The logic with which you can access all the above uses an observer pattern logic. You need to subscribe to sensors and provide a callback function. For example:

subscribeOrientation(function(ipAddress,orientation){
	/*...code...*/
});

The callback function is optional for all the subscribe methods and alternatively you can register to jQuery events:

$(document).on("orientationChanged",function(ip,e){
				console.log("triggered",e);
			})

These are all the methods you can subscribe to:

	subscribeOrientation(callback);
	subscribeMagnetometer(callback);
	
	/*where frequency determine the frequency in Hz of accelerometer data broadcasting from the device. The lower the frequency the more sporadic the updates. */
	subscribeAttitude(frequency,callback); 
	subscrubeDistance(callback);
	subscribeAudioJack(callback);
	subscribePowerSource(callback);
	subscribeTouch(callback);

Playing media remotely

It's possible to play video, audio and display an image remotely. The supported formats are:
images JPEG, PNG
video H.264 MP4 (more info here)
audio AAC, MP3

        playVideo(url,callback);//the callback is called when the video ends
        playVideo(url);
        playAudio(url);
        setBrightness(brightness);

Using the camera

Tramontana allows you to use the camera remotely and optionally upload the picture to Dropbox. To use the Dropbox feature the only thing you need to do is connecting your dropbox account from the App's landing page.

The method to take a picture can have 2 optional parameters, the first one for the camera number
0 = back camera (default)
1 = front camera

The second allows you to display the standard iOS camera view. true = interface
false = background shooting (default)

	 takePicture()
	 takePicture(camera)
	 takePicture(camera,ui)
	 

Dependencies

jQuery