コード例 #1
0
/* LEDs are numbered 0-3, RGB values should be in 0-255.
 * If you specify too large an LED, it sets them all. */
void lb_set_rgb(unsigned int led, int red, int green, int blue)
{
	int i;
	if (led >= NUM_LEDS)
		for (i = 0; i < NUM_LEDS; i++)
			setrgb(i, red, green, blue);
	else
		setrgb(led, red, green, blue);
}
コード例 #2
0
/* Change current display brightness (0-255) */
void lb_set_brightness(unsigned int newval)
{
	int i;
	CPRINTS("LB_bright 0x%02x", newval);
	brightness = newval;
	for (i = 0; i < NUM_LEDS; i++)
		setrgb(i, current[i][0], current[i][1], current[i][2]);
}
コード例 #3
0
ファイル: rgblight.c プロジェクト: anechiporuk/qmk_firmware
void sethsv(uint16_t hue, uint8_t sat, uint8_t val, LED_TYPE *led1) {
  uint8_t r = 0, g = 0, b = 0, base, color;

  if (val > RGBLIGHT_LIMIT_VAL) {
      val=RGBLIGHT_LIMIT_VAL; // limit the val
  }

  if (sat == 0) { // Acromatic color (gray). Hue doesn't mind.
    r = val;
    g = val;
    b = val;
  } else {
    base = ((255 - sat) * val) >> 8;
    color = (val - base) * (hue % 60) / 60;

    switch (hue / 60) {
      case 0:
        r = val;
        g = base + color;
        b = base;
        break;
      case 1:
        r = val - color;
        g = val;
        b = base;
        break;
      case 2:
        r = base;
        g = val;
        b = base + color;
        break;
      case 3:
        r = base;
        g = val - color;
        b = val;
        break;
      case 4:
        r = base + color;
        g = base;
        b = val;
        break;
      case 5:
        r = val;
        g = base;
        b = val - color;
        break;
    }
  }
  r = pgm_read_byte(&CIE1931_CURVE[r]);
  g = pgm_read_byte(&CIE1931_CURVE[g]);
  b = pgm_read_byte(&CIE1931_CURVE[b]);

  setrgb(r, g, b, led1);
}
コード例 #4
0
ファイル: rgblight.c プロジェクト: 0xdec/qmk_firmware
void rgblight_set(void) {
  if (!rgblight_config.enable) {
    for (uint8_t i = 0; i < RGBLED_NUM; i++) {
      if (i == RGBLIGHT_FLED1 && i == RGBLIGHT_FLED2)
          continue;
      
      led[i].r = 0;
      led[i].g = 0;
      led[i].b = 0;
    }
  }
  
  switch (fled_mode) {
      case FLED_OFF:
      setrgb(0, 0, 0, &led[RGBLIGHT_FLED1]);
      setrgb(0, 0, 0, &led[RGBLIGHT_FLED2]);
      break;
      
      case FLED_INDI:
      copyrgb(&fleds[0], &led[RGBLIGHT_FLED1]);
      copyrgb(&fleds[1], &led[RGBLIGHT_FLED2]);
      break;
      
      case FLED_RGB:
      if (fled_hs[0].hue == 0 && fled_hs[0].hue == 0 && (rgblight_config.mode >= 15 && rgblight_config.mode <= 23))
          setrgb(0, 0, 0, &led[RGBLIGHT_FLED1]);
      else
        sethsv(fled_hs[0].hue, fled_hs[0].sat, fled_val, &led[RGBLIGHT_FLED1]);
      
      if (fled_hs[1].hue == 0 && fled_hs[1].hue == 0 && (rgblight_config.mode >= 15 && rgblight_config.mode <= 23))
          setrgb(0, 0, 0, &led[RGBLIGHT_FLED2]);
      else
          sethsv(fled_hs[1].hue, fled_hs[1].sat, fled_val, &led[RGBLIGHT_FLED2]);
      break;
      
      default:
      break;
  }

   ws2812_setleds(led, RGBLED_NUM);
}
コード例 #5
0
ファイル: dislin.c プロジェクト: galadri3l/code
int main ()
{ int n = 100, i, ic;
  double fpi = 3.1415926 / 180.0, step, x;
  float  xray[100], y1ray[100], y2ray[100];

  step = 360. / (n - 1);

  for (i = 0; i < n; i++)
  { xray[i] = (float) (i * step);
    x = xray[i] * fpi;
    y1ray[i] = (float) sin (x);
    y2ray[i] = (float) cos (x);
  }

  metafl ("cons");
  scrmod ("revers");
  disini ();
  pagera ();
  complx ();
  axspos (450, 1800);
  axslen (2200, 1200);

  name   ("X-axis", "x");
  name   ("Y-axis", "y");

  labdig (-1, "x");
  ticks  (9, "x");
  ticks  (10, "y");

  titlin ("Demonstration of CURVE", 1);
  titlin ("SIN(X), COS(X)", 3);

  ic =   intrgb (0.95,0.95,0.95);
  axsbgd (ic);

  graf   (0.0, 360.0, 0.0, 90.0, -1.0, 1.0, -1.0, 0.5);
  setrgb (0.7, 0.7, 0.7);
  grid   (1, 1);

  color  ("fore");
  height (50);
  title  ();

  color  ("red");
  curve  (xray, y1ray, n);
  color  ("green");
  curve  (xray, y2ray, n);
  disfin ();
  return 0;
}
コード例 #6
0
ファイル: tun10.c プロジェクト: RnbwNoise/SecondReality
void tunneli_main(void)
{
	char far *const vram = MK_FP(0xa000, 0);
	int x, frame = 0;
	const int y = 0;
	uint16_t sx = 0, sy = 0;

	for (x = 0; x <= 200; x++) rows[x] = x * 320;
	memcpy(sinit, sini, 4097 * 2);
	memcpy(cosit, &sini[4097 * 2], 2048 * 2);
	memcpy(pcalc, tun, sizeof(pcalc));

	// int10h(0x13);

	dis_partstart();

	for (x = 0; x <= 64; x++) setrgb(64 + x, 64 - x, 64 - x, 64 - x);
	for (x = 0; x <= 64; x++) setrgb(128 + x, (64 - x) *3 / 4, (64 - x) *3 / 4, (64 - x) *3 / 4);

	setrgb(68, 0, 0, 0);
	setrgb(132, 0, 0, 0);
	setrgb(255, 0, 63, 0);

	memset(putki, 0, sizeof(putki));

	waitr();
	for (x = 0; x <= 100; x++) sade[x] = pascal_round(16384.0f / ((x * 7) + 95));

	for (;;)
	{
		const int frames = waitr();
		int ry = 0, sync;

		for (x = 80; x >= 4; x--)
		{
			const uint16_t bx = (uint16_t)(putki[x].x - putki[5].x);
			const uint16_t by = (uint16_t)(putki[x].y - putki[5].y);
			const uint8_t bbc = (uint8_t)(putki[x].c + pascal_round(x / 1.3f));
			if (bbc >= 64)
			{
				struct bc *pcp = &pcalc[(uint8_t)sade[x]][0];
				int cx = 64;
				while (cx--)
				{
					uint16_t di = bx + pcp->x;
					vram[oldpos[ry]] = 0;
					if (di <= 319)
					{
						const uint16_t row = by + pcp->y;
						if (row <= 199)
						{
							di += rows[row];
							vram[di] = bbc;
							oldpos[ry] = di;
						}
					}
					pcp++;
					ry++;
				}
			}
		}

		for (sync = 1; sync <= frames; sync++)
		{
			putki[100].x = cosit[sy & 2047] - sinit[(sy * 3) & 4095] - cosit[sx & 2047];
			putki[100].y = sinit[(sx * 2) & 4095] - cosit[sx & 2047] + sinit[y & 4095];
			memmove(&putki[0], &putki[1], sizeof(putki[0]) * 100);
			sy++;
			sx++;

			if ((sy & 15) > 7) putki[99].c = 128; else putki[99].c = 64;
			if (frame >= veke - 102) putki[99].c = 0;
			if (frame++ == veke) return;;

			if (dis_exit()) return;
		}
	}
}
コード例 #7
0
ファイル: tun10.c プロジェクト: RnbwNoise/SecondReality
static int waitr(void)
{
	setrgb(0, 0, 0, 0);
	return dis_waitb();
}
コード例 #8
0
ファイル: rgblight.c プロジェクト: 0xdec/qmk_firmware
void sethsv(uint16_t hue, uint8_t sat, uint8_t val, LED_TYPE *led1) {
  uint8_t r = 0, g = 0, b = 0, base, color;
  
  // if led is front leds, cache the hue and sat values
  if (led1 == &led[RGBLIGHT_FLED1]) {
      fled_hs[0].hue = hue;
      fled_hs[0].sat = sat;
  } else if (led1 == &led[RGBLIGHT_FLED2]) {
      fled_hs[1].hue = hue;
      fled_hs[1].sat = sat;
  }

  if (val > RGBLIGHT_LIMIT_VAL) {
      val=RGBLIGHT_LIMIT_VAL; // limit the val
  }

  if (sat == 0) { // Acromatic color (gray). Hue doesn't mind.
    r = val;
    g = val;
    b = val;
  } else {
    base = ((255 - sat) * val) >> 8;
    color = (val - base) * (hue % 60) / 60;

    switch (hue / 60) {
      case 0:
        r = val;
        g = base + color;
        b = base;
        break;
      case 1:
        r = val - color;
        g = val;
        b = base;
        break;
      case 2:
        r = base;
        g = val;
        b = base + color;
        break;
      case 3:
        r = base;
        g = val - color;
        b = val;
        break;
      case 4:
        r = base + color;
        g = base;
        b = val;
        break;
      case 5:
        r = val;
        g = base;
        b = val - color;
        break;
    }
  }
  r = pgm_read_byte(&CIE1931_CURVE[r]);
  g = pgm_read_byte(&CIE1931_CURVE[g]);
  b = pgm_read_byte(&CIE1931_CURVE[b]);

  setrgb(r, g, b, led1);
}
コード例 #9
0
ファイル: console.cpp プロジェクト: CDSteer/Cpp-Tic-Tac-Toe
void resetall() {
	setrgb(COLOR_RESET, COLOR_RESET);
	clrscr();
	gotoxy(0, 0);
	showcursor(true);
}