// ServoWrite writes value to the specified pin
422905
func (d *DirectPinDriver) ServoWrite(level byte) (err error) {
	if writer, ok := d.Connection().(ServoWriter); ok {
		return writer.ServoWrite(d.Pin(), level)
	}
	err = ErrServoWriteUnsupported
	return
}
498318
func (p *port) Write(b []byte) (n int, err error) {
	var done uint32
	if err = syscall.WriteFile(p.handle, b, &done, nil); err != nil {
		return
	}
	n = int(done)
	return
}
759748
func (f WriteHandlerFunc) ServeWrite(r Request, data []byte) byte {
	return f(r, data)
}
1013290
func (mw *Writer) Write(buf []byte) (int, error) {
	if mw.err != nil {
		return 0, mw.err
	}

	var wrCnt int
	for _, b := range buf {
		zeros, ones := numBits(b)

		// If possible, avoid flushing to maintain high efficiency.
		if ensured := mw.bufCnt < EnsureRawBytes; ensured {
			goto skipEncode
		}
		if huffLen, _ := mw.computeHuffLen(mw.buf0s+zeros, mw.buf1s+ones); huffLen > 0 {
			goto skipEncode
		}

		mw.err = mw.encodeBlock(FinalNil)
		if mw.err != nil {
			break
		}

	skipEncode:
		mw.buf0s += zeros
		mw.buf1s += ones
		mw.buf[mw.bufCnt] = b
		mw.bufCnt++
		wrCnt++
	}

	mw.InputOffset += int64(wrCnt)
	return wrCnt, mw.err
}
324675
func (rwops *RWops) Write(buf []byte) (n int, err error) {
	return rwops.Write2(buf, 1, uint(len(buf)))
}
829291
func (s *Adaptor) PwmWrite(pin string, level byte) (err error) {
	return s.AnalogWrite(pin, level)
}
532952
func (d *Adaptor) DigitalWrite(pin string, level byte) (err error) {
	p, err := strconv.Atoi(pin)

	if err != nil {
		return
	}

	if err = d.littleWire.pinMode(uint8(p), 0); err != nil {
		return
	}

	return d.littleWire.digitalWrite(uint8(p), level)
}
466224
func (c *Adaptor) ServoWrite(pin string, angle byte) (err error) {
	pwmPin, err := c.PWMPin(pin)
	if err != nil {
		return
	}

	// 0.5 ms => -90
	// 1.5 ms =>   0
	// 2.0 ms =>  90
	const minDuty = 100 * 0.0005 * pwmPeriod
	const maxDuty = 100 * 0.0020 * pwmPeriod
	duty := uint32(gobot.ToScale(gobot.FromScale(float64(angle), 0, 180), minDuty, maxDuty))
	return pwmPin.SetDutyCycle(duty)
}
526723
func (o *LargeObject) Write(p []byte) (int, error) {
	n, err := fpInt32(o.lo.fp.CallFn("lowrite", []fpArg{fpIntArg(o.fd), p}))
	return int(n), err
}
596856
func (m *MCP23017Driver) write(reg uint8, pin uint8, val uint8) (err error) {
	if debug {
		log.Printf("write: MCP address: 0x%X, register:0x%X,value: 0x%X\n", m.GetAddressOrDefault(mcp23017Address), reg, val)
	}
	if _, err = m.connection.Write([]uint8{reg, val}); err != nil {
		return err
	}
	return nil
}
1360907
func (sm3 *SM3) Write(p []byte) (int, error) {
	toWrite := len(p)
	sm3.length += uint64(len(p) * 8)

	msg := append(sm3.unhandleMsg, p...)
	nblocks := len(msg) / sm3.BlockSize()
	sm3.update(msg, nblocks)

	// Update unhandleMsg
	sm3.unhandleMsg = msg[nblocks*sm3.BlockSize():]

	return toWrite, nil
}
1060600
func (w *commandWriter) Write(data []byte) (int, error) {

	var (
		written int
		err     error
	)

	for len(data) > 0 {
		if w.eof {
			return written, io.EOF
		}
		// never send more data than our EnvelopeSize.
		n := min(w.client.Parameters.EnvelopeSize-1000, len(data))
		if err := w.sendInput(data[:n]); err != nil {
			break
		}
		data = data[n:]
		written += n
	}

	return written, err
}
794326
func (w *stdWriter) Write(p []byte) (n int, err error) {
	if w == nil || w.Writer == nil {
		return 0, errors.New("Writer not instantiated")
	}
	if p == nil {
		return 0, nil
	}

	header := [stdWriterPrefixLen]byte{stdWriterFdIndex: w.prefix}
	binary.BigEndian.PutUint32(header[stdWriterSizeIndex:], uint32(len(p)))
	buf := bufPool.Get().(*bytes.Buffer)
	buf.Write(header[:])
	buf.Write(p)

	n, err = w.Writer.Write(buf.Bytes())
	n -= stdWriterPrefixLen
	if n < 0 {
		n = 0
	}

	buf.Reset()
	bufPool.Put(buf)
	return
}
644182
func (rc *rawConn) Write(fn func(fd uintptr) (done bool)) error {
	return rc.opError(opRawWrite, rc.rc.Write(fn))
}
843102
func (c *cacheControlResponseWriter) Write(data []byte) (int, error) {
	if c.statusCode == http.StatusOK || c.statusCode == 0 {
		headers := c.ResponseWriter.Header()
		if headers.Get("Cache-Control") == "" {
			c.config.SetHeaders(headers)
		}
	}
	return c.ResponseWriter.Write(data)
}
32799
func Write(p protocol.Protocol, w io.Writer, seqID int32, e Enveloper) error {
	body, err := e.ToWire()
	if err != nil {
		return err
	}
	return p.EncodeEnveloped(wire.Envelope{
		SeqID: seqID,
		Name:  e.MethodName(),
		Type:  e.EnvelopeType(),
		Value: body,
	}, w)
}
222669
func (f *Adaptor) DigitalWrite(pin string, level byte) (err error) {
	p, err := strconv.Atoi(pin)
	if err != nil {
		return
	}

	if f.Board.Pins()[p].Mode != client.Output {
		err = f.Board.SetPinMode(p, client.Output)
		if err != nil {
			return
		}
	}

	err = f.Board.DigitalWrite(p, int(level))
	return
}