exposing i2c blocks in pins
This commit is contained in:
		@@ -11,7 +11,7 @@ namespace pins {
 | 
			
		||||
     * @param toLow the lower bound of the value's target range
 | 
			
		||||
     * @param toHigh the upper bound of the value's target range, eg: 4
 | 
			
		||||
     */
 | 
			
		||||
    //% help=pins/map weight=15
 | 
			
		||||
    //% help=pins/map weight=3
 | 
			
		||||
    //% blockId=math_map block="map %value|from low %fromLow|from high %fromHigh|to low %toLow|to high %toHigh"
 | 
			
		||||
    export function map(value: number, fromLow: number, fromHigh: number, toLow: number, toHigh: number): number {
 | 
			
		||||
        return ((value - fromLow) * (toHigh - toLow)) / (fromHigh - fromLow) + toLow;
 | 
			
		||||
@@ -20,6 +20,8 @@ namespace pins {
 | 
			
		||||
    /**
 | 
			
		||||
     * Read one number from 7-bit I2C address.
 | 
			
		||||
     */
 | 
			
		||||
    //% help=pins/i2c-read-number
 | 
			
		||||
    //% blockId=pins_i2c_readnumber block="i2c read number|at address %address|of format %format=i2c_sizeof" weight=7
 | 
			
		||||
    export function i2cReadNumber(address: number, format: NumberFormat): number {
 | 
			
		||||
        let buf = pins.i2cReadBuffer(address, pins.sizeOf(format))
 | 
			
		||||
        return buf.getNumber(format, 0)
 | 
			
		||||
@@ -28,6 +30,8 @@ namespace pins {
 | 
			
		||||
    /**
 | 
			
		||||
     * Write one number to a 7-bit I2C address.
 | 
			
		||||
     */
 | 
			
		||||
    //% help=pins/i2c-write-number
 | 
			
		||||
    //% blockId=i2c_writenumber block="i2c write number|at address %address|with value %value|of format %format=i2c_sizeof" weight=6
 | 
			
		||||
    export function i2cWriteNumber(address: number, value: number, format: NumberFormat): void {
 | 
			
		||||
        let buf = createBuffer(pins.sizeOf(format))
 | 
			
		||||
        buf.setNumber(format, 0, value)
 | 
			
		||||
@@ -37,6 +41,7 @@ namespace pins {
 | 
			
		||||
    /**
 | 
			
		||||
     * Get the size in bytes of specified number format.
 | 
			
		||||
     */
 | 
			
		||||
    //%
 | 
			
		||||
    export function sizeOf(format: NumberFormat) {
 | 
			
		||||
        switch (format) {
 | 
			
		||||
            case NumberFormat.Int8LE:
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user