public StepperMotorDevice(string n, ShiftRegister rr, int bitA1, int bitA2, int bitB1, int bitB2, int portaEndStopOrario, int portaEndStopAntiOrario) : base(n, rr) { _bitA1 = bitA1; _bitA2 = bitA2; _bitB1 = bitB1; _bitB2 = bitB2; GpioController gpio = GpioController.GetDefault(); if (gpio == null) { throw new Exception("GPIO Initialization Failed"); } _endStopOr = gpio.OpenPin(portaEndStopOrario); _endStopAn = gpio.OpenPin(portaEndStopAntiOrario); _endStopOr.SetDriveMode(GpioPinDriveMode.InputPullUp); _endStopAn.SetDriveMode(GpioPinDriveMode.InputPullUp); _fase = 0; Folle(); }
public MainPage() { this.InitializeComponent(); _physicalFL = new FileLogger(PHYSICAL_LOG_FILE_NAME); _masterFL = new FileLogger(MASTER_LOG_FILE_NAME); _converter = new MCP3208ADC(SERIAL_NUMBER); _shiftR = new ShiftRegister(SHIFT_REGISTER_BUS_LENGHT, DATA_SHIFT_REGISTER_PIN, CLOCK_SHIFT_REGISTER_PIN, LATCH_SHIFT_REGISTER_PIN); _lcd = new LCD(_shiftR, LCD_BIT0_PIN, LCD_BIT1_PIN, LCD_BIT2_PIN, LCD_BIT3_PIN, LCD_ENABLE_PIN, LCD_REGISTER_SELECT_PIN); _sensori = new SensoreAnalogico[] { new SensoreLuminosita(_converter, LUM_SHIFT_NUMBER), new SensoreCO2(_converter, CO2_SHIFT_NUMBER), new SensoreUmiditaAria(_converter, UA_SHIFT_NUMBER), new SensoreUmiditaTerreno(_converter, UT_SHIFT_NUMBER), new SensoreTemperatura(_converter, TEMP_SHIFT_NUMBER) }; _printStatus.Interval = TimeSpan.FromMilliseconds(CHANGE_STATUS_MILLISECONDS_TIMER); _printStatus.Tick += PrintStatus_Tick; _printStatus.Start(); _lightFence = new StepperMotorDevice("Blinding Fence", _shiftR, A1_STEPPER_PIN, A2_STEPPER_PIN, B1_STEPPER_PIN, B2_STEPPER_PIN, STOP_ORARIO_PIN, STOP_ANTIORARIO_PIN); _lightFence.WriteLog += WritePhysicalLogAsync; _lightBulb = new OnOffDevice("Agro Light Bulb", _shiftR, LIGHT_BULB_PIN); _lightBulb.WriteLog += WritePhysicalLogAsync; _lightController = new LightController("Light Controller", _lightFence, _lightBulb); _lightController.WriteLog += WriteMasterLogAsync; _heatResistor = new PwmDevice("Heat Resistor", HEAT_RES_PIN); _heatResistor.WriteLog += WritePhysicalLogAsync; _airCicleFan = new PwmDevice("Air Circle Fan", AIR_CIRLE_FAN_PIN); _airCicleFan.WriteLog += WritePhysicalLogAsync; _airCicleFan.ChangeDutyCycle(50); _airCicleFan.Start(); _heatResistor.ChangeDutyCycle(50); _heatResistor.Start(); Task.Delay(1000).Wait(); _airCicleFan.Stop(); _heatResistor.Stop(); txtStatus.Text = "Running..."; }
public LCD( ShiftRegister shift, int bit0, int bit1, int bit2, int bit3, int enable, int registerSelect) { this.shift = shift; _LCDRegisterSelect = registerSelect; _LCDEnable = enable; _LCDBit0 = bit0; _LCDBit1 = bit1; _LCDBit2 = bit2; _LCDBit3 = bit3; shift[_LCDRegisterSelect] = false; shift.OutBits(); // 4 bit data communication shift[_LCDBit3] = false; shift[_LCDBit2] = false; shift[_LCDBit1] = true; shift[_LCDBit0] = true; shift.OutBits(); shift[_LCDEnable] = true; //Toggle the Enable Pin shift.OutBits(); shift[_LCDEnable] = false; shift.OutBits(); shift[_LCDBit3] = false; shift[_LCDBit2] = false; shift[_LCDBit1] = true; shift[_LCDBit0] = true; shift.OutBits(); shift[_LCDEnable] = true; //Toggle the Enable Pin shift.OutBits(); shift[_LCDEnable] = false; shift.OutBits(); shift[_LCDBit3] = false; shift[_LCDBit2] = false; shift[_LCDBit1] = true; shift[_LCDBit0] = true; shift.OutBits(); shift[_LCDEnable] = true; //Toggle the Enable Pin shift.OutBits(); shift[_LCDEnable] = false; shift.OutBits(); shift[_LCDBit3] = false; shift[_LCDBit2] = false; shift[_LCDBit1] = true; shift[_LCDBit0] = false; shift.OutBits(); shift[_LCDEnable] = true; //Toggle the Enable Pin shift.OutBits(); shift[_LCDEnable] = false; shift.OutBits(); SendCmd(DISP_ON); SendCmd(CLR_DISP); }
public PhysicalDevice(string n, ShiftRegister rr) : base(n) { _reg = rr; }
public PhysicalDevice(string n) : base(n) { _reg = null; }
public PhysicalDevice() : base() { _reg = null; }
public OnOffDevice(string n, ShiftRegister rr, int bn) : base(n, rr) { _bitN = bn; _status = false; _reg.WriteBit(_bitN, _status); }