ftp.nice.ch/pub/next/developer/objc/screen/ScreenMunger.2.0.N.bs.tar.gz#/ScreenMunger/bright2.c

This is bright2.c in view mode; [Download] [Up]

#import <stdio.h>
#import <nextdev/evsio.h>
#import <sys/file.h>
#import <sys/ioctl.h>
#import <sys/signal.h>

/* bright2.c -- smoothly alter the screen brightness at a very rapid rate
 *
 * 5/92, CWS -- modified to use the evs driver, added support for signal
 * trapping.  This now runs forever until the user kills it.
 */

// This param is rather delicate; small changes can produce noticable
// visual differences.  The loops run fast enough to really play with
// the scan line frequency.  I wonder what a color monitor'll do?

#define DELAY 20

int fd = 0;

void handle(sig)
   int sig;
{
  int i = 40;
  (void) ioctl(fd, EVSIOSB, &i);
  close(fd);
  fprintf(stdout, "\nCaught signal %d...\n", sig);
  exit(0);
}


void pause(sig)
   int sig;
{
  int i = 40;
  (void) ioctl(fd, EVSIOSB, &i);
  raise(SIGSTOP);
}


main() {
  int i,j;

// do the signal trapping stuff
  if (signal(SIGINT, &handle)) {
      fprintf(stdout, "Couldn't establish new error handler for SIGINT.\n");
      exit(1);
  }

  if (signal(SIGTERM, &handle)) {
      fprintf(stdout, "Couldn't establish new error handler for SIGTERM.\n");
      exit(2);
  }

  if (signal(SIGTSTP, &pause)) {
      fprintf(stdout, "Couldn't establish new errorhandler for SIGTSTP.\n");
      exit(3);
  }

  fd = open("/dev/evs0", O_RDONLY, NULL);
  
  if (fd <= 0) {
    fprintf(stdout,"Error, openning /dev/evs0: %d.\n", errno);
    exit(4);
  }
  
  for(;;) {
    for (i=0; i < 61; i++) {
      (void) ioctl(fd, EVSIOSB, &i);
      for(j=0;j<DELAY;j++);
    }
    
    for (i=61; i > 0; i--) {
      (void) ioctl(fd, EVSIOSB, &i);
      for(j=0;j<DELAY;j++);
    }
  }
  
// if we exit, do this

  i = 40;
  (void) ioctl(fd, EVSIOSB, &i);
  close(fd);
  exit(0);
}

These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.