// Drive is called from simra.
// This is used to update sprites position.
// This will be called 60 times per sec.
2159
func (s *sample) Drive() {
	degree++
	if degree >= 360 {
		degree = 0
	}

	p := s.ball.GetPosition()
	switch s.buttonState {
	case ctrlUp:
		s.ball.SetPositionY(p.Y + 1)
	case ctrlDown:
		s.ball.SetPositionY(p.Y - 1)
	}

	s.ball.SetRotate(degree * math.Pi / 180)
}
408605
func (h *JHD1313M1Driver) Write(message string) error {
	// This wait fixes an odd bug where the clear function doesn't always work properly.
	time.Sleep(1 * time.Millisecond)
	for _, val := range message {
		if val == '\n' {
			if err := h.SetPosition(16); err != nil {
				return err
			}
			continue
		}
		if _, err := h.lcdConnection.Write([]byte{LCD_DATA, byte(val)}); err != nil {
			return err
		}
	}
	return nil
}
947307
func (s *DriveService) Upsert(ctx context.Context, title string, data io.Reader) (file *client.File, err error) {
	if file, err = s.Get(ctx, title); err != nil {
		if !os.IsNotExist(err) {
			return
		}
	}
	if file == nil {
		file = &client.File{Title: title}
		file.Parents = []*client.ParentReference{
			{Id: s.parentID},
		}
		file.MimeType = MimeTypeCamliBlob
		return s.apiservice.Files.Insert(file).Media(data).Context(ctx).Do()
	}

	// TODO: handle large blobs
	return s.apiservice.Files.Update(file.Id, file).Media(data).Context(ctx).Do()
}
320289
func (sim *simra) NewSprite() Spriter {
	return &sprite{
		simra:         sim,
		animationSets: map[string]*AnimationSet{},
	}
}
1060663
func (c *Client) CopyVolume(
	ctx context.Context, src, dest string) (Volume, error) {

	_, err := apiv1.CopyIsiVolume(ctx, c.API, src, dest)
	if err != nil {
		return nil, err
	}

	return c.GetVolume(ctx, dest, dest)
}
486034
func (s *SSD1306Driver) Set(x, y, c int) {
	s.buffer.SetPixel(x, y, c)
}
532866
func (c *CyclePDB) Write(towrite []boltcycle.KvPair) (err error) {
	atomic.AddInt64(&c.stats.TotalWriteCount, int64(len(towrite)))

	return c.blobs.latest().Update(func(tx *bolt.Tx) error {
		bucket := tx.Bucket(c.bucketTimesIn)
		if bucket == nil {
			return errorUnableToFindRootBucket
		}

		for i := 0; err == nil && i < len(towrite); i++ {
			p := towrite[i]
			err = bucket.Put(p.Key, p.Value)
		}
		return err
	})
}
770315
func (d *Driver) Rate() (err error) {
	buf, _ := d.createPacket(videoRateQuery, 0x48, 0)
	d.seq++
	binary.Write(buf, binary.LittleEndian, d.seq)
	binary.Write(buf, binary.LittleEndian, CalculateCRC16(buf.Bytes()))

	_, err = d.cmdConn.Write(buf.Bytes())
	return
}
531003
func (mr *MockInstanceMockRecorder) Disks() *gomock.Call {
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Disks", reflect.TypeOf((*MockInstance)(nil).Disks))
}
775734
func (s *DriveService) Stat(ctx context.Context, title string) (int64, error) {
	file, err := s.Get(ctx, title)
	if err != nil || file == nil {
		return 0, err
	}
	return file.FileSize, err
}
1283577
func (r *Application) Storage(disk float64) *Application {
	r.Disk = &disk
	return r
}
1059140
func (gce *Connection) Disk(zone, name string) (*Disk, error) {
	d, err := gce.raw.GetDisk(gce.projectID, zone, name)
	if err != nil {
		return nil, errors.Annotatef(err, "cannot get disk %q in zone %q", name, zone)
	}
	return NewDisk(d), nil
}
996390
func (w *SegmentWAL) Sync() error {
	var head *segmentFile
	var err error

	// Flush the writer and retrieve the reference to the head segment under mutex lock.
	func() {
		w.mtx.Lock()
		defer w.mtx.Unlock()
		if err = w.flush(); err != nil {
			return
		}
		head = w.head()
	}()
	if err != nil {
		return errors.Wrap(err, "flush buffer")
	}
	if head != nil {
		// But only fsync the head segment after releasing the mutex as it will block on disk I/O.
		start := time.Now()
		err := fileutil.Fdatasync(head.File)
		w.metrics.fsyncDuration.Observe(time.Since(start).Seconds())
		return err
	}
	return nil
}
741055
func (m *MotorDriver) On() (err error) {
	if m.isDigital() {
		err = m.changeState(1)
	} else {
		if m.CurrentSpeed == 0 {
			m.CurrentSpeed = 255
		}
		err = m.Speed(m.CurrentSpeed)
	}
	return
}
198589
func (rr *rasterRenderer) Save(w io.Writer) error {
	if typed, isTyped := w.(RGBACollector); isTyped {
		typed.SetRGBA(rr.i)
		return nil
	}
	return png.Encode(w, rr.i)
}
41264
func (sc *SpriteContainer) AddSprite(s *Sprite, subTex *sprite.SubTex, arrangeCallback func()) error {
	simlog.FuncIn()
	var sn *spriteNodePair
	i, ok := sc.spriteNodePairs.Load(s)
	if !ok {
		sn = &spriteNodePair{}
	} else {
		sn = i.(*spriteNodePair)
		if sn.inuse {
			return fmt.Errorf("this sprite is already added and currently still being available")
		}
	}

	sn.sprite = s
	if sn.znode == nil {
		sn.znode = sc.gl.NewNode(func(eng sprite.Engine, n *sprite.Node, t clock.Time) {
			if arrangeCallback != nil {
				arrangeCallback()
			}
		})
		sc.spriteNodePairs.Store(s, sn)
	}
	sc.gl.AppendNode(sn.znode)
	sn.inuse = true
	if subTex != nil {
		sc.gl.SetSubTex(sn.znode, subTex)
	}
	simlog.FuncOut()
	return nil
}
790165
func (gce *Connection) Disks() ([]*Disk, error) {
	computeDisks, err := gce.raw.ListDisks(gce.projectID)
	if err != nil {
		return nil, errors.Annotate(err, "cannot list disks")
	}
	disks := make([]*Disk, len(computeDisks))
	for i, disk := range computeDisks {
		disks[i] = NewDisk(disk)
	}
	return disks, nil
}