private async Task Initialze() { if (LightningProvider.IsLightningEnabled) { LowLevelDevicesController.DefaultProvider = LightningProvider.GetAggregateProvider(); } else { throw new Exception("Lightning drivers not enabled. Please enable Lightning drivers."); } _camera = new Camera(); await _camera.Initialize(); SpeedSensor.Initialize(); SpeedSensor.Start(); SpeechSynthesis.Initialze(); await AudioPlayerController.Initialize(); _accelerometerSensor = new AccelerometerGyroscopeSensor(); await _accelerometerSensor.Initialize(); _accelerometerSensor.Start(); _automaticSpeakController = new AutomaticSpeakController(_accelerometerSensor); _motorController = new MotorController(); await _motorController.Initialize(_automaticSpeakController); _servoController = new ServoController(); await _servoController.Initialize(); _distanceMeasurementSensor = new DistanceMeasurementSensor(); await _distanceMeasurementSensor.Initialize(I2C_ADDRESS_SERVO); _automaticDrive = new AutomaticDrive(_motorController, _servoController, _distanceMeasurementSensor); _speechRecognation = new SpeechRecognition(); await _speechRecognation.Initialze(_motorController, _servoController, _automaticDrive); _speechRecognation.Start(); _gamepadController = new GamepadController(_motorController, _servoController, _automaticDrive, _accelerometerSensor); _camera.Start(); _httpServerController = new HttpServerController(_motorController, _servoController, _automaticDrive, _camera); SystemController.Initialize(_accelerometerSensor, _automaticSpeakController, _motorController, _servoController, _automaticDrive, _camera, _httpServerController, _speechRecognation, _gamepadController); await SystemController.SetAudioRenderVolume(AUDIO_RENDER_VOLUME, true); await SystemController.SetAudioCaptureVolume(AUDIO_CAPTURE_VOLUME, true); await AudioPlayerController.PlayAndWaitAsync(AudioName.Welcome); _automaticSpeakController.Start(); }
void IFoundation.Initialize(IEngine engine) { // Initialize _engine = engine ?? throw new TeaArgumentNullException(nameof(engine)); _engine.Add(this); _isInitialized = true; // Add sub-components _motorController = new MotorController(); _motorController.Initialize(this); _sensorAnalyzer = new SensorAnalyzer(); _sensorAnalyzer.Initialize(this); }