// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddControllers() .AddNewtonsoftJson(); // Swagger generator services.AddSwaggerGen(o => { o.SwaggerDoc(openApiInfo.Version, openApiInfo); }); // SenseHatService (emulation mode is obtained from appsettings.json) var emulationMode = string.Equals( Configuration["Emulation"], "Y", StringComparison.OrdinalIgnoreCase); var senseHatService = SenseHatServiceHelper.GetService(emulationMode); services.AddSingleton(senseHatService); }
static void Main(string[] args) { // Parse input arguments, and set emulation mode accordingly var emulationMode = ParseInputArgumentsToSetEmulationMode(args); // Instantiate service var senseHatService = SenseHatServiceHelper.GetService(emulationMode); // Display the mode Console.WriteLine($"Emulation mode: {senseHatService.EmulationMode}"); // Infinite loop while (true) { // Display sensor readings Console.WriteLine(senseHatService.SensorReadings); // Change the LED array color ChangeFillColor(senseHatService); // Delay Task.Delay(msDelayTime).Wait(); } }