Beispiel #1
0
static void m2i_rename(path_t *path, cbmdirent_t *dent, uint8_t *newname) {
  uint16_t offset;
  uint8_t *ptr;

  set_busy_led(1);
  /* Locate entry in the M2I file */
  offset = dent->pvt.m2i.offset;
  if (load_entry(path->part, offset)) {
    update_leds();
    return;
  }

  /* Re-load the entry because load_entry modifies it */
  /* Assume this never fails because load_entry was successful */
  image_read(path->part, offset, ops_scratch, M2I_ENTRY_LEN);

  /* Copy the new filename */
  ptr = ops_scratch + M2I_CBMNAME_OFFSET;
  memset(ptr, ' ', CBM_NAME_LENGTH);
  while (*newname)
    *ptr++ = *newname++;

  /* Write new entry */
  image_write(path->part, offset, ops_scratch, M2I_ENTRY_LEN, 1);

  update_leds();
}
Beispiel #2
0
/**
 * mark_buffer_clean - mark a buffer as clean
 * @buf: pointer to the buffer
 *
 * This function marks the given buffer as clean, tracks
 * this in active_buffers and turns off the dirty LED if required.
 */
void mark_buffer_clean(buffer_t *buf) {
  if (buf->dirty) {
    buf->dirty = 0;
    active_buffers -= 16;
		update_leds();
  }
}
Beispiel #3
0
void main(void) {
  //WDTCTL = WDTPW + WDTHOLD;
  
  // use 1MHz calibrated values
  DCOCTL = CALDCO_1MHZ;
  BCSCTL1 = CALBC1_1MHZ;
  // wdt set as interval
  //WDTCTL = WDTPW + WDTTMSEL + WDTIS1;
  // wdt interrupt
  //  IE1 |= WDTIE;
  // enable global interrupts using intrinsic
  //__enable_interrupt();
  
  // initialize pins for SPI
  init();
  led_mode = CHASE;
  
  colorwipe(clear); // clear led strip
  //delayMillis(1000);
  while (1) { 
    //demos();
    //check switches
    check_switches();
    //update LEDs
    update_leds();
  }

}
Beispiel #4
0
void fs_emu_video_after_update() {
    fs_emu_video_buffer_unlock();
    int64_t t = fs_emu_monotonic_time();

    if (fs_emu_cursor_is_visible_to() > 0) {
        if (fs_emu_cursor_is_visible_to() < fs_emu_monotonic_time()) {
            //fs_log("%lld\n", fs_emu_monotonic_time());
            fs_emu_show_cursor(0);
        }
    }

    update_leds(t);

    update_video_stats_system_video();

    if (g_fs_emu_benchmark_start_time) {
        static int64_t last_report = 0;
        if (t - last_report > 5000000) {
            double ttime = ((t - g_fs_emu_benchmark_start_time) / 1000000.0);
            double sys_fps = g_fs_emu_total_sys_frames / ttime;
            double emu_fps = g_fs_emu_total_emu_frames / ttime;
            //fs_log("average fps sys: %0.1f emu: %0.1f\n", sys_fps, emu_fps);
            printf("average fps sys: %0.1f emu: %0.1f\n", sys_fps, emu_fps);
            last_report = t;
        }
    }
}
Beispiel #5
0
static void cmd_handler (void)
{
  /* Handle commands and filenames */
  if (ieee_data.ieeeflags & COMMAND_RECVD) {
# ifdef HAVE_HOTPLUG
    /* This seems to be a nice point to handle card changes */
    if (disk_state != DISK_OK) {
      set_busy_led(1);
      /* If the disk was changed the buffer contents are useless */
      if (disk_state == DISK_CHANGED || disk_state == DISK_REMOVED) {
        free_multiple_buffers(FMB_ALL);
        change_init();
        filesystem_init(0);
      } else {
        /* Disk state indicated an error, try to recover by initialising */
        filesystem_init(1);
      }
      update_leds();
    }
# endif
    if (ieee_data.secondary_address == 0x0f) {
      parse_doscommand();                   /* Command channel */
    } else {
      datacrc = 0xffff;                     /* Filename in command buffer */
      file_open(ieee_data.secondary_address);
    }
    command_length = 0;
    ieee_data.ieeeflags &= (uint8_t) ~COMMAND_RECVD;
  } /* COMMAND_RECVD */

  /* We're done, clean up unused buffers */
  free_multiple_buffers(FMB_UNSTICKY);
  d64_bam_commit();
}
void on_20ms_event()
{
    pf_on_20_ms_event();
    telemetry::filter_pos();
    do_heartbeat();
    update_leds();
}
Beispiel #7
0
/**
 * mark_buffer_dirty - mark a buffer as dirty
 * @buf: pointer to the buffer
 *
 * This function marks the given buffer as dirty, tracks
 * this in active_buffers and turns on the dirty LED.
 */
void mark_buffer_dirty(buffer_t *buf) {
  if (!buf->dirty) {
    buf->dirty = 1;
    active_buffers += 16;
		update_leds();
  }
}
Beispiel #8
0
int main(void) {
	init();
	while(1) {
		update_leds();
	}
	return 0;
}
Beispiel #9
0
void setup()
{
    ps.begin(57600);
    ps.setPacketHandler(&on_packet_received);

    FastLED.addLeds<WS2811, DATA_PIN, GRB>(leds, NUM_LEDS);
    update_leds();
}
Beispiel #10
0
 //Keyboard main function
 //Handles all keyboard related tasks
 void keyboard_main( )
 {
	//Update LEDs if USB in use (bluetooth uses different method)
	if(!bluefruit_configured())
		update_leds(keyboard_leds);
	
	uint8_t needs_debounce = 0; // For determining if matrix needs debouncing
	uint16_t matrix_changed = 0;
	matrix_scan();
	// Now that we have scanned the matrix, determine if any actions need to be done
	for (uint8_t row = 0; row < NUMROWS; row++)
	{
		//Check to see if switches in this row has changed
		if ((matrix_changed = matrix_rows[row] ^ matrix_last[row]))
		{
			//At least one switch has changed in this row
			needs_debounce = 1; //We need to debounce
			for (int col = 0; col < NUMCOLS; col++)
			{
				//Find out which columns have changed and act
				if(matrix_changed & ((uint16_t)1<< col))
				{
					//This switch has changed, do whatever the switch was programmed to do
					if(matrix_rows[row] & ((uint16_t)1<< col))
					{
						//Keydown event
						key_execute(get_keycode(row,col),KEY_IS_DOWN);
						//phex(get_keycode(row,col).type);
						//print(":");
						//phex(get_keycode(row,col).code);
						//print(" key is down\n");
					}
					else
					{
						//Keyup event
						key_execute(get_keycode(row,col),KEY_IS_UP);
						//phex(get_keycode(row,col).type);
						//print(":");
						//phex(get_keycode(row,col).code);
						//print(" key is up\n");
					}
					
				}
			}
			matrix_last[row] = matrix_rows[row]; //Row has been dealt with
		}
		else
		{
			//Nothing has changed, do nothing?
		}
	}
	//Allow switch state to stabilize if an edge is detected.
	if (needs_debounce)
		_delay_us(DEBOUNCE_TIME);
 }
static void update_disk_led()
{
#ifdef SHOW_DISK_LED
	static int last_led_status = 0;

	if (led_status != last_led_status) {
		update_leds();
		last_led_status = led_status;
	}
#endif
}
int main(void) {
  usb_init();
  while(!usb_configured());
  CPU_PRESCALE(0);
  MCUCR |= 0x80; MCUCR |= 0x80;

  // Init keyboard
  struct pin input_pins[3] = INPUT_PINS;
  struct pin output_pins[3] = OUTPUT_PINS;

  for(int i=0; i<3; i++) {
    *input_pins[i].ddr = *input_pins[i].ddr & ~input_pins[i].bits;
    *input_pins[i].port = *input_pins[i].port | input_pins[i].bits;
    *output_pins[i].ddr = *output_pins[i].ddr | output_pins[i].bits;
    *output_pins[i].port = *output_pins[i].port  & ~output_pins[i].bits;
  }

  sei();

  // Start looping
  for(;;) {

    // usb_keyboard_press(KEY_A+name[i], 0);

    bool test = false;
    
    for(uint8_t r = 0, k = 0; r < NUMBER_OF_ROWS; r++) {
      ROW_PORT = (ROW_PORT & ~ROW_MASK) | row_bits[r]; _delay_us(1);  //  pull row r;
      for(uint8_t c = 0; c < NUMBER_OF_COLUMNS; c++, k++) {
        if( (*column_pins[c].pin & column_pins[c].bit) == 0 ) { // probe column c;
          
          usb_keyboard_press(alp_index[r], 0);
          usb_keyboard_press(num_index[c], 0);
          usb_keyboard_press(KEY_SPACE, 0);

          test = true;
          
        }
      }
    }

    if(test)
      usb_keyboard_press(KEY_ENTER, 0);

    leds = mask - leds;
    update_leds(leds);

    _delay_ms(500);
    
  }
}
void key_init(void)
{
	int i;
	for (i=0;i<256;i++) keypush[i]=0; /*none key is pressed*/
	extended_key_follows=FALSE;
	update_leds();
	raw_key_r=0;raw_key=0;
	new_key_handler.pm_offset = (int) key_handler;
	new_key_handler.pm_selector = _go32_my_cs();
	_go32_dpmi_get_protected_mode_interrupt_vector(0x9, &old_key_handler);
	_go32_dpmi_allocate_iret_wrapper(&new_key_handler);
	_go32_dpmi_set_protected_mode_interrupt_vector(0x9, &new_key_handler);
	keyboard_handler_replaced = TRUE;
}
Beispiel #14
0
/**
 * free_buffer - deallocate a buffer
 * @buffer: pointer to the buffer structure to mark as free
 *
 * This function deallocates the given buffer. If the pointer is NULL,
 * the buffer is already freed or the buffer is assigned to secondary
 * address 15 nothing will happen. This function will also update the
 * two LEDs according to the remaining number of open and writable
 * buffers.
 */
void free_buffer(buffer_t *buffer) {
  if (buffer == NULL) return;
  if (buffer->secondary == 15) return;
  if (!buffer->allocated) return;

  buffer->allocated = 0;

  if (buffer->dirty)
    active_buffers -= 16;
  if (buffer->secondary < BUFFER_SEC_SYSTEM)
    active_buffers--;
	update_leds();

}
Beispiel #15
0
void
update_modifier(struct wskbd_internal *id, u_int type, int toggle, int mask)
{
	if (toggle) {
		if (type == WSCONS_EVENT_KEY_DOWN)
			id->t_modifiers ^= mask;
	} else {
		if (type == WSCONS_EVENT_KEY_DOWN)
			id->t_modifiers |= mask;
		else
			id->t_modifiers &= ~mask;
	}
	if (mask & MOD_ANYLED)
		update_leds(id);
}
Beispiel #16
0
static uint8_t eefs_delete(path_t *path, cbmdirent_t *dent) {
  eefs_error_t res;

  set_dirty_led(1);

  repad_filename(dent->name);
  res = eepromfs_delete(dent->name);
  translate_error(res);

  update_leds();

  /* check result, can only be not_found or ok */
  if (res == EEFS_ERROR_OK)
    return 1;
  else
    return 0;
}
int main(void) {
  CPU_PRESCALE(0);
  MCUCR |= 0x80; MCUCR |= 0x80;
  usb_init();
  while(!usb_configured());
  keyboard_init();

  for(uint8_t t=0; t<6; t++) {
    for(uint8_t r = 0; r < NUMBER_OF_ROWS; r++) {
      pull_row(r);
      _delay_us(16);
      sprintf(tmp_str, "row %02d: ", r);
      print_S(tmp_str);
      _delay_ms(5);
      for(uint8_t c = 0; c < NUMBER_OF_COLUMNS; c++) {
        bool b = probe_column(c);
        if(!b) {
          print_S("0");
        }
        else
          print_S("1");
      }
      release_rows();
      print_S(" ");
      for(uint8_t c = 0; c < NUMBER_OF_COLUMNS; c++) {
        bool b = probe_column(c);
        if(b) {
          print_S("1");
        }
        else
          print_S("0");
      }
      print_S("\n");
      leds = mask-leds;
      update_leds(leds);
      _delay_ms(200);
    }
  }
  
  EIMSK = 0; PCICR = 0; SPCR = 0; ACSR = 0; EECR = 0;
  TIMSK0 = 0; TIMSK1 = 0; UCSR1B = 0;
  DDRB = 0; DDRC = 0; DDRD = 0;
  PORTB = 0; PORTC = 0; PORTD = 0;
  asm volatile("jmp 0x7000");

}
Beispiel #18
0
/*
 *  Put the system to sleep after turning all lights off.
 */
static void slumber(void) {
	// disable timer interrupt
	TIMSK &= ~(1 << OCIE1A);
	// make sure we are not interrupted anymore
	_delay_ms(10);
	// enable PCINT0
	PCMSK |= (1<<PCINT0);
	GIMSK |= (1<<PCIE);
	// invalidate clock
	clock.state = INVALID;
	// turn off the lights
	update_leds();
	set_sleep_mode(SLEEP_MODE_PWR_DOWN);
	sei();
	sleep_mode();
	// restore interrupt configuration and reset clock
	GIMSK &= ~(1<<PCIE);
	TIMSK |= 1 << OCIE1A;
}
Beispiel #19
0
main()
{
   // initialize the controller
   initsystem();

   sock_init();
   http_init();
   tcp_reserveport(80);

   // set the initial state of the LED's 
   strcpy(led_LED0,"ledon.gif");  ledOut(LED0, ON);
   strcpy(led_LED1,"ledon.gif");  ledOut(LED1, ON);
   strcpy(led_LED2,"ledon.gif");  ledOut(LED2, ON);
   strcpy(led_LED3,"ledon.gif");  ledOut(LED3, ON);

   // process WEB page requests and update the LED's
   while (1) {
      update_leds();
      http_handler();
   }
}
Beispiel #20
0
void main()
{
   // initialize the controller
   brdInit();
   sock_init();
   http_init();
   tcp_reserveport(80);

   // set the initial state of the LED's 
   strcpy(led_DS4,"ledon.gif");  ledOut(DS4, ON);
   strcpy(led_DS5,"ledon.gif");  ledOut(DS5, ON);
   strcpy(led_DS6,"ledoff.gif"); ledOut(DS6, OFF);
   strcpy(led_DS7,"ledon.gif");  ledOut(DS7, ON);
   strcpy(led_DS8,"ledon.gif");  ledOut(DS8, ON);

   // process WEB page requests and update the LED's
   while (1) {
      update_leds();
      http_handler();
   }
}
void* eread(void* pv)
{
	int k,i,fd;
	fd=*((int*)pv);
	char buf[64];
	char* ps[2]={"off","on"};
	while(1)
	{
		k=read(fd,buf,64);
		printf("k=%d\n",k);
		if(k<0)
		{
			perror("read");
			exit(2);
		}
		if(k==0) { printf("no data from aoa\n"); }
		if(buf[0]==0x41) update_leds(buf[1]-1,buf[2]);
		if(buf[0]==0x42) update_trigger(buf[1]-1,buf[2]);
		//if(buf[0]==0x43) update_seek(buf[1]);
	}
}
Beispiel #22
0
void run_led_driver() {
	prep_leds();

	switch(led_state) {

	case led_off:
		break;
	case led_start:
		turn_on(REDLED);
		break;

	case led_setup_start:
		turn_on(REDLED);
		blink_slow(YELLOWLED);
		blink_slow(GREENLED1);
		blink_slow(GREENLED2);
		break;
	case led_setup_slave_assoc:
		turn_on(REDLED);
		blink_slow(YELLOWLED);
		turn_on(GREENLED1);
		blink_slow(GREENLED2);
		break;
	case led_setup_slave_found_master:
		turn_on(REDLED);
		blink_slow(YELLOWLED);
		turn_on(GREENLED1);
		turn_on(GREENLED2);
		break;
	case led_setup_master_assoc:
		turn_on(REDLED);
		blink_fast(YELLOWLED);
		turn_on(GREENLED1);
		turn_on(GREENLED2);
		break;

	case led_main_start:
		turn_on(REDLED);
		blink_slow(YELLOWLED);
		blink_slow_sliding(GREENLED1);
		blink_slow_alternating(GREENLED2);
		break;
	case led_main_assoc:
		turn_on(REDLED);
		turn_on(YELLOWLED);
		blink_slow_alternating(GREENLED1);
		break;
	case led_main_connected:
		turn_on(REDLED);
		turn_on(YELLOWLED);
		turn_on(GREENLED1);
		blink_slow(GREENLED2);
		break;

	case led_error:
		blink_slow(REDLED + YELLOWLED + GREENLED1);
		break;
	}

	update_leds();
}
Beispiel #23
0
void ieee_mainloop(void) {
  int16_t cmd = 0;

  set_error(ERROR_DOSVERSION);

  ieee_data.bus_state = BUS_IDLE;
  ieee_data.device_state = DEVICE_IDLE;
  for(;;) {
    switch(ieee_data.bus_state) {
      case BUS_SLEEP:                               /* BUS_SLEEP */
        set_atn_irq(0);
        ieee_bus_idle();
        set_error(ERROR_OK);
        set_busy_led(0);
        uart_puts_P(PSTR("ieee.c/sleep ")); set_dirty_led(1);

        /* Wait until the sleep key is used again */
        while (!key_pressed(KEY_SLEEP))
          system_sleep();
        reset_key(KEY_SLEEP);

        set_atn_irq(1);
        update_leds();

        ieee_data.bus_state = BUS_IDLE;
        break;

      case BUS_IDLE:                                /* BUS_IDLE */
        ieee_bus_idle();
        while(IEEE_ATN) {   ;               /* wait for ATN */
          if (key_pressed(KEY_NEXT | KEY_PREV | KEY_HOME)) {
            change_disk();
          } else if (key_pressed(KEY_SLEEP)) {
            reset_key(KEY_SLEEP);
            ieee_data.bus_state = BUS_SLEEP;
            break;
          } else if (display_found && key_pressed(KEY_DISPLAY)) {
            display_service();
            reset_key(KEY_DISPLAY);
          }
          system_sleep();
      }

      if (ieee_data.bus_state != BUS_SLEEP)
        ieee_data.bus_state = BUS_FOUNDATN;
      break;

      case BUS_FOUNDATN:                            /* BUS_FOUNDATN */
        ieee_data.bus_state = BUS_ATNPROCESS;
        cmd = ieee_getc();
      break;

      case BUS_ATNPROCESS:                          /* BUS_ATNPROCESS */
        if(cmd < 0) {
          uart_putc('c');
          ieee_data.bus_state = BUS_IDLE;
          break;
        } else cmd &= 0xFF;
        uart_puts_p("ATN "); uart_puthex(cmd);
        uart_putcrlf();

        if (cmd == 0x3f) {                                  /* UNLISTEN */
          if(ieee_data.device_state == DEVICE_LISTEN) {
            ieee_data.device_state = DEVICE_IDLE;
            uart_puts_p("UNLISTEN\r\n");
          }
          ieee_data.bus_state = BUS_IDLE;
          break;
        } else if (cmd == 0x5f) {                           /* UNTALK */
          if(ieee_data.device_state == DEVICE_TALK) {
            ieee_data.device_state = DEVICE_IDLE;
            uart_puts_p("UNTALK\r\n");
          }
          ieee_data.bus_state = BUS_IDLE;
          break;
        } else if (cmd == (0x40 + device_address)) {        /* TALK */
          uart_puts_p("TALK ");
          uart_puthex(device_address); uart_putcrlf();
          ieee_data.device_state = DEVICE_TALK;
          /* disk drives never talk immediatly after TALK, so stay idle
             and wait for a secondary address given by 0x60-0x6f DATA */
          ieee_data.bus_state = BUS_IDLE;
          break;
        } else if (cmd == (0x20 + device_address)) {        /* LISTEN */
          ieee_data.device_state = DEVICE_LISTEN;
          uart_puts_p("LISTEN ");
          uart_puthex(device_address); uart_putcrlf();
          ieee_data.bus_state = BUS_IDLE;
          break;
        } else if ((cmd & 0xf0) == 0x60) {                  /* DATA */
          /* 8250LP sends data while ATN is still active, so wait
             for bus controller to release ATN or we will misinterpret
             data as a command */
          while(!IEEE_ATN);
          if(ieee_data.device_state == DEVICE_LISTEN) {
            cmd = ieee_listen_handler(cmd);
            cmd_handler();
            break;
          } else if (ieee_data.device_state == DEVICE_TALK) {
            ieee_data.secondary_address = cmd & 0x0f;
            uart_puts_p("DATA T ");
            uart_puthex(ieee_data.secondary_address);
            uart_putcrlf();
            if(ieee_talk_handler() == TIMEOUT_ABORT) {
              ieee_data.device_state = DEVICE_IDLE;
            }
            ieee_data.bus_state = BUS_IDLE;
            break;
          } else {
            ieee_data.bus_state = BUS_IDLE;
            break;
          }
        } else if (ieee_data.device_state == DEVICE_IDLE) {
          ieee_data.bus_state = BUS_IDLE;
          break;
          /* ----- if we reach this, we're LISTENer or TALKer ----- */
        } else if ((cmd & 0xf0) == 0xe0) {                  /* CLOSE */
          ieee_data.secondary_address = cmd & 0x0f;
          uart_puts_p("CLOSE ");
          uart_puthex(ieee_data.secondary_address);
          uart_putcrlf();
          /* Close all buffers if sec. 15 is closed */
          if(ieee_data.secondary_address == 15) {
            free_multiple_buffers(FMB_USER_CLEAN);
          } else {
            /* Close a single buffer */
            buffer_t *buf;
            buf = find_buffer (ieee_data.secondary_address);
            if (buf != NULL) {
              buf->cleanup(buf);
              free_buffer(buf);
            }
          }
          ieee_data.bus_state = BUS_IDLE;
          break;
        } else if ((cmd & 0xf0) == 0xf0) {                  /* OPEN */
          cmd = ieee_listen_handler(cmd);
          cmd_handler();
          break;
        } else {
          /* Command for other device or unknown command */
          ieee_data.bus_state = BUS_IDLE;
        }
      break;
    }   /* switch   */
  }     /* for()    */
}
void key_handler(void)
{
    asm("cli; pusha");
    raw_key_r = inportb(0x60);

    if (extended_key_follows==2)
    {
      extended_key_follows=1; /*extended_key_follows==2 is used for PAUSE*/
      raw_key_r=0;
    }
    else
    {
        /*now find the extended scancode of pressed key */
        if (extended_key_follows)
        {
          key_leave=raw_key_r&0x80;
          raw_key_r=(raw_key_r & 0x7f) + 0x80;
          extended_key_follows=0;
        }
        else
        {
          key_leave=raw_key_r&0x80;
          switch (raw_key_r)
          {
            case 0xe1:
              extended_key_follows=2; /*start of pause sequence*/
              raw_key_r=0;
              break;
            case 0xe0:
              extended_key_follows=1;
              raw_key_r=0;
              break;
            default:
              raw_key_r=raw_key_r & 0x7f;
          }
        }
        /*key-joystick*/
        keypush[raw_key_r]=!key_leave;
#ifdef KEYBOARD_EXCLUSIVE
        k_test=keyforget[raw_key_r] && joy_keyboard;
#else
        k_test=keyforget[raw_key_r];
#endif
        /*forget scancodes used by keysticks*/
        if (joy_keyboard && !ui_is_active && keyforget[raw_key_r]) raw_key_r=0;

        switch (raw_key_r) {
                case 0xaa:  /*ignore 0xe0 0xaa sent by gray arrows*/
                        raw_key_r=0;
                        key_leave=0;
                        break;
                case 0x2a:
                        SHIFT_LEFT = !key_leave;
                        break;
                case 0x36:
                        SHIFT_RIGHT = !key_leave;
                        break;
				case 0x38:
						alt_key = !key_leave;					/*ALT KEY*/
						if (!alt_key) alt_function = -1;		/* no alt function */
						break;
                case 0x1d:
                case 0x9d:
                        control = !key_leave;
                        break;
                case 0x41:                                      /*F7*/
                        if (!key_leave)
                        {
                          joy_keyboard=!joy_keyboard;
                          update_leds();
#ifdef KEYBOARD_EXCLUSIVE
                          if (!joy_keyboard)
                          {
                            /* return all keyboard joysticks to default state */
                            if (joytypes[0]>=joy_keyset0 && joytypes[0]<=joy_keyset3)
                            {
                              stick0=STICK_CENTRE;
                              trig0=1;
                            }
                            if (joytypes[1]>=joy_keyset0 && joytypes[1]<=joy_keyset3)
                            {
                              stick1=STICK_CENTRE;
                              trig1=1;
                            }
                            if (joytypes[2]>=joy_keyset0 && joytypes[2]<=joy_keyset3)
                            {
                              stick2=STICK_CENTRE;
                              trig2=1;
                            }
                            if (joytypes[3]>=joy_keyset0 && joytypes[3]<=joy_keyset3)
                            {
                              stick3=STICK_CENTRE;
                              trig3=1;
                            }
                          }
                          else
                          {
                            k_test=1; /*force updatate of all keyboard joysticks*/
                          }
#endif
                        }
                        raw_key_r=0;
                        break;
                case 0x3c:
                        if (!key_leave)
                          key_consol &= ~CONSOL_OPTION;	/* OPTION key ON */
                        else
                          key_consol |= CONSOL_OPTION;	/* OPTION key OFF */
                        break;
                case 0x3d:
                        if (!key_leave)
                          key_consol &= ~CONSOL_SELECT;	/* SELECT key ON */
                        else
                          key_consol |= CONSOL_SELECT;	/* SELECT key OFF */
                        break;
                case 0x3e:
                        if (!key_leave)
                          key_consol &= ~CONSOL_START;	/* START key ON */
                        else
                          key_consol |= CONSOL_START;	/* START key OFF */
                        break;
        }

        if (k_test)  /*keystick key was pressed*/
        {
          for (ki=0;ki<4;ki++)
            if (keyset_used[ki])
            {
              kstick=STICK_CENTRE;
              if (keypush[keysets[ki][1]] || keypush[keysets[ki][4]] || keypush[keysets[ki][6]])
                kstick&=0xfb; /*left*/
              if (keypush[keysets[ki][3]] || keypush[keysets[ki][5]] || keypush[keysets[ki][8]])
                kstick&=0xf7; /*right*/
              if (keypush[keysets[ki][1]] || keypush[keysets[ki][2]] || keypush[keysets[ki][3]])
                kstick&=0xfd; /*down*/
              if (keypush[keysets[ki][6]] || keypush[keysets[ki][7]] || keypush[keysets[ki][8]])
                kstick&=0xfe; /*up*/
              ktrig=keypush[keysets[ki][0]]>0 ? 0:1;

              if (joytypes[0]==(joy_keyset0+ki))
                {  stick0=kstick;trig0=ktrig; }
              else
              if (joytypes[1]==(joy_keyset0+ki))
                {  stick1=kstick;trig1=ktrig; }
              else
              if (joytypes[2]==(joy_keyset0+ki))
                {  stick2=kstick;trig2=ktrig; }
              else
              if (joytypes[3]==(joy_keyset0+ki))
                {  stick3=kstick;trig3=ktrig; }
            }
        }

        key_shift = SHIFT_LEFT | SHIFT_RIGHT;
        raw_key_r=(key_leave?0x200:0)|raw_key_r;
        if (raw_key_r==0x200) raw_key_r=0;
        if (raw_key==last_raw_key && raw_key_r!=0) {raw_key=raw_key_r;raw_key_r=0;}
    }
    outportb(0x20, 0x20);
    asm("popa; sti");
}
/* Note: scancodes are a bit changed:
   raw_key & 0x7f = standard scancode
   raw_key & 0x80 = 1 if key was preceeded with 0xe0 (like the gray arrows)
   raw_key & 0x200 = 1 if key was depressed
                                                Robert Golias
*/
int Atari_Keyboard(void)
{
        int i;
        int keycode;
        int shift_mask;

        last_raw_key=raw_key;
/*
 * Trigger and Joystick handling should
 * be moved into the Keyboard Interrupt Routine  - done for keyboard-emulated joysticks
 */

        if (joy_in) {
                read_joystick(js0_centre_x, js0_centre_y);      /* read real PC joystick */
           if (joytypes[0]==joy_analog)
           {  stick0=astick; trig0=atrig; }
           if (joytypes[1]==joy_analog)
           {  stick1=astick; trig1=atrig; }
           if (joytypes[2]==joy_analog)
           {  stick2=astick; trig2=atrig; }
           if (joytypes[3]==joy_analog)
           {  stick3=astick; trig3=atrig; }
        }

        /* read LPT joysticks */
        for (i=0;i<4;i++)
          if (joytypes[i]>=joy_lpt1 && joytypes[i]<=joy_lpt3)
            read_LPTjoy(lptport[i],i);

/*
 * This needs a bit of tidying up - array lookup
 */
/* Atari5200 stuff */
        if (machine_type == MACHINE_5200 && !ui_is_active) {
                switch (raw_key) {
                case 0x3b:
                        keycode = AKEY_UI;
                        break;
                case 0x3f:                              /* F5 */
                        keycode = AKEY_COLDSTART;       /* 5200 has no warmstart */
                        break;
                case 0x44:                              /* F10 */
                        if (!norepkey)
                        {
                            keycode = key_shift ? AKEY_SCREENSHOT_INTERLACE : AKEY_SCREENSHOT;
                            norepkey=TRUE;
                        }else
                            keycode = AKEY_NONE;
                        break;
                case 0x43:
                        keycode = AKEY_EXIT;
                        break;
                case 0x02:
                        keycode = 0x3f;
                        break;
                case 0x03:
                        keycode = 0x3d;
                        break;
                case 0x04:
                        keycode = 0x3b;
                        break;
                case 0x0D:
                        keycode = 0x23;         /* = = * */
                        break;
                case 0x05:
                        keycode = 0x37;
                        break;
                case 0x06:
                        keycode = 0x35;
                        break;
                case 0x07:
                        keycode = 0x33;
                        break;
                case 0x08:
                        keycode = 0x2f;
                        break;
                case 0x09:
                        keycode = 0x2d;
                        break;
                case 0x0C:
                        keycode = 0x27;         /* - = * */
                        break;
                case 0x0a:
                        keycode = 0x2b;
                        break;
                case 0x0b:
                        keycode = 0x25;
                        break;
                case 0x3e:                              /* 1f : */
                        keycode = 0x39;         /* start */
                        break;
                case 0x19:
                        keycode = 0x31;         /* pause */
                        break;
                case 0x13:
                        keycode = 0x29;         /* reset */
                        break;
                case 0x42:                              /* F8 */
                        if (!norepkey) {
                                keycode = Atari_Exit(1) ? AKEY_NONE : AKEY_EXIT;        /* invoke monitor */
                                norepkey = TRUE;
                        }
                        else
                                keycode = AKEY_NONE;
                        break;
                default:
                        keycode = AKEY_NONE;
                        norepkey = FALSE;
                        break;
                }
                if (raw_key_r!=0) {raw_key=raw_key_r;raw_key_r=0;}
                return keycode;
        }

        /* preinitialize of keycode */
        shift_mask = key_shift ? 0x40 : 0;
        keycode = shift_mask | (control ? 0x80 : 0);

        switch (raw_key) {
        case 0x3b:                                      /* F1 */
                if (control) {
                        PC_keyboard = TRUE;     /* PC keyboard mode (default) */
                        keycode = AKEY_NONE;
			update_leds();
                }
                else if (key_shift) {
                        PC_keyboard = FALSE;    /* Atari keyboard mode */
                        keycode = AKEY_NONE;
			update_leds();
                }
                else
                        keycode = AKEY_UI;
                break;
        case 0xCF:                                      /* gray END*/
                if (!norepkey) {
                        keycode = AKEY_BREAK;
                        norepkey = TRUE;
                }
                else
                        keycode = AKEY_NONE;
                break;
        case 0x44:                                      /* F10 */
                if (!norepkey)
                {
                     keycode = key_shift ? AKEY_SCREENSHOT_INTERLACE : AKEY_SCREENSHOT;
                     norepkey = TRUE;
                }
                else
                     keycode = AKEY_NONE;
                break;
        case 0x3f:                                      /* F5 */
                keycode = key_shift ? AKEY_COLDSTART : AKEY_WARMSTART;
                break;
        case 0x40:                                      /* F6 */
                if (machine_type != MACHINE_XLXE)
                        keycode = AKEY_PIL;
                else
                        keycode = AKEY_HELP;
                break;
        case 0x42:                                      /* F8 */
                if (!norepkey && !ui_is_active) {
                        keycode = Atari_Exit(1) ? AKEY_NONE : AKEY_EXIT;        /* invoke monitor */
                        norepkey = TRUE;
                }
                else
                        keycode = AKEY_NONE;
                break;
        case 0x43:                                      /* F9 */
                keycode = AKEY_EXIT;
                break;
		case 0x57:					/* F11 */
		 		keycode = AKEY_NONE;
				for(i = 0; i < 4; i++) {
		 		  if (++joy_autofire[i] > 2)
		 		    joy_autofire[i] = 0;
		 		}
		 		raw_key = 0;	/* aviod continuous change */
		 		break;
        case 0x01:
                keycode |= AKEY_ESCAPE;
                break;
        case 0xD0:
        case 0x50:
                if (PC_keyboard)
                        keycode = AKEY_DOWN;
                else {
                        keycode |= AKEY_EQUAL;
                        keycode ^= shift_mask;
                }
                break;
        case 0xCB:
        case 0x4b:
                if (PC_keyboard)
                        keycode = AKEY_LEFT;
                else {
                        keycode |= AKEY_PLUS;
                        keycode ^= shift_mask;
                }
                break;
        case 0xCD:
        case 0x4d:
                if (PC_keyboard)
                        keycode = AKEY_RIGHT;
                else {
                        keycode |= AKEY_ASTERISK;
                        keycode ^= shift_mask;
                }
                break;
        case 0xC8:
        case 0x48:
                if (PC_keyboard)
                        keycode = AKEY_UP;
                else {
                        keycode |= AKEY_MINUS;
                        keycode ^= shift_mask;
                }
                break;
        case 0x29:                                      /* "`" key on top-left */
                keycode |= AKEY_ATARI;  /* Atari key (inverse video) */
                break;
        case 0x3a:
                keycode |= AKEY_CAPSTOGGLE;             /* Caps key */
                break;
        case 0x02:
                keycode |= AKEY_1;              /* 1 */
                break;
        case 0x03:
                if (!PC_keyboard)
                        keycode |= AKEY_2;
                else if (key_shift)
                        keycode = AKEY_AT;
                else
                        keycode |= AKEY_2;      /* 2,@ */
                break;
        case 0x04:
                keycode |= AKEY_3;              /* 3 */
                break;
        case 0x05:
                keycode |= AKEY_4;              /* 4 */
                break;
        case 0x06:
                keycode |= AKEY_5;              /* 5 */
                break;
        case 0x07:
                if (!PC_keyboard)
                        keycode |= AKEY_6;
                else if (key_shift)
                        keycode = AKEY_CIRCUMFLEX;      /* 6,^ */
                else
                        keycode |= AKEY_6;
                break;
        case 0x08:
                if (!PC_keyboard)
                        keycode |= AKEY_7;
                else if (key_shift)
                        keycode = AKEY_AMPERSAND;       /* 7,& */
                else
                        keycode |= AKEY_7;
                break;
        case 0x09:
                if (!PC_keyboard)
                        keycode |= AKEY_8;
                else if (key_shift)
                        keycode = AKEY_ASTERISK;        /* 8,* */
                else
                        keycode |= AKEY_8;
                break;
        case 0x0a:
                if (!PC_keyboard)
                        keycode |= AKEY_9;
                else if (key_shift)
                        keycode = AKEY_PARENLEFT;
                else
                        keycode |= AKEY_9;      /* 9,( */
                break;
        case 0x0b:
                if (!PC_keyboard)
                        keycode |= AKEY_0;
                else if (key_shift)
                        keycode = AKEY_PARENRIGHT;      /* 0,) */
                else
                        keycode |= AKEY_0;
                break;
        case 0x0c:
                if (!PC_keyboard)
                        keycode |= AKEY_LESS;
                else if (key_shift)
                        keycode = AKEY_UNDERSCORE;
                else
                        keycode |= AKEY_MINUS;
                break;
        case 0x0d:
                if (!PC_keyboard)
                        keycode |= AKEY_GREATER;
                else if (key_shift)
                        keycode = AKEY_PLUS;
                else
                        keycode |= AKEY_EQUAL;
                break;
        case 0x0e:
                keycode |= AKEY_BACKSPACE;
                break;


        case 0x0f:
                keycode |= AKEY_TAB;
                break;
        case 0x10:
                keycode |= AKEY_q;
                break;
        case 0x11:
				if (alt_key)
				{
					keycode = AKEY_UI;
					alt_function = MENU_SOUND_RECORDING;	/* ALT+W .. Select system */
				}
				else
                	keycode |= AKEY_w;
                break;
        case 0x12:
                keycode |= AKEY_e;
                break;
        case 0x13:
				if (alt_key)
				{
					keycode = AKEY_UI;
					alt_function = MENU_RUN;			/* ALT+R .. Run file */
				}
				else
	                keycode |= AKEY_r;
                break;
        case 0x14:
                keycode |= AKEY_t;
                break;
        case 0x15:
				if (alt_key)
				{
					keycode = AKEY_UI;
					alt_function = MENU_SYSTEM;			/* ALT+Y .. Select system */
				}
				else
	                keycode |= AKEY_y;
                break;
        case 0x16:
                keycode |= AKEY_u;
                break;
        case 0x17:
                keycode |= AKEY_i;
                break;
        case 0x18:
				if (alt_key)
				{
					keycode = AKEY_UI;
					alt_function = MENU_SOUND;			/* ALT+O .. mono/stereo sound */
				}
				else
	                keycode |= AKEY_o;
                break;
        case 0x19:
                keycode |= AKEY_p;
                break;
        case 0x1a:
                if (!PC_keyboard)
                        keycode |= AKEY_MINUS;
                else if (control | key_shift)
                        keycode |= AKEY_UP;
                else
                        keycode = AKEY_BRACKETLEFT;
                break;
        case 0x1b:
                if (!PC_keyboard)
                        keycode |= AKEY_EQUAL;
                else if (control | key_shift)
                        keycode |= AKEY_DOWN;
                else
                        keycode = AKEY_BRACKETRIGHT;
                break;
        case 0x9c:
        case 0x1c:
                keycode |= AKEY_RETURN;
                break;

        case 0x1e:
				if (alt_key)
				{
					keycode = AKEY_UI;
					alt_function = MENU_ABOUT;			/* ALT+A .. About */
				}
				else
					keycode |= AKEY_a;
                break;
        case 0x1f:
				if (alt_key)
				{
					keycode = AKEY_UI;
					alt_function = MENU_SAVESTATE;			/* ALT+S .. Save state */
				}
				else
	                keycode |= AKEY_s;
                break;
        case 0x20:
				if (alt_key)
				{
					keycode = AKEY_UI;
					alt_function = MENU_DISK;			/* ALT+D .. Disk management */
				}
				else
	                keycode |= AKEY_d;
                break;
        case 0x21:
                keycode |= AKEY_f;
                break;
        case 0x22:
                keycode |= AKEY_g;
                break;
        case 0x23:
                keycode |= AKEY_h;
                break;
        case 0x24:
                keycode |= AKEY_j;
                break;
        case 0x25:
                keycode |= AKEY_k;
                break;
        case 0x26:
				if (alt_key)
				{
					keycode = AKEY_UI;
					alt_function = MENU_LOADSTATE;			/* ALT+L .. Load state */
				}
				else
	                keycode |= AKEY_l;
                break;
        case 0x27:
                keycode |= AKEY_SEMICOLON;
                break;
        case 0x28:
                if (!PC_keyboard)
                        keycode |= AKEY_PLUS;
                else if (key_shift)
                        keycode = AKEY_DBLQUOTE;
                else
                        keycode = AKEY_QUOTE;
                break;
        case 0x2b:                                      /* PC key "\,|" */
        case 0x56:                                      /* PC key "\,|" */
                if (!PC_keyboard)
                        keycode |= AKEY_ASTERISK;
                else if (key_shift)
                        keycode = AKEY_BAR;
                else
                        keycode |= AKEY_BACKSLASH;
                break;


        case 0x2c:
                keycode |= AKEY_z;
                break;
        case 0x2d:
                keycode |= AKEY_x;
                break;
        case 0x2e:
				if (alt_key)
				{
					keycode = AKEY_UI;			
					alt_function = MENU_CARTRIDGE;			/* ALT+C .. Cartridge management */
				}
				else
	                keycode |= AKEY_c;
                break;
        case 0x2f:
                keycode |= AKEY_v;
                break;
        case 0x30:
                keycode |= AKEY_b;
                break;
        case 0x31:
                keycode |= AKEY_n;
                break;
        case 0x32:
                keycode |= AKEY_m;
                break;
        case 0x33:
                if (!PC_keyboard)
                        keycode |= AKEY_COMMA;
                else if (key_shift && !control)
                        keycode = AKEY_LESS;
                else
                        keycode |= AKEY_COMMA;
                break;
        case 0x34:
                if (!PC_keyboard)
                        keycode |= AKEY_FULLSTOP;
                else if (key_shift && !control)
                        keycode = AKEY_GREATER;
                else
                        keycode |= AKEY_FULLSTOP;
                break;
        case 0x35:
                keycode |= AKEY_SLASH;
                break;
        case 0x39:
                keycode |= AKEY_SPACE;
                break;


        case 0xc7:                                      /* HOME key */
                keycode |= 118;                 /* clear screen */
                break;
        case 0xd2:                                      /* INSERT key */
                if (key_shift)
                        keycode = AKEY_INSERT_LINE;
                else
                        keycode = AKEY_INSERT_CHAR;
                break;
        case 0xd3:                                      /* DELETE key */
                if (key_shift)
                        keycode = AKEY_DELETE_LINE;
                else
                        keycode = AKEY_DELETE_CHAR;
                break;
        default:
                keycode = AKEY_NONE;
                norepkey = FALSE;
                break;
        }

        if (raw_key_r!=0) {raw_key=raw_key_r;raw_key_r=0;}

        return keycode;
}
Beispiel #26
0
int main(void)
{
	uint8_t button;
	mode_t mode = MODE_OFF;
	mode_t next_mode = MODE_OFF;
	
	uint8_t up_time = 0;
	uint8_t down_time = 0;
	uint8_t time = 0;

	init_hardware();

	leds[GREEN_LED].state = LED_OFF;
	leds[GREEN_LED].on_time = 31;
	leds[GREEN_LED].off_time = 31;

	leds[RED_LED].state = LED_HIZ;


	while (1) {
		button = poll_button();

		if (button & 2) {
			if (down_time < 255) {
				down_time++;
			}
			up_time = 0;
		} else {
			if (up_time < 255) {
				up_time++;
			}
			down_time = 0;
		}

		if (time < 255) {
			time++;
		}

		// Button pressed
		if (button == 1) {
			if (mode != MODE_OFF && up_time >= 62) {
				next_mode = MODE_OFF;
			} else if (mode < MODE_CYCLE_END) {
				next_mode = mode + 1;
				if (next_mode == MODE_CYCLE_END) {
					next_mode = MODE_OFF;
				}
			} else {
				next_mode = MODE_OFF;
			}
		}

		// Button held
		if (down_time >= 37) {
			switch (mode) {
			case MODE_CYCLE_LEVEL1:
				next_mode = MODE_HOLD_BLINKY;
				break;
			case MODE_CYCLE_LEVEL2:
				next_mode = MODE_PERSIST_BLINKY;
				break;
			default:
				break;
			}
		}

		// Button released
		if (button == 2 && mode > MODE_PERSIST_END) {
			next_mode = MODE_OFF;
		}

		if (poll_temp() >= OVERTEMP) {
			if (mode > MODE_CYCLE_LEVEL2) {
				next_mode = MODE_CYCLE_LEVEL2;
			} else if (next_mode > MODE_CYCLE_LEVEL2) {
				next_mode = MODE_OFF;
			}
		}

		if (next_mode != mode) {
			mode = next_mode;

			set_power(mode);

			switch (mode) {
			case MODE_OFF:
				set_light(0);
				break;
			case MODE_CYCLE_LEVEL1:
				set_light(50);
				break;
			case MODE_CYCLE_LEVEL2:
				set_light(250);
				break;
			case MODE_CYCLE_LEVEL3:
				set_light(1000);
				break;
			case MODE_CYCLE_LEVEL4:
				set_light(1500);
				break;
			case MODE_CYCLE_LEVEL5:
				set_light(2000);
				break;
			case MODE_PERSIST_BLINKY:
			case MODE_HOLD_BLINKY:
				time = 0;
				set_light(2000);
				break;
			default:
				mode = MODE_OFF;
				break;
			}
		}

		switch (mode) {
		case MODE_PERSIST_BLINKY:
		case MODE_HOLD_BLINKY:
			if (time >= 24) {
				set_light(2000);
				time = 0;
			} else if (time >= 8) {
				set_light(0);
			}
			break;
		default:
			break;
		}

		switch (poll_charger()) {
		case CHARGE_SHUTDOWN:
			leds[GREEN_LED].state = LED_OFF;
			break;
		case CHARGE_CHARGING:
			leds[GREEN_LED].state |= LED_FLASH;
			break;
		case CHARGE_FINISHED:
			leds[GREEN_LED].state = LED_ON;
			break;
		}

		update_leds();
		sleep();
	}

	return 0;
}
Beispiel #27
0
static READ8_HANDLER( supercon_port3_r )
{
	supercon_state *state = space->machine().driver_data<supercon_state>();
	int i;
	UINT8 key_data=0;

	static const char *const status_lines[8] =
			{ "STATUS_1", "STATUS_2", "STATUS_3", "STATUS_4", "STATUS_5", "STATUS_6", "STATUS_7", "STATUS_8" };

	LOG(("Read from %04x \n",0x1E00));

/* remove last bit (only if it was not already set) */

	if ( state->m_data_1F00 & LED_LINE_AH )
	{
		if (state->m_last_LED_value != state->m_LED_AH)
			state->m_LED_AH=state->m_LED_AH & ~state->m_data_1E00;
	}
	else if ( state->m_data_1F00 & LED_LINE_ST)
	{
		if (state->m_last_LED_value != state->m_LED_ST)
			state->m_LED_ST=state->m_LED_ST & ~state->m_data_1E00;
	}
	else if ( state->m_data_1F00 & LED_LINE_18 )
	{
		if (state->m_last_LED_value != state->m_LED_18)
			state->m_LED_18=state->m_LED_18 & ~state->m_data_1E00;
	}


	LOG(("LED_18 from %02x \n",state->m_LED_18));
	LOG(("LED_AH from %02x \n",state->m_LED_AH));
	LOG(("LED_ST from %02x \n",state->m_LED_ST));

	if (state->m_led_update)			/*No LED Update if Port 1C00,1D00 was read */
		update_leds(state);

	state->m_remove_led_flag=TRUE;
	state->m_led_update=TRUE;

	state->m_LED_18=0;
	state->m_LED_AH=0;
	state->m_LED_ST=0;


/* Start */

	if (!state->m_emu_started)
		return 0xbf;
	else
		state->m_timer_update_irq->adjust( attotime::zero, 0, attotime::from_hz(598) );  //HACK adjust timer after start ???


/* Buttons */

	i=get_first_bit(state->m_data_1E00);
	if (i==NOT_VALID)
		return 0xff;

	key_data=input_port_read(space->machine(), status_lines[i]);

	if (key_data != 0xc0)
	{
		LOG(("%s, key_data: %02x \n",status_lines[i],key_data));

/* Button: New Game -> initialize board */

		if (i==0 && key_data==0x80)
		{
			set_board(state);
			set_pieces(state);

			state->m_emu_started=FALSE;
		}

/* Button: Clear Board -> remove all pieces */

		if (i==3 && key_data==0x80)
			clear_pieces(state);

		if (key_data != 0xff )
			return key_data;

	}

	return 0xc0;
}
Beispiel #28
0
static void
unicast_sent(struct unicast_conn *c, int status, int num_tx){
	update_leds();
}
Beispiel #29
0
static void
broadcast_sent(struct broadcast_conn *c, int status, int num_tx) {
	update_leds();
}
Beispiel #30
0
int
main (void)
{
	double t;
	int i, word, x, y;
	const TWordPos *w;
	TRGB color, *p;

	/* Initialize GPIO (sets up clock) */
	GPIOInit ();

	/* Set LED port pin to output */
	GPIOSetDir (LED_PORT, LED_PIN0, 1);
	GPIOSetValue (LED_PORT, LED_PIN0, LED_OFF);

	/* Init Power Management Routines */
	pmu_init ();

	/* setup SPI chipselect pin */
	spi_init ();
	spi_init_pin (SPI_CS_RGB);

	/* transmit image */
	t = 0;
	word = 0;
	while(1)
	{
		/* set background to red */
		memset(g_data, g_cie[0x00], sizeof(g_data));
		for(y=0; y<LED_Y; y++)
			for(x=0; x<LED_X; x++)
			{
				g_data[y][x].r = g_cie[0x16];
				g_data[y][x].g = g_cie[0x0B];
			}

		/* get next word */
		i = g_sentence[word/DELAY];
		word++;
		if(word>=(WORD_COUNT*DELAY))
			word=0;

		if(i>=0)
		{
			w = &g_words[i];

			for(i=0; i<w->length; i++)
			{
				/* word coordinates */
				x = w->x + i;
				y = w->y;

				/* update color */
				color.r = (sin( x*0.1+cos(y*0.1+t))*CIE_MAX_INDEX2)+CIE_MAX_INDEX2;
				color.g = (cos(-y*0.2-sin(x*0.3-t))*CIE_MAX_INDEX2)+CIE_MAX_INDEX2;
				color.b = (cos( x*0.5-cos(y*0.4+t))*CIE_MAX_INDEX2)+CIE_MAX_INDEX2;

				p = &g_data[y][x];
				p->r = g_cie[color.r];
				p->g = g_cie[color.g];
				p->b = g_cie[color.b];
			}
		}
		/* send data */
		update_leds();
		pmu_wait_ms(1);

		t+=0.01;
	}
}