Beispiel #1
0
int main(void) {
	coord_t		width, height;

    halInit();
    chSysInit();

    /* Initialize and clear the display */
    gdispInit();
    gdispClear(Black);

    // Get the screen size
    width = gdispGetWidth();
    height = gdispGetHeight();

    // Code Here
	gdispDrawCircle(width/2, height/2, 20, Yellow);
    gdispFillCircle (width/4, height/4, 50, Blue);
    gdispFillEllipse (width-100, height-100, 30, 60, Red);
    gdispDrawEllipse (width-100, height-100, 50, 20, Yellow);
    gdispDrawArc(width-width/8, height/8, 30, 10, 70, Gray);
    gdispFillArc(width/8, height/8, 30, 10, 70, Gray);

    while(TRUE) {
        chThdSleepMilliseconds(500);
    }   
}
Beispiel #2
0
	void gwinFillCircle(GHandle gh, coord_t x, coord_t y, coord_t radius) {
		if (!((gh->flags & GWIN_FLG_VISIBLE)))
			return;

		#if GDISP_NEED_CLIP
			gdispSetClip(gh->x, gh->y, gh->width, gh->height);
		#endif
		gdispFillCircle(gh->x+x, gh->y+y, radius, gh->color);
	}
static void draw_point(coord_t x, coord_t y) {
  color_t c = ncoreDrawingArea->color;

  if (nMode == NCORE_MODE_DRAW)
	c = ncoreDrawingArea->color;
  else if (nMode == NCORE_MODE_ERASE)
	c = ncoreDrawingArea->bgcolor;

  if (nPenWidth == 1)
	gdispDrawPixel(x, y, c);
  else
	gdispFillCircle(x, y, nPenWidth, c);
}
Beispiel #4
0
/// \method fill_circle(x1, y1, r, colour)
///
/// Fill a circle having a centre point at (x1,y1), radius r, using the given colour.
/// Option to round the ends
///
STATIC mp_obj_t pyb_ugfx_fill_circle(mp_uint_t n_args, const mp_obj_t *args) {
    // extract arguments
    //pyb_ugfx_obj_t *self = args[0];
    int x0 = mp_obj_get_int(args[1]);
    int y0 = mp_obj_get_int(args[2]);
	int r = mp_obj_get_int(args[3]);
    int col = mp_obj_get_int(args[4]);


	gdispFillCircle(x0, y0, r, col);	

    return mp_const_none;
}
Beispiel #5
0
int main(void) {
	color_t color = Black;
	uint16_t pen = 0;

	halInit();
	chSysInit();

	gdispInit();
	ginputGetMouse(0);
	gdispSetOrientation(GDISP_ROTATE_90);

	drawScreen();

	while (TRUE) {
		ginputGetMouseStatus(0, &ev);
		if (!(ev.current_buttons & GINPUT_MOUSE_BTN_LEFT))
			continue;

		/* inside color box ? */
		if(ev.y >= OFFSET && ev.y <= COLOR_SIZE) {
			     if(GET_COLOR(0)) 	color = Black;
			else if(GET_COLOR(1))	color = Red;
			else if(GET_COLOR(2))	color = Yellow;
			else if(GET_COLOR(3))	color = Green;
			else if(GET_COLOR(4))	color = Blue;
			else if(GET_COLOR(5))	color = White;
		
		/* inside pen box ? */
		} else if(ev.x >= OFFSET && ev.x <= PEN_SIZE) {
			     if(GET_PEN(1))		pen = 0;
			else if(GET_PEN(2))		pen = 1;
			else if(GET_PEN(3))		pen = 2;
			else if(GET_PEN(4))		pen = 3;
			else if(GET_PEN(5))		pen = 4;		

		/* inside drawing area ? */
		} else if(DRAW_AREA(ev.x, ev.y)) {
			if(pen == 0)
				gdispDrawPixel(ev.x, ev.y, color);
			else
				gdispFillCircle(ev.x, ev.y, pen, color);
		}
	}
}
Beispiel #6
0
int main(void) {
	coord_t		width, height;

    /* Initialize and clear the display */
    gfxInit();

    // Get the screen size
    width = gdispGetWidth();
    height = gdispGetHeight();

    // Code Here
	gdispFillArc(width/2, height/2, width/4, -10, -45, White);
	gdispDrawCircle(width/2+width/8, height/2-height/8, 13, Green);
	gdispFillCircle (width/2+width/8, height/2-height/8, 10, Red);
	gdispDrawArc(width/2+width/8, height/2-height/8, 20, 25, 115, Gray);
	gdispFillEllipse (width-width/6, height-height/6, width/8, height/16, Blue);
	gdispDrawEllipse (width-width/6, height-height/6, width/16, height/8, Yellow);

    while(TRUE) {
    	gfxSleepMilliseconds(500);
    }   
}
// Custom drawing functions for the buttons
static void nbtnColorBarDraw(GHandle gh, bool_t enabled, bool_t isdown, const char *txt, const GButtonDrawStyle *pstyle, void *param) {
  #define ccs nCurColorScheme

  int i, j, k;

  (void)txt;
  (void)pstyle;
  (void)param;
  (void)enabled;

  ginputGetMouseStatus(0, &curPtr);

  // Draw the toolbars according to the mode
  if (tbMode == 0) {
	k = (curPtr.x - gh->x) / (NPAD_COLORBAR_WIDTH / 8);

	for (i = 0; i < 8; i++) {
	  j = gh->x + (NPAD_TOOLBAR_BTN_WIDTH / 2) + NPAD_TOOLBAR_BTN_WIDTH * i;

	  if (isdown == TRUE) {
		// Update selection - this is like lazy release.
		if (k >= 0 && k <= 7) {
		  selPenWidth = k + 1;
		  ncoreSetPenWidth((uint8_t) selPenWidth);
		}

		gdispFillArea(gh->x + NPAD_TOOLBAR_BTN_WIDTH * i, gh->y,
		              NPAD_TOOLBAR_BTN_WIDTH, NPAD_TOOLBAR_BTN_HEIGHT,
		              selPenWidth - i == 1 ? ccs.toolbarBgActive : ccs.toolbarBgUnsel);
	  }
	  else {
		gdispFillArea(gh->x + NPAD_TOOLBAR_BTN_WIDTH * i, gh->y,
		              NPAD_TOOLBAR_BTN_WIDTH, NPAD_TOOLBAR_BTN_HEIGHT,
		              selPenWidth - i == 1 ? ccs.toolbarBgSel : ccs.toolbarBgUnsel);

		gdispDrawBox(gh->x + NPAD_TOOLBAR_BTN_WIDTH * i, gh->y,
		             NPAD_TOOLBAR_BTN_WIDTH, NPAD_TOOLBAR_BTN_HEIGHT,
		             selPenWidth - i == 1 ? ccs.toolbarSeparator: ccs.toolbarBgUnsel);
	  }

	  gdispFillCircle(j, gh->y + 10, i + 1, myColors[selColorIndex]);
	}

  } else {
	k = (curPtr.x - gh->x) / (NPAD_COLORBAR_WIDTH / 8);

	for (i = 0; i < 8; i++) {
	  j = gh->x + (NPAD_TOOLBAR_BTN_WIDTH / 2) + NPAD_TOOLBAR_BTN_WIDTH * i;

	  if (isdown == TRUE) {
		// Update selection - this is like lazy release.
		if (k >= 0 && k <= 7) {
		  selColorIndex = k;
		  selColor = myColors[k];
		  ncoreSetPenColor(selColor);
		}

		gdispFillArea(gh->x + NPAD_TOOLBAR_BTN_WIDTH * i, gh->y,
		              NPAD_TOOLBAR_BTN_WIDTH, NPAD_TOOLBAR_BTN_HEIGHT,
		              k == i ? ccs.toolbarBgActive : ccs.toolbarBgUnsel);
	  }
	  else {
		gdispFillArea(gh->x + NPAD_TOOLBAR_BTN_WIDTH * i, gh->y,
		              NPAD_TOOLBAR_BTN_WIDTH, NPAD_TOOLBAR_BTN_HEIGHT,
		              selColorIndex == i ? ccs.toolbarBgSel : ccs.toolbarBgUnsel);

		gdispDrawBox(gh->x + NPAD_TOOLBAR_BTN_WIDTH * i, gh->y,
		             NPAD_TOOLBAR_BTN_WIDTH, NPAD_TOOLBAR_BTN_HEIGHT,
		             selColorIndex == i ? ccs.toolbarSeparator: ccs.toolbarBgUnsel);
	  }

	  gdispFillCircle(j, gh->y + (NPAD_TOOLBAR_BTN_HEIGHT / 2), 3, myColors[i] );
	}
  }


  #undef ccs
}
Beispiel #8
0
/*
 * Application entry point.
 */
int main(void) {
    color_t color = Black;
    uint16_t pen = 0;

  /*
   * System initializations.
   * - HAL initialization, this also initializes the configured device drivers
   *   and performs the board-specific initializations.
   * - Kernel initialization, the main() function becomes a thread and the
   *   RTOS is active.
   */
    halInit();
    chSysInit();

    gdispInit();
    ginputGetMouse(0);
    gdispSetOrientation(GDISP_ROTATE_90);

    drawScreen();
	
	palSetPadMode(GPIOC, 7, PAL_MODE_OUTPUT_PUSHPULL);
	palSetPadMode(GPIOC, 8, PAL_MODE_OUTPUT_PUSHPULL);
	palSetPadMode(GPIOC, 9, PAL_MODE_OUTPUT_PUSHPULL);

  /*
   * Creates the blinker thread.
   */
  (void)chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL);
  
  while (TRUE) {

    ginputGetMouseStatus(0, &ev);
    if (!(ev.current_buttons & GINPUT_MOUSE_BTN_LEFT))
    {
        chThdSleepMicroseconds(500); // Senza questo sleep l'USB non parte
        continue;
    }

    /* inside color box ? */
    if(ev.y >= OFFSET && ev.y <= COLOR_SIZE) {
      if(GET_COLOR(0))   color = Black;
      else if(GET_COLOR(1))   color = Red;
      else if(GET_COLOR(2))   color = Yellow;
      else if(GET_COLOR(3))   color = Green;
      else if(GET_COLOR(4))   color = Blue;
      else if(GET_COLOR(5))   color = White;

    /* inside pen box ? */
    } else if(ev.x >= OFFSET && ev.x <= PEN_SIZE) {
      if(GET_PEN(1))             pen = 0;
      else if(GET_PEN(2))             pen = 1;
      else if(GET_PEN(3))             pen = 2;
      else if(GET_PEN(4))             pen = 3;
      else if(GET_PEN(5))             pen = 4;

    /* inside drawing area ? */
    } else if(DRAW_AREA(ev.x, ev.y)) {
      if(pen == 0)
         gdispDrawPixel(ev.x, ev.y, color);
      else
          gdispFillCircle(ev.x, ev.y, pen, color);
    }
  }
}
Beispiel #9
0
/*
 * Application entry point.
 */
int main(void) {
    color_t color = Black;
    uint16_t pen = 0;
    Thread *shelltp = NULL;

  /*
   * System initializations.
   * - HAL initialization, this also initializes the configured device drivers
   *   and performs the board-specific initializations.
   * - Kernel initialization, the main() function becomes a thread and the
   *   RTOS is active.
   */
    halInit();
    chSysInit();

    gdispInit();
    ginputGetMouse(0);
    gdispSetOrientation(GDISP_ROTATE_90);

    drawScreen();

  /*
   * Initializes a serial-over-USB CDC driver.
   */
  sduObjectInit(&SDU1);
  sduStart(&SDU1, &serusbcfg);

  /*
   * Activates the USB driver and then the USB bus pull-up on D+.
   * Note, a delay is inserted in order to not have to disconnect the cable
   * after a reset.
   */
  usbDisconnectBus(serusbcfg.usbp);
  chThdSleepMilliseconds(1000);
  usbStart(serusbcfg.usbp, &usbcfg);
  usbConnectBus(serusbcfg.usbp);

  /*
   * Shell manager initialization.
   */
  shellInit();

  /*
   * Creates the blinker thread.
   */
  chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL);

  /*
   * Normal main() thread activity, in this demo it does nothing except
   * sleeping in a loop and check the button state.
   */
  while (TRUE) {
    if (!shelltp && (SDU1.config->usbp->state == USB_ACTIVE))
      shelltp = shellCreate(&shell_cfg1, SHELL_WA_SIZE, NORMALPRIO);
    else if (chThdTerminated(shelltp)) {
      chThdRelease(shelltp);    /* Recovers memory of the previous shell.   */
      shelltp = NULL;           /* Triggers spawning of a new shell.        */
    }

    ginputGetMouseStatus(0, &ev);
    if (!(ev.current_buttons & GINPUT_MOUSE_BTN_LEFT))
    {
        chThdSleepMicroseconds(500); // Senza questo sleep l'USB non parte
        continue;
    }

    /* inside color box ? */
    if(ev.y >= OFFSET && ev.y <= COLOR_SIZE) {
      if(GET_COLOR(0))   color = Black;
      else if(GET_COLOR(1))   color = Red;
      else if(GET_COLOR(2))   color = Yellow;
      else if(GET_COLOR(3))   color = Green;
      else if(GET_COLOR(4))   color = Blue;
      else if(GET_COLOR(5))   color = White;

    /* inside pen box ? */
    } else if(ev.x >= OFFSET && ev.x <= PEN_SIZE) {
      if(GET_PEN(1))             pen = 0;
      else if(GET_PEN(2))             pen = 1;
      else if(GET_PEN(3))             pen = 2;
      else if(GET_PEN(4))             pen = 3;
      else if(GET_PEN(5))             pen = 4;

    /* inside drawing area ? */
    } else if(DRAW_AREA(ev.x, ev.y)) {
      if(pen == 0)
         gdispDrawPixel(ev.x, ev.y, color);
      else
          gdispFillCircle(ev.x, ev.y, pen, color);
    }
  }
}