Example #1
0
void acceleration_task() {
	vTaskDelay(60);
	uint8_t buffer[6];
	LIS302DL_Read(buffer, LIS302DL_OUT_X_ADDR, 6);
	for (;;) {
		signed char result;
		xQueueReceive(queue, &result, portMAX_DELAY);
		display_bar(-128, 128, result);
	}
}
Example #2
0
void build_bar(struct Bar* bar, int inX, int inY, unsigned int inW, unsigned int inColor, unsigned int inPixels, unsigned int inContrast, char inOrientation, char inRemove_from)
{
	bar->x = inX;
	bar->y = inY;
	bar->w = inW;
	bar->h = inPixels;
	bar->color = inColor;
	bar->pixels = inPixels;
	bar->orientation = inOrientation;
	bar->contrast = inContrast;
	bar->remove_from = inRemove_from;
	display_bar(bar, 0);
}
Example #3
0
void build_bar(struct Bar* bar, int16_t inX, int16_t inY, uint16_t inW, uint16_t inColor, uint16_t inPixels, uint16_t inContrast, char inOrientation, char inRemove_from)
{
	bar->y_pos = inX;
	bar->x_pos = inY;
	bar->width = inW;
	bar->height = inPixels;
	bar->color = inColor;
	bar->pixels = inPixels;
	bar->orientation = inOrientation;
	bar->contrast = inContrast;
	bar->remove_from = inRemove_from;
	display_bar(bar, 0);
}
Example #4
0
/**
 * Called by FS client to give information about the progress of an
 * operation.
 *
 * @param cls closure
 * @param info details about the event, specifying the event type
 *        and various bits about the event
 * @return client-context (for the next progress call
 *         for this operation; should be set to NULL for
 *         SUSPEND and STOPPED events).  The value returned
 *         will be passed to future callbacks in the respective
 *         field in the `struct GNUNET_FS_ProgressInfo`
 */
static void *
progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *info)
{
  char *s;
  const char *s2;
  char *t;

  switch (info->status)
  {
  case GNUNET_FS_STATUS_DOWNLOAD_START:
    if (verbose > 1)
      FPRINTF (stderr, _("Starting download `%s'.\n"),
               info->value.download.filename);
    break;
  case GNUNET_FS_STATUS_DOWNLOAD_PROGRESS:
    if (verbose)
    {
      s = GNUNET_strdup (GNUNET_STRINGS_relative_time_to_string (info->value.download.eta,
								 GNUNET_YES));
      if (info->value.download.specifics.progress.block_download_duration.rel_value_us
          == GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us)
        s2 = _("<unknown time>");
      else
        s2 = GNUNET_STRINGS_relative_time_to_string (
						     info->value.download.specifics.progress.block_download_duration,
						     GNUNET_YES);
      t = GNUNET_STRINGS_byte_size_fancy (info->value.download.completed *
                                          1000LL /
                                          (info->value.download.
                                           duration.rel_value_us + 1));
      FPRINTF (stdout,
               _("Downloading `%s' at %llu/%llu (%s remaining, %s/s). Block took %s to download\n"),
               info->value.download.filename,
               (unsigned long long) info->value.download.completed,
               (unsigned long long) info->value.download.size, s, t, s2);
      GNUNET_free (s);
      GNUNET_free (t);
    }
    else
    {
      display_bar (info->value.download.completed,
		   info->value.download.size,
		   60);
    }
    break;
  case GNUNET_FS_STATUS_DOWNLOAD_ERROR:
#if !WINDOWS
    if (0 != isatty (1))
      fprintf (stdout, "\n");
#else
    if (FILE_TYPE_CHAR == GetFileType (GetStdHandle (STD_OUTPUT_HANDLE)))
      fprintf (stdout, "\n");
#endif
    FPRINTF (stderr, _("Error downloading: %s.\n"),
             info->value.download.specifics.error.message);
    GNUNET_SCHEDULER_shutdown ();
    break;
  case GNUNET_FS_STATUS_DOWNLOAD_COMPLETED:
    s = GNUNET_STRINGS_byte_size_fancy (info->value.download.completed * 1000 /
                                        (info->value.download.
                                         duration.rel_value_us + 1));
#if !WINDOWS
    if (0 != isatty (1))
      fprintf (stdout, "\n");
#else
    if (FILE_TYPE_CHAR == GetFileType (GetStdHandle (STD_OUTPUT_HANDLE)))
      fprintf (stdout, "\n");
#endif
    FPRINTF (stdout, _("Downloading `%s' done (%s/s).\n"),
             info->value.download.filename, s);
    GNUNET_free (s);
    if (info->value.download.dc == dc)
      GNUNET_SCHEDULER_shutdown ();
    break;
  case GNUNET_FS_STATUS_DOWNLOAD_STOPPED:
    if (info->value.download.dc == dc)
      GNUNET_SCHEDULER_add_now (&cleanup_task, NULL);
    break;
  case GNUNET_FS_STATUS_DOWNLOAD_ACTIVE:
  case GNUNET_FS_STATUS_DOWNLOAD_INACTIVE:
    break;
  default:
    FPRINTF (stderr, _("Unexpected status: %d\n"), info->status);
    break;
  }
  return NULL;
}