2022-07-20 13:07:21 +00:00
/* Note: This file was automatically generated. */
/ * T h i s l i b r a r y a l l o w s y o u t o w r i t e t o N e o p i x e l / W S 2 8 1 x / A P A 1 0 x / S K 6 8 1 2 L E D s t r i p s
* < p > These use a high speed single - wire protocol which needs platform - specific
* implementation on some devices - hence this library to simplify things . < / p >
* @url http : //www.espruino.com/Reference#l_neopixel_undefined
* /
declare function neopixel ( ) : void ;
/ * T h i s l i b r a r y p r o v i d e s T V o u t c a p a b i l i t y o n t h e E s p r u i n o a n d E s p r u i n o P i c o .
* See the < a href = "/Television" > Television < / a > page for more information .
* @url http : //www.espruino.com/Reference#l_tv_undefined
* /
declare function tv ( ) : void ;
/ * T h e N R F c l a s s i s f o r c o n t r o l l i n g f u n c t i o n a l i t y o f t h e N o r d i c n R F 5 1 / n R F 5 2 c h i p s .
* Most functionality is related to Bluetooth Low Energy , however there are also some functions related to NFC that apply to NRF52 - based devices .
* @url http : //www.espruino.com/Reference#NRF
* /
declare function NRF ( ) : void ;
declare namespace NRF {
/* @url http:/ / www . espruino . com / Reference # l_NRF_getSecurityStatus
* /
function getSecurityStatus ( ) : any ;
/ * G e t t h i s d e v i c e & # 3 9 ; s d e f a u l t B l u e t o o t h M A C a d d r e s s .
* < p > For Puck . js , the last 5 characters of this ( eg . < code > ee :ff < / code > )
* are used in the device & # 39 ; s advertised Bluetooth name . < / p >
* @url http : //www.espruino.com/Reference#l_NRF_getAddress
* /
function getAddress ( ) : any ;
/* @url http:/ / www . espruino . com / Reference # l_NRF_setServices
* /
function setServices ( data : any , options : any ) : void ;
/* @url http:/ / www . espruino . com / Reference # l_NRF_setAdvertising
* /
function setAdvertising ( data : any , options : any ) : void ;
/ * I f a d e v i c e i s c o n n e c t e d t o E s p r u i n o , d i s c o n n e c t f r o m i t .
* @url http : //www.espruino.com/Reference#l_NRF_disconnect
* /
function disconnect ( ) : void ;
/ * < p > D i s a b l e B l u e t o o t h a d v e r t i s i n g a n d d i s c o n n e c t f r o m a n y d e v i c e t h a t
* connected to Puck . js as a peripheral ( this won & # 39 ; t affect any devices
* that Puck . js initiated connections to ) . < / p >
* This makes Puck . js undiscoverable , so it can & # 39 ; t be connected to .
* Use < code > NRF . wake ( ) < / code > to wake up and make Puck . js connectable again .
* @url http : //www.espruino.com/Reference#l_NRF_sleep
* /
function sleep ( ) : void ;
/ * < p > E n a b l e B l u e t o o t h a d v e r t i s i n g ( t h i s i s e n a b l e d b y d e f a u l t ) , w h i c h
* allows other devices to discover and connect to Puck . js . < / p >
* Use < code > NRF . sleep ( ) < / code > to disable advertising .
* @url http : //www.espruino.com/Reference#l_NRF_wake
* /
function wake ( ) : void ;
/ * < p > R e s t a r t t h e B l u e t o o t h s o f t d e v i c e ( i f t h e r e i s c u r r e n t l y a B L E c o n n e c t i o n ,
* it will queue a restart to be done when the connection closes ) . < / p >
* < p > You shouldn & # 39 ; t need to call this function in normal usage . However , Nordic & # 39 ; s
* BLE softdevice has some settings that cannot be reset . For example there
* are only a certain number of unique UUIDs . Once these are all used the
* only option is to restart the softdevice to clear them all out . < / p >
* @url http : //www.espruino.com/Reference#l_NRF_restart
* /
function restart ( callback : any ) : void ;
/ * G e t t h e b a t t e r y l e v e l i n v o l t s ( t h e v o l t a g e t h a t t h e N R F c h i p i s r u n n i n g o f f o f ) .
* < p > This is the battery level of the device itself - it has nothing to with any
* device that might be connected . < / p >
* @url http : //www.espruino.com/Reference#l_NRF_getBattery
* /
function getBattery ( ) : number ;
/ * < p > T h i s i s j u s t l i k e < c o d e > N R F . s e t A d v e r t i s i n g < / c o d e > , e x c e p t i n s t e a d o f a d v e r t i s i n g
* the data , it returns the packet that would be advertised as an array . < / p >
* @url http : //www.espruino.com/Reference#l_NRF_getAdvertisingData
* /
function getAdvertisingData ( data : any , options : any ) : any ;
/ * S e t t h e B L E r a d i o t r a n s m i t p o w e r . T h e d e f a u l t T X p o w e r i s 0 d B m , a n d
* @url http : //www.espruino.com/Reference#l_NRF_setTxPower
* /
function setTxPower ( power : number ) : void ;
/ * < p > < s t r o n g > T H I S I S D E P R E C A T E D < / s t r o n g > - p l e a s e u s e < c o d e > N R F . s e t C o n n e c t i o n I n t e r v a l < / c o d e > f o r
* peripheral and < code > NRF . connect ( addr , options ) < / code > / < code > BluetoothRemoteGATTServer . connect ( options ) < / code >
* for central connections . < / p >
* < p > This sets the connection parameters - these affect the transfer speed and
* power usage when the device is connected . < / p >
* < ul >
* < li > When not low power , the connection interval is between 7.5 and 20 ms < / li >
* < li > When low power , the connection interval is between 500 and 1000 ms < / li >
* < / ul >
* < p > When low power connection is enabled , transfers of data over Bluetooth
* will be very slow , however power usage while connected will be drastically
* decreased . < / p >
* < p > This will only take effect after the connection is disconnected and
* re - established . < / p >
* @url http : //www.espruino.com/Reference#l_NRF_setLowPowerConnection
* /
function setLowPowerConnection ( lowPower : boolean ) : void ;
/ * S e n d a U S B H I D r e p o r t . H I D m u s t f i r s t b e e n a b l e d w i t h < c o d e > N R F . s e t S e r v i c e s ( { } , { h i d : h i d _ r e p o r t } ) < / c o d e >
* @url http : //www.espruino.com/Reference#l_NRF_sendHIDReport
* /
function sendHIDReport ( data : any , callback : any ) : void ;
/ * C h e c k i f A p p l e N o t i f i c a t i o n C e n t e r S e r v i c e ( A N C S ) i s c u r r e n t l y a c t i v e o n t h e B L E c o n n e c t i o n
* @url http : //www.espruino.com/Reference#l_NRF_ancsIsActive
* /
function ancsIsActive ( ) : boolean ;
/ * S e n d a n A N C S a c t i o n f o r a s p e c i f i c N o t i f i c a t i o n U I D . C o r r e s p o n d s t o p o s a c t i o n / n e g a c t i o n i n t h e & # 3 9 ; A N C S & # 3 9 ; e v e n t t h a t w a s r e c e i v e d
* @url http : //www.espruino.com/Reference#l_NRF_ancsAction
* /
function ancsAction ( uid : number , positive : boolean ) : void ;
/ * G e t A N C S i n f o f o r a n o t i f i c a t i o n , e g :
* @url http : //www.espruino.com/Reference#l_NRF_ancsGetNotificationInfo
* /
function ancsGetNotificationInfo ( uid : number ) : Promise < any > ;
/ * C h e c k i f A p p l e M e d i a S e r v i c e ( A M S ) i s c u r r e n t l y a c t i v e o n t h e B L E c o n n e c t i o n
* @url http : //www.espruino.com/Reference#l_NRF_amsIsActive
* /
function amsIsActive ( ) : boolean ;
/ * < p > G e t A p p l e M e d i a S e r v i c e ( A M S ) i n f o f o r t h e c u r r e n t m e d i a p l a y e r .
* & quot ; playbackinfo & quot ; returns a concatenation of three comma - separated values : < / p >
* < ul >
* < li > PlaybackState : a string that represents the integer value of the playback state : < ul >
* < li > PlaybackStatePaused = 0 < / li >
* < li > PlaybackStatePlaying = 1 < / li >
* < li > PlaybackStateRewinding = 2 < / li >
* < li > PlaybackStateFastForwarding = 3 < / li >
* < / ul >
* < / li >
* < li > PlaybackRate : a string that represents the floating point value of the playback rate . < / li >
* < li > ElapsedTime : a string that represents the floating point value of the elapsed time of the current track , in seconds < / li >
* < / ul >
* @url http : //www.espruino.com/Reference#l_NRF_amsGetPlayerInfo
* /
function amsGetPlayerInfo ( id : any ) : Promise < any > ;
/ * G e t A p p l e M e d i a S e r v i c e ( A M S ) i n f o f o r t h e c u r r e n t l y - p l a y i n g t r a c k
* @url http : //www.espruino.com/Reference#l_NRF_amsGetTrackInfo
* /
function amsGetTrackInfo ( id : any ) : Promise < any > ;
/ * S e n d a n A M S c o m m a n d t o a n A p p l e M e d i a S e r v i c e d e v i c e t o c o n t r o l m u s i c p l a y b a c k
* Command is one of play , pause , playpause , next , prev , volup , voldown , repeat , shuffle , skipforward , skipback , like , dislike , bookmark
* @url http : //www.espruino.com/Reference#l_NRF_amsCommand
* /
function amsCommand ( id : any ) : void ;
/ * < p > I f s e t t o t r u e , w h e n e v e r a d e v i c e b o n d s i t w i l l b e a d d e d t o t h e
* whitelist . < / p >
* < p > When set to false , the whitelist is cleared and newly bonded
* devices will not be added to the whitelist . < / p >
* < p > < strong > Note : < / strong > This is remembered between < code > reset ( ) < / code > s but isn & # 39 ; t
* remembered after power - on ( you & # 39 ; ll have to add it to < code > onInit ( ) < / code > . < / p >
* @url http : //www.espruino.com/Reference#l_NRF_setWhitelist
* /
function setWhitelist ( whitelisting : boolean ) : void ;
/ * < p > W h e n c o n n e c t e d , B l u e t o o t h L E d e v i c e s c o m m u n i c a t e a t a s e t i n t e r v a l .
* Lowering the interval ( eg . more packets / second ) means a lower delay when
* sending data , higher bandwidth , but also more power consumption . < / p >
* < p > By default , when connected as a peripheral Espruino automatically adjusts the
* connection interval . When connected it & # 39 ; s as fast as possible ( 7.5 ms ) but when idle
* for over a minute it drops to 200 ms . On continued activity ( & gt ; 1 BLE operation ) the
* interval is raised to 7.5 ms again . < / p >
* The options for < code > interval < / code > are :
* < ul >
* < li > < code > undefined < / code > / < code > & quot ; auto & quot ; < / code > : ( default ) automatically adjust connection interval < / li >
* < li > < code > 100 < / code > : set min and max connection interval to the same number ( between 7.5 ms and 4000 ms ) < / li >
* < li > < code > { minInterval :20 , maxInterval :100 } < / code > : set min and max connection interval as a range < / li >
* < / ul >
* < p > This configuration is not remembered during a < code > save ( ) < / code > - you will have to
* re - set it via < code > onInit < / code > . < / p >
* < p > < strong > Note : < / strong > If connecting to another device ( as Central ) , you can use
* an extra argument to < code > NRF . connect < / code > or < code > BluetoothRemoteGATTServer . connect < / code >
* to specify a connection interval . < / p >
* < strong > Note : < / strong > This overwrites any changes imposed by the deprecated < code > NRF . setLowPowerConnection < / code >
* @url http : //www.espruino.com/Reference#l_NRF_setConnectionInterval
* /
function setConnectionInterval ( interval : any ) : void ;
/* @url http:/ / www . espruino . com / Reference # l_NRF_startBonding
* /
function startBonding ( forceRepair : boolean ) : any ;
}
/ * T h e B l u e t o o t h S e r i a l p o r t - u s e d w h e n d a t a i s s e n t o r r e c e i v e d o v e r B l u e t o o t h S m a r t o n n R F 5 1 / n R F 5 2 c h i p s .
* @url http : //www.espruino.com/Reference#l__global_Bluetooth
* /
declare const Bluetooth : Serial ;
declare namespace Bluetooth {
/* @url http:/ / www . espruino . com / Reference # l_Bluetooth_setConsole
* /
function setConsole ( ) : void ;
}
/ * C l a s s c o n t a i n i n g u t i l i t y f u n c t i o n s f o r t h e S e e e d W I O L T E b o a r d
* @url http : //www.espruino.com/Reference#WioLTE
* /
declare function WioLTE ( ) : void ;
declare namespace WioLTE {
/ * S e t t h e W I O & # 3 9 ; s L E D
* @url http : //www.espruino.com/Reference#l_WioLTE_LED
* /
function LED ( red : number , green : number , blue : number ) : void ;
/ * S e t t h e p o w e r o f G r o v e c o n n e c t o r s , e x c e p t f o r < c o d e > D 3 8 < / c o d e > a n d < c o d e > D 3 9 < / c o d e > w h i c h a r e a l w a y s o n .
* @url http : //www.espruino.com/Reference#l_WioLTE_setGrovePower
* /
function setGrovePower ( onoff : boolean ) : void ;
/ * T u r n p o w e r t o t h e W I O & # 3 9 ; s L E D o n o r o f f .
* Turning the LED on won & # 39 ; t immediately display a color - that must be done with < code > WioLTE . LED ( r , g , b ) < / code >
* @url http : //www.espruino.com/Reference#l_WioLTE_setLEDPower
* /
function setLEDPower ( onoff : boolean ) : void ;
/* @url http:/ / www . espruino . com / Reference # l_WioLTE_D38
* /
const D38 : any ;
/* @url http:/ / www . espruino . com / Reference # l_WioLTE_D20
* /
const D20 : any ;
/* @url http:/ / www . espruino . com / Reference # l_WioLTE_A6
* /
const A6 : any ;
/* @url http:/ / www . espruino . com / Reference # l_WioLTE_I2C
* /
const I2C : any ;
/* @url http:/ / www . espruino . com / Reference # l_WioLTE_UART
* /
const UART : any ;
/* @url http:/ / www . espruino . com / Reference # l_WioLTE_A4
* /
const A4 : any ;
}
/ * T h i s c l a s s p r o v i d e s G r a p h i c s o p e r a t i o n s t h a t c a n b e a p p l i e d t o a s u r f a c e .
* Use Graphics . createXXX to create a graphics object that renders in the way you want . See < a href = "https://www.espruino.com/Graphics" > the Graphics page < / a > for more information .
* < strong > Note : < / strong > On boards that contain an LCD , there is a built - in & # 39 ; LCD & # 39 ; object of type Graphics . For instance to draw a line you & # 39 ; d type : < code > LCD . drawLine ( 0 , 0 , 100 , 100 ) < / code >
* @url http : //www.espruino.com/Reference#Graphics
* /
declare function Graphics ( ) : void ;
type Graphics = {
/ * S e t t h e c u r r e n t f o n t
* @url http : //www.espruino.com/Reference#l_Graphics_setFont6x15
* /
setFont6x15 : ( scale : number ) = > Graphics ;
/ * < p > O n i n s t a n c e s o f g r a p h i c s t h a t d r i v e a d i s p l a y w i t h
* an offscreen buffer , calling this function will
* copy the contents of the offscreen buffer to the
* screen . < / p >
* < p > Call this when you have drawn something to Graphics
* and you want it shown on the screen . < / p >
* < p > If a display does not have an offscreen buffer ,
* it may not have a < code > g . flip ( ) < / code > method . < / p >
* < p > On Bangle . js 1 , there are different graphics modes
* chosen with < code > Bangle . setLCDMode ( ) < / code > . The default mode
* is unbuffered and in this mode < code > g . flip ( ) < / code > does not
* affect the screen contents . < / p >
* < p > On some devices , this command will attempt to
* only update the areas of the screen that have
* changed in order to increase speed . If you have
* accessed the < code > Graphics . buffer < / code > directly then you
* may need to use < code > Graphics . flip ( true ) < / code > to force
* a full update of the screen . < / p >
* @url http : //www.espruino.com/Reference#l_Graphics_flip
* /
flip : ( all : boolean ) = > void ;
/ * T h e w i d t h o f t h i s G r a p h i c s i n s t a n c e
* @url http : //www.espruino.com/Reference#l_Graphics_getWidth
* /
getWidth : ( ) = > number ;
/ * T h e h e i g h t o f t h i s G r a p h i c s i n s t a n c e
* @url http : //www.espruino.com/Reference#l_Graphics_getHeight
* /
getHeight : ( ) = > number ;
/ * T h e n u m b e r o f b i t s p e r p i x e l o f t h i s G r a p h i c s i n s t a n c e
* < p > < strong > Note : < / strong > Bangle . js 2 behaves a little differently here . The display
* is 3 bit , so < code > getBPP < / code > returns 3 and < code > asBMP < / code > / < code > asImage < / code > / etc return 3 bit images .
* However in order to allow dithering , the colors returned by < code > Graphics . getColor < / code > and < code > Graphics . theme < / code >
* are actually 16 bits . < / p >
* @url http : //www.espruino.com/Reference#l_Graphics_getBPP
* /
getBPP : ( ) = > number ;
/ * < p > R e s e t t h e s t a t e o f G r a p h i c s t o t h e d e f a u l t s ( e g . C o l o r , F o n t , e t c )
* that would have been used when Graphics was initialised . < / p >
* @url http : //www.espruino.com/Reference#l_Graphics_reset
* /
reset : ( ) = > Graphics ;
/ * C l e a r t h e L C D w i t h t h e B a c k g r o u n d C o l o r
* @url http : //www.espruino.com/Reference#l_Graphics_clear
* /
clear : ( reset : boolean ) = > Graphics ;
/ * F i l l a r e c t a n g u l a r a r e a i n t h e F o r e g r o u n d C o l o r
* < p > On devices with enough memory , you can specify < code > { x , y , x2 , y2 , r } < / code > as the first
* argument , which allows you to draw a rounded rectangle . < / p >
* @url http : //www.espruino.com/Reference#l_Graphics_fillRect
* /
fillRect : ( x1 : any , y1 : number , x2 : number , y2 : number ) = > Graphics ;
/ * F i l l a r e c t a n g u l a r a r e a i n t h e B a c k g r o u n d C o l o r
* < p > On devices with enough memory , you can specify < code > { x , y , x2 , y2 , r } < / code > as the first
* argument , which allows you to draw a rounded rectangle . < / p >
* @url http : //www.espruino.com/Reference#l_Graphics_clearRect
* /
clearRect : ( x1 : any , y1 : number , x2 : number , y2 : number ) = > Graphics ;
/ * D r a w a n u n f i l l e d r e c t a n g l e 1 p x w i d e i n t h e F o r e g r o u n d C o l o r
* @url http : //www.espruino.com/Reference#l_Graphics_drawRect
* /
drawRect : ( x1 : any , y1 : number , x2 : number , y2 : number ) = > Graphics ;
/ * D r a w a f i l l e d c i r c l e i n t h e F o r e g r o u n d C o l o r
* @url http : //www.espruino.com/Reference#l_Graphics_fillCircle
* /
fillCircle : ( x : number , y : number , rad : number ) = > Graphics ;
/ * D r a w a n u n f i l l e d c i r c l e 1 p x w i d e i n t h e F o r e g r o u n d C o l o r
* @url http : //www.espruino.com/Reference#l_Graphics_drawCircle
* /
drawCircle : ( x : number , y : number , rad : number ) = > Graphics ;
/ * D r a w a c i r c l e , c e n t r e d a t ( x , y ) w i t h r a d i u s r i n t h e c u r r e n t f o r e g r o u n d c o l o r
* @url http : //www.espruino.com/Reference#l_Graphics_drawCircleAA
* /
drawCircleAA : ( x : number , y : number , r : number ) = > Graphics ;
/ * D r a w a f i l l e d e l l i p s e i n t h e F o r e g r o u n d C o l o r
* @url http : //www.espruino.com/Reference#l_Graphics_fillEllipse
* /
fillEllipse : ( x1 : number , y1 : number , x2 : number , y2 : number ) = > Graphics ;
/ * D r a w a n e l l i p s e i n t h e F o r e g r o u n d C o l o r
* @url http : //www.espruino.com/Reference#l_Graphics_drawEllipse
* /
drawEllipse : ( x1 : number , y1 : number , x2 : number , y2 : number ) = > Graphics ;
/ * G e t a p i x e l & # 3 9 ; s c o l o r
* @url http : //www.espruino.com/Reference#l_Graphics_getPixel
* /
getPixel : ( x : number , y : number ) = > number ;
/ * S e t a p i x e l & # 3 9 ; s c o l o r
* @url http : //www.espruino.com/Reference#l_Graphics_setPixel
* /
setPixel : ( x : number , y : number , col : any ) = > Graphics ;
/ * S e t t h e c o l o r t o u s e f o r s u b s e q u e n t d r a w i n g o p e r a t i o n s .
* If just < code > r < / code > is specified as an integer , the numeric value will be written directly into a pixel . eg . On a 24 bit < code > Graphics < / code > instance you set bright blue with either < code > g . setColor ( 0 , 0 , 1 ) < / code > or < code > g . setColor ( 0x0000FF ) < / code > .
* A good shortcut to ensure you get white on all platforms is to use < code > g . setColor ( - 1 ) < / code >
* The mapping is as follows :
* < ul >
* < li > 32 bit : < code > r , g , b < / code > = & gt ; < code > 0xFF rrggbb < / code > < / li >
* < li > 24 bit : < code > r , g , b < / code > = & gt ; < code > 0 xrrggbb < / code > < / li >
* < li > 16 bit : < code > r , g , b < / code > = & gt ; < code > 0 brrrrrggggggbbbbb < / code > ( RGB565 ) < / li >
* < li > Other bpp : < code > r , g , b < / code > = & gt ; white if < code > r + g + b & gt ; 50 % < / code > , otherwise black ( use < code > r < / code > on its own as an integer ) < / li >
* < / ul >
* If you specified < code > color_order < / code > when creating the < code > Graphics < / code > instance , < code > r < / code > , < code > g < / code > and < code > b < / code > will be swapped as you specified .
* < p > < strong > Note : < / strong > On devices with low flash memory , < code > r < / code > < strong > must < / strong > be an integer representing the color in the current bit depth . It cannot
* be a floating point value , and < code > g < / code > and < code > b < / code > are ignored . < / p >
* @url http : //www.espruino.com/Reference#l_Graphics_setColor
* /
setColor : ( r : any , g : any , b : any ) = > Graphics ;
/ * S e t t h e b a c k g r o u n d c o l o r t o u s e f o r s u b s e q u e n t d r a w i n g o p e r a t i o n s .
* See < code > Graphics . setColor < / code > for more information on the mapping of < code > r < / code > , < code > g < / code > , and < code > b < / code > to pixel values .
* < p > < strong > Note : < / strong > On devices with low flash memory , < code > r < / code > < strong > must < / strong > be an integer representing the color in the current bit depth . It cannot
* be a floating point value , and < code > g < / code > and < code > b < / code > are ignored . < / p >
* @url http : //www.espruino.com/Reference#l_Graphics_setBgColor
* /
setBgColor : ( r : any , g : any , b : any ) = > Graphics ;
/ * G e t t h e c o l o r t o u s e f o r s u b s e q u e n t d r a w i n g o p e r a t i o n s
* @url http : //www.espruino.com/Reference#l_Graphics_getColor
* /
getColor : ( ) = > number ;
/ * G e t t h e b a c k g r o u n d c o l o r t o u s e f o r s u b s e q u e n t d r a w i n g o p e r a t i o n s
* @url http : //www.espruino.com/Reference#l_Graphics_getBgColor
* /
getBgColor : ( ) = > number ;
/ * < p > T h i s s e t s t h e & # 3 9 ; c l i p r e c t & # 3 9 ; t h a t s u b s e q u e n t d r a w i n g o p e r a t i o n s a r e c l i p p e d t o
* sit between . < / p >
* < p > These values are inclusive - eg < code > g . setClipRect ( 1 , 0 , 5 , 0 ) < / code > will ensure that only
* pixel rows 1 , 2 , 3 , 4 , 5 are touched on column 0 . < / p >
* < p > < strong > Note : < / strong > For maximum flexibility on Bangle . js 1 , the values here are not range checked . For normal
* use , X and Y should be between 0 and < code > getWidth ( ) - 1 < / code > / < code > getHeight ( ) - 1 < / code > . < / p >
* < p > < strong > Note : < / strong > The x / y values here are rotated , so that if < code > Graphics . setRotation < / code > is used
* they correspond to the coordinates given to the draw functions , < em > not to the
* physical device pixels < / em > . < / p >
* @url http : //www.espruino.com/Reference#l_Graphics_setClipRect
* /
setClipRect : ( x1 : number , y1 : number , x2 : number , y2 : number ) = > Graphics ;
/ * M a k e s u b s e q u e n t c a l l s t o < c o d e > d r a w S t r i n g < / c o d e > u s e t h e b u i l t - i n 4 x 6 p i x e l b i t m a p p e d F o n t
* It is recommended that you use < code > Graphics . setFont ( & quot ; 4 x6 & quot ; ) < / code > for more flexibility .
* @url http : //www.espruino.com/Reference#l_Graphics_setFontBitmap
* /
setFontBitmap : ( ) = > Graphics ;
/ * M a k e s u b s e q u e n t c a l l s t o < c o d e > d r a w S t r i n g < / c o d e > u s e a V e c t o r F o n t o f t h e g i v e n h e i g h t .
* It is recommended that you use < code > Graphics . setFont ( & quot ; Vector & quot ; , size ) < / code > for more flexibility .
* @url http : //www.espruino.com/Reference#l_Graphics_setFontVector
* /
setFontVector : ( size : number ) = > Graphics ;
/ * < p > M a k e s u b s e q u e n t c a l l s t o < c o d e > d r a w S t r i n g < / c o d e > u s e a C u s t o m F o n t o f t h e g i v e n h e i g h t . S e e t h e < a h r e f = " h t t p : / / w w w . e s p r u i n o . c o m / F o n t s " > F o n t s p a g e < / a > f o r m o r e
* information about custom fonts and how to create them . < / p >
* For examples of use , see the < a href = "https://www.espruino.com/Fonts#font-modules" > font module s < / a > .
* < p > < strong > Note : < / strong > while you can specify the character code of the first character with < code > firstChar < / code > ,
* the newline character 13 will always be treated as a newline and not rendered . < / p >
* @url http : //www.espruino.com/Reference#l_Graphics_setFontCustom
* /
setFontCustom : ( bitmap : any , firstChar : number , width : any , height : number ) = > Graphics ;
/ * S e t t h e a l i g n m e n t f o r s u b s e q u e n t c a l l s t o < c o d e > d r a w S t r i n g < / c o d e >
* @url http : //www.espruino.com/Reference#l_Graphics_setFontAlign
* /
setFontAlign : ( x : number , y : number , rotation : number ) = > Graphics ;
/ * S e t t h e f o n t b y n a m e . V a r i o u s f o r m s a r e a v a i l a b l e :
* < ul >
* < li > < code > g . setFont ( & quot ; 4 x6 & quot ; ) < / code > - standard 4 x6 bitmap font < / li >
* < li > < code > g . setFont ( & quot ; Vector :12 & quot ; ) < / code > - vector font 12 px high < / li >
* < li > < code > g . setFont ( & quot ; 4x6 :2 & quot ; ) < / code > - 4 x6 bitmap font , doubled in size < / li >
* < li > < code > g . setFont ( & quot ; 6x8 :2x3 & quot ; ) < / code > - 6 x8 bitmap font , doubled in width , tripled in height < / li >
* < / ul >
* You can also use these forms , but they are not recommended :
* < ul >
* < li > < code > g . setFont ( & quot ; Vector12 & quot ; ) < / code > - vector font 12 px high < / li >
* < li > < code > g . setFont ( & quot ; 4 x6 & quot ; , 2 ) < / code > - 4 x6 bitmap font , doubled in size < / li >
* < / ul >
* < code > g . getFont ( ) < / code > will return the current font as a String .
* For a list of available font names , you can use < code > g . getFonts ( ) < / code > .
* @url http : //www.espruino.com/Reference#l_Graphics_setFont
* /
setFont : ( name : any , size : number ) = > Graphics ;
/ * G e t t h e f o n t b y n a m e - c a n b e s a v e d a n d u s e d w i t h < c o d e > G r a p h i c s . s e t F o n t < / c o d e > .
* < p > Normally this might return something like < code > & quot ; 4 x6 & quot ; < / code > , but if a scale
* factor is specified , a colon and then the size is reported , like & quot ; 4x6 :2 & quot ; < / p >
* < p > < strong > Note : < / strong > For custom fonts , < code > Custom < / code > is currently
* reported instead of the font name . < / p >
* @url http : //www.espruino.com/Reference#l_Graphics_getFont
* /
getFont : ( ) = > string ;
/ * R e t u r n a n a r r a y o f a l l f o n t s c u r r e n t l y i n t h e G r a p h i c s l i b r a r y .
* < p > < strong > Note : < / strong > Vector fonts are specified as < code > Vector # < / code > where < code > # < / code > is the font height . As there
* are effectively infinite fonts , just < code > Vector < / code > is included in the list . < / p >
* @url http : //www.espruino.com/Reference#l_Graphics_getFonts
* /
getFonts : ( ) = > any [ ] ;
/ * R e t u r n t h e h e i g h t i n p i x e l s o f t h e c u r r e n t f o n t
* @url http : //www.espruino.com/Reference#l_Graphics_getFontHeight
* /
getFontHeight : ( ) = > number ;
/ * R e t u r n t h e s i z e i n p i x e l s o f a s t r i n g o f t e x t i n t h e c u r r e n t f o n t
* @url http : //www.espruino.com/Reference#l_Graphics_stringWidth
* /
stringWidth : ( str : any ) = > number ;
/ * R e t u r n t h e w i d t h a n d h e i g h t i n p i x e l s o f a s t r i n g o f t e x t i n t h e c u r r e n t f o n t
* @url http : //www.espruino.com/Reference#l_Graphics_stringMetrics
* /
stringMetrics : ( str : any ) = > any ;
/ * D r a w a l i n e b e t w e e n x 1 , y 1 a n d x 2 , y 2 i n t h e c u r r e n t f o r e g r o u n d c o l o r
* @url http : //www.espruino.com/Reference#l_Graphics_drawLine
* /
drawLine : ( x1 : number , y1 : number , x2 : number , y2 : number ) = > Graphics ;
/ * D r a w a l i n e b e t w e e n x 1 , y 1 a n d x 2 , y 2 i n t h e c u r r e n t f o r e g r o u n d c o l o r
* @url http : //www.espruino.com/Reference#l_Graphics_drawLineAA
* /
drawLineAA : ( x1 : number , y1 : number , x2 : number , y2 : number ) = > Graphics ;
/ * D r a w a l i n e f r o m t h e l a s t p o s i t i o n o f l i n e T o o r m o v e T o t o t h i s p o s i t i o n
* @url http : //www.espruino.com/Reference#l_Graphics_lineTo
* /
lineTo : ( x : number , y : number ) = > Graphics ;
/ * M o v e t h e c u r s o r t o a p o s i t i o n - s e e l i n e T o
* @url http : //www.espruino.com/Reference#l_Graphics_moveTo
* /
moveTo : ( x : number , y : number ) = > Graphics ;
/ * D r a w a p o l y l i n e ( l i n e s b e t w e e n e a c h o f t h e p o i n t s i n < c o d e > p o l y < / c o d e > ) i n t h e c u r r e n t f o r e g r o u n d c o l o r
* < strong > Note : < / strong > there is a limit of 64 points ( 128 XY elements ) for polygons
* @url http : //www.espruino.com/Reference#l_Graphics_drawPoly
* /
drawPoly : ( poly : any , closed : boolean ) = > Graphics ;
/ * D r a w a n < s t r o n g > a n t i a l i a s e d < / s t r o n g > p o l y l i n e ( l i n e s b e t w e e n e a c h o f t h e p o i n t s i n < c o d e > p o l y < / c o d e > ) i n t h e c u r r e n t f o r e g r o u n d c o l o r
* < strong > Note : < / strong > there is a limit of 64 points ( 128 XY elements ) for polygons
* @url http : //www.espruino.com/Reference#l_Graphics_drawPolyAA
* /
drawPolyAA : ( poly : any , closed : boolean ) = > Graphics ;
/ * S e t t h e c u r r e n t r o t a t i o n o f t h e g r a p h i c s d e v i c e .
* @url http : //www.espruino.com/Reference#l_Graphics_setRotation
* /
setRotation : ( rotation : number , reflect : boolean ) = > Graphics ;
/ * < p > R e t u r n t h e w i d t h a n d h e i g h t i n p i x e l s o f a n i m a g e ( e i t h e r G r a p h i c s , I m a g e O b j e c t , I m a g e S t r i n g o r A r r a y B u f f e r ) . R e t u r n s
* < code > undefined < / code > if image couldn & # 39 ; t be decoded . < / p >
* < p > < code > frames < / code > is also included is the image contains more information than you & # 39 ; d expect for a single bitmap . In
* this case the bitmap might be an animation with multiple frames < / p >
* @url http : //www.espruino.com/Reference#l_Graphics_imageMetrics
* /
imageMetrics : ( str : any ) = > any ;
/ * < p > R e t u r n t h i s G r a p h i c s o b j e c t a s a n I m a g e t h a t c a n b e u s e d w i t h < c o d e > G r a p h i c s . d r a w I m a g e < / c o d e > .
* Check out < a href = "http://www.espruino.com/Graphics#images-bitmaps" > the Graphics reference page < / a >
* for more information on images . < / p >
* Will return undefined if data can & # 39 ; t be allocated for the image .
* The image data itself will be referenced rather than copied if :
* < ul >
* < li > An image < code > object < / code > was requested ( not < code > string < / code > ) < / li >
* < li > The Graphics instance was created with < code > Graphics . createArrayBuffer < / code > < / li >
* < li > Is 8 bpp < em > OR < / em > the < code > { msb :true } < / code > option was given < / li >
* < li > No other format options ( zigzag / etc ) were given < / li >
* < / ul >
* < p > Otherwise data will be copied , which takes up more space and
* may be quite slow . < / p >
* @url http : //www.espruino.com/Reference#l_Graphics_asImage
* /
asImage : ( type : any ) = > any ;
/ * < p > R e t u r n t h e a r e a o f t h e G r a p h i c s c a n v a s t h a t h a s b e e n m o d i f i e d , a n d o p t i o n a l l y c l e a r
* the modified area to 0 . < / p >
* For instance if < code > g . setPixel ( 10 , 20 ) < / code > was called , this would return < code > { x1 :10 , y1 :20 , x2 :10 , y2 :20 } < / code >
* @url http : //www.espruino.com/Reference#l_Graphics_getModified
* /
getModified : ( reset : boolean ) = > any ;
/ * < p > S c r o l l t h e c o n t e n t s o f t h i s g r a p h i c s i n a c e r t a i n d i r e c t i o n . T h e r e m a i n i n g a r e a
* is filled with the background color . < / p >
* < p > Note : This uses repeated pixel reads and writes , so will not work on platforms that
* don & # 39 ; t support pixel reads . < / p >
* @url http : //www.espruino.com/Reference#l_Graphics_scroll
* /
scroll : ( x : number , y : number ) = > Graphics ;
/ * C r e a t e a W i n d o w s B M P f i l e f r o m t h i s G r a p h i c s i n s t a n c e , a n d r e t u r n i t a s a S t r i n g .
* @url http : //www.espruino.com/Reference#l_Graphics_asBMP
* /
asBMP : ( ) = > any ;
/ * C r e a t e a U R L o f t h e f o r m < c o d e > d a t a : i m a g e / b m p ; b a s e 6 4 , . . . < / c o d e > t h a t c a n b e p a s t e d i n t o t h e b r o w s e r .
* The Espruino Web IDE can detect this data on the console and render the image inline automatically .
* @url http : //www.espruino.com/Reference#l_Graphics_asURL
* /
asURL : ( ) = > any ;
/ * O u t p u t t h i s i m a g e a s a b i t m a p U R L o f t h e f o r m < c o d e > d a t a : i m a g e / b m p ; b a s e 6 4 , . . . < / c o d e > . T h e E s p r u i n o W e b I D E w i l l d e t e c t t h i s o n t h e c o n s o l e a n d w i l l r e n d e r t h e i m a g e i n l i n e a u t o m a t i c a l l y .
* This is identical to < code > console . log ( g . asURL ( ) ) < / code > - it is just a convenient function for easy debugging and producing screenshots of what is currently in the Graphics instance .
* < p > < strong > Note : < / strong > This may not work on some bit depths of Graphics instances . It will also not work for the main Graphics instance
* of Bangle . js 1 as the graphics on Bangle . js 1 are stored in write - only memory . < / p >
* @url http : //www.espruino.com/Reference#l_Graphics_dump
* /
dump : ( ) = > void ;
/ * C a l c u l a t e t h e s q u a r e a r e a u n d e r a B e z i e r c u r v e .
* < p > x0 , y0 : start point
* x1 , y1 : control point
* y2 , y2 : end point < / p >
* Max 10 points without start point .
* @url http : //www.espruino.com/Reference#l_Graphics_quadraticBezier
* /
quadraticBezier : ( arr : any , options : any ) = > any ;
/ * S e t t h e c u r r e n t f o n t
* @url http : //www.espruino.com/Reference#l_Graphics_setFont12x20
* /
setFont12x20 : ( scale : number ) = > Graphics ;
}
declare namespace Graphics {
/ * < p > O n d e v i c e s l i k e P i x l . j s o r H Y S T M b o a r d s t h a t c o n t a i n a b u i l t - i n d i s p l a y
* this will return an instance of the graphics class that can be used to
* access that display . < / p >
* Internally , this is stored as a member called < code > gfx < / code > inside the & # 39 ; hiddenRoot & # 39 ; .
* @url http : //www.espruino.com/Reference#l_Graphics_getInstance
* /
function getInstance ( ) : any ;
/ * C r e a t e a G r a p h i c s o b j e c t t h a t r e n d e r s t o a n A r r a y B u f f e r . T h i s w i l l h a v e a f i e l d c a l l e d & # 3 9 ; b u f f e r & # 3 9 ; t h a t c a n g e t u s e d t o g e t a t t h e b u f f e r i t s e l f
* @url http : //www.espruino.com/Reference#l_Graphics_createArrayBuffer
* /
function createArrayBuffer ( width : number , height : number , bpp : number , options : any ) : Graphics ;
/ * C r e a t e a G r a p h i c s o b j e c t t h a t r e n d e r s b y c a l l i n g a J a v a S c r i p t c a l l b a c k f u n c t i o n t o d r a w p i x e l s
* @url http : //www.espruino.com/Reference#l_Graphics_createCallback
* /
function createCallback ( width : number , height : number , bpp : number , callback : any ) : Graphics ;
/ * C r e a t e a G r a p h i c s o b j e c t t h a t r e n d e r s t o S D L w i n d o w ( L i n u x - b a s e d d e v i c e s o n l y )
* @url http : //www.espruino.com/Reference#l_Graphics_createSDL
* /
function createSDL ( width : number , height : number , bpp : number ) : Graphics ;
}
/ * A s i m p l e V T 1 0 0 t e r m i n a l e m u l a t o r .
* < p > When data is sent to the < code > Terminal < / code > object , < code > Graphics . getInstance ( ) < / code >
* is called and if an instance of < code > Graphics < / code > is found then characters
* are written to it . < / p >
* @url http : //www.espruino.com/Reference#l__global_Terminal
* /
declare const Terminal : Serial ;
/ * C l a s s c o n t a i n i n g u t i l i t y f u n c t i o n s f o r a c c e s s i n g I O o n t h e h e x a g o n a l b a d g e
* @url http : //www.espruino.com/Reference#Badge
* /
declare function Badge ( ) : void ;
declare namespace Badge {
/ * C a p a c i t i v e s e n s e - t h e h i g h e r t h e c a p a c i t a n c e , t h e h i g h e r t h e n u m b e r r e t u r n e d .
* Supply a corner number between 1 and 6 , and an integer value will be returned that is proportional to the capacitance
* @url http : //www.espruino.com/Reference#l_Badge_capSense
* /
function capSense ( corner : number ) : number ;
/ * < p > R e t u r n a n a p p r o x i m a t e b a t t e r y p e r c e n t a g e r e m a i n i n g b a s e d o n
* a normal CR2032 battery ( 2.8 - 2.2 v ) < / p >
* @url http : //www.espruino.com/Reference#l_Badge_getBatteryPercentage
* /
function getBatteryPercentage ( ) : number ;
/ * S e t t h e L C D & # 3 9 ; s c o n t r a s t
* @url http : //www.espruino.com/Reference#l_Badge_setContrast
* /
function setContrast ( c : number ) : void ;
}
/* @url http:/ / www . espruino . com / Reference # l_tensorflow_undefined
* /
declare function tensorflow ( ) : void ;
declare namespace tensorflow {
/* @url http:/ / www . espruino . com / Reference # l_tensorflow_create
* /
function create ( arenaSize : number , model : any ) : TFMicroInterpreter ;
}
/ * C l a s s c o n t a i n i n g a n i n s t a n c e o f T F M i c r o I n t e r p r e t e r
* @url http : //www.espruino.com/Reference#TFMicroInterpreter
* /
declare function TFMicroInterpreter ( ) : void ;
type TFMicroInterpreter = {
/* @url http:/ / www . espruino . com / Reference # l_TFMicroInterpreter_getInput
* /
getInput : ( ) = > EspruinoArrayBufferView ;
/* @url http:/ / www . espruino . com / Reference # l_TFMicroInterpreter_getOutput
* /
getOutput : ( ) = > EspruinoArrayBufferView ;
/* @url http:/ / www . espruino . com / Reference # l_TFMicroInterpreter_invoke
* /
invoke : ( ) = > void ;
}
/ * C r y p t o g r a p h i c f u n c t i o n s
* < strong > Note : < / strong > This library is currently only included in builds for boards where there is space . For other boards there is < code > crypto . js < / code > which implements SHA1 in JS .
* @url http : //www.espruino.com/Reference#l_crypto_undefined
* /
declare function Espruinocrypto ( ) : void ;
declare namespace Espruinocrypto {
/ * C l a s s c o n t a i n i n g A E S e n c r y p t i o n / d e c r y p t i o n
* @url http : //www.espruino.com/Reference#l_crypto_AES
* /
const AES : any ;
/ * P e r f o r m s a S H A 1 h a s h a n d r e t u r n s t h e r e s u l t a s a 2 0 b y t e A r r a y B u f f e r .
* < p > < strong > Note : < / strong > On some boards ( currently only Espruino Original ) there
* isn & # 39 ; t space for a fully unrolled SHA1 implementation so a slower
* all - JS implementation is used instead . < / p >
* @url http : //www.espruino.com/Reference#l_crypto_SHA1
* /
function SHA1 ( message : any ) : ArrayBuffer ;
/ * P e r f o r m s a S H A 2 2 4 h a s h a n d r e t u r n s t h e r e s u l t a s a 2 8 b y t e A r r a y B u f f e r
* @url http : //www.espruino.com/Reference#l_crypto_SHA224
* /
function SHA224 ( message : any ) : ArrayBuffer ;
/ * P e r f o r m s a S H A 2 5 6 h a s h a n d r e t u r n s t h e r e s u l t a s a 3 2 b y t e A r r a y B u f f e r
* @url http : //www.espruino.com/Reference#l_crypto_SHA256
* /
function SHA256 ( message : any ) : ArrayBuffer ;
/ * P e r f o r m s a S H A 3 8 4 h a s h a n d r e t u r n s t h e r e s u l t a s a 4 8 b y t e A r r a y B u f f e r
* @url http : //www.espruino.com/Reference#l_crypto_SHA384
* /
function SHA384 ( message : any ) : ArrayBuffer ;
/ * P e r f o r m s a S H A 5 1 2 h a s h a n d r e t u r n s t h e r e s u l t a s a 6 4 b y t e A r r a y B u f f e r
* @url http : //www.espruino.com/Reference#l_crypto_SHA512
* /
function SHA512 ( message : any ) : ArrayBuffer ;
/ * P a s s w o r d - B a s e d K e y D e r i v a t i o n F u n c t i o n 2 a l g o r i t h m , u s i n g S H A 5 1 2
* @url http : //www.espruino.com/Reference#l_crypto_PBKDF2
* /
function PBKDF2 ( passphrase : any , salt : any , options : any ) : ArrayBuffer ;
}
/ * C l a s s c o n t a i n i n g A E S e n c r y p t i o n / d e c r y p t i o n
* < strong > Note : < / strong > This library is currently only included in builds for boards where there is space . For other boards there is < code > crypto . js < / code > which implements SHA1 in JS .
* @url http : //www.espruino.com/Reference#AES
* /
declare function AES ( ) : void ;
declare namespace AES {
/* @url http:/ / www . espruino . com / Reference # l_AES_encrypt
* /
function encrypt ( passphrase : any , key : any , options : any ) : ArrayBuffer ;
/* @url http:/ / www . espruino . com / Reference # l_AES_decrypt
* /
function decrypt ( passphrase : any , key : any , options : any ) : ArrayBuffer ;
}
/* Class containing utility functions for the <a href="http:/ / www . espruino . com / Bangle . js " > Bangle . js Smart Watch < / a >
* @url http : //www.espruino.com/Reference#Bangle
* /
declare function Bangle ( ) : void ;
declare namespace Bangle {
/ * < p > T h i s f u n c t i o n c a n b e u s e d t o a d j u s t t h e b r i g h t n e s s o f B a n g l e . j s & # 3 9 ; s d i s p l a y , a n d
* hence prolong its battery life . < / p >
* < p > Due to hardware design constraints , software PWM has to be used which
* means that the display may flicker slightly when Bluetooth is active
* and the display is not at full power . < / p >
* < strong > Power consumption < / strong >
* < ul >
* < li > 0 = 7 mA < / li >
* < li > 0.1 = 12 mA < / li >
* < li > 0.2 = 18 mA < / li >
* < li > 0.5 = 28 mA < / li >
* < li > 0.9 = 40 mA ( switching overhead ) < / li >
* < li > 1 = 40 mA < / li >
* < / ul >
* @url http : //www.espruino.com/Reference#l_Bangle_setLCDBrightness
* /
function setLCDBrightness ( brightness : number ) : void ;
/ * T h i s f u n c t i o n c a n b e u s e d t o c h a n g e t h e w a y g r a p h i c s i s h a n d l e d o n B a n g l e . j s .
* Available options for < code > Bangle . setLCDMode < / code > are :
* < ul >
* < li > < code > Bangle . setLCDMode ( ) < / code > or < code > Bangle . setLCDMode ( & quot ; direct & quot ; ) < / code > ( the default ) - The drawable area is 240 x240 16 bit . Unbuffered , so draw calls take effect immediately . Terminal and vertical scrolling work ( horizontal scrolling doesn & # 39 ; t ) . < / li >
* < li > < code > Bangle . setLCDMode ( & quot ; doublebuffered & quot ; ) < / code > - The drawable area is 240 x160 16 bit , terminal and scrolling will not work . < code > g . flip ( ) < / code > must be called for draw operations to take effect . < / li >
* < li > < code > Bangle . setLCDMode ( & quot ; 120 x120 & quot ; ) < / code > - The drawable area is 120 x120 8 bit , < code > g . getPixel < / code > , terminal , and full scrolling work . Uses an offscreen buffer stored on Bangle . js , < code > g . flip ( ) < / code > must be called for draw operations to take effect . < / li >
* < li > < code > Bangle . setLCDMode ( & quot ; 80 x80 & quot ; ) < / code > - The drawable area is 80 x80 8 bit , < code > g . getPixel < / code > , terminal , and full scrolling work . Uses an offscreen buffer stored on Bangle . js , < code > g . flip ( ) < / code > must be called for draw operations to take effect . < / li >
* < / ul >
* You can also call < code > Bangle . setLCDMode ( ) < / code > to return to normal , unbuffered < code > & quot ; direct & quot ; < / code > mode .
* @url http : //www.espruino.com/Reference#l_Bangle_setLCDMode
* /
function setLCDMode ( mode : any ) : void ;
/ * T h e c u r r e n t L C D m o d e .
* See < code > Bangle . setLCDMode < / code > for examples .
* @url http : //www.espruino.com/Reference#l_Bangle_getLCDMode
* /
function getLCDMode ( ) : any ;
/ * < p > T h i s c a n b e u s e d t o m o v e t h e d i s p l a y e d m e m o r y a r e a u p o r d o w n t e m p o r a r i l y . I t & # 3 9 ; s
* used for displaying notifications while keeping the main display contents
* intact . < / p >
* @url http : //www.espruino.com/Reference#l_Bangle_setLCDOffset
* /
function setLCDOffset ( y : number ) : void ;
/ * T h i s f u n c t i o n c a n b e u s e d t o t u r n B a n g l e . j s & # 3 9 ; s L C D p o w e r s a v i n g o n o r o f f .
* With power saving off , the display will remain in the state you set it with < code > Bangle . setLCDPower < / code > .
* With power saving on , the display will turn on if a button is pressed , the watch is turned face up , or the screen is updated ( see < code > Bangle . setOptions < / code > for configuration ) . It & # 39 ; ll turn off automatically after the given timeout .
* < strong > Note : < / strong > This function also sets the Backlight and Lock timeout ( the time at which the touchscreen / buttons start being ignored ) . To set both separately , use < code > Bangle . setOptions < / code >
* @url http : //www.espruino.com/Reference#l_Bangle_setLCDTimeout
* /
function setLCDTimeout ( isOn : number ) : void ;
/ * < p > S e t h o w o f t e n t h e w a t c h s h o u l d p o l l f o r n e w a c c e l e r a t i o n / g y r o d a t a a n d k i c k t h e W a t c h d o g t i m e r . I t i s n & # 3 9 ; t
* recommended that you make this interval much larger than 1000 ms , but values up to 4000 ms are allowed . < / p >
* < p > Calling this will set < code > Bangle . setOptions ( { powerSave : false } ) < / code > - disabling the dynamic adjustment of
* poll interval to save battery power when Bangle . js is stationary . < / p >
* @url http : //www.espruino.com/Reference#l_Bangle_setPollInterval
* /
function setPollInterval ( interval : number ) : void ;
/ * S e t i n t e r n a l o p t i o n s u s e d f o r g e s t u r e s , e t c . . .
* < ul >
* < li > < code > wakeOnBTN1 < / code > should the LCD turn on when BTN1 is pressed ? default = < code > true < / code > < / li >
* < li > < code > wakeOnBTN2 < / code > ( Bangle . js 1 ) should the LCD turn on when BTN2 is pressed ? default = < code > true < / code > < / li >
* < li > < code > wakeOnBTN3 < / code > ( Bangle . js 1 ) should the LCD turn on when BTN3 is pressed ? default = < code > true < / code > < / li >
* < li > < code > wakeOnFaceUp < / code > should the LCD turn on when the watch is turned face up ? default = < code > false < / code > < / li >
* < li > < code > wakeOnTouch < / code > should the LCD turn on when the touchscreen is pressed ? default = < code > false < / code > < / li >
* < li > < code > wakeOnTwist < / code > should the LCD turn on when the watch is twisted ? default = < code > true < / code > < / li >
* < li > < code > twistThreshold < / code > How much acceleration to register a twist of the watch strap ? Can be negative for oppsite direction . default = < code > 800 < / code > < / li >
* < li > < code > twistMaxY < / code > Maximum acceleration in Y to trigger a twist ( low Y means watch is facing the right way up ) . default = < code > - 800 < / code > < / li >
* < li > < code > twistTimeout < / code > How little time ( in ms ) must a twist take from low - & gt ; high acceleration ? default = < code > 1000 < / code > < / li >
* < li > < code > gestureStartThresh < / code > how big a difference before we consider a gesture started ? default = < code > sqr ( 800 ) < / code > < / li >
* < li > < code > gestureEndThresh < / code > how small a difference before we consider a gesture ended ? default = < code > sqr ( 2000 ) < / code > < / li >
* < li > < code > gestureInactiveCount < / code > how many samples do we keep after a gesture has ended ? default = < code > 4 < / code > < / li >
* < li > < code > gestureMinLength < / code > how many samples must a gesture have before we notify about it ? default = < code > 10 < / code > < / li >
* < li > < code > powerSave < / code > after a minute of not being moved , Bangle . js will change the accelerometer poll interval down to 800 ms ( 10 x accelerometer samples ) .
* On movement it & # 39 ; ll be raised to the default 80 ms . If < code > Bangle . setPollInterval < / code > is used this is disabled , and for it to work the poll interval
* must be either 80 ms or 800 ms . default = < code > true < / code > < / li >
* < li > < code > lockTimeout < / code > how many milliseconds before the screen locks < / li >
* < li > < code > lcdPowerTimeout < / code > how many milliseconds before the screen turns off < / li >
* < li > < code > backlightTimeout < / code > how many milliseconds before the screen & # 39 ; s backlight turns off < / li >
* < li > < code > hrmPollInterval < / code > set the requested poll interval ( in milliseconds ) for the heart rate monitor . On Bangle . js 2 only 10 , 20 , 40 , 80 , 160 , 200 ms are supported , and polling rate may not be exact . The algorithm & # 39 ; s filtering is tuned for 20 - 40 ms poll intervals , so higher / lower intervals may effect the reliability of the BPM reading . < / li >
* < li > < code > seaLevelPressure < / code > ( Bangle . js 2 ) Normally 1013.25 millibars - this is used for calculating altitude with the pressure sensor < / li >
* < / ul >
* Where accelerations are used they are in internal units , where < code > 8192 = 1 g < / code >
* @url http : //www.espruino.com/Reference#l_Bangle_setOptions
* /
function setOptions ( options : any ) : void ;
/ * R e t u r n t h e c u r r e n t s t a t e o f o p t i o n s a s s e t b y < c o d e > B a n g l e . s e t O p t i o n s < / c o d e >
* @url http : //www.espruino.com/Reference#l_Bangle_getOptions
* /
function getOptions ( ) : any ;
/ * A l s o s e e t h e < c o d e > B a n g l e . l c d P o w e r < / c o d e > e v e n t
* @url http : //www.espruino.com/Reference#l_Bangle_isLCDOn
* /
function isLCDOn ( ) : boolean ;
/ * < p > T h i s f u n c t i o n c a n b e u s e d t o l o c k o r u n l o c k B a n g l e . j s
* ( eg whether buttons and touchscreen work or not ) < / p >
* @url http : //www.espruino.com/Reference#l_Bangle_setLocked
* /
function setLocked ( isLocked : boolean ) : void ;
/ * A l s o s e e t h e < c o d e > B a n g l e . l o c k < / c o d e > e v e n t
* @url http : //www.espruino.com/Reference#l_Bangle_isLocked
* /
function isLocked ( ) : boolean ;
/* @url http:/ / www . espruino . com / Reference # l_Bangle_isCharging
* /
function isCharging ( ) : boolean ;
/ * W r i t e s a c o m m a n d d i r e c t l y t o t h e S T 7 7 3 5 L C D c o n t r o l l e r
* @url http : //www.espruino.com/Reference#l_Bangle_lcdWr
* /
function lcdWr ( cmd : number , data : any ) : void ;
/ * I s t h e H e a r t r a t e m o n i t o r p o w e r e d ?
* Set power with < code > Bangle . setHRMPower ( . . . ) ; < / code >
* @url http : //www.espruino.com/Reference#l_Bangle_isHRMOn
* /
function isHRMOn ( ) : boolean ;
/ * I s t h e G P S p o w e r e d ?
* Set power with < code > Bangle . setGPSPower ( . . . ) ; < / code >
* @url http : //www.espruino.com/Reference#l_Bangle_isGPSOn
* /
function isGPSOn ( ) : boolean ;
/ * G e t t h e l a s t a v a i l a b l e G P S f i x i n f o ( o r < c o d e > u n d e f i n e d < / c o d e > i f G P S i s o f f ) .
* The fix info received is the same as you & # 39 ; d get from the < code > Bangle . GPS < / code > event .
* @url http : //www.espruino.com/Reference#l_Bangle_getGPSFix
* /
function getGPSFix ( ) : any ;
/ * I s t h e c o m p a s s p o w e r e d ?
* Set power with < code > Bangle . setCompassPower ( . . . ) ; < / code >
* @url http : //www.espruino.com/Reference#l_Bangle_isCompassOn
* /
function isCompassOn ( ) : boolean ;
/ * < p > R e s e t s t h e c o m p a s s m i n i m u m / m a x i m u m v a l u e s . C a n b e u s e d i f t h e c o m p a s s i s n & # 3 9 ; t
* providing a reliable heading any more . < / p >
* @url http : //www.espruino.com/Reference#l_Bangle_resetCompass
* /
function resetCompass ( ) : void ;
/ * < p > S e t t h e p o w e r t o t h e b a r o m e t e r I C . O n c e e n b l e d , < c o d e > B a n g l e . p r e s s u r e < / c o d e > e v e n t s
* are fired each time a new barometer reading is available . < / p >
* When on , the barometer draws roughly 50 uA
* @url http : //www.espruino.com/Reference#l_Bangle_setBarometerPower
* /
function setBarometerPower ( isOn : boolean , appID : any ) : boolean ;
/ * I s t h e B a r o m e t e r p o w e r e d ?
* Set power with < code > Bangle . setBarometerPower ( . . . ) ; < / code >
* @url http : //www.espruino.com/Reference#l_Bangle_isBarometerOn
* /
function isBarometerOn ( ) : boolean ;
/ * R e t u r n s t h e c u r r e n t a m o u n t o f s t e p s r e c o r d e d b y t h e s t e p c o u n t e r
* @url http : //www.espruino.com/Reference#l_Bangle_getStepCount
* /
function getStepCount ( ) : number ;
/ * S e t s t h e c u r r e n t v a l u e o f t h e s t e p c o u n t e r
* @url http : //www.espruino.com/Reference#l_Bangle_setStepCount
* /
function setStepCount ( count : number ) : void ;
/ * G e t t h e m o s t r e c e n t M a g n e t o m e t e r / C o m p a s s r e a d i n g . D a t a i s i n t h e s a m e f o r m a t a s t h e < c o d e > B a n g l e . o n ( & # 3 9 ; m a g & # 3 9 ; , < / c o d e > e v e n t .
* Returns an < code > { x , y , z , dx , dy , dz , heading } < / code > object
* < ul >
* < li > < code > x / y / z < / code > raw x , y , z magnetometer readings < / li >
* < li > < code > dx / dy / dz < / code > readings based on calibration since magnetometer turned on < / li >
* < li > < code > heading < / code > in degrees based on calibrated readings ( will be NaN if magnetometer hasn & # 39 ; t been rotated around 360 degrees ) < / li >
* < / ul >
* < p > To get this event you must turn the compass on
* with < code > Bangle . setCompassPower ( 1 ) < / code > . < / p >
* @url http : //www.espruino.com/Reference#l_Bangle_getCompass
* /
function getCompass ( ) : any ;
/ * G e t t h e m o s t r e c e n t a c c e l e r o m e t e r r e a d i n g . D a t a i s i n t h e s a m e f o r m a t a s t h e < c o d e > B a n g l e . o n ( & # 3 9 ; a c c e l & # 3 9 ; , < / c o d e > e v e n t .
* < ul >
* < li > < code > x < / code > is X axis ( left - right ) in < code > g < / code > < / li >
* < li > < code > y < / code > is Y axis ( up - down ) in < code > g < / code > < / li >
* < li > < code > z < / code > is Z axis ( in - out ) in < code > g < / code > < / li >
* < li > < code > diff < / code > is difference between this and the last reading in < code > g < / code > ( calculated by comparing vectors , not magnitudes ) < / li >
* < li > < code > td < / code > is the elapsed < / li >
* < li > < code > mag < / code > is the magnitude of the acceleration in < code > g < / code > < / li >
* < / ul >
* @url http : //www.espruino.com/Reference#l_Bangle_getAccel
* /
function getAccel ( ) : any ;
/ * < c o d e > r a n g e < / c o d e > i s o n e o f :
* < ul >
* < li > < code > undefined < / code > or < code > & # 39 ; current & # 39 ; < / code > - health data so far in the last 10 minutes is returned , < / li >
* < li > < code > & # 39 ; last & # 39 ; < / code > - health data during the last 10 minutes < / li >
* < li > < code > & # 39 ; day & # 39 ; < / code > - the health data so far for the day < / li >
* < / ul >
* < code > getHealthStatus < / code > returns an object containing :
* < ul >
* < li > < code > movement < / code > is the 32 bit sum of all < code > acc . diff < / code > readings since power on ( and rolls over ) . It is the difference in accelerometer values as < code > g * 8192 < / code > < / li >
* < li > < code > steps < / code > is the number of steps during this period < / li >
* < li > < code > bpm < / code > the best BPM reading from HRM sensor during this period < / li >
* < li > < code > bpmConfidence < / code > best BPM confidence ( 0 - 100 % ) during this period < / li >
* < / ul >
* @url http : //www.espruino.com/Reference#l_Bangle_getHealthStatus
* /
function getHealthStatus ( range : any ) : any ;
/ * < p > F e a t u r e f l a g - I f t r u e , t h i s B a n g l e . j s f i r m w a r e r e a d s < c o d e > s e t t i n g . j s o n < / c o d e > a n d
* modifies beep & amp ; buzz behaviour accordingly ( the bootloader
* doesn & # 39 ; t need to do it ) . < / p >
* @url http : //www.espruino.com/Reference#l_Bangle_F_BEEPSET
* /
const F_BEEPSET : boolean ;
/ * R e a d s d e b u g i n f o
* @url http : //www.espruino.com/Reference#l_Bangle_dbg
* /
function dbg ( ) : any ;
/ * W r i t e s a r e g i s t e r o n t h e a c c e l e r o m e t e r
* @url http : //www.espruino.com/Reference#l_Bangle_accelWr
* /
function accelWr ( reg : number , data : number ) : void ;
/ * R e a d s a r e g i s t e r f r o m t h e a c c e l e r o m e t e r
* < strong > Note : < / strong > On Espruino 2 v06 and before this function only returns a number ( < code > cnt < / code > is ignored ) .
* @url http : //www.espruino.com/Reference#l_Bangle_accelRd
* /
function accelRd ( reg : number , cnt : number ) : any ;
/ * W r i t e s a r e g i s t e r o n t h e b a r o m e t e r I C
* @url http : //www.espruino.com/Reference#l_Bangle_barometerWr
* /
function barometerWr ( reg : number , data : number ) : void ;
/ * R e a d s a r e g i s t e r f r o m t h e b a r o m e t e r I C
* @url http : //www.espruino.com/Reference#l_Bangle_barometerRd
* /
function barometerRd ( reg : number , cnt : number ) : any ;
/ * W r i t e s a r e g i s t e r o n t h e M a g n e t o m e t e r / C o m p a s s
* @url http : //www.espruino.com/Reference#l_Bangle_compassWr
* /
function compassWr ( reg : number , data : number ) : void ;
/ * R e a d a r e g i s t e r o n t h e M a g n e t o m e t e r / C o m p a s s
* @url http : //www.espruino.com/Reference#l_Bangle_compassRd
* /
function compassRd ( reg : number , cnt : number ) : any ;
/ * W r i t e s a r e g i s t e r o n t h e H e a r t r a t e m o n i t o r
* @url http : //www.espruino.com/Reference#l_Bangle_hrmWr
* /
function hrmWr ( reg : number , data : number ) : void ;
/ * R e a d a r e g i s t e r o n t h e H e a r t r a t e m o n i t o r
* @url http : //www.espruino.com/Reference#l_Bangle_hrmRd
* /
function hrmRd ( reg : number , cnt : number ) : any ;
/ * C h a n g e s a p i n s t a t e o n t h e I O e x p a n d e r
* @url http : //www.espruino.com/Reference#l_Bangle_ioWr
* /
function ioWr ( mask : number , isOn : number ) : void ;
/* <p>Perform a Spherical <a href="https:/ / en . wikipedia . org / wiki / Web_Mercator_projection " > Web Mercator projection < / a >
* of latitude and longitude into < code > x < / code > and < code > y < / code > coordinates , which are roughly
* equivalent to meters from < code > { lat :0 , lon :0 } < / code > . < / p >
* < p > This is the formula used for most online mapping and is a good way
* to compare GPS coordinates to work out the distance between them . < / p >
* @url http : //www.espruino.com/Reference#l_Bangle_project
* /
function project ( latlong : any ) : any ;
/ * U s e t h e p i e z o s p e a k e r t o B e e p f o r a c e r t a i n t i m e p e r i o d a n d f r e q u e n c y
* @url http : //www.espruino.com/Reference#l_Bangle_beep
* /
function beep ( time : number , freq : number ) : Promise < any > ;
/ * U s e t h e v i b r a t i o n m o t o r t o b u z z f o r a c e r t a i n t i m e p e r i o d
* @url http : //www.espruino.com/Reference#l_Bangle_buzz
* /
function buzz ( time : number , strength : number ) : Promise < any > ;
/ * T u r n B a n g l e . j s o f f . I t c a n o n l y b e w o k e n b y p r e s s i n g B T N 1 .
* @url http : //www.espruino.com/Reference#l_Bangle_off
* /
function off ( ) : void ;
/ * < p > T u r n B a n g l e . j s ( m o s t l y ) o f f , b u t k e e p t h e C P U i n s l e e p
* mode until BTN1 is pressed to preserve the RTC ( current time ) . < / p >
* @url http : //www.espruino.com/Reference#l_Bangle_softOff
* /
function softOff ( ) : void ;
/ * < u l >
* < li > On platforms with an LCD of & gt ; = 8 bpp this is 222 x 104 x 2 bits < / li >
* < li > Otherwise it & # 39 ; s 119 x 56 x 1 bits < / li >
* < / ul >
* @url http : //www.espruino.com/Reference#l_Bangle_getLogo
* /
function getLogo ( ) : any ;
/ * < p > L o a d a l l w i d g e t s f r o m f l a s h S t o r a g e . C a l l t h i s o n c e a t t h e b e g i n n i n g
* of your application if you want any on - screen widgets to be loaded . < / p >
* < p > They will be loaded into a global < code > WIDGETS < / code > array , and
* can be rendered with < code > Bangle . drawWidgets < / code > . < / p >
* @url http : //www.espruino.com/Reference#l_Bangle_loadWidgets
* /
function loadWidgets ( ) : void ;
/* @url http:/ / www . espruino . com / Reference # l_Bangle_drawWidgets
* /
function drawWidgets ( ) : void ;
/ * < p > L o a d t h e B a n g l e . j s a p p l a u n c h e r , w h i c h w i l l a l l o w t h e u s e r
* to select an application to launch . < / p >
* @url http : //www.espruino.com/Reference#l_Bangle_showLauncher
* /
function showLauncher ( ) : void ;
/* @url http:/ / www . espruino . com / Reference # l_Bangle_setUI
* /
function setUI ( ) : void ;
/ * < p > E r a s e a l l s t o r a g e a n d r e l o a d i t w i t h t h e d e f a u l t
* contents . < / p >
* < p > This is only available on Bangle . js 2.0 . On Bangle . js 1.0
* you need to use < code > Install Default Apps < / code > under the < code > More . . . < / code > tab
* of < a href = "http://banglejs.com/apps" > http : //banglejs.com/apps</a></p>
* @url http : //www.espruino.com/Reference#l_Bangle_factoryReset
* /
function factoryReset ( ) : void ;
/ * < p > R e t u r n s t h e r e c t a n g l e o n t h e s c r e e n t h a t i s c u r r e n t l y
* reserved for the app . < / p >
* @url http : //www.espruino.com/Reference#l_Bangle_appRect
* /
const appRect : any ;
}
/* Class containing <a href="https:/ / www . espruino . com / MicroBit " > micro :bit & # 39 ; s < / a > utility functions .
* @url http : //www.espruino.com/Reference#Microbit
* /
declare function Microbit ( ) : void ;
declare namespace Microbit {
/ * T h e m i c r o : b i t & # 3 9 ; s s p e a k e r p i n
* @url http : //www.espruino.com/Reference#l_Microbit_SPEAKER
* /
const SPEAKER : Pin ;
/ * T h e m i c r o : b i t & # 3 9 ; s m i c r o p h o n e p i n
* < code > MIC_ENABLE < / code > should be set to 1 before using this
* @url http : //www.espruino.com/Reference#l_Microbit_MIC
* /
const MIC : Pin ;
/ * T h e m i c r o : b i t & # 3 9 ; s m i c r o p h o n e e n a b l e p i n
* @url http : //www.espruino.com/Reference#l_Microbit_MIC_ENABLE
* /
const MIC_ENABLE : Pin ;
/* @url http:/ / www . espruino . com / Reference # l_Microbit_mag
* /
function mag ( ) : any ;
/* @url http:/ / www . espruino . com / Reference # l_Microbit_accel
* /
function accel ( ) : any ;
/ * < s t r o n g > N o t e : < / s t r o n g > T h i s f u n c t i o n i s o n l y a v a i l a b l e o n t h e < a h r e f = " / M i c r o B i t " > B B C m i c r o : b i t < / a > b o a r d
* Write the given value to the accelerometer
* @url http : //www.espruino.com/Reference#l_Microbit_accelWr
* /
function accelWr ( addr : number , data : number ) : void ;
/ * T u r n o n t h e a c c e l e r o m e t e r , a n d c r e a t e < c o d e > M i c r o b i t . a c c e l < / c o d e > a n d < c o d e > M i c r o b i t . g e s t u r e < / c o d e > e v e n t s .
* < p > < strong > Note : < / strong > The accelerometer is currently always enabled - this code
* just responds to interrupts and reads < / p >
* @url http : //www.espruino.com/Reference#l_Microbit_accelOn
* /
function accelOn ( ) : void ;
/ * T u r n o f f e v e n t s f r o m t h e a c c e l e r o m e t e r ( s t a r t e d w i t h < c o d e > M i c r o b i t . a c c e l O n < / c o d e > )
* @url http : //www.espruino.com/Reference#l_Microbit_accelOff
* /
function accelOff ( ) : void ;
/ * P l a y a w a v e f o r m o n t h e M i c r o : b i t & # 3 9 ; s s p e a k e r
* @url http : //www.espruino.com/Reference#l_Microbit_play
* /
function play ( waveform : any , samplesPerSecond : any , callback : any ) : void ;
/ * R e c o r d s s o u n d f r o m t h e m i c r o : b i t & # 3 9 ; s o n b o a r d m i c r o p h o n e a n d r e t u r n s t h e r e s u l t
* @url http : //www.espruino.com/Reference#l_Microbit_record
* /
function record ( samplesPerSecond : any , callback : any , samples : any ) : void ;
}
/ * T h i s i s t h e F i l e o b j e c t - i t a l l o w s y o u t o s t r e a m d a t a t o a n d f r o m f i l e s ( A s o p p o s e d t o t h e < c o d e > r e q u i r e ( & # 3 9 ; f s & # 3 9 ; ) . r e a d F i l e ( . . ) < / c o d e > s t y l e f u n c t i o n s t h a t r e a d a n e n t i r e f i l e ) .
* To create a File object , you must type < code > var fd = E . openFile ( & # 39 ; filepath & # 39 ; , & # 39 ; mode & # 39 ; ) < / code > - see < a href = "#l_E_openFile" > E . openFile < / a > for more information .
* < strong > Note : < / strong > If you want to remove an SD card after you have started using it , you < em > must < / em > call < code > E . unmountSD ( ) < / code > or you may cause damage to the card .
* @url http : //www.espruino.com/Reference#File
* /
declare function EspruinoFile ( ) : void ;
type EspruinoFile = {
/ * C l o s e a n o p e n f i l e .
* @url http : //www.espruino.com/Reference#l_File_close
* /
close : ( ) = > void ;
/ * W r i t e d a t a t o a f i l e .
* < p > < strong > Note : < / strong > By default this function flushes all changes to the
* SD card , which makes it slow ( but also safe ! ) . You can use
* < code > E . setFlags ( { unsyncFiles :1 } ) < / code > to disable this behaviour and
* really speed up writes - but then you must be sure to close
* all files you are writing before power is lost or you will
* cause damage to your SD card & # 39 ; s filesystem . < / p >
* @url http : //www.espruino.com/Reference#l_File_write
* /
write : ( buffer : any ) = > number ;
/ * R e a d d a t a i n a f i l e i n b y t e s i z e c h u n k s
* @url http : //www.espruino.com/Reference#l_File_read
* /
read : ( length : number ) = > any ;
/ * S k i p t h e s p e c i f i e d n u m b e r o f b y t e s f o r w a r d i n t h e f i l e
* @url http : //www.espruino.com/Reference#l_File_skip
* /
skip : ( nBytes : number ) = > void ;
/ * S e e k t o a c e r t a i n p o s i t i o n i n t h e f i l e
* @url http : //www.espruino.com/Reference#l_File_seek
* /
seek : ( nBytes : number ) = > void ;
/ * P i p e t h i s f i l e t o a s t r e a m ( a n o b j e c t w i t h a & # 3 9 ; w r i t e & # 3 9 ; m e t h o d )
* @url http : //www.espruino.com/Reference#l_File_pipe
* /
pipe : ( destination : any , options : any ) = > void ;
}
/ * T h i s l i b r a r y h a n d l e s i n t e r f a c i n g w i t h a F A T 3 2 f i l e s y s t e m o n a n S D c a r d . T h e A P I i s d e s i g n e d t o b e s i m i l a r t o n o d e . j s & # 3 9 ; s - H o w e v e r E s p r u i n o d o e s n o t c u r r e n t l y s u p p o r t a s y n c h r o n o u s f i l e I O , s o t h e f u n c t i o n s b e h a v e l i k e n o d e . j s & # 3 9 ; s x x x x S y n c f u n c t i o n s . V e r s i o n s o f t h e f u n c t i o n s w i t h & # 3 9 ; S y n c & # 3 9 ; a f t e r t h e m a r e a l s o p r o v i d e d f o r c o m p a t i b i l i t y .
* To use this , you must type < code > var fs = require ( & # 39 ; fs & # 39 ; ) < / code > to get access to the library
* See < a href = "http://www.espruino.com/File+IO" > the page on File IO < / a > for more information , and for examples on wiring up an SD card if your device doesn & # 39 ; t come with one .
* < strong > Note : < / strong > If you want to remove an SD card after you have started using it , you < em > must < / em > call < code > E . unmountSD ( ) < / code > or you may cause damage to the card .
* @url http : //www.espruino.com/Reference#l_fs_undefined
* /
declare function fs ( ) : void ;
declare namespace fs {
/ * L i s t a l l f i l e s i n t h e s u p p l i e d d i r e c t o r y , r e t u r n i n g t h e m a s a n a r r a y o f s t r i n g s .
* NOTE : Espruino does not yet support Async file IO , so this function behaves like the & # 39 ; Sync & # 39 ; version .
* @url http : //www.espruino.com/Reference#l_fs_readdir
* /
function readdir ( path : any ) : any ;
/ * L i s t a l l f i l e s i n t h e s u p p l i e d d i r e c t o r y , r e t u r n i n g t h e m a s a n a r r a y o f s t r i n g s .
* @url http : //www.espruino.com/Reference#l_fs_readdirSync
* /
function readdirSync ( path : any ) : any ;
/ * W r i t e t h e d a t a t o t h e g i v e n f i l e
* NOTE : Espruino does not yet support Async file IO , so this function behaves like the & # 39 ; Sync & # 39 ; version .
* @url http : //www.espruino.com/Reference#l_fs_writeFile
* /
function writeFile ( path : any , data : any ) : boolean ;
/ * W r i t e t h e d a t a t o t h e g i v e n f i l e
* @url http : //www.espruino.com/Reference#l_fs_writeFileSync
* /
function writeFileSync ( path : any , data : any ) : boolean ;
/ * A p p e n d t h e d a t a t o t h e g i v e n f i l e , c r e a t e d a n e w f i l e i f i t d o e s n & # 3 9 ; t e x i s t
* NOTE : Espruino does not yet support Async file IO , so this function behaves like the & # 39 ; Sync & # 39 ; version .
* @url http : //www.espruino.com/Reference#l_fs_appendFile
* /
function appendFile ( path : any , data : any ) : boolean ;
/ * A p p e n d t h e d a t a t o t h e g i v e n f i l e , c r e a t e d a n e w f i l e i f i t d o e s n & # 3 9 ; t e x i s t
* @url http : //www.espruino.com/Reference#l_fs_appendFileSync
* /
function appendFileSync ( path : any , data : any ) : boolean ;
/ * R e a d a l l d a t a f r o m a f i l e a n d r e t u r n a s a s t r i n g
* NOTE : Espruino does not yet support Async file IO , so this function behaves like the & # 39 ; Sync & # 39 ; version .
* @url http : //www.espruino.com/Reference#l_fs_readFile
* /
function readFile ( path : any ) : any ;
/ * R e a d a l l d a t a f r o m a f i l e a n d r e t u r n a s a s t r i n g .
* < strong > Note : < / strong > The size of files you can load using this method is limited by the amount of available RAM . To read files a bit at a time , see the < code > File < / code > class .
* @url http : //www.espruino.com/Reference#l_fs_readFileSync
* /
function readFileSync ( path : any ) : any ;
/ * D e l e t e t h e g i v e n f i l e
* NOTE : Espruino does not yet support Async file IO , so this function behaves like the & # 39 ; Sync & # 39 ; version .
* @url http : //www.espruino.com/Reference#l_fs_unlink
* /
function unlink ( path : any ) : boolean ;
/ * D e l e t e t h e g i v e n f i l e
* @url http : //www.espruino.com/Reference#l_fs_unlinkSync
* /
function unlinkSync ( path : any ) : boolean ;
/ * < p > R e t u r n i n f o r m a t i o n o n t h e g i v e n f i l e . T h i s r e t u r n s a n o b j e c t w i t h t h e f o l l o w i n g
* fields : < / p >
* < p > size : size in bytes
* dir : a boolean specifying if the file is a directory or not
* mtime : A Date structure specifying the time the file was last modified < / p >
* @url http : //www.espruino.com/Reference#l_fs_statSync
* /
function statSync ( path : any ) : any ;
/ * C r e a t e t h e d i r e c t o r y
* NOTE : Espruino does not yet support Async file IO , so this function behaves like the & # 39 ; Sync & # 39 ; version .
* @url http : //www.espruino.com/Reference#l_fs_mkdir
* /
function mkdir ( path : any ) : boolean ;
/ * C r e a t e t h e d i r e c t o r y
* @url http : //www.espruino.com/Reference#l_fs_mkdirSync
* /
function mkdirSync ( path : any ) : boolean ;
/* @url http:/ / www . espruino . com / Reference # l_fs_pipe
* /
function pipe ( source : any , destination : any , options : any ) : void ;
}
/* Class containing utility functions for <a href="http:/ / www . espruino . com / Pixl . js " > Pixl . js < / a >
* @url http : //www.espruino.com/Reference#Pixl
* /
declare function Pixl ( ) : void ;
declare namespace Pixl {
/ * D E P R E C A T E D - P l e a s e u s e < c o d e > E . g e t B a t t e r y ( ) < / c o d e > i n s t e a d .
* < p > Return an approximate battery percentage remaining based on
* a normal CR2032 battery ( 2.8 - 2.2 v ) < / p >
* @url http : //www.espruino.com/Reference#l_Pixl_getBatteryPercentage
* /
function getBatteryPercentage ( ) : number ;
/ * S e t t h e L C D & # 3 9 ; s c o n t r a s t
* @url http : //www.espruino.com/Reference#l_Pixl_setContrast
* /
function setContrast ( c : number ) : void ;
/ * T h i s f u n c t i o n c a n b e u s e d t o t u r n P i x l . j s & # 3 9 ; s L C D o f f o r o n .
* < ul >
* < li > With the LCD off , Pixl . js draws around 0.1 mA < / li >
* < li > With the LCD on , Pixl . js draws around 0.25 mA < / li >
* < / ul >
* @url http : //www.espruino.com/Reference#l_Pixl_setLCDPower
* /
function setLCDPower ( isOn : boolean ) : void ;
/ * W r i t e s a c o m m a n d d i r e c t l y t o t h e S T 7 5 6 7 L C D c o n t r o l l e r
* @url http : //www.espruino.com/Reference#l_Pixl_lcdw
* /
function lcdw ( c : number ) : void ;
/ * D i s p l a y a m e n u o n P i x l . j s & # 3 9 ; s s c r e e n , a n d s e t u p t h e b u t t o n s t o n a v i g a t e t h r o u g h i t .
* DEPRECATED : Use < code > E . showMenu < / code >
* @url http : //www.espruino.com/Reference#l_Pixl_menu
* /
function menu ( menu : any ) : any ;
}
/ * < p > W e b B l u e t o o t h - s t y l e G A T T s e r v e r - g e t t h i s u s i n g < c o d e > N R F . c o n n e c t ( a d d r e s s ) < / c o d e >
* or < code > NRF . requestDevice ( options ) < / code > and < code > response . gatt . connect < / code > < / p >
* < a href = "https://webbluetoothcg.github.io/web-bluetooth/#bluetoothremotegattserver" > https : //webbluetoothcg.github.io/web-bluetooth/#bluetoothremotegattserver</a>
* @url http : //www.espruino.com/Reference#BluetoothRemoteGATTServer
* /
declare function BluetoothRemoteGATTServer ( ) : void ;
type BluetoothRemoteGATTServer = {
/ * < p > D i s c o n n e c t f r o m a p r e v i o u s l y c o n n e c t e d B L E d e v i c e c o n n e c t e d w i t h
* < code > BluetoothRemoteGATTServer . connect < / code > - this does not disconnect from something that has
* connected to the Espruino . < / p >
* < p > < strong > Note : < / strong > While < code > . disconnect < / code > is standard Web Bluetooth , in the spec it
* returns undefined not a < code > Promise < / code > for implementation reasons . In Espruino
* we return a < code > Promise < / code > to make it easier to detect when Espruino is free
* to connect to something else . < / p >
* @url http : //www.espruino.com/Reference#l_BluetoothRemoteGATTServer_disconnect
* /
disconnect : ( ) = > Promise < any > ;
/ * S e e < c o d e > N R F . c o n n e c t < / c o d e > f o r u s a g e e x a m p l e s .
* @url http : //www.espruino.com/Reference#l_BluetoothRemoteGATTServer_getPrimaryService
* /
getPrimaryService : ( service : any ) = > Promise < any > ;
/* @url http:/ / www . espruino . com / Reference # l_BluetoothRemoteGATTServer_getPrimaryServices
* /
getPrimaryServices : ( ) = > Promise < any > ;
}
/ * W e b B l u e t o o t h - s t y l e G A T T s e r v i c e - g e t t h i s u s i n g < c o d e > B l u e t o o t h R e m o t e G A T T S e r v e r . g e t P r i m a r y S e r v i c e ( s ) < / c o d e >
* < a href = "https://webbluetoothcg.github.io/web-bluetooth/#bluetoothremotegattservice" > https : //webbluetoothcg.github.io/web-bluetooth/#bluetoothremotegattservice</a>
* @url http : //www.espruino.com/Reference#BluetoothRemoteGATTService
* /
declare function BluetoothRemoteGATTService ( ) : void ;
type BluetoothRemoteGATTService = {
/ * S e e < c o d e > N R F . c o n n e c t < / c o d e > f o r u s a g e e x a m p l e s .
* @url http : //www.espruino.com/Reference#l_BluetoothRemoteGATTService_getCharacteristic
* /
getCharacteristic : ( characteristic : any ) = > Promise < any > ;
/* @url http:/ / www . espruino . com / Reference # l_BluetoothRemoteGATTService_getCharacteristics
* /
getCharacteristics : ( ) = > Promise < any > ;
}
/ * W e b B l u e t o o t h - s t y l e G A T T c h a r a c t e r i s t i c - g e t t h i s u s i n g < c o d e > B l u e t o o t h R e m o t e G A T T S e r v i c e . g e t C h a r a c t e r i s t i c ( s ) < / c o d e >
* < a href = "https://webbluetoothcg.github.io/web-bluetooth/#bluetoothremotegattcharacteristic" > https : //webbluetoothcg.github.io/web-bluetooth/#bluetoothremotegattcharacteristic</a>
* @url http : //www.espruino.com/Reference#BluetoothRemoteGATTCharacteristic
* /
declare function BluetoothRemoteGATTCharacteristic ( ) : void ;
type BluetoothRemoteGATTCharacteristic = {
/ * S t o p n o t i f i c a t i o n s ( t h a t w e r e r e q u e s t e d w i t h < c o d e > B l u e t o o t h R e m o t e G A T T C h a r a c t e r i s t i c . s t a r t N o t i f i c a t i o n s < / c o d e > )
* @url http : //www.espruino.com/Reference#l_BluetoothRemoteGATTCharacteristic_stopNotifications
* /
stopNotifications : ( ) = > Promise < any > ;
}
/ * T h i s c l a s s e x i s t s i n o r d e r t o i n t e r f a c e E s p r u i n o w i t h f a s t - m o v i n g t r i g g e r w h e e l s . T r i g g e r w h e e l s a r e p h y s i c a l d i s c s w i t h e v e n l y s p a c e d t e e t h c u t i n t o t h e m , a n d o f t e n w i t h o n e o r t w o t e e t h n e x t t o e a c h o t h e r m i s s i n g . A s e n s o r s e n d s a s i g n a l w h e n e v e r a t o o t h p a s s e d b y , a n d t h i s a l l o w s a d e v i c e t o m e a s u r e n o t o n l y R P M , b u t a b s o l u t e p o s i t i o n .
* This class is currently in testing - it is NOT AVAILABLE on normal boards .
* @url http : //www.espruino.com/Reference#Trig
* /
declare function Trig ( ) : void ;
declare namespace Trig {
/ * G e t t h e p o s i t i o n o f t h e t r i g g e r w h e e l a t t h e g i v e n t i m e ( f r o m g e t T i m e )
* @url http : //www.espruino.com/Reference#l_Trig_getPosAtTime
* /
function getPosAtTime ( time : number ) : number ;
/ * I n i t i a l i s e t h e t r i g g e r c l a s s
* @url http : //www.espruino.com/Reference#l_Trig_setup
* /
function setup ( pin : Pin , options : any ) : void ;
/ * S e t a t r i g g e r f o r a c e r t a i n p o i n t i n t h e c y c l e
* @url http : //www.espruino.com/Reference#l_Trig_setTrigger
* /
function setTrigger ( num : number , pos : number , pins : any , pulseLength : number ) : void ;
/ * D i s a b l e a t r i g g e r
* @url http : //www.espruino.com/Reference#l_Trig_killTrigger
* /
function killTrigger ( num : number ) : void ;
/ * G e t t h e c u r r e n t s t a t e o f a t r i g g e r
* @url http : //www.espruino.com/Reference#l_Trig_getTrigger
* /
function getTrigger ( num : number ) : any ;
/ * G e t t h e R P M o f t h e t r i g g e r w h e e l
* @url http : //www.espruino.com/Reference#l_Trig_getRPM
* /
function getRPM ( ) : number ;
/ * G e t t h e c u r r e n t e r r o r f l a g s f r o m t h e t r i g g e r w h e e l - a n d z e r o t h e m
* @url http : //www.espruino.com/Reference#l_Trig_getErrors
* /
function getErrors ( ) : number ;
/ * G e t t h e c u r r e n t e r r o r f l a g s f r o m t h e t r i g g e r w h e e l - a n d z e r o t h e m
* @url http : //www.espruino.com/Reference#l_Trig_getErrorArray
* /
function getErrorArray ( ) : any ;
}
/* Class containing <a href="http:/ / www . puck - js . com " > Puck . js & # 39 ; s < / a > utility functions .
* @url http : //www.espruino.com/Reference#Puck
* /
declare function Puck ( ) : void ;
declare namespace Puck {
/ * T u r n o n t h e m a g n e t o m e t e r , t a k e a s i n g l e r e a d i n g , a n d t h e n t u r n i t o f f a g a i n .
* < p > An object of the form < code > { x , y , z } < / code > is returned containing magnetometer readings .
* Due to residual magnetism in the Puck and magnetometer itself , with
* no magnetic field the Puck will not return < code > { x :0 , y :0 , z :0 } < / code > . < / p >
* < p > Instead , it & # 39 ; s up to you to figure out what the & # 39 ; zero value & # 39 ; is for your
* Puck in your location and to then subtract that from the value returned . If
* you & # 39 ; re not trying to measure the Earth & # 39 ; s magnetic field then it & # 39 ; s a good idea
* to just take a reading at startup and use that . < / p >
* < p > With the aerial at the top of the board , the < code > y < / code > reading is vertical , < code > x < / code > is
* horizontal , and < code > z < / code > is through the board . < / p >
* < p > Readings are in increments of 0.1 micro Tesla ( uT ) . The Earth & # 39 ; s magnetic field
* varies from around 25 - 60 uT , so the reading will vary by 250 to 600 depending
* on location . < / p >
* @url http : //www.espruino.com/Reference#l_Puck_mag
* /
function mag ( ) : any ;
/ * T u r n o n t h e m a g n e t o m e t e r , t a k e a s i n g l e t e m p e r a t u r e r e a d i n g f r o m t h e M A G 3 1 1 0 c h i p , a n d t h e n t u r n i t o f f a g a i n .
* ( If the magnetometer is already on , this just returns the last reading obtained )
* < code > E . getTemperature ( ) < / code > uses the microcontroller & # 39 ; s temperature sensor , but this uses the magnetometer & # 39 ; s .
* < p > The reading obtained is an integer ( so no decimal places ) , but the sensitivity is factory trimmed . to 1 & deg ; C , however the temperature
* offset isn & # 39 ; t - so absolute readings may still need calibrating . < / p >
* @url http : //www.espruino.com/Reference#l_Puck_magTemp
* /
function magTemp ( ) : number ;
/ * T u r n t h e m a g n e t o m e t e r o f f
* @url http : //www.espruino.com/Reference#l_Puck_magOff
* /
function magOff ( ) : void ;
/* Writes a register on the LIS3MDL / MAX3110 Magnetometer . Can be used for configuring advanced functions .
* < p > Check out < a href = "http://www.espruino.com/Puck.js#on-board-peripherals" > the Puck . js page on the magnetometer < / a >
* for more information and links to module s that use this function . < / p >
* @url http : //www.espruino.com/Reference#l_Puck_magWr
* /
function magWr ( reg : number , data : number ) : void ;
/* Reads a register from the LIS3MDL / MAX3110 Magnetometer . Can be used for configuring advanced functions .
* < p > Check out < a href = "http://www.espruino.com/Puck.js#on-board-peripherals" > the Puck . js page on the magnetometer < / a >
* for more information and links to module s that use this function . < / p >
* @url http : //www.espruino.com/Reference#l_Puck_magRd
* /
function magRd ( reg : number ) : number ;
/ * O n P u c k . j s v 2 . 0 t h i s w i l l u s e t h e o n - b o a r d P C T 2 0 7 5 T P t e m p e r a t u r e s e n s o r , b u t o n P u c k . j s t h e l e s s a c c u r a t e o n - c h i p T e m p e r a t u r e s e n s o r i s u s e d .
* @url http : //www.espruino.com/Reference#l_Puck_getTemperature
* /
function getTemperature ( ) : number ;
/ * T u r n t h e a c c e l e r o m e t e r o f f a f t e r i t h a s b e e n t u r n e d o n b y < c o d e > P u c k . a c c e l O n ( ) < / c o d e > .
* < p > Check out < a href = "http://www.espruino.com/Puck.js#on-board-peripherals" > the Puck . js page on the accelerometer < / a >
* for more information . < / p >
* @url http : //www.espruino.com/Reference#l_Puck_accelOff
* /
function accelOff ( ) : void ;
/ * T u r n o n t h e a c c e l e r o m e t e r , t a k e a s i n g l e r e a d i n g , a n d t h e n t u r n i t o f f a g a i n .
* The values reported are the raw values from the chip . In normal configuration :
* < ul >
* < li > accelerometer : full - scale ( 32768 ) is 4 g , so you need to divide by 8192 to get correctly scaled values < / li >
* < li > gyro : full - scale ( 32768 ) is 245 dps , so you need to divide by 134 to get correctly scaled values < / li >
* < / ul >
* If taking more than one reading , we & # 39 ; d suggest you use < code > Puck . accelOn ( ) < / code > and the < code > Puck . accel < / code > event .
* @url http : //www.espruino.com/Reference#l_Puck_accel
* /
function accel ( ) : any ;
/ * W r i t e s a r e g i s t e r o n t h e L S M 6 D S 3 T R - C A c c e l e r o m e t e r . C a n b e u s e d f o r c o n f i g u r i n g a d v a n c e d f u n c t i o n s .
* < p > Check out < a href = "http://www.espruino.com/Puck.js#on-board-peripherals" > the Puck . js page on the accelerometer < / a >
* for more information and links to module s that use this function . < / p >
* @url http : //www.espruino.com/Reference#l_Puck_accelWr
* /
function accelWr ( reg : number , data : number ) : void ;
/ * R e a d s a r e g i s t e r f r o m t h e L S M 6 D S 3 T R - C A c c e l e r o m e t e r . C a n b e u s e d f o r c o n f i g u r i n g a d v a n c e d f u n c t i o n s .
* < p > Check out < a href = "http://www.espruino.com/Puck.js#on-board-peripherals" > the Puck . js page on the accelerometer < / a >
* for more information and links to module s that use this function . < / p >
* @url http : //www.espruino.com/Reference#l_Puck_accelRd
* /
function accelRd ( reg : number ) : number ;
/ * < p > T r a n s m i t t h e g i v e n s e t o f I R p u l s e s - d a t a s h o u l d b e a n a r r a y o f p u l s e t i m e s
* in milliseconds ( as < code > [ on , off , on , off , on , etc ] < / code > ) . < / p >
* < p > For example < code > Puck . IR ( pulseTimes ) < / code > - see < a href = "http://www.espruino.com/Puck.js+Infrared" > http : //www.espruino.com/Puck.js+Infrared</a>
* for a full example . < / p >
* < p > You can also attach an external LED to Puck . js , in which case
* you can just execute < code > Puck . IR ( pulseTimes , led_cathode , led_anode ) < / code > < / p >
* < p > It is also possible to just supply a single pin for IR transmission
* with < code > Puck . IR ( pulseTimes , led_anode ) < / code > ( on 2 v05 and above ) . < / p >
* @url http : //www.espruino.com/Reference#l_Puck_IR
* /
function IR ( data : any , cathode : Pin , anode : Pin ) : void ;
/ * C a p a c i t i v e s e n s e - t h e h i g h e r t h e c a p a c i t a n c e , t h e h i g h e r t h e n u m b e r r e t u r n e d .
* < p > If called without arguments , a value depending on the capacitance of what is
* attached to pin D11 will be returned . If you attach a length of wire to D11 ,
* you & # 39 ; ll be able to see a higher value returned when your hand is near the wire
* than when it is away . < / p >
* < p > You can also supply pins to use yourself , however if you do this then
* the TX pin must be connected to RX pin and sense plate via a roughly 1 MOhm
* resistor . < / p >
* < p > When not supplying pins , Puck . js uses an internal resistor between D12 ( tx )
* and D11 ( rx ) . < / p >
* @url http : //www.espruino.com/Reference#l_Puck_capSense
* /
function capSense ( tx : Pin , rx : Pin ) : number ;
/ * R e t u r n a l i g h t v a l u e b a s e d o n t h e l i g h t t h e r e d L E D i s s e e i n g .
* < p > < strong > Note : < / strong > If called more than 5 times per second , the received light value
* may not be accurate . < / p >
* @url http : //www.espruino.com/Reference#l_Puck_light
* /
function light ( ) : number ;
/ * D E P R E C A T E D - P l e a s e u s e < c o d e > E . g e t B a t t e r y ( ) < / c o d e > i n s t e a d .
* < p > Return an approximate battery percentage remaining based on
* a normal CR2032 battery ( 2.8 - 2.2 v ) . < / p >
* @url http : //www.espruino.com/Reference#l_Puck_getBatteryPercentage
* /
function getBatteryPercentage ( ) : number ;
/ * < p > R u n a s e l f - t e s t , a n d r e t u r n t r u e f o r a p a s s . T h i s c h e c k s f o r s h o r t s
* between pins , so your Puck shouldn & # 39 ; t have anything connected to it . < / p >
* < p > < strong > Note : < / strong > This self - test auto starts if you hold the button on your Puck
* down while inserting the battery , leave it pressed for 3 seconds ( while
* the green LED is lit ) and release it soon after all LEDs turn on . 5
* red blinks is a fail , 5 green is a pass . < / p >
* < p > If the self test fails , it & # 39 ; ll set the Puck . js Bluetooth advertising name
* to < code > Puck . js ! ERR < / code > where ERR is a 3 letter error code . < / p >
* @url http : //www.espruino.com/Reference#l_Puck_selfTest
* /
function selfTest ( ) : boolean ;
}
/* @url http:/ / www . espruino . com / Reference # l_CC3000_undefined
* /
declare function CC3000 ( ) : void ;
declare namespace CC3000 {
/ * I n i t i a l i s e t h e C C 3 0 0 0 a n d r e t u r n a W L A N o b j e c t
* @url http : //www.espruino.com/Reference#l_CC3000_connect
* /
function connect ( spi : any , cs : Pin , en : Pin , irq : Pin ) : WLAN ;
}
/ * A n i n s t a n t i a t i o n o f a W i F i n e t w o r k a d a p t o r
* @url http : //www.espruino.com/Reference#WLAN
* /
declare function WLAN ( ) : void ;
type WLAN = {
/ * C o n n e c t t o a w i r e l e s s n e t w o r k
* @url http : //www.espruino.com/Reference#l_WLAN_connect
* /
connect : ( ap : any , key : any , callback : any ) = > boolean ;
/ * C o m p l e t e l y u n i n i t i a l i s e a n d p o w e r d o w n t h e C C 3 0 0 0 . A f t e r t h i s y o u & # 3 9 ; l l h a v e t o u s e < c o d e > r e q u i r e ( & q u o t ; C C 3 0 0 0 & q u o t ; ) . c o n n e c t ( ) < / c o d e > a g a i n .
* @url http : //www.espruino.com/Reference#l_WLAN_disconnect
* /
disconnect : ( ) = > void ;
/ * C o m p l e t e l y u n i n i t i a l i s e a n d p o w e r d o w n t h e C C 3 0 0 0 , t h e n r e c o n n e c t t o t h e o l d a c c e s s p o i n t .
* @url http : //www.espruino.com/Reference#l_WLAN_reconnect
* /
reconnect : ( ) = > void ;
/ * G e t t h e c u r r e n t I P a d d r e s s
* @url http : //www.espruino.com/Reference#l_WLAN_getIP
* /
getIP : ( ) = > any ;
/ * S e t t h e c u r r e n t I P a d d r e s s f o r g e t a n I P f r o m D H C P ( i f n o o p t i o n s o b j e c t i s s p e c i f i e d ) .
* < strong > Note : < / strong > Changes are written to non - volatile memory , but will only take effect after calling < code > wlan . reconnect ( ) < / code >
* @url http : //www.espruino.com/Reference#l_WLAN_setIP
* /
setIP : ( options : any ) = > boolean ;
}
/ * < p > T h i s l i b r a r y i m p l e m e n t s a t e l n e t c o n s o l e f o r t h e E s p r u i n o i n t e r p r e t e r . I t r e q u i r e s a n e t w o r k
* connection , e . g . Wifi , and < strong > currently only functions on the ESP8266 and on Linux < / strong > . It uses
* port 23 on the ESP8266 and port 2323 on Linux . < / p >
* < strong > Note : < / strong > To enable on Linux , run < code > . / espruino -- telnet < / code >
* @url http : //www.espruino.com/Reference#l_TelnetServer_undefined
* /
declare function TelnetServer ( ) : void ;
declare namespace TelnetServer {
/* @url http:/ / www . espruino . com / Reference # l_TelnetServer_setOptions
* /
function setOptions ( options : any ) : void ;
}
/* Class containing utility functions for the <a href="http:/ / www . espruino . com / EspruinoESP8266 " > ESP8266 < / a >
* @url http : //www.espruino.com/Reference#ESP8266
* /
declare function ESP8266 ( ) : void ;
declare namespace ESP8266 {
/ * < s t r o n g > D E P R E C A T E D < / s t r o n g > - p l e a s e u s e < c o d e > W i f i . p i n g < / c o d e > i n s t e a d .
* Perform a network ping request . The parameter can be either a String or a numeric IP address .
* @url http : //www.espruino.com/Reference#l_ESP8266_ping
* /
function ping ( ipAddr : any , pingCallback : any ) : void ;
/ * P e r f o r m a h a r d w a r e r e s e t / r e b o o t o f t h e e s p 8 2 6 6 .
* @url http : //www.espruino.com/Reference#l_ESP8266_reboot
* /
function reboot ( ) : void ;
/ * A t b o o t t i m e t h e e s p 8 2 6 6 & # 3 9 ; s f i r m w a r e c a p t u r e s t h e c a u s e o f t h e r e s e t / r e b o o t . T h i s f u n c t i o n r e t u r n s t h i s i n f o r m a t i o n i n a n o b j e c t w i t h t h e f o l l o w i n g f i e l d s :
* < ul >
* < li > < code > reason < / code > : & quot ; power on & quot ; , & quot ; wdt reset & quot ; , & quot ; exception & quot ; , & quot ; soft wdt & quot ; , & quot ; restart & quot ; , & quot ; deep sleep & quot ; , or & quot ; reset pin & quot ; < / li >
* < li > < code > exccause < / code > : exception cause < / li >
* < li > < code > epc1 < / code > , < code > epc2 < / code > , < code > epc3 < / code > : instruction pointers < / li >
* < li > < code > excvaddr < / code > : address being accessed < / li >
* < li > < code > depc < / code > : ( ? ) < / li >
* < / ul >
* @url http : //www.espruino.com/Reference#l_ESP8266_getResetInfo
* /
function getResetInfo ( ) : RstInfo ;
/ * E n a b l e o r d i s a b l e t h e l o g g i n g o f d e b u g i n f o r m a t i o n . A v a l u e o f < c o d e > t r u e < / c o d e > e n a b l e s d e b u g l o g g i n g w h i l e a v a l u e o f < c o d e > f a l s e < / c o d e > d i s a b l e s d e b u g l o g g i n g . D e b u g o u t p u t i s s e n t t o U A R T 1 ( g p i o 2 ) .
* @url http : //www.espruino.com/Reference#l_ESP8266_logDebug
* /
function logDebug ( enable : boolean ) : void ;
/ * S e t t h e d e b u g l o g g i n g m o d e . I t c a n b e d i s a b l e d ( w h i c h f r e e s ~ 1 . 2 K B o f h e a p ) , e n a b l e d i n - m e m o r y o n l y , o r i n - m e m o r y a n d o u t p u t t o a U A R T .
* @url http : //www.espruino.com/Reference#l_ESP8266_setLog
* /
function setLog ( mode : number ) : void ;
/ * P r i n t s t h e c o n t e n t s o f t h e d e b u g l o g t o t h e c o n s o l e .
* @url http : //www.espruino.com/Reference#l_ESP8266_printLog
* /
function printLog ( ) : void ;
/ * R e t u r n s o n e l i n e f r o m t h e l o g o r u p t o 1 2 8 c h a r a c t e r s .
* @url http : //www.espruino.com/Reference#l_ESP8266_readLog
* /
function readLog ( ) : void ;
/ * D u m p s i n f o a b o u t a l l s o c k e t s t o t h e l o g . T h i s i s f o r t r o u b l e s h o o t i n g t h e s o c k e t i m p l e m e n t a t i o n .
* @url http : //www.espruino.com/Reference#l_ESP8266_dumpSocketInfo
* /
function dumpSocketInfo ( ) : void ;
/ * < p > < s t r o n g > N o t e : < / s t r o n g > T h i s i s d e p r e c a t e d . U s e < c o d e > E . s e t C l o c k ( 8 0 / 1 6 0 ) < / c o d e >
* < strong > Note : < / strong >
* Set the operating frequency of the ESP8266 processor . The default is 160 Mhz . < / p >
* < strong > Warning < / strong > : changing the cpu frequency affects the timing of some I / O operations , notably of software SPI and I2C , so things may be a bit slower at 80 Mhz .
* @url http : //www.espruino.com/Reference#l_ESP8266_setCPUFreq
* /
function setCPUFreq ( freq : any ) : void ;
/ * R e t u r n s a n o b j e c t t h a t c o n t a i n s d e t a i l s a b o u t t h e s t a t e o f t h e E S P 8 2 6 6 w i t h t h e f o l l o w i n g f i e l d s :
* < ul >
* < li > < code > sdkVersion < / code > - Version of the SDK . < / li >
* < li > < code > cpuFrequency < / code > - CPU operating frequency in Mhz . < / li >
* < li > < code > freeHeap < / code > - Amount of free heap in bytes . < / li >
* < li > < code > maxCon < / code > - Maximum number of concurrent connections . < / li >
* < li > < code > flashMap < / code > - Configured flash size & amp ; map : & # 39 ; 512KB :256 / 256 & # 39 ; . . & # 39 ; 4MB :512 / 512 & # 39 ; < / li >
* < li > < code > flashKB < / code > - Configured flash size in KB as integer < / li >
* < li > < code > flashChip < / code > - Type of flash chip as string with manufacturer & amp ; chip , ex : & # 39 ; 0xEF 0x4016 ` </li>
* < / ul >
* @url http : //www.espruino.com/Reference#l_ESP8266_getState
* /
function getState ( ) : any ;
/ * < s t r o n g > N o t e : < / s t r o n g > T h i s i s d e p r e c a t e d . U s e < c o d e > r e q u i r e ( & q u o t ; F l a s h & q u o t ; ) . g e t F r e e ( ) < / c o d e >
* @url http : //www.espruino.com/Reference#l_ESP8266_getFreeFlash
* /
function getFreeFlash ( ) : any ;
/* @url http:/ / www . espruino . com / Reference # l_ESP8266_crc32
* /
function crc32 ( arrayOfData : any ) : any ;
/ * < s t r o n g > T h i s f u n c t i o n i s d e p r e c a t e d . < / s t r o n g > P l e a s e u s e < c o d e > r e q u i r e ( & q u o t ; n e o p i x e l & q u o t ; ) . w r i t e ( p i n , d a t a ) < / c o d e > i n s t e a d
* @url http : //www.espruino.com/Reference#l_ESP8266_neopixelWrite
* /
function neopixelWrite ( pin : Pin , arrayOfData : any ) : void ;
/ * < p > P u t t h e E S P 8 2 6 6 i n t o & # 3 9 ; d e e p s l e e p & # 3 9 ; f o r t h e g i v e n n u m b e r o f m i c r o s e c o n d s ,
* reducing power consumption drastically . < / p >
* meaning of option values :
* 0 - the 108 th Byte of init parameter decides whether RF calibration will be performed or not .
* 1 - run RF calibration after waking up . Power consumption is high .
* 2 - no RF calibration after waking up . Power consumption is low .
* 4 - no RF after waking up . Power consumption is the lowest .
* < p > < strong > Note : < / strong > unlike normal Espruino boards & # 39 ; & # 39 ; deep sleep & # 39 ; mode , ESP8266 deep sleep actually turns off the processor . After the given number of microseconds have elapsed , the ESP8266 will restart as if power had been turned off and then back on . < em > All contents of RAM will be lost < / em > .
* Connect GPIO 16 to RST to enable wakeup . < / p >
* < strong > Special : < / strong > 0 microseconds cause sleep forever until external wakeup RST pull down occurs .
* @url http : //www.espruino.com/Reference#l_ESP8266_deepSleep
* /
function deepSleep ( micros : any , option : any ) : void ;
}
/ * T h i s l i b r a r y a l l o w s y o u t o c r e a t e h t t p s e r v e r s a n d m a k e h t t p r e q u e s t s
* In order to use this , you will need an extra module to get network connectivity such as the < a href = "/CC3000" > TI CC3000 < / a > or < a href = "/WIZnet" > WIZnet W5500 < / a > .
* This is designed to be a cut - down version of the < a href = "http://nodejs.org/api/http.html" > node . js library < / a > . Please see the < a href = "/Internet" > Internet < / a > page for more information on how to use it .
* @url http : //www.espruino.com/Reference#l_http_undefined
* /
declare function http ( ) : void ;
declare namespace http {
/ * C r e a t e a n H T T P S e r v e r
* When a request to the server is made , the callback is called . In the callback you can use the methods on the response ( < code > httpSRs < / code > ) to send data . You can also add < code > request . on ( & # 39 ; data & # 39 ; , function ( ) { . . . } ) < / code > to listen for POSTed data
* @url http : //www.espruino.com/Reference#l_http_createServer
* /
function createServer ( callback : any ) : httpSrv ;
}
/ * T h e H T T P s e r v e r c r e a t e d b y < c o d e > r e q u i r e ( & # 3 9 ; h t t p & # 3 9 ; ) . c r e a t e S e r v e r < / c o d e >
* @url http : //www.espruino.com/Reference#httpSrv
* /
declare function httpSrv ( ) : void ;
type httpSrv = {
/ * S t a r t l i s t e n i n g f o r n e w H T T P c o n n e c t i o n s o n t h e g i v e n p o r t
* @url http : //www.espruino.com/Reference#l_httpSrv_listen
* /
listen : ( port : number ) = > any ;
/ * S t o p l i s t e n i n g f o r n e w H T T P c o n n e c t i o n s
* @url http : //www.espruino.com/Reference#l_httpSrv_close
* /
close : ( ) = > void ;
}
/ * T h e H T T P s e r v e r r e q u e s t
* @url http : //www.espruino.com/Reference#httpSRq
* /
declare function httpSRq ( ) : void ;
type httpSRq = {
/ * T h e h e a d e r s t o s e n t t o t h e s e r v e r w i t h t h i s H T T P r e q u e s t .
* @url http : //www.espruino.com/Reference#l_httpSRq_headers
* /
headers : any
/ * T h e H T T P m e t h o d u s e d w i t h t h i s r e q u e s t . O f t e n < c o d e > & q u o t ; G E T & q u o t ; < / c o d e > .
* @url http : //www.espruino.com/Reference#l_httpSRq_method
* /
method : any
/ * T h e U R L r e q u e s t e d i n t h i s H T T P r e q u e s t , f o r i n s t a n c e :
* < ul >
* < li > < code > & quot ; / & q u o t ; < / c o d e > - t h e m a i n p a g e < / l i >
* < li > < code > & quot ; / f a v i c o n . i c o & q u o t ; < / c o d e > - t h e w e b p a g e & # 3 9 ; s i c o n < / l i >
* < / ul >
* @url http : //www.espruino.com/Reference#l_httpSRq_url
* /
url : any
/ * R e t u r n h o w m a n y b y t e s a r e a v a i l a b l e t o r e a d . I f t h e r e i s a l r e a d y a l i s t e n e r f o r d a t a , t h i s w i l l a l w a y s r e t u r n 0 .
* @url http : //www.espruino.com/Reference#l_httpSRq_available
* /
available : ( ) = > number ;
/ * R e t u r n a s t r i n g c o n t a i n i n g c h a r a c t e r s t h a t h a v e b e e n r e c e i v e d
* @url http : //www.espruino.com/Reference#l_httpSRq_read
* /
read : ( chars : number ) = > any ;
/ * P i p e t h i s t o a s t r e a m ( a n o b j e c t w i t h a & # 3 9 ; w r i t e & # 3 9 ; m e t h o d )
* @url http : //www.espruino.com/Reference#l_httpSRq_pipe
* /
pipe : ( destination : any , options : any ) = > void ;
}
/ * T h e H T T P s e r v e r r e s p o n s e
* @url http : //www.espruino.com/Reference#httpSRs
* /
declare function httpSRs ( ) : void ;
type httpSRs = {
/ * < p > T h i s f u n c t i o n w r i t e s t h e < c o d e > d a t a < / c o d e > a r g u m e n t a s a s t r i n g . D a t a t h a t i s p a s s e d i n
* ( including arrays ) will be converted to a string with the normal JavaScript
* < code > toString < / code > method . For more information about sending binary data see < code > Socket . write < / code > < / p >
* @url http : //www.espruino.com/Reference#l_httpSRs_write
* /
write : ( data : any ) = > boolean ;
/ * S e e < c o d e > S o c k e t . w r i t e < / c o d e > f o r m o r e i n f o r m a t i o n a b o u t t h e d a t a a r g u m e n t
* @url http : //www.espruino.com/Reference#l_httpSRs_end
* /
end : ( data : any ) = > void ;
/ * < p > S e n d t h e g i v e n s t a t u s c o d e a n d h e a d e r s . I f n o t e x p l i c i t l y c a l l e d
* this will be done automatically the first time data is written
* to the response . < / p >
* < p > This cannot be called twice , or after data has already been sent
* in the response . < / p >
* @url http : //www.espruino.com/Reference#l_httpSRs_writeHead
* /
writeHead : ( statusCode : number , headers : any ) = > void ;
/ * S e t a v a l u e t o s e n d i n t h e h e a d e r o f t h i s H T T P r e s p o n s e . T h i s u p d a t e s t h e < c o d e > h t t p S R s . h e a d e r s < / c o d e > p r o p e r t y .
* Any headers supplied to < code > writeHead < / code > will overwrite any headers with the same name .
* @url http : //www.espruino.com/Reference#l_httpSRs_setHeader
* /
setHeader : ( name : any , value : any ) = > void ;
}
/ * T h e H T T P c l i e n t r e q u e s t , r e t u r n e d b y < c o d e > h t t p . r e q u e s t ( ) < / c o d e > a n d < c o d e > h t t p . g e t ( ) < / c o d e > .
* @url http : //www.espruino.com/Reference#httpCRq
* /
declare function httpCRq ( ) : void ;
type httpCRq = {
/ * < p > T h i s f u n c t i o n w r i t e s t h e < c o d e > d a t a < / c o d e > a r g u m e n t a s a s t r i n g . D a t a t h a t i s p a s s e d i n
* ( including arrays ) will be converted to a string with the normal JavaScript
* < code > toString < / code > method . For more information about sending binary data see < code > Socket . write < / code > < / p >
* @url http : //www.espruino.com/Reference#l_httpCRq_write
* /
write : ( data : any ) = > boolean ;
/ * F i n i s h t h i s H T T P r e q u e s t - o p t i o n a l d a t a t o a p p e n d a s a n a r g u m e n t
* See < code > Socket . write < / code > for more information about the data argument
* @url http : //www.espruino.com/Reference#l_httpCRq_end
* /
end : ( data : any ) = > void ;
}
/ * T h e H T T P c l i e n t r e s p o n s e , p a s s e d t o t h e c a l l b a c k o f < c o d e > h t t p . r e q u e s t ( ) < / c o d e > a n < c o d e > h t t p . g e t ( ) < / c o d e > .
* @url http : //www.espruino.com/Reference#httpCRs
* /
declare function httpCRs ( ) : void ;
type httpCRs = {
/ * T h e h e a d e r s r e c e i v e d a l o n g w i t h t h e H T T P r e s p o n s e
* @url http : //www.espruino.com/Reference#l_httpCRs_headers
* /
headers : any
/ * T h e H T T P r e s p o n s e & # 3 9 ; s s t a t u s c o d e - u s u a l l y < c o d e > & q u o t ; 2 0 0 & q u o t ; < / c o d e > i f a l l w e n t w e l l
* @url http : //www.espruino.com/Reference#l_httpCRs_statusCode
* /
statusCode : any
/ * T h e H T T P r e s p o n s e & # 3 9 ; s s t a t u s m e s s a g e - U s u a l l y < c o d e > & q u o t ; O K & q u o t ; < / c o d e > i f a l l w e n t w e l l
* @url http : //www.espruino.com/Reference#l_httpCRs_statusMessage
* /
statusMessage : any
/ * T h e H T T P v e r s i o n r e p o r t e d b a c k b y t h e s e r v e r - u s u a l l y < c o d e > & q u o t ; 1 . 1 & q u o t ; < / c o d e >
* @url http : //www.espruino.com/Reference#l_httpCRs_httpVersion
* /
httpVersion : any
/ * R e t u r n h o w m a n y b y t e s a r e a v a i l a b l e t o r e a d . I f t h e r e i s a & # 3 9 ; d a t a & # 3 9 ; e v e n t h a n d l e r , t h i s w i l l a l w a y s r e t u r n 0 .
* @url http : //www.espruino.com/Reference#l_httpCRs_available
* /
available : ( ) = > number ;
/ * R e t u r n a s t r i n g c o n t a i n i n g c h a r a c t e r s t h a t h a v e b e e n r e c e i v e d
* @url http : //www.espruino.com/Reference#l_httpCRs_read
* /
read : ( chars : number ) = > any ;
/ * P i p e t h i s t o a s t r e a m ( a n o b j e c t w i t h a & # 3 9 ; w r i t e & # 3 9 ; m e t h o d )
* @url http : //www.espruino.com/Reference#l_httpCRs_pipe
* /
pipe : ( destination : any , options : any ) = > void ;
}
/ * L i b r a r y t h a t i n i t i a l i s e s a n e t w o r k d e v i c e t h a t c a l l s i n t o J a v a S c r i p t
* @url http : //www.espruino.com/Reference#l_NetworkJS_undefined
* /
declare function NetworkJS ( ) : void ;
/ * L i b r a r y f o r c o m m u n i c a t i o n w i t h t h e W I Z n e t E t h e r n e t m o d u l e
* @url http : //www.espruino.com/Reference#l_WIZnet_undefined
* /
declare function WIZnet ( ) : void ;
declare namespace WIZnet {
/ * I n i t i a l i s e t h e W I Z n e t m o d u l e a n d r e t u r n a n E t h e r n e t o b j e c t
* @url http : //www.espruino.com/Reference#l_WIZnet_connect
* /
function connect ( spi : any , cs : Pin ) : Ethernet ;
}
/ * A n i n s t a n t i a t i o n o f a n E t h e r n e t n e t w o r k a d a p t o r
* @url http : //www.espruino.com/Reference#Ethernet
* /
declare function Ethernet ( ) : void ;
type Ethernet = {
/ * G e t t h e c u r r e n t I P a d d r e s s , s u b n e t , g a t e w a y a n d m a c a d d r e s s .
* @url http : //www.espruino.com/Reference#l_Ethernet_getIP
* /
getIP : ( options : any ) = > any ;
/ * S e t t h e c u r r e n t I P a d d r e s s o r g e t a n I P f r o m D H C P ( i f n o o p t i o n s o b j e c t i s s p e c i f i e d )
* < p > If & # 39 ; mac & # 39 ; is specified as an option , it must be a string of the form < code > & quot ; 00 :01 : 02 :03 : 04 :05 & quot ; < / code >
* The default mac is 00 :08 : DC :01 : 02 :03. < / p >
* @url http : //www.espruino.com/Reference#l_Ethernet_setIP
* /
setIP : ( options : any , callback : any ) = > boolean ;
/ * < p > S e t h o s t n a m e a l l o w t o s e t t h e h o s n a m e u s e d d u r i n g t h e d h c p r e q u e s t .
* min 8 and max 12 char , best set before calling < code > eth . setIP ( ) < / code >
* Default is WIZnet010203 , 010203 is the default nic as part of the mac .
* Best to set the hosname before calling setIP ( ) . < / p >
* @url http : //www.espruino.com/Reference#l_Ethernet_setHostname
* /
setHostname : ( hostname : any , callback : any ) = > boolean ;
/ * R e t u r n s t h e h o s t n a m e
* @url http : //www.espruino.com/Reference#l_Ethernet_getHostname
* /
getHostname : ( callback : any ) = > any ;
/ * G e t t h e c u r r e n t s t a t u s o f t h e e t h e r n e t d e v i c e
* @url http : //www.espruino.com/Reference#l_Ethernet_getStatus
* /
getStatus : ( options : any ) = > any ;
}
/ * T h i s c l a s s h e l p s t o c o n v e r t U R L s i n t o O b j e c t s o f i n f o r m a t i o n r e a d y f o r h t t p . r e q u e s t / g e t
* @url http : //www.espruino.com/Reference#url
* /
declare function url ( ) : void ;
declare namespace url {
/ * A u t i l i t y f u n c t i o n t o s p l i t a U R L i n t o p a r t s
* This is useful in web servers for instance when handling a request .
* For instance < code > url . parse ( & quot ; / a ? b = c & a m p ; d = e & q u o t ; , t r u e ) < / c o d e > r e t u r n s < c o d e > { & q u o t ; m e t h o d & q u o t ; : & q u o t ; G E T & q u o t ; , & q u o t ; h o s t & q u o t ; : & q u o t ; & q u o t ; , & q u o t ; p a t h & q u o t ; : & q u o t ; / a ? b = c & a m p ; d = e & q u o t ; , & q u o t ; p a t h n a m e & q u o t ; : & q u o t ; / a & q u o t ; , & q u o t ; s e a r c h & q u o t ; : & q u o t ; ? b = c & a m p ; d = e & q u o t ; , & q u o t ; p o r t & q u o t ; : 8 0 , & q u o t ; q u e r y & q u o t ; : { & q u o t ; b & q u o t ; : & q u o t ; c & q u o t ; , & q u o t ; d & q u o t ; : & q u o t ; e & q u o t ; } } < / c o d e >
* @url http : //www.espruino.com/Reference#l_url_parse
* /
function parse ( urlStr : any , parseQuery : boolean ) : any ;
}
/ * T h i s l i b r a r y a l l o w s y o u t o c r e a t e T C P I P s e r v e r s a n d c l i e n t s
* In order to use this , you will need an extra module to get network connectivity .
* This is designed to be a cut - down version of the < a href = "http://nodejs.org/api/net.html" > node . js library < / a > . Please see the < a href = "/Internet" > Internet < / a > page for more information on how to use it .
* @url http : //www.espruino.com/Reference#l_net_undefined
* /
declare function net ( ) : void ;
declare namespace net {
/ * C r e a t e a S e r v e r
* When a request to the server is made , the callback is called . In the callback you can use the methods on the connection to send data . You can also add < code > connection . on ( & # 39 ; data & # 39 ; , function ( ) { . . . } ) < / code > to listen for received data
* @url http : //www.espruino.com/Reference#l_net_createServer
* /
function createServer ( callback : any ) : Server ;
/ * C r e a t e a T C P s o c k e t c o n n e c t i o n
* @url http : //www.espruino.com/Reference#l_net_connect
* /
function connect ( options : any , callback : any ) : Socket ;
}
/ * T h e s o c k e t s e r v e r c r e a t e d b y < c o d e > r e q u i r e ( & # 3 9 ; n e t & # 3 9 ; ) . c r e a t e S e r v e r < / c o d e >
* @url http : //www.espruino.com/Reference#Server
* /
declare function Server ( ) : void ;
type Server = {
/ * S t a r t l i s t e n i n g f o r n e w c o n n e c t i o n s o n t h e g i v e n p o r t
* @url http : //www.espruino.com/Reference#l_Server_listen
* /
listen : ( port : number ) = > any ;
/ * S t o p l i s t e n i n g f o r n e w c o n n e c t i o n s
* @url http : //www.espruino.com/Reference#l_Server_close
* /
close : ( ) = > void ;
}
/ * A n a c t u a l s o c k e t c o n n e c t i o n - a l l o w i n g t r a n s m i t / r e c e i v e o f T C P d a t a
* @url http : //www.espruino.com/Reference#Socket
* /
declare function Socket ( ) : void ;
type Socket = {
/ * R e t u r n h o w m a n y b y t e s a r e a v a i l a b l e t o r e a d . I f t h e r e i s a l r e a d y a l i s t e n e r f o r d a t a , t h i s w i l l a l w a y s r e t u r n 0 .
* @url http : //www.espruino.com/Reference#l_Socket_available
* /
available : ( ) = > number ;
/ * R e t u r n a s t r i n g c o n t a i n i n g c h a r a c t e r s t h a t h a v e b e e n r e c e i v e d
* @url http : //www.espruino.com/Reference#l_Socket_read
* /
read : ( chars : number ) = > any ;
/ * P i p e t h i s t o a s t r e a m ( a n o b j e c t w i t h a & # 3 9 ; w r i t e & # 3 9 ; m e t h o d )
* @url http : //www.espruino.com/Reference#l_Socket_pipe
* /
pipe : ( destination : any , options : any ) = > void ;
/ * C l o s e t h i s s o c k e t - o p t i o n a l d a t a t o a p p e n d a s a n a r g u m e n t .
* See < code > Socket . write < / code > for more information about the data argument
* @url http : //www.espruino.com/Reference#l_Socket_end
* /
end : ( data : any ) = > void ;
}
/ * T h i s l i b r a r y a l l o w s y o u t o c r e a t e U D P / D A T A G R A M s e r v e r s a n d c l i e n t s
* In order to use this , you will need an extra module to get network connectivity .
* This is designed to be a cut - down version of the < a href = "http://nodejs.org/api/dgram.html" > node . js library < / a > . Please see the < a href = "/Internet" > Internet < / a > page for more information on how to use it .
* @url http : //www.espruino.com/Reference#l_dgram_undefined
* /
declare function dgram ( ) : void ;
declare namespace dgram {
/ * C r e a t e a U D P s o c k e t
* @url http : //www.espruino.com/Reference#l_dgram_createSocket
* /
function createSocket ( type : any , callback : any ) : dgramSocket ;
}
/ * A n a c t u a l s o c k e t c o n n e c t i o n - a l l o w i n g t r a n s m i t / r e c e i v e o f T C P d a t a
* @url http : //www.espruino.com/Reference#dgramSocket
* /
declare function dgramSocket ( ) : void ;
type dgramSocket = {
/* @url http:/ / www . espruino . com / Reference # l_dgramSocket_send
* /
send : ( buffer : any , offset : any , length : any , args : any ) = > void ;
/* @url http:/ / www . espruino . com / Reference # l_dgramSocket_bind
* /
bind : ( port : number , callback : any ) = > any ;
/ * C l o s e t h e s o c k e t
* @url http : //www.espruino.com/Reference#l_dgramSocket_close
* /
close : ( ) = > void ;
/* @url http:/ / www . espruino . com / Reference # l_dgramSocket_addMembership
* /
addMembership : ( group : any , ip : any ) = > void ;
}
/ * T h i s l i b r a r y a l l o w s y o u t o c r e a t e T C P I P s e r v e r s a n d c l i e n t s u s i n g T L S e n c r y p t i o n
* In order to use this , you will need an extra module to get network connectivity .
* This is designed to be a cut - down version of the < a href = "http://nodejs.org/api/tls.html" > node . js library < / a > . Please see the < a href = "/Internet" > Internet < / a > page for more information on how to use it .
* @url http : //www.espruino.com/Reference#l_tls_undefined
* /
declare function tls ( ) : void ;
/ * S i m p l e l i b r a r y f o r c o m p r e s s i o n / d e c o m p r e s s i o n u s i n g < a h r e f = " h t t p s : / / g i t h u b . c o m / a t o m i c o b j e c t / h e a t s h r i n k " > h e a t s h r i n k < / a > , a n < a h r e f = " h t t p s : / / e n . w i k i p e d i a . o r g / w i k i / L e m p e l % E 2 % 8 0 % 9 3 Z i v % E 2 % 8 0 % 9 3 S t o r e r % E 2 % 8 0 % 9 3 S z y m a n s k i " > L Z S S < / a > c o m p r e s s i o n t o o l .
* Espruino uses heatshrink internally to compress RAM down to fit in Flash memory when < code > save ( ) < / code > is used . This just exposes that functionality .
* Functions here take and return buffers of data . There is no support for streaming , so both the compressed and decompressed data must be able to fit in memory at the same time .
* @url http : //www.espruino.com/Reference#l_heatshrink_undefined
* /
declare function heatshrink ( ) : void ;
declare namespace heatshrink {
/* @url http:/ / www . espruino . com / Reference # l_heatshrink_compress
* /
function compress ( data : any ) : ArrayBuffer ;
/* @url http:/ / www . espruino . com / Reference # l_heatshrink_decompress
* /
function decompress ( data : any ) : ArrayBuffer ;
}
/ * C r e a t e s a Q u e u e O b j e c t
* @url http : //www.espruino.com/Reference#l_Queue_Queue
* /
declare function Queue ( queueName : any ) : any ;
type Queue = {
/ * r e a d s o n e c h a r a c t e r f r o m q u e u e , i f a v a i l a b l e
* @url http : //www.espruino.com/Reference#l_Queue_read
* /
read : ( ) = > void ;
/ * W r i t e s o n e c h a r a c t e r t o q u e u e
* @url http : //www.espruino.com/Reference#l_Queue_writeChar
* /
writeChar : ( char : any ) = > void ;
/ * l o g s l i s t o f q u e u e s
* @url http : //www.espruino.com/Reference#l_Queue_log
* /
log : ( ) = > void ;
}
/ * C r e a t e s a T a s k O b j e c t
* @url http : //www.espruino.com/Reference#l_Task_Task
* /
declare function Task ( taskName : any ) : any ;
type Task = {
/ * S u s p e n d t a s k , b e c a r e f u l n o t t o s u s p e n d E s p r u i n o t a s k i t s e l f
* @url http : //www.espruino.com/Reference#l_Task_suspend
* /
suspend : ( ) = > void ;
/ * R e s u m e s a s u s p e n d e d t a s k
* @url http : //www.espruino.com/Reference#l_Task_resume
* /
resume : ( ) = > void ;
/ * r e t u r n s n a m e o f a c t u a l t a s k
* @url http : //www.espruino.com/Reference#l_Task_getCurrent
* /
getCurrent : ( ) = > any ;
/ * S e n d s a b i n a r y n o t i f y t o t a s k
* @url http : //www.espruino.com/Reference#l_Task_notify
* /
notify : ( ) = > void ;
/ * l o g s l i s t o f t a s k s
* @url http : //www.espruino.com/Reference#l_Task_log
* /
log : ( ) = > void ;
}
/ * C r e a t e s a T i m e r O b j e c t
* @url http : //www.espruino.com/Reference#l_Timer_Timer
* /
declare function Timer ( timerName : any , group : number , index : number , isrIndex : number ) : any ;
type Timer = {
/ * S t a r t s a t i m e r
* @url http : //www.espruino.com/Reference#l_Timer_start
* /
start : ( duration : number ) = > void ;
/ * R e s c h e d u l e s a t i m e r , n e e d s t o b e s t a r t e d a t l e a s t o n c e
* @url http : //www.espruino.com/Reference#l_Timer_reschedule
* /
reschedule : ( duration : number ) = > void ;
/ * l o g s l i s t o f t i m e r s
* @url http : //www.espruino.com/Reference#l_Timer_log
* /
log : ( ) = > void ;
}
/* Class containing utility functions for the <a href="http:/ / www . espruino . com / ESP32 " > ESP32 < / a >
* @url http : //www.espruino.com/Reference#ESP32
* /
declare function ESP32 ( ) : void ;
declare namespace ESP32 {
/* @url http:/ / www . espruino . com / Reference # l_ESP32_setAtten
* /
function setAtten ( pin : Pin , atten : number ) : void ;
/ * P e r f o r m a h a r d w a r e r e s e t / r e b o o t o f t h e E S P 3 2 .
* @url http : //www.espruino.com/Reference#l_ESP32_reboot
* /
function reboot ( ) : void ;
/ * P u t d e v i c e i n d e e p s l e e p s t a t e f o r & q u o t ; u s & q u o t ; m i c r o s e c o n d s .
* @url http : //www.espruino.com/Reference#l_ESP32_deepSleep
* /
function deepSleep ( us : number ) : void ;
/ * R e t u r n s a n o b j e c t t h a t c o n t a i n s d e t a i l s a b o u t t h e s t a t e o f t h e E S P 3 2 w i t h t h e f o l l o w i n g f i e l d s :
* < ul >
* < li > < code > sdkVersion < / code > - Version of the SDK . < / li >
* < li > < code > freeHeap < / code > - Amount of free heap in bytes . < / li >
* < li > < code > BLE < / code > - Status of BLE , enabled if true . < / li >
* < li > < code > Wifi < / code > - Status of Wifi , enabled if true . < / li >
* < li > < code > minHeap < / code > - Minimum heap , calculated by heap_caps_get_minimum_free_size < / li >
* < / ul >
* @url http : //www.espruino.com/Reference#l_ESP32_getState
* /
function getState ( ) : any ;
/* @url http:/ / www . espruino . com / Reference # l_ESP32_setBLE_Debug
* /
function setBLE_Debug ( level : number ) : void ;
/ * < p > S w i t c h e s B l u e t o o t h o f f / o n , r e m o v e s s a v e d c o d e f r o m F l a s h , r e s e t s t h e b o a r d ,
* and on restart creates jsVars depending on available heap ( actual additional 1800 ) < / p >
* @url http : //www.espruino.com/Reference#l_ESP32_enableBLE
* /
function enableBLE ( enable : boolean ) : void ;
/ * < p > S w i t c h e s W i f i o f f / o n , r e m o v e s s a v e d c o d e f r o m F l a s h , r e s e t s t h e b o a r d ,
* and on restart creates jsVars depending on available heap ( actual additional 3900 ) < / p >
* @url http : //www.espruino.com/Reference#l_ESP32_enableWifi
* /
function enableWifi ( enable : boolean ) : void ;
}
/ * T h i s i s t h e b u i l t - i n c l a s s f o r t h e A r d u i n o - s t y l e p i n n a m i n g s o n S T N u c l e o b o a r d s
* @url http : //www.espruino.com/Reference#Nucleo
* /
declare function Nucleo ( ) : void ;
declare namespace Nucleo {
/* @url http:/ / www . espruino . com / Reference # l_Nucleo_A0
* /
const A0 : Pin ;
/* @url http:/ / www . espruino . com / Reference # l_Nucleo_A1
* /
const A1 : Pin ;
/* @url http:/ / www . espruino . com / Reference # l_Nucleo_A2
* /
const A2 : Pin ;
/* @url http:/ / www . espruino . com / Reference # l_Nucleo_A3
* /
const A3 : Pin ;
/* @url http:/ / www . espruino . com / Reference # l_Nucleo_A4
* /
const A4 : Pin ;
/* @url http:/ / www . espruino . com / Reference # l_Nucleo_A5
* /
const A5 : Pin ;
/* @url http:/ / www . espruino . com / Reference # l_Nucleo_D0
* /
const D0 : Pin ;
/* @url http:/ / www . espruino . com / Reference # l_Nucleo_D1
* /
const D1 : Pin ;
/* @url http:/ / www . espruino . com / Reference # l_Nucleo_D2
* /
const D2 : Pin ;
/* @url http:/ / www . espruino . com / Reference # l_Nucleo_D3
* /
const D3 : Pin ;
/* @url http:/ / www . espruino . com / Reference # l_Nucleo_D4
* /
const D4 : Pin ;
/* @url http:/ / www . espruino . com / Reference # l_Nucleo_D5
* /
const D5 : Pin ;
/* @url http:/ / www . espruino . com / Reference # l_Nucleo_D6
* /
const D6 : Pin ;
/* @url http:/ / www . espruino . com / Reference # l_Nucleo_D7
* /
const D7 : Pin ;
/* @url http:/ / www . espruino . com / Reference # l_Nucleo_D8
* /
const D8 : Pin ;
/* @url http:/ / www . espruino . com / Reference # l_Nucleo_D9
* /
const D9 : Pin ;
/* @url http:/ / www . espruino . com / Reference # l_Nucleo_D10
* /
const D10 : Pin ;
/* @url http:/ / www . espruino . com / Reference # l_Nucleo_D11
* /
const D11 : Pin ;
/* @url http:/ / www . espruino . com / Reference # l_Nucleo_D12
* /
const D12 : Pin ;
/* @url http:/ / www . espruino . com / Reference # l_Nucleo_D13
* /
const D13 : Pin ;
/* @url http:/ / www . espruino . com / Reference # l_Nucleo_D14
* /
const D14 : Pin ;
/* @url http:/ / www . espruino . com / Reference # l_Nucleo_D15
* /
const D15 : Pin ;
}
/ * T h i s i s a b u i l t - i n c l a s s t o a l l o w y o u t o u s e t h e E S P 8 2 6 6 N o d e M C U b o a r d s & # 3 9 ; s p i n n a m i n g s t o a c c e s s p i n s . I t i s o n l y a v a i l a b l e o n E S P 8 2 6 6 - b a s e d b o a r d s .
* @url http : //www.espruino.com/Reference#NodeMCU
* /
declare function NodeMCU ( ) : void ;
declare namespace NodeMCU {
/* @url http:/ / www . espruino . com / Reference # l_NodeMCU_A0
* /
const A0 : Pin ;
/* @url http:/ / www . espruino . com / Reference # l_NodeMCU_D0
* /
const D0 : Pin ;
/* @url http:/ / www . espruino . com / Reference # l_NodeMCU_D1
* /
const D1 : Pin ;
/* @url http:/ / www . espruino . com / Reference # l_NodeMCU_D2
* /
const D2 : Pin ;
/* @url http:/ / www . espruino . com / Reference # l_NodeMCU_D3
* /
const D3 : Pin ;
/* @url http:/ / www . espruino . com / Reference # l_NodeMCU_D4
* /
const D4 : Pin ;
/* @url http:/ / www . espruino . com / Reference # l_NodeMCU_D5
* /
const D5 : Pin ;
/* @url http:/ / www . espruino . com / Reference # l_NodeMCU_D6
* /
const D6 : Pin ;
/* @url http:/ / www . espruino . com / Reference # l_NodeMCU_D7
* /
const D7 : Pin ;
/* @url http:/ / www . espruino . com / Reference # l_NodeMCU_D8
* /
const D8 : Pin ;
/* @url http:/ / www . espruino . com / Reference # l_NodeMCU_D9
* /
const D9 : Pin ;
/* @url http:/ / www . espruino . com / Reference # l_NodeMCU_D10
* /
const D10 : Pin ;
}
/ * C r e a t e a s o f t w a r e S e r i a l p o r t . T h i s h a s l i m i t e d f u n c t i o n a l i t y ( o n l y l o w b a u d r a t e s ) , b u t i t c a n w o r k o n a n y p i n s .
* Use < code > Serial . setup < / code > to configure this port .
* @url http : //www.espruino.com/Reference#l_Serial_Serial
* /
declare function Serial ( ) : any ;
type Serial = {
/ * S e t t h i s S e r i a l p o r t a s t h e p o r t f o r t h e J a v a S c r i p t c o n s o l e ( R E P L ) .
* < p > Unless < code > force < / code > is set to true , changes in the connection state of the board
* ( for instance plugging in USB ) will cause the console to change . < / p >
* See < code > E . setConsole < / code > for a more flexible version of this function .
* @url http : //www.espruino.com/Reference#l_Serial_setConsole
* /
setConsole : ( force : boolean ) = > void ;
/ * < p > I f t h e s e r i a l ( o r s o f t w a r e s e r i a l ) d e v i c e w a s s e t u p ,
* uninitialise it . < / p >
* @url http : //www.espruino.com/Reference#l_Serial_unsetup
* /
unsetup : ( ) = > void ;
/ * P r i n t a s t r i n g t o t h e s e r i a l p o r t - w i t h o u t a l i n e f e e d
* < strong > Note : < / strong > This function replaces any occurances of < code > \ n < / code > in the string with < code > \ r \ n < / code > . To avoid this , use < code > Serial . write < / code > .
* @url http : //www.espruino.com/Reference#l_Serial_print
* /
print : ( string : any ) = > void ;
/ * P r i n t a l i n e t o t h e s e r i a l p o r t w i t h a n e w l i n e ( < c o d e > \ r \ n < / c o d e > ) a t t h e e n d o f i t .
* < strong > Note : < / strong > This function converts data to a string first , eg < code > Serial . print ( [ 1 , 2 , 3 ] ) < / code > is equivalent to < code > Serial . print ( & quot ; 1 , 2 , 3 & quot ; ) . If you & # 39 ; d like to write raw bytes , use < / code > Serial . write ` .
* @url http : //www.espruino.com/Reference#l_Serial_println
* /
println : ( string : any ) = > void ;
/ * W r i t e a c h a r a c t e r o r a r r a y o f d a t a t o t h e s e r i a l p o r t
* This method writes unmodified data , eg < code > Serial . write ( [ 1 , 2 , 3 ] ) < / code > is equivalent to < code > Serial . write ( & quot ; \ 1 \ 2 \ 3 & quot ; ) < / code > . If you & # 39 ; d like data converted to a string first , use < code > Serial . print < / code > .
* @url http : //www.espruino.com/Reference#l_Serial_write
* /
write : ( data : any ) = > void ;
/ * R e t u r n h o w m a n y b y t e s a r e a v a i l a b l e t o r e a d . I f t h e r e i s a l r e a d y a l i s t e n e r f o r d a t a , t h i s w i l l a l w a y s r e t u r n 0 .
* @url http : //www.espruino.com/Reference#l_Serial_available
* /
available : ( ) = > number ;
/ * R e t u r n a s t r i n g c o n t a i n i n g c h a r a c t e r s t h a t h a v e b e e n r e c e i v e d
* @url http : //www.espruino.com/Reference#l_Serial_read
* /
read : ( chars : number ) = > any ;
/ * P i p e t h i s U S A R T t o a s t r e a m ( a n o b j e c t w i t h a & # 3 9 ; w r i t e & # 3 9 ; m e t h o d )
* @url http : //www.espruino.com/Reference#l_Serial_pipe
* /
pipe : ( destination : any , options : any ) = > void ;
}
declare namespace Serial {
/ * T r y a n d f i n d a U S A R T ( S e r i a l ) h a r d w a r e d e v i c e t h a t w i l l w o r k o n t h i s p i n ( e g . < c o d e > S e r i a l 1 < / c o d e > )
* May return undefined if no device can be found .
* @url http : //www.espruino.com/Reference#l_Serial_find
* /
function find ( pin : Pin ) : any ;
}
/ * T h e U S B S e r i a l p o r t
* @url http : //www.espruino.com/Reference#l__global_USB
* /
declare const USB : Serial ;
/ * T h e f i r s t S e r i a l ( U S A R T ) p o r t
* @url http : //www.espruino.com/Reference#l__global_Serial1
* /
declare const Serial1 : Serial ;
/ * T h e s e c o n d S e r i a l ( U S A R T ) p o r t
* @url http : //www.espruino.com/Reference#l__global_Serial2
* /
declare const Serial2 : Serial ;
/ * T h e t h i r d S e r i a l ( U S A R T ) p o r t
* @url http : //www.espruino.com/Reference#l__global_Serial3
* /
declare const Serial3 : Serial ;
/ * T h e f o u r t h S e r i a l ( U S A R T ) p o r t
* @url http : //www.espruino.com/Reference#l__global_Serial4
* /
declare const Serial4 : Serial ;
/ * T h e f i f t h S e r i a l ( U S A R T ) p o r t
* @url http : //www.espruino.com/Reference#l__global_Serial5
* /
declare const Serial5 : Serial ;
/ * T h e s i x t h S e r i a l ( U S A R T ) p o r t
* @url http : //www.espruino.com/Reference#l__global_Serial6
* /
declare const Serial6 : Serial ;
/ * A l o o p b a c k s e r i a l d e v i c e . D a t a s e n t t o < c o d e > L o o p b a c k A < / c o d e > c o m e s o u t o f < c o d e > L o o p b a c k B < / c o d e > a n d v i c e v e r s a
* @url http : //www.espruino.com/Reference#l__global_LoopbackA
* /
declare const LoopbackA : Serial ;
/ * A l o o p b a c k s e r i a l d e v i c e . D a t a s e n t t o < c o d e > L o o p b a c k A < / c o d e > c o m e s o u t o f < c o d e > L o o p b a c k B < / c o d e > a n d v i c e v e r s a
* @url http : //www.espruino.com/Reference#l__global_LoopbackB
* /
declare const LoopbackB : Serial ;
/ * A t e l n e t s e r i a l d e v i c e t h a t m a p s t o t h e b u i l t - i n t e l n e t c o n s o l e s e r v e r ( d e v i c e s t h a t h a v e b u i l t - i n w i f i o n l y ) .
* @url http : //www.espruino.com/Reference#l__global_Telnet
* /
declare const Telnet : any ;
/ * T h i s i s t h e b u i l t - i n J a v a S c r i p t c l a s s t h a t i s t h e p r o t o t y p e f o r :
* < ul >
* < li > < a href = "/Reference#Uint8Array" > Uint8Array < / a > < / li >
* < li > < a href = "/Reference#UintClamped8Array" > UintClamped8Array < / a > < / li >
* < li > < a href = "/Reference#Int8Array" > Int8Array < / a > < / li >
* < li > < a href = "/Reference#Uint16Array" > Uint16Array < / a > < / li >
* < li > < a href = "/Reference#Int16Array" > Int16Array < / a > < / li >
* < li > < a href = "/Reference#Uint24Array" > Uint24Array < / a > ( Espruino - specific - not standard JS ) < / li >
* < li > < a href = "/Reference#Uint32Array" > Uint32Array < / a > < / li >
* < li > < a href = "/Reference#Int32Array" > Int32Array < / a > < / li >
* < li > < a href = "/Reference#Float32Array" > Float32Array < / a > < / li >
* < li > < a href = "/Reference#Float64Array" > Float64Array < / a > < / li >
* < / ul >
* < p > If you want to access arrays of differing types of data
* you may also find < code > DataView < / code > useful . < / p >
* @url http : //www.espruino.com/Reference#ArrayBufferView
* /
declare function EspruinoArrayBufferView ( ) : void ;
type EspruinoArrayBufferView = {
/ * T h e b u f f e r t h i s v i e w r e f e r e n c e s
* @url http : //www.espruino.com/Reference#l_ArrayBufferView_buffer
* /
buffer : any
/ * T h e l e n g t h , i n b y t e s , o f t h e < c o d e > A r r a y B u f f e r V i e w < / c o d e >
* @url http : //www.espruino.com/Reference#l_ArrayBufferView_byteLength
* /
byteLength : number
/ * T h e o f f s e t , i n b y t e s , t o t h e f i r s t b y t e o f t h e v i e w w i t h i n t h e b a c k i n g < c o d e > A r r a y B u f f e r < / c o d e >
* @url http : //www.espruino.com/Reference#l_ArrayBufferView_byteOffset
* /
byteOffset : number
/ * C o p y t h e c o n t e n t s o f < c o d e > a r r a y < / c o d e > i n t o t h i s o n e , m a p p i n g < c o d e > t h i s [ x + o f f s e t ] = a r r a y [ x ] ; < / c o d e >
* @url http : //www.espruino.com/Reference#l_ArrayBufferView_set
* /
set : ( arr : any , offset : number ) = > void ;
/ * R e t u r n a n a r r a y w h i c h i s m a d e f r o m t h e f o l l o w i n g : < c o d e > A . m a p ( f u n c t i o n ) = [ f u n c t i o n ( A [ 0 ] ) , f u n c t i o n ( A [ 1 ] ) , . . . ] < / c o d e >
* < strong > Note : < / strong > This returns an < code > ArrayBuffer < / code > of the same type it was called on . To get an < code > Array < / code > , use < code > Array . map < / code > , eg . < code > [ ] . map . call ( myArray , x = & gt ; x + 1 ) < / code >
* @url http : //www.espruino.com/Reference#l_ArrayBufferView_map
* /
map : ( fn : any , thisArg : any ) = > EspruinoArrayBufferView ;
/ * R e t u r n s a s m a l l e r p a r t o f t h i s a r r a y w h i c h r e f e r e n c e s t h e s a m e d a t a ( i t d o e s n & # 3 9 ; t c o p y i t ) .
* @url http : //www.espruino.com/Reference#l_ArrayBufferView_subarray
* /
subarray : ( begin : number , end : any ) = > EspruinoArrayBufferView ;
/ * R e t u r n t h e i n d e x o f t h e v a l u e i n t h e a r r a y , o r < c o d e > - 1 < / c o d e >
* @url http : //www.espruino.com/Reference#l_ArrayBufferView_indexOf
* /
indexOf : ( value : any , startIndex : number ) = > any ;
/ * R e t u r n < c o d e > t r u e < / c o d e > i f t h e a r r a y i n c l u d e s t h e v a l u e , < c o d e > f a l s e < / c o d e > o t h e r w i s e
* @url http : //www.espruino.com/Reference#l_ArrayBufferView_includes
* /
includes : ( value : any , startIndex : number ) = > boolean ;
/ * J o i n a l l e l e m e n t s o f t h i s a r r a y t o g e t h e r i n t o o n e s t r i n g , u s i n g & # 3 9 ; s e p a r a t o r & # 3 9 ; b e t w e e n t h e m . e g . < c o d e > [ 1 , 2 , 3 ] . j o i n ( & # 3 9 ; & # 3 9 ; ) = = & # 3 9 ; 1 2 3 & # 3 9 ; < / c o d e >
* @url http : //www.espruino.com/Reference#l_ArrayBufferView_join
* /
join : ( separator : any ) = > any ;
/ * D o a n i n - p l a c e q u i c k s o r t o f t h e a r r a y
* @url http : //www.espruino.com/Reference#l_ArrayBufferView_sort
* /
sort : ( variable : any ) = > EspruinoArrayBufferView ;
/ * E x e c u t e s a p r o v i d e d f u n c t i o n o n c e p e r a r r a y e l e m e n t .
* @url http : //www.espruino.com/Reference#l_ArrayBufferView_forEach
* /
forEach : ( fn : any , thisArg : any ) = > void ;
/ * E x e c u t e < c o d e > p r e v i o u s V a l u e = i n i t i a l V a l u e < / c o d e > a n d t h e n < c o d e > p r e v i o u s V a l u e = c a l l b a c k ( p r e v i o u s V a l u e , c u r r e n t V a l u e , i n d e x , a r r a y ) < / c o d e > f o r e a c h e l e m e n t i n t h e a r r a y , a n d f i n a l l y r e t u r n p r e v i o u s V a l u e .
* @url http : //www.espruino.com/Reference#l_ArrayBufferView_reduce
* /
reduce : ( callback : any , initialValue : any ) = > any ;
/ * F i l l t h i s a r r a y w i t h t h e g i v e n v a l u e , f o r e v e r y i n d e x < c o d e > & g t ; = s t a r t < / c o d e > a n d < c o d e > & l t ; e n d < / c o d e >
* @url http : //www.espruino.com/Reference#l_ArrayBufferView_fill
* /
fill : ( value : any , start : number , end : any ) = > EspruinoArrayBufferView ;
/ * R e t u r n a n a r r a y w h i c h c o n t a i n s o n l y t h o s e e l e m e n t s f o r w h i c h t h e c a l l b a c k f u n c t i o n r e t u r n s & # 3 9 ; t r u e & # 3 9 ;
* @url http : //www.espruino.com/Reference#l_ArrayBufferView_filter
* /
filter : ( fn : any , thisArg : any ) = > any ;
/ * R e t u r n t h e a r r a y e l e m e n t w h e r e < c o d e > f u n c t i o n < / c o d e > r e t u r n s < c o d e > t r u e < / c o d e > , o r < c o d e > u n d e f i n e d < / c o d e > i f i t d o e s n & # 3 9 ; t r e t u r n s < c o d e > t r u e < / c o d e > f o r a n y e l e m e n t .
* @url http : //www.espruino.com/Reference#l_ArrayBufferView_find
* /
find : ( fn : any ) = > any ;
/ * R e t u r n t h e a r r a y e l e m e n t & # 3 9 ; s i n d e x w h e r e < c o d e > f u n c t i o n < / c o d e > r e t u r n s < c o d e > t r u e < / c o d e > , o r < c o d e > - 1 < / c o d e > i f i t d o e s n & # 3 9 ; t r e t u r n s < c o d e > t r u e < / c o d e > f o r a n y e l e m e n t .
* @url http : //www.espruino.com/Reference#l_ArrayBufferView_findIndex
* /
findIndex : ( fn : any ) = > any ;
/ * R e v e r s e t h e c o n t e n t s o f t h i s < c o d e > A r r a y B u f f e r V i e w < / c o d e > i n - p l a c e
* @url http : //www.espruino.com/Reference#l_ArrayBufferView_reverse
* /
reverse : ( ) = > EspruinoArrayBufferView ;
/ * R e t u r n a c o p y o f a p o r t i o n o f t h i s a r r a y ( i n a n e w a r r a y ) .
* < strong > Note : < / strong > This currently returns a normal < code > Array < / code > , not an < code > ArrayBuffer < / code >
* @url http : //www.espruino.com/Reference#l_ArrayBufferView_slice
* /
slice : ( start : number , end : any ) = > any [ ] ;
}
/ * C r e a t e a t y p e d a r r a y b a s e d o n t h e g i v e n i n p u t . E i t h e r a n e x i s t i n g A r r a y B u f f e r , a n I n t e g e r a s a L e n g t h , o r a s i m p l e a r r a y . I f a n < c o d e > A r r a y B u f f e r V i e w < / c o d e > ( e g . < c o d e > U i n t 8 A r r a y < / c o d e > r a t h e r t h a n < c o d e > A r r a y B u f f e r < / c o d e > ) i s g i v e n , i t w i l l b e c o m p l e t e l y c o p i e d r a t h e r t h a n r e f e r e n c e d .
* @url http : //www.espruino.com/Reference#l_Uint24Array_Uint24Array
* /
declare function Uint24Array ( arr : any , byteOffset : number , length : number ) : EspruinoArrayBufferView ;
type Uint24Array = {
}
/ * C r e a t e a w a v e f o r m c l a s s . T h i s a l l o w s h i g h s p e e d i n p u t a n d o u t p u t o f w a v e f o r m s . I t h a s a n i n t e r n a l v a r i a b l e c a l l e d < c o d e > b u f f e r < / c o d e > ( a s w e l l a s < c o d e > b u f f e r 2 < / c o d e > w h e n d o u b l e - b u f f e r e d - s e e < c o d e > o p t i o n s < / c o d e > b e l o w ) w h i c h c o n t a i n s t h e d a t a t o i n p u t / o u t p u t .
* When double - buffered , a & # 39 ; buffer & # 39 ; event will be emitted each time a buffer is finished with ( the argument is that buffer ) . When the recording stops , a & # 39 ; finish & # 39 ; event will be emitted ( with the first argument as the buffer ) .
* @url http : //www.espruino.com/Reference#l_Waveform_Waveform
* /
declare function Waveform ( samples : number , options : any ) : any ;
type Waveform = {
/ * W i l l s t a r t o u t p u t t i n g t h e w a v e f o r m o n t h e g i v e n p i n - t h e p i n m u s t h a v e p r e v i o u s l y b e e n i n i t i a l i s e d w i t h a n a l o g W r i t e . I f n o t r e p e a t i n g , i t & # 3 9 ; l l e m i t a < c o d e > f i n i s h < / c o d e > e v e n t w h e n i t i s d o n e .
* @url http : //www.espruino.com/Reference#l_Waveform_startOutput
* /
startOutput : ( output : Pin , freq : number , options : any ) = > void ;
/ * W i l l s t a r t i n p u t t i n g t h e w a v e f o r m o n t h e g i v e n p i n t h a t s u p p o r t s a n a l o g . I f n o t r e p e a t i n g , i t & # 3 9 ; l l e m i t a < c o d e > f i n i s h < / c o d e > e v e n t w h e n i t i s d o n e .
* @url http : //www.espruino.com/Reference#l_Waveform_startInput
* /
startInput : ( output : Pin , freq : number , options : any ) = > void ;
/ * S t o p a w a v e f o r m t h a t i s c u r r e n t l y o u t p u t t i n g
* @url http : //www.espruino.com/Reference#l_Waveform_stop
* /
stop : ( ) = > void ;
}
/ * < p > T h i s m o d u l e a l l o w s y o u t o r e a d a n d w r i t e p a r t o f t h e n o n v o l a t i l e f l a s h
* memory of your device using a filesystem - like API . < / p >
* < p > Also see the < code > Flash < / code > library , which provides a low level , more dangerous way
* to access all parts of your flash memory . < / p >
* The < code > Storage < / code > library provides two distinct types of file :
* < ul >
* < li > < code > require ( & quot ; Storage & quot ; ) . write ( . . . ) < / code > / < code > require ( & quot ; Storage & quot ; ) . read ( . . . ) < / code > / etc create simple
* contiguous files of fixed length . This is the recommended file type . < / li >
* < li > < code > require ( & quot ; Storage & quot ; ) . open ( . . . ) < / code > creates a < code > StorageFile < / code > , which stores the file in
* numbered chunks ( < code > & quot ; filename \ 1 & quot ; < / code > / < code > & quot ; filename \ 2 & quot ; < / code > / etc ) . It allows data to be appended
* and for the file to be read line by line . < / li >
* < / ul >
* < p > You must read a file using the same method you used to write it - eg . you can & # 39 ; t create a
* file with < code > require ( & quot ; Storage & quot ; ) . open ( . . . ) < / code > and then read it with < code > require ( & quot ; Storage & quot ; ) . read ( . . . ) < / code > . < / p >
* < p > < strong > Note : < / strong > In firmware 2 v05 and later , the maximum length for filenames
* is 28 characters . However in 2 v04 and earlier the max length is 8 . < / p >
* @url http : //www.espruino.com/Reference#l_Storage_undefined
* /
declare function EspruinoStorage ( ) : void ;
declare namespace EspruinoStorage {
/ * < p > E r a s e t h e f l a s h s t o r a g e a r e a . T h i s w i l l r e m o v e a l l f i l e s
* created with < code > require ( & quot ; Storage & quot ; ) . write ( . . . ) < / code > as well
* as any code saved with < code > save ( ) < / code > or < code > E . setBootCode ( ) < / code > . < / p >
* @url http : //www.espruino.com/Reference#l_Storage_eraseAll
* /
function eraseAll ( ) : void ;
/ * E r a s e a s i n g l e f i l e f r o m t h e f l a s h s t o r a g e a r e a .
* < p > < strong > Note : < / strong > This function should be used with normal files , and not
* < code > StorageFile < / code > s created with < code > require ( & quot ; Storage & quot ; ) . open ( filename , . . . ) < / code > < / p >
* @url http : //www.espruino.com/Reference#l_Storage_erase
* /
function erase ( name : any ) : void ;
/ * < p > R e a d a f i l e f r o m t h e f l a s h s t o r a g e a r e a t h a t h a s
* been written with < code > require ( & quot ; Storage & quot ; ) . write ( . . . ) < / code > . < / p >
* < p > This function returns a memory - mapped String that points to the actual
* memory area in read - only memory , so it won & # 39 ; t use up RAM . < / p >
* As such you can check if a file exists efficiently using < code > require ( & quot ; Storage & quot ; ) . read ( filename ) !== undefined < / code > .
* < p > If you evaluate this string with < code > eval < / code > , any functions
* contained in the String will keep their code stored
* in flash memory . < / p >
* < p > < strong > Note : < / strong > This function should be used with normal files , and not
* < code > StorageFile < / code > s created with < code > require ( & quot ; Storage & quot ; ) . open ( filename , . . . ) < / code > < / p >
* @url http : //www.espruino.com/Reference#l_Storage_read
* /
function read ( name : any , offset : number , length : number ) : any ;
/ * < p > R e a d a f i l e f r o m t h e f l a s h s t o r a g e a r e a t h a t h a s
* been written with < code > require ( & quot ; Storage & quot ; ) . write ( . . . ) < / code > ,
* and parse JSON in it into a JavaScript object . < / p >
* < p > This is identical to < code > JSON . parse ( require ( & quot ; Storage & quot ; ) . read ( . . . ) ) < / code > .
* It will throw an exception if the data in the file is not
* valid JSON . < / p >
* < p > < strong > Note : < / strong > This function should be used with normal files , and not
* < code > StorageFile < / code > s created with < code > require ( & quot ; Storage & quot ; ) . open ( filename , . . . ) < / code > < / p >
* @url http : //www.espruino.com/Reference#l_Storage_readJSON
* /
function readJSON ( name : any , noExceptions : boolean ) : any ;
/ * < p > R e a d a f i l e f r o m t h e f l a s h s t o r a g e a r e a t h a t h a s
* been written with < code > require ( & quot ; Storage & quot ; ) . write ( . . . ) < / code > ,
* and return the raw binary data as an ArrayBuffer . < / p >
* This can be used :
* < ul >
* < li > In a < code > DataView < / code > with < code > new DataView ( require ( & quot ; Storage & quot ; ) . readArrayBuffer ( & quot ; x & quot ; ) ) < / code > < / li >
* < li > In a < code > Uint8Array / Float32Array / etc < / code > with < code > new Uint8Array ( require ( & quot ; Storage & quot ; ) . readArrayBuffer ( & quot ; x & quot ; ) ) < / code > < / li >
* < / ul >
* < p > < strong > Note : < / strong > This function should be used with normal files , and not
* < code > StorageFile < / code > s created with < code > require ( & quot ; Storage & quot ; ) . open ( filename , . . . ) < / code > < / p >
* @url http : //www.espruino.com/Reference#l_Storage_readArrayBuffer
* /
function readArrayBuffer ( name : any ) : any ;
/ * < p > W r i t e / c r e a t e a f i l e i n t h e f l a s h s t o r a g e a r e a . T h i s i s
* nonvolatile and will not disappear when the device resets
* or power is lost . < / p >
* < p > Simply write < code > require ( & quot ; Storage & quot ; ) . writeJSON ( & quot ; MyFile & quot ; , [ 1 , 2 , 3 ] ) < / code > to write
* a new file , and < code > require ( & quot ; Storage & quot ; ) . readJSON ( & quot ; MyFile & quot ; ) < / code > to read it . < / p >
* This is equivalent to : < code > require ( & quot ; Storage & quot ; ) . write ( name , JSON . stringify ( data ) ) < / code >
* < p > < strong > Note : < / strong > This function should be used with normal files , and not
* < code > StorageFile < / code > s created with < code > require ( & quot ; Storage & quot ; ) . open ( filename , . . . ) < / code > < / p >
* @url http : //www.espruino.com/Reference#l_Storage_writeJSON
* /
function writeJSON ( name : any , data : any ) : boolean ;
/ * < p > T h e F l a s h S t o r a g e s y s t e m i s j o u r n a l i n g . T o m a k e t h e m o s t o f t h e l i m i t e d
* write cycles of Flash memory , Espruino marks deleted / replaced files as
* garbage and moves on to a fresh part of flash memory . Espruino only
* fully erases those files when it is running low on flash , or when
* < code > compact < / code > is called . < / p >
* < p > < code > compact < / code > may fail if there isn & # 39 ; t enough RAM free on the stack to
* use as swap space , however in this case it will not lose data . < / p >
* < p > < strong > Note : < / strong > < code > compact < / code > rearranges the contents of memory . If code is
* referencing that memory ( eg . functions that have their code stored in flash )
* then they may become garbled when compaction happens . To avoid this ,
* call < code > eraseFiles < / code > before uploading data that you intend to reference to
* ensure that uploaded files are right at the start of flash and cannot be
* compacted further . < / p >
* @url http : //www.espruino.com/Reference#l_Storage_compact
* /
function compact ( ) : void ;
/ * < p > T h i s w r i t e s i n f o r m a t i o n a b o u t a l l b l o c k s i n f l a s h
* memory to the console - and is only useful for debugging
* flash storage . < / p >
* @url http : //www.espruino.com/Reference#l_Storage_debug
* /
function debug ( ) : void ;
/ * < p > R e t u r n t h e a m o u n t o f f r e e b y t e s a v a i l a b l e i n
* Storage . Due to fragmentation there may be more
* bytes available , but this represents the maximum
* size of file that can be written . < / p >
* @url http : //www.espruino.com/Reference#l_Storage_getFree
* /
function getFree ( ) : number ;
/ * < p > O p e n a f i l e i n t h e S t o r a g e a r e a . T h i s c a n b e u s e d f o r a p p e n d i n g d a t a
* ( normal read / write operations only write the entire file ) . < / p >
* Please see < code > StorageFile < / code > for more information ( and examples ) .
* < strong > Note : < / strong > These files write through immediately - they do not need closing .
* @url http : //www.espruino.com/Reference#l_Storage_open
* /
function open ( name : any , mode : any ) : StorageFile ;
}
/ * T h i s i s t h e b u i l t - i n J a v a S c r i p t c l a s s f o r E s p r u i n o u t i l i t y f u n c t i o n s .
* @url http : //www.espruino.com/Reference#E
* /
declare function E ( ) : void ;
declare namespace E {
/* @url http:/ / www . espruino . com / Reference # l_E_showMenu
* /
function showMenu ( ) : void ;
/* @url http:/ / www . espruino . com / Reference # l_E_showPrompt
* /
function showPrompt ( ) : void ;
/* @url http:/ / www . espruino . com / Reference # l_E_showScroller
* /
function showScroller ( ) : void ;
/ * U n m o u n t t h e S D c a r d , s o i t c a n b e r e m o v e d . I f y o u r e m o v e t h e S D c a r d w i t h o u t c a l l i n g t h i s y o u m a y c a u s e c o r r u p t i o n , a n d y o u w i l l b e u n a b l e t o a c c e s s a n o t h e r S D c a r d u n t i l y o u r e s e t E s p r u i n o o r c a l l < c o d e > E . u n m o u n t S D ( ) < / c o d e > .
* @url http : //www.espruino.com/Reference#l_E_unmountSD
* /
function unmountSD ( ) : void ;
/ * O p e n a f i l e
* @url http : //www.espruino.com/Reference#l_E_openFile
* /
function openFile ( path : any , mode : any ) : EspruinoFile ;
/ * U s e t h e m i c r o c o n t r o l l e r & # 3 9 ; s i n t e r n a l t h e r m i s t o r t o w o r k o u t t h e t e m p e r a t u r e .
* On Puck . js v2 . 0 this will use the on - board PCT2075TP temperature sensor , but on other devices it may not be desperately well calibrated .
* While this is implemented on Espruino boards , it may not be implemented on other devices . If so it & # 39 ; ll return NaN .
* < strong > Note : < / strong > This is not entirely accurate and varies by a few degrees from chip to chip . It measures the < strong > die temperature < / strong > , so when connected to USB it could be reading 10 over degrees C above ambient temperature . When running from battery with < code > setDeepSleep ( true ) < / code > it is much more accurate though .
* @url http : //www.espruino.com/Reference#l_E_getTemperature
* /
function getTemperature ( ) : number ;
/ * C h e c k t h e i n t e r n a l v o l t a g e r e f e r e n c e . T o w o r k o u t a n a c t u a l v o l t a g e o f a n i n p u t p i n , y o u c a n u s e < c o d e > a n a l o g R e a d ( p i n ) * E . g e t A n a l o g V R e f ( ) < / c o d e >
* < p > < strong > Note : < / strong > This value is calculated by reading the voltage on an internal voltage reference with the ADC .
* It will be slightly noisy , so if you need this for accurate measurements we & # 39 ; d recommend that you call
* this function several times and average the results . < / p >
* While this is implemented on Espruino boards , it may not be implemented on other devices . If so it & # 39 ; ll return NaN .
* @url http : //www.espruino.com/Reference#l_E_getAnalogVRef
* /
function getAnalogVRef ( ) : number ;
/ * A D V A N C E D : T h i s i s a g r e a t w a y t o c r a s h E s p r u i n o i f y o u & # 3 9 ; r e n o t s u r e w h a t y o u a r e d o i n g
* Create a native function that executes the code at the given address . Eg . < code > E . nativeCall ( 0x08012345 , & # 39 ; double ( double , double ) & # 39 ; ) ( 1.1 , 2.2 ) < / code >
* If you & # 39 ; re executing a thumb function , you & # 39 ; ll almost certainly need to set the bottom bit of the address to 1 .
* Note it & # 39 ; s not guaranteed that the call signature you provide can be used - there are limits on the number of arguments allowed .
* When supplying < code > data < / code > , if it is a & # 39 ; flat string & # 39 ; then it will be used directly , otherwise it & # 39 ; ll be converted to a flat string and used .
* @url http : //www.espruino.com/Reference#l_E_nativeCall
* /
function nativeCall ( addr : number , sig : any , data : any ) : any ;
/ * C l i p a n u m b e r t o b e b e t w e e n m i n a n d m a x ( i n c l u s i v e )
* @url http : //www.espruino.com/Reference#l_E_clip
* /
function clip ( x : number , min : number , max : number ) : number ;
/ * S u m t h e c o n t e n t s o f t h e g i v e n A r r a y , S t r i n g o r A r r a y B u f f e r a n d r e t u r n t h e r e s u l t
* @url http : //www.espruino.com/Reference#l_E_sum
* /
function sum ( arr : any ) : number ;
/ * W o r k o u t t h e v a r i a n c e o f t h e c o n t e n t s o f t h e g i v e n A r r a y , S t r i n g o r A r r a y B u f f e r a n d r e t u r n t h e r e s u l t . T h i s i s e q u i v a l e n t t o < c o d e > v = 0 ; f o r ( i i n a r r ) v + = M a t h . p o w ( m e a n - a r r [ i ] , 2 ) < / c o d e >
* @url http : //www.espruino.com/Reference#l_E_variance
* /
function variance ( arr : any , mean : number ) : number ;
/ * C o n v o l v e a r r 1 w i t h a r r 2 . T h i s i s e q u i v a l e n t t o < c o d e > v = 0 ; f o r ( i i n a r r 1 ) v + = a r r 1 [ i ] * a r r 2 [ ( i + o f f s e t ) % a r r 2 . l e n g t h ] < / c o d e >
* @url http : //www.espruino.com/Reference#l_E_convolve
* /
function convolve ( arr1 : any , arr2 : any , offset : number ) : number ;
/ * < p > P e r f o r m s a F a s t F o u r i e r T r a n s f o r m ( F F T ) i n 3 2 b i t f l o a t s o n t h e s u p p l i e d d a t a a n d w r i t e s i t b a c k i n t o t h e
* original arrays . Note that if only one array is supplied , the data written back is the modulus of the complex
* result < code > sqrt ( r * r + i * i ) < / code > . < / p >
* < p > In order to perform the FFT , there has to be enough room on the stack to allocate two arrays of 32 bit
* floating point numbers - this will limit the maximum size of FFT possible to around 1024 items on
* most platforms . < / p >
* < p > < strong > Note : < / strong > on the Original Espruino board , FFTs are performed in 64 bit arithmetic as there isn & # 39 ; t
* space to include the 32 bit maths routines ( 2 x more RAM is required ) . < / p >
* @url http : //www.espruino.com/Reference#l_E_FFT
* /
function FFT ( arrReal : any , arrImage : any , inverse : boolean ) : void ;
/ * < p > K i c k s a W a t c h d o g t i m e r s e t u p w i t h < c o d e > E . e n a b l e W a t c h d o g ( . . . , f a l s e ) < / c o d e > . S e e
* < code > E . enableWatchdog < / code > for more information . < / p >
* < strong > NOTE : < / strong > This is only implemented on STM32 and nRF5x devices ( all official Espruino boards ) .
* @url http : //www.espruino.com/Reference#l_E_kickWatchdog
* /
function kickWatchdog ( ) : void ;
/ * G e t a n d r e s e t t h e e r r o r f l a g s . R e t u r n s a n a r r a y t h a t c a n c o n t a i n :
* < code > & # 39 ; FIFO_FULL & # 39 ; < / code > : The receive FIFO filled up and data was lost . This could be state transitions for setWatch , or received characters .
* < code > & # 39 ; BUFFER_FULL & # 39 ; < / code > : A buffer for a stream filled up and characters were lost . This can happen to any stream - Serial , HTTP , etc .
* < code > & # 39 ; CALLBACK & # 39 ; < / code > : A callback ( < code > setWatch < / code > , < code > setInterval < / code > , < code > on ( & # 39 ; data & # 39 ; , . . . ) < / code > ) caused an error and so was removed .
* < code > & # 39 ; LOW_MEMORY & # 39 ; < / code > : Memory is running low - Espruino had to run a garbage collection pass or remove some of the command history
* < code > & # 39 ; MEMORY & # 39 ; < / code > : Espruino ran out of memory and was unable to allocate some data that it needed .
* < code > & # 39 ; UART_OVERFLOW & # 39 ; < / code > : A UART received data but it was not read in time and was lost
* @url http : //www.espruino.com/Reference#l_E_getErrorFlags
* /
function getErrorFlags ( ) : any ;
/ * G e t E s p r u i n o & # 3 9 ; s i n t e r p r e t e r f l a g s t h a t c o n t r o l t h e w a y i t h a n d l e s y o u r J a v a S c r i p t c o d e .
* < ul >
* < li > < code > deepSleep < / code > - Allow deep sleep modes ( also set by setDeepSleep ) < / li >
* < li > < code > pretokenise < / code > - When adding functions , pre - minify them and tokenise reserved words < / li >
* < li > < code > unsafeFlash < / code > - Some platforms stop writes / erases to interpreter memory to stop you bricking the device accidentally - this removes that protection < / li >
* < li > < code > unsyncFiles < / code > - When writing files , < em > don & # 39 ; t < / em > flush all data to the SD card after each command ( the default is < em > to < / em > flush ) . This is much faster , but can cause filesystem damage if power is lost without the filesystem unmounted . < / li >
* < / ul >
* @url http : //www.espruino.com/Reference#l_E_getFlags
* /
function getFlags ( ) : any ;
/ * S e t t h e E s p r u i n o i n t e r p r e t e r f l a g s t h a t c o n t r o l t h e w a y i t h a n d l e s y o u r J a v a S c r i p t c o d e .
* Run < code > E . getFlags ( ) < / code > and check its description for a list of available flags and their values .
* @url http : //www.espruino.com/Reference#l_E_setFlags
* /
function setFlags ( flags : any ) : void ;
/* @url http:/ / www . espruino . com / Reference # l_E_pipe
* /
function pipe ( source : any , destination : any , options : any ) : void ;
/ * C r e a t e a n A r r a y B u f f e r f r o m t h e g i v e n s t r i n g . T h i s i s d o n e v i a a r e f e r e n c e , n o t a c o p y - s o i t i s v e r y f a s t a n d m e m o r y e f f i c i e n t .
* Note that this is an ArrayBuffer , not a Uint8Array . To get one of those , do : < code > new Uint8Array ( E . toArrayBuffer ( & # 39 ; . . . . & # 39 ; ) ) < / code > .
* @url http : //www.espruino.com/Reference#l_E_toArrayBuffer
* /
function toArrayBuffer ( str : any ) : EspruinoArrayBufferView ;
/ * < p > T h i s p e r f o r m s t h e s a m e b a s i c f u n c t i o n a s < c o d e > J S O N . s t r i n g i f y < / c o d e > ,
* however < code > JSON . stringify < / code > adds extra characters to conform
* to the JSON spec which aren & # 39 ; t required if outputting JS . < / p >
* < p > < code > E . toJS < / code > will also stringify JS functions , whereas
* < code > JSON . stringify < / code > ignores them . < / p >
* For example :
* < ul >
* < li > < code > JSON . stringify ( { a :1 , b :2 } ) == & # 39 ; { & quot ; a & quot ; : 1 , & quot ; b & quot ; : 2 } & # 39 ; < / code > < / li >
* < li > < code > E . toJS ( { a :1 , b :2 } ) == & # 39 ; { a :1 , b :2 } & # 39 ; < / code > < / li >
* < / ul >
* < p > < strong > Note : < / strong > Strings generated with < code > E . toJS < / code > can & # 39 ; t be
* reliably parsed by < code > JSON . parse < / code > - however they are
* valid JS so will work with < code > eval < / code > ( but this has security
* implications if you don & # 39 ; t trust the source of the string ) . < / p >
* < p > On the desktop < a href = "https://github.com/json5/json5" > JSON5 parsers < / a >
* will parse the strings produced by < code > E . toJS < / code > without trouble . < / p >
* @url http : //www.espruino.com/Reference#l_E_toJS
* /
function toJS ( arg : any ) : string ;
/ * < p > T h i s c r e a t e s a n d r e t u r n s a s p e c i a l t y p e o f s t r i n g , w h i c h a c t u a l l y r e f e r e n c e s
* a specific memory address . It can be used in order to use sections of
* Flash memory directly in Espruino ( for example to execute code straight
* from flash memory with < code > eval ( E . memoryArea ( . . . ) ) < / code > ) < / p >
* < p > < strong > Note : < / strong > This is only tested on STM32 - based platforms ( Espruino Original
* and Espruino Pico ) at the moment . < / p >
* @url http : //www.espruino.com/Reference#l_E_memoryArea
* /
function memoryArea ( addr : number , len : number ) : string ;
/ * < p > T h i s w r i t e s J a v a S c r i p t c o d e i n t o E s p r u i n o & # 3 9 ; s f l a s h m e m o r y , t o b e e x e c u t e d o n
* startup . It differs from < code > save ( ) < / code > in that < code > save ( ) < / code > saves the whole state of
* the interpreter , whereas this just saves JS code that is executed at boot . < / p >
* Code will be executed before < code > onInit ( ) < / code > and < code > E . on ( & # 39 ; init & # 39 ; , . . . ) < / code > .
* < p > If < code > alwaysExec < / code > is < code > true < / code > , the code will be executed even after a call to
* < code > reset ( ) < / code > . This is useful if you & # 39 ; re making something that you want to
* program , but you want some code that is always built in ( for instance
* setting up a display or keyboard ) . < / p >
* To remove boot code that has been saved previously , use < code > E . setBootCode ( & quot ; & quot ; ) < / code >
* < strong > Note : < / strong > this removes any code that was previously saved with < code > save ( ) < / code >
* @url http : //www.espruino.com/Reference#l_E_setBootCode
* /
function setBootCode ( code : any , alwaysExec : boolean ) : void ;
/ * < p > T h i s s e t s t h e c l o c k f r e q u e n c y o f E s p r u i n o & # 3 9 ; s p r o c e s s o r . I t w i l l r e t u r n < c o d e > 0 < / c o d e > i f
* it is unimplemented or the clock speed cannot be changed . < / p >
* < p > < strong > Note : < / strong > On pretty much all boards , UART , SPI , I2C , PWM , etc will change
* frequency and will need setting up again in order to work . < / p >
* < h3 id = "stm32f4" > STM32F4 < / h3 >
* < p > Options is of the form < code > { M : int , N : int , P : int , Q : int } < / code > - see the & # 39 ; Clocks & # 39 ;
* section of the microcontroller & # 39 ; s reference manual for what these mean . < / p >
* < ul >
* < li > System clock = 8 Mhz < em > N / ( M < / em > P ) < / li >
* < li > USB clock ( should be 48 Mhz ) = 8 Mhz < em > N / ( M < / em > Q ) < / li >
* < / ul >
* Optional arguments are :
* < ul >
* < li > < code > latency < / code > - flash latency from 0 . . 15 < / li >
* < li > < code > PCLK1 < / code > - Peripheral clock 1 divisor ( default : 2 ) < / li >
* < li > < code > PCLK2 < / code > - Peripheral clock 2 divisor ( default : 4 ) < / li >
* < / ul >
* < p > The Pico & # 39 ; s default is < code > { M :8 , N :336 , P :4 , Q :7 , PCLK1 :2 , PCLK2 :4 } < / code > , use
* < code > { M :8 , N :336 , P :8 , Q :7 , PCLK :1 , PCLK2 :2 } < / code > to halve the system clock speed
* while keeping the peripherals running at the same speed ( omitting PCLK1 / 2
* will lead to the peripherals changing speed too ) . < / p >
* < p > On STM32F4 boards ( eg . Espruino Pico ) , the USB clock needs to be kept at 48 Mhz
* or USB will fail to work . You & # 39 ; ll also experience USB instability if the processor
* clock falls much below 48 Mhz . < / p >
* < h3 id = "esp8266" > ESP8266 < / h3 >
* Just specify an integer value , either 80 or 160 ( for 80 or 160 Mhz )
* @url http : //www.espruino.com/Reference#l_E_setClock
* /
function setClock ( options : any ) : number ;
/ * R e t u r n s t h e c u r r e n t c o n s o l e d e v i c e - s e e < c o d e > E . s e t C o n s o l e < / c o d e > f o r m o r e i n f o r m a t i o n .
* @url http : //www.espruino.com/Reference#l_E_getConsole
* /
function getConsole ( ) : any ;
/ * R e v e r s e t h e 8 b i t s i n a b y t e , s w a p p i n g M S B a n d L S B .
* For example , < code > E . reverseByte ( 0 b10010000 ) == 0 b00001001 < / code > .
* Note that you can reverse all the bytes in an array with : < code > arr = arr . map ( E . reverseByte ) < / code >
* @url http : //www.espruino.com/Reference#l_E_reverseByte
* /
function reverseByte ( x : number ) : number ;
/ * O u t p u t t h e c u r r e n t l i s t o f U t i l i t y T i m e r T a s k s - f o r d e b u g g i n g o n l y
* @url http : //www.espruino.com/Reference#l_E_dumpTimers
* /
function dumpTimers ( ) : void ;
/ * D u m p a n y l o c k e d v a r i a b l e s t h a t a r e n & # 3 9 ; t r e f e r e n c e d f r o m < c o d e > g l o b a l < / c o d e > - f o r d e b u g g i n g m e m o r y l e a k s o n l y .
* @url http : //www.espruino.com/Reference#l_E_dumpLockedVars
* /
function dumpLockedVars ( ) : void ;
/ * D u m p a n y l o c k e d v a r i a b l e s t h a t a r e n & # 3 9 ; t r e f e r e n c e d f r o m < c o d e > g l o b a l < / c o d e > - f o r d e b u g g i n g m e m o r y l e a k s o n l y .
* @url http : //www.espruino.com/Reference#l_E_dumpFreeList
* /
function dumpFreeList ( ) : void ;
/ * S h o w f r a g m e n t a t i o n .
* < ul >
* < li > < code > < / code > is free space < / li >
* < li > < code > # < / code > is a normal variable < / li >
* < li > < code > L < / code > is a locked variable ( address used , cannopt be moved ) < / li >
* < li > < code > = < / code > represents data in a Flat String ( must be contiguous ) < / li >
* < / ul >
* @url http : //www.espruino.com/Reference#l_E_dumpFragmentation
* /
function dumpFragmentation ( ) : void ;
/ * < p > D u m p s a c o m m a - s e p a r a t e d l i s t o f a l l a l l o c a t e d v a r i a b l e s
* along with the variables they link to . Can be used
* to visualise where memory is used . < / p >
* @url http : //www.espruino.com/Reference#l_E_dumpVariables
* /
function dumpVariables ( ) : void ;
/ * B E T A : d e f r a g m e n t m e m o r y !
* @url http : //www.espruino.com/Reference#l_E_defrag
* /
function defrag ( ) : void ;
/ * < p > R e t u r n t h e a d d r e s s i n m e m o r y o f t h e g i v e n v a r i a b l e . T h i s c a n t h e n
* be used with < code > peek < / code > and < code > poke < / code > functions . However , changing data in
* JS variables directly ( flatAddress = false ) will most likely result in a crash . < / p >
* < p > This functions exists to allow embedded targets to set up
* peripherals such as DMA so that they write directly to
* JS variables . < / p >
* See < a href = "http://www.espruino.com/Internals" > http : //www.espruino.com/Internals</a> for more information
* @url http : //www.espruino.com/Reference#l_E_getAddressOf
* /
function getAddressOf ( v : any , flatAddress : boolean ) : number ;
/ * S e a r c h i n a n O b j e c t , A r r a y , o r F u n c t i o n
* @url http : //www.espruino.com/Reference#l_E_lookupNoCase
* /
function lookupNoCase ( haystack : any , needle : any , returnKey : boolean ) : any ;
/ * G e t t h e c u r r e n t i n t e r p r e t e r s t a t e i n a t e x t f o r m s u c h t h a t i t c a n b e c o p i e d t o a n e w d e v i c e
* @url http : //www.espruino.com/Reference#l_E_dumpStr
* /
function dumpStr ( ) : string ;
/ * S e t t h e s e e d f o r t h e r a n d o m n u m b e r g e n e r a t o r u s e d b y < c o d e > M a t h . r a n d o m ( ) < / c o d e > .
* @url http : //www.espruino.com/Reference#l_E_srand
* /
function srand ( v : number ) : void ;
/ * < p > U n l i k e & # 3 9 ; M a t h . r a n d o m ( ) & # 3 9 ; w h i c h u s e s a p s e u d o - r a n d o m n u m b e r g e n e r a t o r , t h i s
* method reads from the internal voltage reference several times , xoring and
* rotating to try and make a relatively random value from the noise in the
* signal . < / p >
* @url http : //www.espruino.com/Reference#l_E_hwRand
* /
function hwRand ( ) : number ;
/ * < p > P e r f o r m a s t a n d a r d 3 2 b i t C R C ( C y c l i c r e d u n d a n c y c h e c k ) o n t h e s u p p l i e d d a t a ( o n e b y t e a t a t i m e )
* and return the result as an unsigned integer . < / p >
* @url http : //www.espruino.com/Reference#l_E_CRC32
* /
function CRC32 ( data : any ) : any ;
/ * C o n v e r t h u e , s a t u r a t i o n a n d b r i g h t n e s s t o r e d , g r e e n a n d b l u e ( p a c k e d i n t o a n i n t e g e r i f < c o d e > a s A r r a y = = f a l s e < / c o d e > o r a n a r r a y i f < c o d e > a s A r r a y = = t r u e < / c o d e > ) .
* < p > This replaces < code > Graphics . setColorHSB < / code > and < code > Graphics . setBgColorHSB < / code > . On devices with 24 bit colour it can
* be used as : < code > Graphics . setColor ( E . HSBtoRGB ( h , s , b ) ) < / code > < / p >
* < p > You can quickly set RGB items in an Array or Typed Array using < code > array . set ( E . HSBtoRGB ( h , s , b , true ) , offset ) < / code > ,
* which can be useful with arrays used with < code > require ( & quot ; neopixel & quot ; ) . write < / code > . < / p >
* @url http : //www.espruino.com/Reference#l_E_HSBtoRGB
* /
function HSBtoRGB ( hue : number , sat : number , bri : number , asArray : boolean ) : any ;
/ * < p > S e t a p a s s w o r d o n t h e c o n s o l e ( R E P L ) . W h e n p o w e r e d o n , E s p r u i n o w i l l
* then demand a password before the console can be used . If you want to
* lock the console immediately after this you can call < code > E . lockConsole ( ) < / code > < / p >
* To remove the password , call this function with no arguments .
* < p > < strong > Note : < / strong > There is no protection against multiple password attempts , so someone
* could conceivably try every password in a dictionary . < / p >
* < p > < strong > Note : < / strong > This password is stored in memory in plain text . If someone is able
* to execute arbitrary JavaScript code on the device ( eg , you use < code > eval < / code > on input
* from unknown sources ) or read the device & # 39 ; s firmware then they may be able to
* obtain it . < / p >
* @url http : //www.espruino.com/Reference#l_E_setPassword
* /
function setPassword ( password : any ) : void ;
/ * < p > I f a p a s s w o r d h a s b e e n s e t w i t h < c o d e > E . s e t P a s s w o r d ( ) < / c o d e > , t h i s w i l l l o c k t h e c o n s o l e
* so the password needs to be entered to unlock it . < / p >
* @url http : //www.espruino.com/Reference#l_E_lockConsole
* /
function lockConsole ( ) : void ;
/ * S e t t h e t i m e z o n e t o b e u s e d w i t h < c o d e > D a t e < / c o d e > o b j e c t s .
* For example < code > E . setTimeZone ( 1 ) < / code > will be GMT + 0100
* Time can be set with < code > setTime < / code > .
* @url http : //www.espruino.com/Reference#l_E_setTimeZone
* /
function setTimeZone ( zone : number ) : void ;
/ * P r o v i d e a s s e m b l y t o E s p r u i n o .
* < p > < strong > This function is not part of Espruino < / strong > . Instead , it is detected
* by the Espruino IDE ( or command - line tools ) at upload time and is
* replaced with machine code and an < code > E . nativeCall < / code > call . < / p >
* See < a href = "http://www.espruino.com/Assembler" > the documentation on the Assembler < / a > for more information .
* @url http : //www.espruino.com/Reference#l_E_asm
* /
function asm ( callspec : any , assemblycode : any ) : void ;
/ * P r o v i d e s t h e a b i l i t y t o w r i t e C c o d e i n s i d e y o u r J a v a S c r i p t f i l e .
* < p > < strong > This function is not part of Espruino < / strong > . Instead , it is detected
* by the Espruino IDE ( or command - line tools ) at upload time , is sent
* to our web service to be compiled , and is replaced with machine code
* and an < code > E . nativeCall < / code > call . < / p >
* See < a href = "http://www.espruino.com/InlineC" > the documentation on Inline C < / a > for more information and examples .
* @url http : //www.espruino.com/Reference#l_E_compiledC
* /
function compiledC ( code : any ) : void ;
/ * < p > F o r c e s a h a r d r e b o o t o f t h e m i c r o c o n t r o l l e r - a s c l o s e a s p o s s i b l e
* to if the reset pin had been toggled . < / p >
* < p > < strong > Note : < / strong > This is different to < code > reset ( ) < / code > , which performs a software
* reset of Espruino ( resetting the interpreter and pin states , but not
* all the hardware ) < / p >
* @url http : //www.espruino.com/Reference#l_E_reboot
* /
function reboot ( ) : void ;
/ * < p > U S B H I D w i l l o n l y t a k e e f f e c t n e x t t i m e y o u u n p l u g a n d r e - p l u g y o u r E s p r u i n o . I f y o u & # 3 9 ; r e
* disconnecting it from power you & # 39 ; ll have to make sure you have < code > save ( ) < / code > d after calling
* this function . < / p >
* @url http : //www.espruino.com/Reference#l_E_setUSBHID
* /
function setUSBHID ( opts : any ) : void ;
/* @url http:/ / www . espruino . com / Reference # l_E_sendUSBHID
* /
function sendUSBHID ( data : any ) : boolean ;
/ * < p > I n d e v i c e s t h a t c o m e w i t h b a t t e r i e s , t h i s f u n c t i o n r e t u r n s
* the battery charge percentage as an integer between 0 and 100 . < / p >
* < p > < strong > Note : < / strong > this is an estimation only , based on battery voltage .
* The temperature of the battery ( as well as the load being drawn
* from it at the time < code > E . getBattery < / code > is called ) will affect the
* readings . < / p >
* @url http : //www.espruino.com/Reference#l_E_getBattery
* /
function getBattery ( ) : number ;
/ * G e t s t h e R T C & # 3 9 ; s c u r r e n t p r e s c a l e r v a l u e i f < c o d e > c a l i b r a t e < / c o d e > i s u n d e f i n e d o r f a l s e .
* < p > If < code > calibrate < / code > is true , the low speed oscillator & # 39 ; s speed is calibrated against the high speed
* oscillator ( usually + / - 2 0 p p m ) a n d a s u g g e s t e d v a l u e t o b e f e d i n t o < c o d e > E . s e t R T C P r e s c a l e r ( . . . ) < / c o d e > i s r e t u r n e d . < / p >
* See < code > E . setRTCPrescaler < / code > for more information .
* @url http : //www.espruino.com/Reference#l_E_getRTCPrescaler
* /
function getRTCPrescaler ( calibrate : boolean ) : number ;
}
/ * C r e a t e s a n I n t e r n a l E r r o r o b j e c t
* @url http : //www.espruino.com/Reference#l_InternalError_InternalError
* /
declare function InternalError ( message : any ) : any ;
type InternalError = {
}
/ * C r e a t e s a p i n f r o m t h e g i v e n a r g u m e n t ( o r r e t u r n s u n d e f i n e d i f n o a r g u m e n t )
* @url http : //www.espruino.com/Reference#l_Pin_Pin
* /
declare function Pin ( value : any ) : any ;
type Pin = {
/ * R e t u r n s t h e i n p u t s t a t e o f t h e p i n a s a b o o l e a n .
* < strong > Note : < / strong > if you didn & # 39 ; t call < code > pinMode < / code > beforehand then this function will also reset the pin & # 39 ; s state to < code > & quot ; input & quot ; < / code >
* @url http : //www.espruino.com/Reference#l_Pin_read
* /
read : ( ) = > boolean ;
/ * S e t s t h e o u t p u t s t a t e o f t h e p i n t o a 1
* < strong > Note : < / strong > if you didn & # 39 ; t call < code > pinMode < / code > beforehand then this function will also reset the pin & # 39 ; s state to < code > & quot ; output & quot ; < / code >
* @url http : //www.espruino.com/Reference#l_Pin_set
* /
set : ( ) = > void ;
/ * S e t s t h e o u t p u t s t a t e o f t h e p i n t o a 0
* < strong > Note : < / strong > if you didn & # 39 ; t call < code > pinMode < / code > beforehand then this function will also reset the pin & # 39 ; s state to < code > & quot ; output & quot ; < / code >
* @url http : //www.espruino.com/Reference#l_Pin_reset
* /
reset : ( ) = > void ;
/ * S e t s t h e o u t p u t s t a t e o f t h e p i n t o t h e p a r a m e t e r g i v e n
* < strong > Note : < / strong > if you didn & # 39 ; t call < code > pinMode < / code > beforehand then this function will also reset the pin & # 39 ; s state to < code > & quot ; output & quot ; < / code >
* @url http : //www.espruino.com/Reference#l_Pin_write
* /
write : ( value : boolean ) = > void ;
/ * S e t s t h e o u t p u t s t a t e o f t h e p i n t o t h e p a r a m e t e r g i v e n a t t h e s p e c i f i e d t i m e .
* < strong > Note : < / strong > this < strong > doesn & # 39 ; t < / strong > change the mode of the pin to an output . To do that , you need to use < code > pin . write ( 0 ) < / code > or < code > pinMode ( pin , & # 39 ; output & # 39 ; ) < / code > first .
* @url http : //www.espruino.com/Reference#l_Pin_writeAtTime
* /
writeAtTime : ( value : boolean , time : number ) = > void ;
/ * R e t u r n t h e c u r r e n t m o d e o f t h e g i v e n p i n . S e e < c o d e > p i n M o d e < / c o d e > f o r m o r e i n f o r m a t i o n .
* @url http : //www.espruino.com/Reference#l_Pin_getMode
* /
getMode : ( ) = > any ;
/ * S e t t h e m o d e o f t h e g i v e n p i n . S e e < a h r e f = " # l _ _ g l o b a l _ p i n M o d e " > < c o d e > p i n M o d e < / c o d e > < / a > f o r m o r e i n f o r m a t i o n o n p i n m o d e s .
* @url http : //www.espruino.com/Reference#l_Pin_mode
* /
mode : ( mode : any ) = > void ;
/ * T o g g l e s t h e s t a t e o f t h e p i n f r o m o f f t o o n , o r f r o m o n t o o f f .
* < strong > Note : < / strong > This method doesn & # 39 ; t currently work on the ESP8266 port of Espruino .
* < strong > Note : < / strong > if you didn & # 39 ; t call < code > pinMode < / code > beforehand then this function will also reset the pin & # 39 ; s state to < code > & quot ; output & quot ; < / code >
* @url http : //www.espruino.com/Reference#l_Pin_toggle
* /
toggle : ( ) = > boolean ;
}
/ * C r e a t e a s o f t w a r e O n e W i r e i m p l e m e n t a t i o n o n t h e g i v e n p i n
* @url http : //www.espruino.com/Reference#l_OneWire_OneWire
* /
declare function OneWire ( pin : Pin ) : any ;
type OneWire = {
/ * P e r f o r m a r e s e t c y c l e
* @url http : //www.espruino.com/Reference#l_OneWire_reset
* /
reset : ( ) = > boolean ;
/ * S e l e c t a R O M - a l w a y s p e r f o r m s a r e s e t f i r s t
* @url http : //www.espruino.com/Reference#l_OneWire_select
* /
select : ( rom : any ) = > void ;
/ * S k i p a R O M
* @url http : //www.espruino.com/Reference#l_OneWire_skip
* /
skip : ( ) = > void ;
/ * W r i t e o n e o r m o r e b y t e s
* @url http : //www.espruino.com/Reference#l_OneWire_write
* /
write : ( data : any , power : boolean ) = > void ;
/ * R e a d a b y t e
* @url http : //www.espruino.com/Reference#l_OneWire_read
* /
read : ( count : any ) = > any ;
/ * S e a r c h f o r d e v i c e s
* @url http : //www.espruino.com/Reference#l_OneWire_search
* /
search : ( command : number ) = > any ;
}
/ * T h i s m o d u l e a l l o w s y o u t o r e a d a n d w r i t e t h e n o n v o l a t i l e f l a s h m e m o r y o f y o u r d e v i c e .
* < p > Also see the < code > Storage < / code > library , which provides a safer file - like
* interface to nonvolatile storage . < / p >
* < p > It should be used with extreme caution , as it is easy to overwrite parts of Flash
* memory belonging to Espruino or even its bootloader . If you damage the bootloader
* then you may need external hardware such as a USB - TTL converter to restore it . For
* more information on restoring the bootloader see < code > Advanced Reflashing < / code > in your
* board & # 39 ; s reference pages . < / p >
* < p > To see which areas of memory you can and can & # 39 ; t overwrite , look at the values
* reported by < code > process . memory ( ) < / code > . < / p >
* < p > < strong > Note : < / strong > On Nordic platforms there are checks in place to help you avoid
* & # 39 ; bricking & # 39 ; your device be damaging the bootloader . You can disable these with < code > E . setFlags ( { unsafeFlash :1 } ) < / code > < / p >
* @url http : //www.espruino.com/Reference#l_Flash_undefined
* /
declare function Flash ( ) : void ;
declare namespace Flash {
/ * R e t u r n s t h e s t a r t a n d l e n g t h o f t h e f l a s h p a g e c o n t a i n i n g t h e g i v e n a d d r e s s .
* @url http : //www.espruino.com/Reference#l_Flash_getPage
* /
function getPage ( addr : number ) : any ;
/ * < p > T h i s m e t h o d r e t u r n s a n a r r a y o f o b j e c t s o f t h e f o r m < c o d e > { a d d r : # , l e n g t h : # } < / c o d e > , r e p r e s e n t i n g
* contiguous areas of flash memory in the chip that are not used for anything . < / p >
* < p > The memory areas returned are on page boundaries . This means that you can
* safely erase the page containing any address here , and you won & # 39 ; t risk
* deleting part of the Espruino firmware . < / p >
* @url http : //www.espruino.com/Reference#l_Flash_getFree
* /
function getFree ( ) : any ;
/ * E r a s e a p a g e o f f l a s h m e m o r y
* @url http : //www.espruino.com/Reference#l_Flash_erasePage
* /
function erasePage ( addr : any ) : void ;
/ * W r i t e d a t a i n t o m e m o r y a t t h e g i v e n a d d r e s s
* < p > In flash memory you may only turn bits that are 1 into bits that are 0 . If
* you & # 39 ; re writing data into an area that you have already written ( so < code > read < / code >
* doesn & # 39 ; t return all < code > 0xFF < / code > ) you & # 39 ; ll need to call < code > erasePage < / code > to clear the
* entire page . < / p >
* @url http : //www.espruino.com/Reference#l_Flash_write
* /
function write ( data : any , addr : number ) : void ;
/ * R e a d f l a s h m e m o r y f r o m t h e g i v e n a d d r e s s
* @url http : //www.espruino.com/Reference#l_Flash_read
* /
function read ( length : number , addr : number ) : any ;
}
/ * B u i l t - i n c l a s s t h a t c a c h e s t h e m o d u l e s u s e d b y t h e < c o d e > r e q u i r e < / c o d e > c o m m a n d
* @url http : //www.espruino.com/Reference#Modules
* /
declare function Modules ( ) : void ;
declare namespace Modules {
/ * R e t u r n a n a r r a y o f m o d u l e n a m e s t h a t h a v e b e e n c a c h e d
* @url http : //www.espruino.com/Reference#l_Modules_getCached
* /
function getCached ( ) : any ;
/ * R e m o v e t h e g i v e n m o d u l e f r o m t h e l i s t o f c a c h e d m o d u l e s
* @url http : //www.espruino.com/Reference#l_Modules_removeCached
* /
function removeCached ( id : any ) : void ;
/ * R e m o v e a l l c a c h e d m o d u l e s
* @url http : //www.espruino.com/Reference#l_Modules_removeAllCached
* /
function removeAllCached ( ) : void ;
/ * A d d t h e g i v e n m o d u l e t o t h e c a c h e
* @url http : //www.espruino.com/Reference#l_Modules_addCached
* /
function addCached ( id : any , sourcecode : any ) : void ;
}
/ * C r e a t e a s o f t w a r e S P I p o r t . T h i s h a s l i m i t e d f u n c t i o n a l i t y ( n o b a u d r a t e ) , b u t i t c a n w o r k o n a n y p i n s .
* Use < code > SPI . setup < / code > to configure this port .
* @url http : //www.espruino.com/Reference#l_SPI_SPI
* /
declare function SPI ( ) : any ;
type SPI = {
/ * S e n d d a t a d o w n S P I , a n d r e t u r n t h e r e s u l t . S e n d i n g a n i n t e g e r w i l l r e t u r n a n i n t e g e r , a S t r i n g w i l l r e t u r n a S t r i n g , a n d a n y t h i n g e l s e w i l l r e t u r n a U i n t 8 A r r a y .
* Sending multiple bytes in one call to send is preferable as they can then be transmitted end to end . Using multiple calls to send ( ) will result in significantly slower transmission speeds .
* For maximum speeds , please pass either Strings or Typed Arrays as arguments . Note that you can even pass arrays of arrays , like < code > [ 1 , [ 2 , 3 , 4 ] , 5 ] < / code >
* @url http : //www.espruino.com/Reference#l_SPI_send
* /
send : ( data : any , nss_pin : Pin ) = > any ;
/ * W r i t e a c h a r a c t e r o r a r r a y o f c h a r a c t e r s t o S P I - w i t h o u t r e a d i n g t h e r e s u l t b a c k .
* For maximum speeds , please pass either Strings or Typed Arrays as arguments .
* @url http : //www.espruino.com/Reference#l_SPI_write
* /
write : ( data : any ) = > void ;
/ * S e n d d a t a d o w n S P I , u s i n g 4 b i t s f o r e a c h & # 3 9 ; r e a l & # 3 9 ; b i t ( M S B f i r s t ) . T h i s c a n b e u s e f u l f o r f a k i n g o n e - w i r e s t y l e p r o t o c o l s
* Sending multiple bytes in one call to send is preferable as they can then be transmitted end to end . Using multiple calls to send ( ) will result in significantly slower transmission speeds .
* @url http : //www.espruino.com/Reference#l_SPI_send4bit
* /
send4bit : ( data : any , bit0 : number , bit1 : number , nss_pin : Pin ) = > void ;
/ * S e n d d a t a d o w n S P I , u s i n g 8 b i t s f o r e a c h & # 3 9 ; r e a l & # 3 9 ; b i t ( M S B f i r s t ) . T h i s c a n b e u s e f u l f o r f a k i n g o n e - w i r e s t y l e p r o t o c o l s
* Sending multiple bytes in one call to send is preferable as they can then be transmitted end to end . Using multiple calls to send ( ) will result in significantly slower transmission speeds .
* @url http : //www.espruino.com/Reference#l_SPI_send8bit
* /
send8bit : ( data : any , bit0 : number , bit1 : number , nss_pin : Pin ) = > void ;
}
declare namespace SPI {
/ * T r y a n d f i n d a n S P I h a r d w a r e d e v i c e t h a t w i l l w o r k o n t h i s p i n ( e g . < c o d e > S P I 1 < / c o d e > )
* May return undefined if no device can be found .
* @url http : //www.espruino.com/Reference#l_SPI_find
* /
function find ( pin : Pin ) : any ;
}
/ * T h e f i r s t S P I p o r t
* @url http : //www.espruino.com/Reference#l__global_SPI1
* /
declare const SPI1 : SPI ;
/ * T h e s e c o n d S P I p o r t
* @url http : //www.espruino.com/Reference#l__global_SPI2
* /
declare const SPI2 : SPI ;
/ * T h e t h i r d S P I p o r t
* @url http : //www.espruino.com/Reference#l__global_SPI3
* /
declare const SPI3 : SPI ;
/ * C r e a t e a s o f t w a r e I 2 C p o r t . T h i s h a s l i m i t e d f u n c t i o n a l i t y ( n o b a u d r a t e ) , b u t i t c a n w o r k o n a n y p i n s .
* Use < code > I2C . setup < / code > to configure this port .
* @url http : //www.espruino.com/Reference#l_I2C_I2C
* /
declare function I2C ( ) : any ;
type I2C = {
/ * S e t u p t h i s I 2 C p o r t
* If not specified in options , the default pins are used ( usually the lowest numbered pins on the lowest port that supports this peripheral )
* @url http : //www.espruino.com/Reference#l_I2C_setup
* /
setup : ( options : any ) = > void ;
/ * T r a n s m i t t o t h e s l a v e d e v i c e w i t h t h e g i v e n a d d r e s s . T h i s i s l i k e A r d u i n o & # 3 9 ; s b e g i n T r a n s m i s s i o n , w r i t e , a n d e n d T r a n s m i s s i o n r o l l e d u p i n t o o n e .
* @url http : //www.espruino.com/Reference#l_I2C_writeTo
* /
writeTo : ( address : any , data : any ) = > void ;
/ * R e q u e s t b y t e s f r o m t h e g i v e n s l a v e d e v i c e , a n d r e t u r n t h e m a s a U i n t 8 A r r a y ( p a c k e d a r r a y o f b y t e s ) . T h i s i s l i k e u s i n g A r d u i n o W i r e & # 3 9 ; s r e q u e s t F r o m , a v a i l a b l e a n d r e a d f u n c t i o n s . S e n d s a S T O P
* @url http : //www.espruino.com/Reference#l_I2C_readFrom
* /
readFrom : ( address : any , quantity : number ) = > Uint8Array ;
}
declare namespace I2C {
/ * T r y a n d f i n d a n I 2 C h a r d w a r e d e v i c e t h a t w i l l w o r k o n t h i s p i n ( e g . < c o d e > I 2 C 1 < / c o d e > )
* May return undefined if no device can be found .
* @url http : //www.espruino.com/Reference#l_I2C_find
* /
function find ( pin : Pin ) : any ;
}
/ * T h e f i r s t I 2 C p o r t
* @url http : //www.espruino.com/Reference#l__global_I2C1
* /
declare const I2C1 : I2C ;
/ * T h e s e c o n d I 2 C p o r t
* @url http : //www.espruino.com/Reference#l__global_I2C2
* /
declare const I2C2 : I2C ;
/ * T h e t h i r d I 2 C p o r t
* @url http : //www.espruino.com/Reference#l__global_I2C3
* /
declare const I2C3 : I2C ;
/ * S e t t h e c u r r e n t f o n t
* @url http : //www.espruino.com/Reference#l__global_setFont9x18
* /
declare function setFont9x18 ( scale : number ) : Graphics ;
/ * S e t t h e c u r r e n t f o n t
* @url http : //www.espruino.com/Reference#l__global_setFont12x26
* /
declare function setFont12x26 ( scale : number ) : Graphics ;
/ * S e t t h e c u r r e n t f o n t
* @url http : //www.espruino.com/Reference#l__global_setFont11x20
* /
declare function setFont11x20 ( scale : number ) : Graphics ;
/ * T h e p i n c o n n e c t e d t o t h e & # 3 9 ; A & # 3 9 ; b u t t o n . R e a d s a s < c o d e > 1 < / c o d e > w h e n p r e s s e d , < c o d e > 0 < / c o d e > w h e n n o t
* @url http : //www.espruino.com/Reference#l__global_BTNA
* /
declare const BTNA : Pin ;
/ * T h e p i n c o n n e c t e d t o t h e & # 3 9 ; B & # 3 9 ; b u t t o n . R e a d s a s < c o d e > 1 < / c o d e > w h e n p r e s s e d , < c o d e > 0 < / c o d e > w h e n n o t
* @url http : //www.espruino.com/Reference#l__global_BTNB
* /
declare const BTNB : Pin ;
/ * T h e p i n c o n n e c t e d t o t h e u p b u t t o n . R e a d s a s < c o d e > 1 < / c o d e > w h e n p r e s s e d , < c o d e > 0 < / c o d e > w h e n n o t
* @url http : //www.espruino.com/Reference#l__global_BTNU
* /
declare const BTNU : Pin ;
/ * T h e p i n c o n n e c t e d t o t h e d o w n b u t t o n . R e a d s a s < c o d e > 1 < / c o d e > w h e n p r e s s e d , < c o d e > 0 < / c o d e > w h e n n o t
* @url http : //www.espruino.com/Reference#l__global_BTND
* /
declare const BTND : Pin ;
/ * T h e p i n c o n n e c t e d t o t h e l e f t b u t t o n . R e a d s a s < c o d e > 1 < / c o d e > w h e n p r e s s e d , < c o d e > 0 < / c o d e > w h e n n o t
* @url http : //www.espruino.com/Reference#l__global_BTNL
* /
declare const BTNL : Pin ;
/ * T h e p i n c o n n e c t e d t o t h e r i g h t b u t t o n . R e a d s a s < c o d e > 1 < / c o d e > w h e n p r e s s e d , < c o d e > 0 < / c o d e > w h e n n o t
* @url http : //www.espruino.com/Reference#l__global_BTNR
* /
declare const BTNR : Pin ;
/ * T h e p i n c o n n e c t e d t o C o r n e r # 1
* @url http : //www.espruino.com/Reference#l__global_CORNER1
* /
declare const CORNER1 : Pin ;
/ * T h e p i n c o n n e c t e d t o C o r n e r # 2
* @url http : //www.espruino.com/Reference#l__global_CORNER2
* /
declare const CORNER2 : Pin ;
/ * T h e p i n c o n n e c t e d t o C o r n e r # 3
* @url http : //www.espruino.com/Reference#l__global_CORNER3
* /
declare const CORNER3 : Pin ;
/ * T h e p i n c o n n e c t e d t o C o r n e r # 4
* @url http : //www.espruino.com/Reference#l__global_CORNER4
* /
declare const CORNER4 : Pin ;
/ * T h e p i n c o n n e c t e d t o C o r n e r # 5
* @url http : //www.espruino.com/Reference#l__global_CORNER5
* /
declare const CORNER5 : Pin ;
/ * T h e p i n c o n n e c t e d t o C o r n e r # 6
* @url http : //www.espruino.com/Reference#l__global_CORNER6
* /
declare const CORNER6 : Pin ;
/ * T h e B a n g l e . j s & # 3 9 ; s v i b r a t i o n m o t o r .
* @url http : //www.espruino.com/Reference#l__global_VIBRATE
* /
declare const VIBRATE : Pin ;
/ * O n m o s t E s p r u i n o b o a r d t h e r e a r e L E D s , i n w h i c h c a s e < c o d e > L E D < / c o d e > w i l l b e a n a c t u a l P i n .
* < p > On Bangle . js there are no LEDs , so to remain compatible with example code that might
* expect an LED , this is an object that behaves like a pin , but which just displays
* a circle on the display < / p >
* @url http : //www.espruino.com/Reference#l__global_LED
* /
declare const LED : any ;
/ * O n m o s t E s p r u i n o b o a r d t h e r e a r e L E D s , i n w h i c h c a s e < c o d e > L E D 1 < / c o d e > w i l l b e a n a c t u a l P i n .
* < p > On Bangle . js there are no LEDs , so to remain compatible with example code that might
* expect an LED , this is an object that behaves like a pin , but which just displays
* a circle on the display < / p >
* @url http : //www.espruino.com/Reference#l__global_LED1
* /
declare const LED1 : any ;
/ * O n m o s t E s p r u i n o b o a r d t h e r e a r e L E D s , i n w h i c h c a s e < c o d e > L E D 2 < / c o d e > w i l l b e a n a c t u a l P i n .
* < p > On Bangle . js there are no LEDs , so to remain compatible with example code that might
* expect an LED , this is an object that behaves like a pin , but which just displays
* a circle on the display < / p >
* @url http : //www.espruino.com/Reference#l__global_LED2
* /
declare const LED2 : any ;
/ * < s t r o n g > N o t e : < / s t r o n g > T h i s f u n c t i o n i s o n l y a v a i l a b l e o n t h e < a h r e f = " / M i c r o B i t " > B B C m i c r o : b i t < / a > b o a r d
* Get the current acceleration of the micro :bit from the on - board accelerometer
* < strong > This is deprecated . < / strong > Please use < code > Microbit . accel < / code > instead .
* @url http : //www.espruino.com/Reference#l__global_acceleration
* /
declare function acceleration ( ) : any ;
/ * < s t r o n g > N o t e : < / s t r o n g > T h i s f u n c t i o n i s o n l y a v a i l a b l e o n t h e < a h r e f = " / M i c r o B i t " > B B C m i c r o : b i t < / a > b o a r d
* Get the current compass position for the micro :bit from the on - board magnetometer
* < strong > This is deprecated . < / strong > Please use < code > Microbit . mag < / code > instead .
* @url http : //www.espruino.com/Reference#l__global_compass
* /
declare function compass ( ) : any ;
/ * T h e p i n m a r k e d S D A o n t h e A r d u i n o p i n f o o t p r i n t . T h i s i s c o n n e c t e d d i r e c t l y t o p i n A 4 .
* @url http : //www.espruino.com/Reference#l__global_SDA
* /
declare const SDA : Pin ;
/ * T h e p i n m a r k e d S D A o n t h e A r d u i n o p i n f o o t p r i n t . T h i s i s c o n n e c t e d d i r e c t l y t o p i n A 5 .
* @url http : //www.espruino.com/Reference#l__global_SCL
* /
declare const SCL : Pin ;
/* @url http:/ / www . espruino . com / Reference # l__global_MOS1
* /
declare const MOS1 : Pin ;
/* @url http:/ / www . espruino . com / Reference # l__global_MOS2
* /
declare const MOS2 : Pin ;
/* @url http:/ / www . espruino . com / Reference # l__global_MOS3
* /
declare const MOS3 : Pin ;
/* @url http:/ / www . espruino . com / Reference # l__global_MOS4
* /
declare const MOS4 : Pin ;
/* @url http:/ / www . espruino . com / Reference # l__global_IOEXT0
* /
declare const IOEXT0 : Pin ;
/* @url http:/ / www . espruino . com / Reference # l__global_IOEXT1
* /
declare const IOEXT1 : Pin ;
/* @url http:/ / www . espruino . com / Reference # l__global_IOEXT2
* /
declare const IOEXT2 : Pin ;
/* @url http:/ / www . espruino . com / Reference # l__global_IOEXT3
* /
declare const IOEXT3 : Pin ;
/ * O n P u c k . j s V 2 ( n o t v 1 . 0 ) t h i s i s t h e p i n t h a t c o n t r o l s t h e F E T , f o r h i g h - p o w e r e d o u t p u t s .
* @url http : //www.espruino.com/Reference#l__global_FET
* /
declare const FET : Pin ;
/* @url http:/ / www . espruino . com / Reference # l__global_HIGH
* /
declare const HIGH : number ;
/* @url http:/ / www . espruino . com / Reference # l__global_LOW
* /
declare const LOW : number ;
/ * R e a d 8 b i t s o f m e m o r y a t t h e g i v e n l o c a t i o n - D A N G E R O U S !
* @url http : //www.espruino.com/Reference#l__global_peek8
* /
declare function peek8 ( addr : number , count : number ) : any ;
/ * W r i t e 8 b i t s o f m e m o r y a t t h e g i v e n l o c a t i o n - V E R Y D A N G E R O U S !
* @url http : //www.espruino.com/Reference#l__global_poke8
* /
declare function poke8 ( addr : number , value : any ) : void ;
/ * R e a d 1 6 b i t s o f m e m o r y a t t h e g i v e n l o c a t i o n - D A N G E R O U S !
* @url http : //www.espruino.com/Reference#l__global_peek16
* /
declare function peek16 ( addr : number , count : number ) : any ;
/ * W r i t e 1 6 b i t s o f m e m o r y a t t h e g i v e n l o c a t i o n - V E R Y D A N G E R O U S !
* @url http : //www.espruino.com/Reference#l__global_poke16
* /
declare function poke16 ( addr : number , value : any ) : void ;
/ * R e a d 3 2 b i t s o f m e m o r y a t t h e g i v e n l o c a t i o n - D A N G E R O U S !
* @url http : //www.espruino.com/Reference#l__global_peek32
* /
declare function peek32 ( addr : number , count : number ) : any ;
/ * W r i t e 3 2 b i t s o f m e m o r y a t t h e g i v e n l o c a t i o n - V E R Y D A N G E R O U S !
* @url http : //www.espruino.com/Reference#l__global_poke32
* /
declare function poke32 ( addr : number , value : any ) : void ;
/ * G e t t h e a n a l o g v a l u e o f t h e g i v e n p i n
* This is different to Arduino which only returns an integer between 0 and 1023
* However only pins connected to an ADC will work ( see the datasheet )
* < strong > Note : < / strong > if you didn & # 39 ; t call < code > pinMode < / code > beforehand then this function will also reset pin & # 39 ; s state to < code > & quot ; analog & quot ; < / code >
* @url http : //www.espruino.com/Reference#l__global_analogRead
* /
declare function analogRead ( pin : Pin ) : number ;
/ * S e t t h e a n a l o g V a l u e o f a p i n . I t w i l l b e o u t p u t u s i n g P W M .
* Objects can contain :
* < ul >
* < li > < code > freq < / code > - pulse frequency in Hz , eg . < code > analogWrite ( A0 , 0.5 , { freq : 10 } ) ; < / code > - specifying a frequency will force PWM output , even if the pin has a DAC < / li >
* < li > < code > soft < / code > - boolean , If true software PWM is used if hardware is not available . < / li >
* < li > < p > < code > forceSoft < / code > - boolean , If true software PWM is used even if hardware PWM or a DAC is available < / p >
* < strong > Note : < / strong > if you didn & # 39 ; t call < code > pinMode < / code > beforehand then this function will also reset pin & # 39 ; s state to < code > & quot ; output & quot ; < / code >
* < / li >
* < / ul >
* @url http : //www.espruino.com/Reference#l__global_analogWrite
* /
declare function analogWrite ( pin : Pin , value : number , options : any ) : void ;
/ * P u l s e t h e p i n w i t h t h e v a l u e f o r t h e g i v e n t i m e i n m i l l i s e c o n d s . I t u s e s a h a r d w a r e t i m e r t o p r o d u c e a c c u r a t e p u l s e s , a n d r e t u r n s i m m e d i a t e l y ( b e f o r e t h e p u l s e h a s f i n i s h e d ) . U s e < c o d e > d i g i t a l P u l s e ( A 0 , 1 , 0 ) < / c o d e > t o w a i t u n t i l a p r e v i o u s p u l s e h a s f i n i s h e d .
* eg . < code > digitalPulse ( A0 , 1 , 5 ) ; < / code > pulses A0 high for 5 ms . < code > digitalPulse ( A0 , 1 , [ 5 , 2 , 4 ] ) ; < / code > pulses A0 high for 5 ms , low for 2 ms , and high for 4 ms
* < strong > Note : < / strong > if you didn & # 39 ; t call < code > pinMode < / code > beforehand then this function will also reset pin & # 39 ; s state to < code > & quot ; output & quot ; < / code >
* digitalPulse is for SHORT pulses that need to be very accurate . If you & # 39 ; re doing anything over a few milliseconds , use setTimeout instead .
* @url http : //www.espruino.com/Reference#l__global_digitalPulse
* /
declare function digitalPulse ( pin : Pin , value : boolean , time : any ) : void ;
/ * S e t t h e d i g i t a l v a l u e o f t h e g i v e n p i n .
* < strong > Note : < / strong > if you didn & # 39 ; t call < code > pinMode < / code > beforehand then this function will also reset pin & # 39 ; s state to < code > & quot ; output & quot ; < / code >
* < p > If pin argument is an array of pins ( eg . < code > [ A2 , A1 , A0 ] < / code > ) the value argument will be treated
* as an array of bits where the last array element is the least significant bit . < / p >
* < p > In this case , pin values are set least significant bit first ( from the right - hand side
* of the array of pins ) . This means you can use the same pin multiple times , for
* example < code > digitalWrite ( [ A1 , A1 , A0 , A0 ] , 0 b0101 ) < / code > would pulse A0 followed by A1 . < / p >
* < p > If the pin argument is an object with a < code > write < / code > method , the < code > write < / code > method will
* be called with the value passed through . < / p >
* @url http : //www.espruino.com/Reference#l__global_digitalWrite
* /
declare function digitalWrite ( pin : Pin , value : number ) : void ;
/ * G e t t h e d i g i t a l v a l u e o f t h e g i v e n p i n .
* < strong > Note : < / strong > if you didn & # 39 ; t call < code > pinMode < / code > beforehand then this function will also reset pin & # 39 ; s state to < code > & quot ; input & quot ; < / code >
* < p > If the pin argument is an array of pins ( eg . < code > [ A2 , A1 , A0 ] < / code > ) the value returned will be an number where
* the last array element is the least significant bit , for example if < code > A0 = A1 = 1 < / code > and < code > A2 = 0 < / code > , < code > digitalRead ( [ A2 , A1 , A0 ] ) == 0 b011 < / code > < / p >
* < p > If the pin argument is an object with a < code > read < / code > method , the < code > read < / code > method will be called and the integer value it returns
* passed back . < / p >
* @url http : //www.espruino.com/Reference#l__global_digitalRead
* /
declare function digitalRead ( pin : Pin ) : number ;
/ * S e t t h e m o d e o f t h e g i v e n p i n .
* < ul >
* < li > < code > auto < / code > / < code > undefined < / code > - Don & # 39 ; t change state , but allow < code > digitalWrite < / code > / etc to automatically change state as appropriate < / li >
* < li > < code > analog < / code > - Analog input < / li >
* < li > < code > input < / code > - Digital input < / li >
* < li > < code > input_pullup < / code > - Digital input with internal ~ 40 k pull - up resistor < / li >
* < li > < code > input_pulldown < / code > - Digital input with internal ~ 40 k pull - down resistor < / li >
* < li > < code > output < / code > - Digital output < / li >
* < li > < code > opendrain < / code > - Digital output that only ever pulls down to 0 v . Sending a logical < code > 1 < / code > leaves the pin open circuit < / li >
* < li > < code > opendrain_pullup < / code > - Digital output that pulls down to 0 v . Sending a logical < code > 1 < / code > enables internal ~ 40 k pull - up resistor < / li >
* < li > < code > af_output < / code > - Digital output from built - in peripheral < / li >
* < li > < p > < code > af_opendrain < / code > - Digital output from built - in peripheral that only ever pulls down to 0 v . Sending a logical < code > 1 < / code > leaves the pin open circuit < / p >
* < p > < strong > Note : < / strong > < code > digitalRead < / code > / < code > digitalWrite < / code > / etc set the pin mode automatically < em > unless < / em > < code > pinMode < / code > has been called first .
* If you want < code > digitalRead < / code > / etc to set the pin mode automatically after you have called < code > pinMode < / code > , simply call it again
* with no mode argument ( < code > pinMode ( pin ) < / code > ) , < code > auto < / code > as the argument ( < code > pinMode ( pin , & quot ; auto & quot ; ) < / code > ) , or with the 3 rd & # 39 ; automatic & # 39 ;
* argument set to true ( < code > pinMode ( pin , & quot ; output & quot ; , true ) < / code > ) . < / p >
* < / li >
* < / ul >
* @url http : //www.espruino.com/Reference#l__global_pinMode
* /
declare function pinMode ( pin : Pin , mode : any , automatic : boolean ) : void ;
/ * R e t u r n t h e c u r r e n t m o d e o f t h e g i v e n p i n . S e e < c o d e > p i n M o d e < / c o d e > f o r m o r e i n f o r m a t i o n o n r e t u r n e d v a l u e s .
* @url http : //www.espruino.com/Reference#l__global_getPinMode
* /
declare function getPinMode ( pin : Pin ) : any ;
/ * C l e a r t h e W a t c h t h a t w a s c r e a t e d w i t h s e t W a t c h . I f n o p a r a m e t e r i s s u p p l i e d , a l l w a t c h e s w i l l b e r e m o v e d .
* To avoid accidentally deleting all Watches , if a parameter is supplied but is < code > undefined < / code > then an Exception will be thrown .
* @url http : //www.espruino.com/Reference#l__global_clearWatch
* /
declare function clearWatch ( id : any ) : void ;
/ * W h e n E s p r u i n o i s b u s y , s e t t h e p i n s p e c i f i e d h e r e h i g h . S e t t h i s t o u n d e f i n e d t o d i s a b l e t h e f e a t u r e .
* @url http : //www.espruino.com/Reference#l__global_setBusyIndicator
* /
declare function setBusyIndicator ( pin : Pin ) : void ;
/ * W h e n E s p r u i n o i s a s l e e p , s e t t h e p i n s p e c i f i e d h e r e l o w ( w h e n i t & # 3 9 ; s a w a k e , s e t i t h i g h ) . S e t t h i s t o u n d e f i n e d t o d i s a b l e t h e f e a t u r e .
* Please see < a href = "http://www.espruino.com/Power+Consumption" > http : //www.espruino.com/Power+Consumption</a> for more details on this.
* @url http : //www.espruino.com/Reference#l__global_setSleepIndicator
* /
declare function setSleepIndicator ( pin : Pin ) : void ;
/ * S e t w h e t h e r w e c a n e n t e r d e e p s l e e p m o d e , w h i c h r e d u c e s p o w e r c o n s u m p t i o n t o a r o u n d 1 0 0 u A . T h i s o n l y w o r k s o n S T M 3 2 E s p r u i n o B o a r d s ( n R F 5 2 b o a r d s s l e e p a u t o m a t i c a l l y ) .
* Please see < a href = "http://www.espruino.com/Power+Consumption" > http : //www.espruino.com/Power+Consumption</a> for more details on this.
* @url http : //www.espruino.com/Reference#l__global_setDeepSleep
* /
declare function setDeepSleep ( sleep : boolean ) : void ;
/ * O u t p u t d e b u g g i n g i n f o r m a t i o n
* Note : This is not included on boards with low amounts of flash memory , or the Espruino board .
* @url http : //www.espruino.com/Reference#l__global_trace
* /
declare function trace ( root : any ) : void ;
/ * O u t p u t c u r r e n t i n t e r p r e t e r s t a t e i n a t e x t f o r m s u c h t h a t i t c a n b e c o p i e d t o a n e w d e v i c e
* Espruino keeps its current state in RAM ( even if the function code is stored in Flash ) . When you type < code > dump ( ) < / code > it dumps the current state of code in RAM plus the hardware state , then if there & # 39 ; s code saved in flash it writes & quot ; // Code saved with E.setBootCode" and dumps that too.
* < strong > Note : < / strong > & # 39 ; Internal & # 39 ; functions are currently not handled correctly . You will need to recreate these in the < code > onInit < / code > function .
* @url http : //www.espruino.com/Reference#l__global_dump
* /
declare function dump ( ) : void ;
/ * < p > R e s t a r t a n d l o a d t h e p r o g r a m o u t o f f l a s h - t h i s h a s a n e f f e c t s i m i l a r t o
* completely rebooting Espruino ( power off / power on ) , but without actually
* performing a full reset of the hardware . < / p >
* < p > This command only executes when the Interpreter returns to the Idle state - for
* instance < code > a = 1 ; load ( ) ; a = 2 ; < / code > will still leave & # 39 ; a & # 39 ; as undefined ( or what it was
* set to in the saved program ) . < / p >
* < p > Espruino will resume from where it was when you last typed < code > save ( ) < / code > .
* If you want code to be executed right after loading ( for instance to initialise
* devices connected to Espruino ) , add an < code > init < / code > event handler to < code > E < / code > with
* < code > E . on ( & # 39 ; init & # 39 ; , function ( ) { . . . your_code . . . } ) ; < / code > . This will then be automatically
* executed by Espruino every time it starts . < / p >
* < p > < strong > If you specify a filename in the argument then that file will be loaded
* from Storage after reset < / strong > in much the same way as calling < code > reset ( ) < / code > then < code > eval ( require ( & quot ; Storage & quot ; ) . read ( filename ) ) < / code > < / p >
* @url http : //www.espruino.com/Reference#l__global_load
* /
declare function load ( filename : any ) : void ;
/ * < p > S a v e t h e s t a t e o f t h e i n t e r p r e t e r i n t o f l a s h ( i n c l u d i n g t h e r e s u l t s o f c a l l i n g
* < code > setWatch < / code > , < code > setInterval < / code > , < code > pinMode < / code > , and any listeners ) . The state will then be loaded automatically
* every time Espruino powers on or is hard - reset . To see what will get saved you can call < code > dump ( ) < / code > . < / p >
* < p > < strong > Note : < / strong > If you set up intervals / etc in < code > onInit ( ) < / code > and you have already called < code > onInit < / code >
* before running < code > save ( ) < / code > , when Espruino resumes there will be two copies of your intervals -
* the ones from before the save , and the ones from after - which may cause you problems . < / p >
* < p > For more information about this and other options for saving , please see
* the < a href = "https://www.espruino.com/Saving" > Saving code on Espruino < / a > page . < / p >
* < p > This command only executes when the Interpreter returns to the Idle state - for
* instance < code > a = 1 ; save ( ) ; a = 2 ; < / code > will save & # 39 ; a & # 39 ; as 2 . < / p >
* < p > When Espruino powers on , it will resume from where it was when you typed < code > save ( ) < / code > .
* If you want code to be executed right after loading ( for instance to initialise
* devices connected to Espruino ) , add a function called < code > onInit < / code > , or add a < code > init < / code >
* event handler to < code > E < / code > with < code > E . on ( & # 39 ; init & # 39 ; , function ( ) { . . . your_code . . . } ) ; < / code > .
* This will then be automatically executed by Espruino every time it starts . < / p >
* < p > In order to stop the program saved with this command being loaded automatically ,
* check out < a href = "https://www.espruino.com/Troubleshooting#espruino-stopped-working-after-i-typed-save-" > the Troubleshooting guide < / a > < / p >
* @url http : //www.espruino.com/Reference#l__global_save
* /
declare function save ( ) : void ;
/ * R e s e t t h e i n t e r p r e t e r - c l e a r p r o g r a m m e m o r y i n R A M , a n d d o n o t l o a d a s a v e d p r o g r a m f r o m f l a s h . T h i s d o e s N O T r e s e t t h e u n d e r l y i n g h a r d w a r e ( w h i c h a l l o w s y o u t o r e s e t t h e d e v i c e w i t h o u t i t d i s c o n n e c t i n g f r o m U S B ) .
* This command only executes when the Interpreter returns to the Idle state - for instance < code > a = 1 ; reset ( ) ; a = 2 ; < / code > will still leave & # 39 ; a & # 39 ; as undefined .
* The safest way to do a full reset is to hit the reset button .
* < p > If < code > reset ( ) < / code > is called with no arguments , it will reset the board & # 39 ; s state in
* RAM but will not reset the state in flash . When next powered on ( or when
* < code > load ( ) < / code > is called ) the board will load the previously saved code . < / p >
* < p > Calling < code > reset ( true ) < / code > will cause < em > all saved code in flash memory to
* be cleared as well < / em > . < / p >
* @url http : //www.espruino.com/Reference#l__global_reset
* /
declare function reset ( clearFlash : boolean ) : void ;
/ * P r i n t t h e s u p p l i e d s t r i n g ( s ) t o t h e c o n s o l e
* < strong > Note : < / strong > If you & # 39 ; re connected to a computer ( not a wall adaptor ) via USB but < strong > you are not running a terminal app < / strong > then when you print data Espruino may pause execution and wait until the computer requests the data it is trying to print .
* @url http : //www.espruino.com/Reference#l__global_print
2022-07-19 07:49:47 +00:00
* /
2022-07-20 13:07:21 +00:00
declare function print ( text : any ) : void ;
2022-07-19 07:49:47 +00:00
2022-07-20 13:07:21 +00:00
/ * F i l l t h e c o n s o l e w i t h t h e c o n t e n t s o f t h e g i v e n f u n c t i o n , s o y o u c a n e d i t i t .
* NOTE : This is a convenience function - it will not edit & # 39 ; inner functions & # 39 ; . For that , you must edit the & # 39 ; outer function & # 39 ; and re - execute it .
* @url http : //www.espruino.com/Reference#l__global_edit
* /
declare function edit ( funcName : any ) : void ;
2022-07-19 07:49:47 +00:00
2022-07-20 13:07:21 +00:00
/ * S h o u l d E s p r u i n o e c h o w h a t y o u t y p e b a c k t o y o u ? t r u e = y e s ( D e f a u l t ) , f a l s e = n o . W h e n e c h o i s o f f , t h e r e s u l t o f e x e c u t i n g a c o m m a n d i s n o t r e t u r n e d . I n s t e a d , y o u m u s t u s e & # 3 9 ; p r i n t & # 3 9 ; t o s e n d o u t p u t .
* @url http : //www.espruino.com/Reference#l__global_echo
* /
declare function echo ( echoOn : boolean ) : void ;
2022-07-19 07:49:47 +00:00
2022-07-20 13:07:21 +00:00
/ * R e t u r n t h e c u r r e n t s y s t e m t i m e i n S e c o n d s ( a s a f l o a t i n g p o i n t n u m b e r )
* @url http : //www.espruino.com/Reference#l__global_getTime
* /
declare function getTime ( ) : number ;
2022-07-19 07:49:47 +00:00
2022-07-20 13:07:21 +00:00
/ * G e t t h e s e r i a l n u m b e r o f t h i s b o a r d
* @url http : //www.espruino.com/Reference#l__global_getSerial
* /
declare function getSerial ( ) : any ;
2022-07-19 07:49:47 +00:00
2022-07-20 13:07:21 +00:00
/ * C h a n g e t h e I n t e r v a l o n a c a l l b a c k c r e a t e d w i t h < c o d e > s e t I n t e r v a l < / c o d e > , f o r e x a m p l e :
* < code > var id = setInterval ( function ( ) { print ( & # 39 ; foo & # 39 ; ) ; } , 1000 ) ; // every second</code>
* < code > changeInterval ( id , 1500 ) ; // now runs every 1.5 seconds</code>
* < p > This takes effect immediately and resets the timeout , so in the example above ,
* regardless of when you call < code > changeInterval < / code > , the next interval will occur 1500 ms
* after it . < / p >
* @url http : //www.espruino.com/Reference#l__global_changeInterval
* /
declare function changeInterval ( id : any , time : number ) : void ;