public void PercentualeApertura(int percentuale) { if (percentuale == 0) { PosizionaFineCorsaAntiOrario(); //Si posiziona a fine-corsa anti oraria chiude le persiane paralume _shift[_bitLampada] = false; _shift.OutBits(); //Spegne la lampada _posizioneAttualeInStep = 0; } else if (percentuale == 100) { _shift[_bitLampada] = true; _shift.OutBits(); //Accende la lampada PosizionaFineCorsaAntiOrario(); //Si posiziona a fine-corsa oraria apre le persiane paralume _posizioneAttualeInStep = _stepTotali; } else if ((percentuale < 100) && (percentuale > 0)) { PosizionaFineCorsaOrario(); //Si posiziona a fine-corsa anti oraria chiude le persiane paralume _shift[_bitLampada] = true; _shift.OutBits(); //Accende la lampada _posizioneAttualeInStep = (Int32)(((double)_stepTotali / 100.0) * (double)percentuale); StepAntiOrario(_posizioneAttualeInStep); } _percentuale = percentuale; this.InvokeWriteLog("LightDevice " + _percentuale); Folle(); }
public Device_OnOffShift(OutShiftRegister shift, int numBit) { _shift = shift; _numBit = numBit; _shift[numBit] = false; _shift.OutBits(); }
/// <summary> /// Rotazione oraria apre la persiana paralume. Rotazione anti-oraria chiude la persiana paralume /// </summary> /// <param name="portaA1"></param> /// <param name="portaA2"></param> /// <param name="portaB1"></param> /// <param name="portaB2"></param> /// <param name="portaEndStopOrario"></param> /// <param name="portaEndStopAntiOrario"></param> /// <param name="portaOnOffLuce"></param> public LightDevice( OutShiftRegister shift, int bitA1, int bitA2, int bitB1, int bitB2, int bitLampada, int portaEndStopOrario, int portaEndStopAntiOrario) : base(shift, bitA1, bitA2, bitB1, bitB2, portaEndStopOrario, portaEndStopAntiOrario) { _shift = shift; _bitLampada = bitLampada; shift[bitLampada] = false; shift.OutBits(); //Conta numero di step fra un fine-corsa e l'altro PosizionaFineCorsaAntiOrario(); //Si posiziona a fine-corsa anti oraria apre completamente la persiana paralume _stepTotali = 0; while (StepOrario(1)) { _stepTotali++; //Conta il numero di step fra i due finecorsa e chiude la persiana paralume } _posizioneAttualeInStep = 0; //Aggiorna la posizione attuale _percentuale = 0; //Aggiorna la percentuale attuale this.InvokeWriteLog("LightDevice " + _percentuale); Folle(); }
private void AttivaFase() { switch (_fase) //Seleziona la fase { case 0: //Fase 0 _shift[_bitA1] = true; _shift[_bitA2] = false; _shift[_bitB1] = false; _shift[_bitB2] = false; _shift.OutBits(); break; case 1: //Fase 1 _shift[_bitA1] = false; _shift[_bitA2] = false; _shift[_bitB1] = true; _shift[_bitB2] = false; _shift.OutBits(); break; case 2: //Fase 2 _shift[_bitA1] = false; _shift[_bitA2] = true; _shift[_bitB1] = false; _shift[_bitB2] = false; _shift.OutBits(); break; case 3: //Fase 3 _shift[_bitA1] = false; _shift[_bitA2] = false; _shift[_bitB1] = false; _shift[_bitB2] = true; _shift.OutBits(); break; } //L'albero motore deve avere il tempo di raggiungere la nuova posizione Task.Delay(20).Wait();// "1" per Stepper Motor Nema 17 "3" M42SP-5 }
/// <summary> /// Accende il dispositivo /// </summary> public void On() { InvokeWriteLog("ShiftRegister " + _numBit + " ON"); _shift[_numBit] = true; _shift.OutBits(); }
public LCD1602Shift( OutShiftRegister shift, int bit0, int bit1, int bit2, int bit3, int enable, int registerSelect) { _shift = shift; _LCDRegisterSelect = registerSelect; _LCDEnable = enable; _LCDBit0 = bit0; _LCDBit1 = bit1; _LCDBit2 = bit2; _LCDBit3 = bit3; shift[_LCDRegisterSelect] = false; shift.OutBits(); // 4 bit data communication //Task.Delay(50); 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(); //Task.Delay(50); 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(); //Task.Delay(50); 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(); //Task.Delay(50); 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); }
//Sends an ASCII character to the LCD void Putc(byte c) { _shift[_LCDBit3] = (c & 0x80) != 0; _shift[_LCDBit2] = (c & 0x40) != 0; _shift[_LCDBit1] = (c & 0x20) != 0; _shift[_LCDBit0] = (c & 0x10) != 0; _shift.OutBits(); _shift[_LCDEnable] = true; //Toggle the Enable Pin _shift.OutBits(); _shift[_LCDEnable] = false; _shift.OutBits(); _shift[_LCDBit3] = (c & 0x08) != 0; _shift[_LCDBit2] = (c & 0x04) != 0; _shift[_LCDBit1] = (c & 0x02) != 0; _shift[_LCDBit0] = (c & 0x01) != 0; _shift.OutBits(); _shift[_LCDEnable] = true; //Toggle the Enable Pin _shift.OutBits(); _shift[_LCDEnable] = false; _shift.OutBits(); //Task.Delay(1); }