Exemplo n.º 1
0
        /// <summary>
        /// Constructor for SPI LCD connection (Adafruit I2C LCD backpack)
        /// </summary>
        public clsLCD_MLC(byte rows, byte cols)
        {
            // initialize i2c bus (only one instance is allowed)
            I2CBus bus = new I2CBus();

            // initialize provider (multiple devices can be attached to same bus)
            MCP23008LcdTransferProvider lcdProvider = new MCP23008LcdTransferProvider(bus);

            lcd = new Lcd(lcdProvider);
            lcd_begin(rows, cols);
        }
Exemplo n.º 2
0
        private static void initializeLCD(I2CBus bus)
        {
            // Use I2C provider
            // Default configuration coresponds to Adafruit's LCD backpack
            // Initialize provider (multiple devices can be attached to same bus)
            var lcdProvider = new MCP23008LcdTransferProvider(_bus);

            // Create the LCD interface
            LCD = new Lcd(lcdProvider);
            // Set the LCD Color property = Led.  This is for cleaner code only.
            //LCD.Color = Led;
            // Set up the LCD's number of columns and rows:
            LCD.Begin(20, 4);
            // Clear the LCD
            LCD.Clear();
        }
        public static void Main()
        {
            var bus = new I2CBus();

            var lcdProvider = new MCP23008LcdTransferProvider(bus);
            var lcd         = new Lcd(lcdProvider);

            lcd.Begin(16, 2);
            lcd.Backlight = true;
            lcd.Write("Payload McPayload Face v1.0");
            for (int i = 0; i < 12; i++)
            {
                lcd.ScrollDisplayLeft();
                Thread.Sleep(200);
            }
            Thread.Sleep(1000);
            lcd.Clear();
            LCDFinish(lcd, "ACC DemoSat 2016");

            //THIS SECTION CREATES / INITIALIZES THE SERIAL LOGGER
            Debug.Print("Flight computer started successfully. Beginning INIT.");

            //Lcd = new LiquidCrystalI2C(0x01, 16, 2);
            //Lcd.write("Testing!");
            lcd.Write("Starting logger.");
            var logger = new Logger();

            Debug.Print("Starting logger.");
            logger.Start();
            LCDFinish(lcd, "Done.");


            lcd.Write("Starting clock...");
            Rebug.Print("Starting clock.");
            Clock.Instance.Start();
            LCDFinish(lcd, "Done.");

            //THIS SECTION CREATES/INITIALIZES THE PRESSURE SENSOR
            //lcd.Write("Init BMP sensor.");
            //Rebug.Print("Initializing BMP Sensor ");
            //var bmploop = new PressureTempAltitudeUpdater(bus, delay: 1000);
            //LCDFinish(lcd);

            //THIS SECTION CREATES/INITIALIZES THE SERIAL BNO 100HZ UPDATER
            lcd.Write("Init BNO sensor...");
            Rebug.Print("Initializing BNO Sensor ");
            var bno     = new SerialBno(SerialPorts.COM1, 5000, 5000, SerialBno.Bno055OpMode.OperationModeNdof);
            var bnoloop = new SerialBnoUpdater(bno, delay: 1000);

            LCDFinish(lcd, "Done.");

            ////Starts up the expensive mag
            lcd.Write("Init exp. mag...");
            Rebug.Print("Initializing expensive magnetometer on com3");
            var expensiveMagLoop = new ExpensiveMagUpdater(delay: 1000);

            LCDFinish(lcd, "Done.");

            lcd.Write("Init calib disp.");
            Rebug.Print("Initializing BNO calibration display loop");
            var printBnoCalib = new BNOCalibUpdate(bno, lcd, delay: 1000);

            LCDFinish(lcd, "Done.");

            //////THIS SECTION CREATES/INITIALIZES THE MAGNETOMETER UPDATER
            var mag_dump_size = 18432;

            lcd.Write("Init fast mag...");
            Rebug.Print("Initializing fast mag dump collector with a size of " + mag_dump_size + "bytes.");
            var customMagLoop = new CustomMagUpdater(mag_dump_size, AnalogChannels.ANALOG_PIN_A0);

            LCDFinish(lcd, "Done.");

            //Thread.Sleep(5000);
            lcd.Write("Init complete...");
            Rebug.Print("Flight computer INIT Complete. Continuing with boot.");
            LCDFinish(lcd, "Continuing boot.");

            //THIS SECTION INITIALIZES AND STARTS THE MEMORY MONITOR
            lcd.Write("Start memory monitor...");
            Rebug.Print("Starting memory monitor...");
            MemoryMonitor.Instance.Start(ref logger);
            LCDFinish(lcd, "Done.");

            ////THIS STARTS THE Mag dump update
            lcd.Write("Start f.mag loop...");
            Rebug.Print("Starting fast mag dump...");
            customMagLoop.Start();
            LCDFinish(lcd, "Done.");

            ////THIS STARTS THE BNO SENSOR UPDATE
            lcd.Write("Start bno loop...");
            Rebug.Print("Starting bno sensor updates...");
            bnoloop.Start();
            LCDFinish(lcd, "Done.");

            //THIS STARTS THE BNO SENSOR UPDATE
            //lcd.Write("Start bmp loop");
            //Rebug.Print("Starting bmp sensor updates...");
            //bmploop.Start();
            //LCDFinish(lcd);

            //THIS STARTS THE EXPENSIVE MAG UPDATE
            lcd.Write("Start e.mag loop...");
            Rebug.Print("Starting expensive mag updates...");
            expensiveMagLoop.Start();
            LCDFinish(lcd, "Done.");

            lcd.Write("Boot successful!");
            LCDFinish(lcd, "Entering run state.");

            Rebug.Print("Flight computer boot successful.");
            printBnoCalib.Start();
        }