Esempio n. 1
0
static t_bbb *mk_bonds(int natoms,rvec x[],real odist,
		       gmx_bool bPBC,matrix box)
{
  real  od2 = odist*odist+1e-5;
  t_pbc pbc;
  t_bbb *bbb;
  int   i,j;
  rvec  dx;
  
  if (bPBC)
    set_pbc(&pbc,box);
  snew(bbb,natoms);
  for(i=0; (i<natoms); i++) {
    for(j=i+1; (j<natoms); j++) {
      if (bPBC)
	pbc_dx(&pbc,x[i],x[j],dx);
      else
	rvec_sub(x[i],x[j],dx);
      if (iprod(dx,dx) <= od2) {
	bbb[i].aa[bbb[i].n++] = j;
	bbb[j].aa[bbb[j].n++] = i;
      }
    }
  }
  if (debug) 
#define PRB(nn) (bbb[(i)].n >= (nn)) ? bbb[i].aa[nn-1] : -1
    for(i=0; (i<natoms); i++)
      fprintf(debug,"bonds from %3d:  %d %d %d %d\n",
	      i,PRB(1),PRB(2),PRB(3),PRB(4));
#undef PRB
  return bbb;
}
Esempio n. 2
0
// Update entire display quickly 
void CAZ_7x4_RGB::write(void) {
  uint8_t dsc, dig, seg, rgb, col;
  int8_t chan, bit;
  uint16_t pwm;

  digitalWrite(_lat, LOW);

  for (chan = 24 * 3 - 1; chan >= 0; chan--)  // For all 24 *3 PWM channels
  {
    dsc = PRB(Chan2Seg[chan]);     // Find which digit, Segment, & rgb for this channel
    seg = dsc >> 4;                // extract segment
    dig = (dsc & 0x0C) >> 2;       // extract digit
    rgb = (dsc & 0x03);            // extract rgb
    col = segments[dig][seg];      // current color index for this segment of display
    pwm = PRB(Palette[col][rgb]);  // PWM value for this color

    for (bit = 11; bit >= 0; bit--)  // 12 bits per channel, send MSB first
    {
      digitalWrite(_clk, LOW);

      if (pwm & (1 << bit))
        digitalWrite(_dat, HIGH);
      else
        digitalWrite(_dat, LOW);

      digitalWrite(_clk, HIGH);
    }
  }
  digitalWrite(_clk, LOW);

  digitalWrite(_lat, HIGH);  // Latch to PWM Drivers
  digitalWrite(_lat, LOW);
}