Exemplo n.º 1
0
void shiftbrite_configure(shiftbrite *sb,
                          uint8_t red_correction,
                          uint8_t green_correction,
                          uint8_t blue_correction,
                          shiftbrite_clock clock) {
  shift_zeros(sb, 5);
  shift_7bit_value(sb, blue_correction);
  shift_zeros(sb, 3);
  shift_7bit_value(sb, red_correction);
  shift_zeros(sb, 1);
  switch(clock) {
    case CLOCK_200MHZ:
      shift_bit(sb, 1);
      shift_bit(sb, 1);
      break;
    case CLOCK_EXTERNAL:
      shift_bit(sb, 1);
      shift_bit(sb, 0);
      break;
    case CLOCK_400MHZ:
      shift_bit(sb, 0);
      shift_bit(sb, 1);
      break;
    case CLOCK_800MHZ:
    default:
      shift_bit(sb, 0);
      shift_bit(sb, 0);
      break;
  }
  shift_7bit_value(sb, green_correction);
}
Exemplo n.º 2
0
static inline void shift_zeros(shiftbrite* sb, uint8_t count) {
  int i;
  for (i = 0; i < count; i++)  {
    shift_bit(sb, 0);
  }
}
Exemplo n.º 3
0
static inline void shift_7bit_value(shiftbrite* sb, uint8_t value) {
  int i;
  for (i = 6; i >= 0; i--) {
    shift_bit(sb, value & (1 << i));
  }
}
Exemplo n.º 4
0
static void write_digit(unsigned char seg, unsigned char data, unsigned char erase, unsigned char skip)
{
	static const unsigned char delete_order[7]={SEG_U,SEG_UR,SEG_UL,SEG_M,SEG_OR,SEG_OL,SEG_O};
	static const unsigned char set_order[7]={SEG_O,SEG_OR,SEG_UR,SEG_U,SEG_UL,SEG_OL,SEG_M};

	unsigned char i;

	if ((skip & SEG_ALL) != SEG_ALL)
	{
		SET_STROBE;

		WAIT_FULL(DATA_DELAY);
		// pump data

		for (i=0x80; i; i>>=1)
		{
			shift_bit(data&i);
		}

		// pump address


		for (i=0x80; i; i>>=1)
		{
			shift_bit(seg&i);
		}

		CLR_STROBE; // falling strobe, latch data

		WAIT_HALF(DATA_DELAY);

		CLR_CLK;

		WAIT_HALF(DATA_DELAY);

		// enable segments??
		if (erase)
		{
			CLR_DATA;
			for (i=0; i<7; i++)
			{
				if (skip&delete_order[i])
				{
					skip_bit();
				}
				else
				{
					shift_mech();
				}
			}
		}
		else
		{
			SET_DATA;
			for (i=0; i<7; i++)
			{
				if (skip&set_order[i])
				{
					skip_bit();
				}
				else
				{
					shift_mech();
				}
			}
		}
		SET_CLK;
	}