Example #1
0
void display_draw( bool sleep ) {

    // Turn on the busy LED:
    display_busy( true );

    // Blank the display if requested:
    if ( sleep ) {
        u8g_SleepOn( &u8g );
    }

    // Render the image:
    u8g_FirstPage( &u8g );
    do {
        // Stop if the draw function doesn't want to continue:
        if ( ! ui_draw( &u8g ) ) {
            break;
        }
    } while ( u8g_NextPage( &u8g ) );
    u8g_Delay( 100 );

    // Turn the display back on if blanking was requested:
    if ( sleep ) {
        u8g_SleepOff( &u8g );
    }

    // Turn off the busy LED:
    display_busy( false );
}
Example #2
0
static int
ejectit(char *name)
{
	int 		fd, r;
	boolean_t	mejectable = B_FALSE;	/* manually ejectable */
	int		result = EJECT_OK;

	/*
	 * If volume management is either not running or not being managed by
	 * vold, and the device is mounted, we try to umount the device.  If we
	 * fail, we give up, unless it used the -f flag.
	 */

	if (_dev_mounted(name)) {
		r = _dev_unmount(name);
		if (r == 0) {
			if (!force_eject) {
				(void) fprintf(stderr,
gettext("WARNING: can not unmount %s, the file system is (probably) busy\n"),
				    name);
				return (EJECT_PARM_ERR);
			} else {
				(void) fprintf(stderr,
gettext("WARNING: %s has a mounted filesystem, ejecting anyway\n"),
				    name);
			}
		}
	}

	/*
	 * Require O_NDELAY for when floppy is not formatted
	 * will still id floppy in drive
	 */

	/*
	 * make sure we are dealing with a raw device
	 *
	 * XXX: NOTE: results from getfullrawname()
	 * really should be free()d when no longer
	 * in use
	 */
	name = getfullrawname(name);

	if ((fd = open(name, O_RDONLY | O_NDELAY)) < 0) {
		if (errno == EBUSY) {
			(void) fprintf(stderr,
gettext("%s is busy (try 'eject floppy' or 'eject cdrom'?)\n"),
			    name);
			return (EJECT_PARM_ERR);
		}
		perror(name);
		return (EJECT_PARM_ERR);
	}

	if (do_closetray) {
		if (ioctl(fd, CDROMCLOSETRAY) < 0) {
			result = EJECT_IOCTL_ERR;
		}
	} else if (ioctl(fd, DKIOCEJECT, 0) < 0) {
		/* check on why eject failed */

		/* check for no floppy in manually ejectable drive */
		if ((errno == ENOSYS) &&
		    !floppy_in_drive(name, fd, &mejectable)) {
			/* use code below to handle "not present" */
			errno = ENXIO;
		}

		if (errno == ENOSYS || errno == ENOTSUP) {
			(void) fprintf(stderr, gettext(OK_TO_EJECT_MSG), name);
		}

		if ((errno == ENOSYS || errno == ENOTSUP) && mejectable) {
			/*
			 * keep track of the fact that this is a manual
			 * ejection
			 */
			result = EJECT_MAN_EJ;

		} else if (errno == EBUSY) {
			/*
			 * if our pathname is s slice (UFS is great) then
			 * check to see what really is busy
			 */
			if (!display_busy(name, B_FALSE)) {
				perror(name);
			}
			result = EJECT_IOCTL_ERR;

		} else if ((errno == EAGAIN) || (errno == ENODEV) ||
		    (errno == ENXIO)) {
			(void) fprintf(stderr,
			    gettext("%s not present in a drive\n"),
			    name);
			result = EJECT_OK;
		} else {
			perror(name);
			result = EJECT_IOCTL_ERR;
		}
	}

	(void) close(fd);
	return (result);
}