device_status mock_depth_stream::on_initialize() { // Populate modes add_available_mode(stream_mode(320, 240, 30, ASTRA_PIXEL_FORMAT_DEPTH_MM)); add_available_mode(stream_mode(320, 240, 60, ASTRA_PIXEL_FORMAT_DEPTH_MM)); add_available_mode(stream_mode(640, 480, 30, ASTRA_PIXEL_FORMAT_DEPTH_MM)); add_available_mode(stream_mode(640, 480, 60, ASTRA_PIXEL_FORMAT_DEPTH_MM)); set_active_mode(*modes_begin()); generator_ = std::make_unique<depth_generator>(active_mode().width(), active_mode().height()); return device_status_value::ok; }
device_status mock_ir_stream::on_initialize() { // Populate modes add_available_mode(stream_mode(320, 240, 30, ASTRA_PIXEL_FORMAT_RGB888)); add_available_mode(stream_mode(320, 240, 60, ASTRA_PIXEL_FORMAT_RGB888)); add_available_mode(stream_mode(640, 480, 30, ASTRA_PIXEL_FORMAT_RGB888)); add_available_mode(stream_mode(640, 480, 60, ASTRA_PIXEL_FORMAT_RGB888)); set_active_mode(*modes_begin()); generator_ = astra::make_unique<infrared_generator>(active_mode().width(), active_mode().height()); return device_status_value::ok; }
//Main Program int main(void) { uint8_t b_prev=0xFF, c_prev=0xFF, d_prev=0xFF; // set for 16 MHz clock CLKPR = 0x80, CLKPR = 0; // Configure all ports as inputs with pullup resistors. DDRB = 0x00; DDRC = 0x00; DDRD = 0x00; PORTB = 0xFF; PORTC = 0xFF; PORTD = 0xFF; //Initialise LED timings (added v1.1) clock_prescale_set(clock_div_1); MCUSR &= ~(1 << WDRF); wdt_disable(); //Read eeprom to get active group and mode ee_byte=read_eeprom_byte(1); set_active_mode(); // Initialize the USB usb_init(); //flash them leds #include "../shared/disco.c" while(!usb_configured()); // Wait for host to load drivers //_delay_ms(500); while(1) { uint8_t b = PINB; uint8_t c = PINC; uint8_t d = PIND; if(b != b_prev || c != c_prev || d != d_prev ) { keycount = 0; modecount = 0; //HWB to toggle active mode //if(!(c & 0x10)) //Pin B10 can be connected to external LED indicator if(!(c & 0x20)) { keyboard_keys[keycount++] = map[18]; } //PIN B9 if(!(c & 0x40)) { keyboard_keys[keycount++] = map[17]; } //PIN B8 if(!(c & 0x80)) { keyboard_keys[keycount++] = map[16]; } //PIN B7 if(!(b & 0x80)) { keyboard_keys[keycount++] = map[15]; } //PIN B6 if(!(b & 0x40)) { keyboard_keys[keycount++] = map[14]; } //PIN B5 if(!(b & 0x20)) { keyboard_keys[keycount++] = map[13]; } //PIN B4 if(!(b & 0x10)) { keyboard_keys[keycount++] = map[12]; } //PIN B3 if(!(b & 0x08)) { keyboard_keys[keycount++] = map[11]; } //PIN B2 if(!(b & 0x04)) { keyboard_keys[keycount++] = map[10]; } //PIN B1 if(!(b & 0x02)) { keyboard_keys[keycount++] = map[9]; } //PIN A10 if(!(b & 0x01)) { keyboard_keys[keycount++] = map[8]; } //PIN A9 if(!(d & 0x40)) { keyboard_keys[keycount++] = map[7]; } //PIN A8 if(!(d & 0x20)) { keyboard_keys[keycount++] = map[6]; } //PIN A7 if(!(d & 0x10)) { keyboard_keys[keycount++] = map[5]; } //PIN A6 if(!(d & 0x08)) { keyboard_keys[keycount++] = map[4]; } //PIN A5 if(!(d & 0x04)) { keyboard_keys[keycount++] = map[3]; } //PIN A4 if(!(d & 0x02)) { keyboard_keys[keycount++] = map[2]; } //PIN A3 if(!(d & 0x01)) { keyboard_keys[keycount++] = map[1]; } //PIN A2 if(!(c & 0x04)) { keyboard_keys[keycount++] = map[0]; } //PIN A1 if(!(d & 0x80)) { //HWB PIN modecount++; } while(keycount < sizeof(keyboard_keys)) { keyboard_keys[keycount++] = KEY_NONE; } usb_keyboard_send(); b_prev = b; c_prev = c; d_prev = d; if (modecount>0){ switch_mode(); } } _delay_ms(2); // Debounce } }